gtsam  4.0.0
gtsam
DSFVector.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
21 #include <gtsam/dllexport.h>
22 #include <gtsam/global_includes.h>
23 
24 #include <boost/shared_ptr.hpp>
25 
26 #include <vector>
27 #include <set>
28 #include <map>
29 
30 namespace gtsam {
31 
38 class GTSAM_EXPORT DSFBase {
39 
40 public:
41  typedef std::vector<size_t> V;
42 
43 private:
44  boost::shared_ptr<V> v_;
45 
46 public:
48  DSFBase(const size_t numNodes);
49 
51  DSFBase(const boost::shared_ptr<V>& v_in);
52 
54  size_t find(size_t key) const;
55 
57  void merge(const size_t& i1, const size_t& i2);
58 
59 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
60  inline size_t findSet(size_t key) const {return find(key);}
61  inline void makeUnionInPlace(const size_t& i1, const size_t& i2) {return merge(i1,i2);}
62 #endif
63 };
64 
69 class GTSAM_EXPORT DSFVector: public DSFBase {
70 
71 private:
72  std::vector<size_t> keys_;
73 
74 public:
76  DSFVector(const size_t numNodes);
77 
79  DSFVector(const std::vector<size_t>& keys);
80 
82  DSFVector(const boost::shared_ptr<V>& v_in, const std::vector<size_t>& keys);
83 
84  // All operations below loop over all keys and hence are *at least* O(n)
85 
87  bool isSingleton(const size_t& label) const;
88 
90  std::set<size_t> set(const size_t& label) const;
91 
93  std::map<size_t, std::set<size_t> > sets() const;
94 
96  std::map<size_t, std::vector<size_t> > arrays() const;
97 };
98 
99 }
Definition: DSFVector.h:38
Included from all GTSAM files.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Definition: DSFVector.h:69
std::vector< size_t > V
Vector of ints.
Definition: DSFVector.h:41