gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/global_includes.h>
22 #include <boost/shared_ptr.hpp>
23 #include <vector>
24 #include <set>
25 #include <map>
26 
27 namespace gtsam {
28 
35 class GTSAM_EXPORT DSFBase {
36 
37 public:
38  typedef std::vector<size_t> V;
39 
40 private:
41  boost::shared_ptr<V> v_;
42 
43 public:
45  DSFBase(const size_t numNodes);
46 
48  DSFBase(const boost::shared_ptr<V>& v_in);
49 
51  size_t find(size_t key) const;
52 
54  void merge(const size_t& i1, const size_t& i2);
55 
57  inline size_t findSet(size_t key) const {return find(key);}
58 
60  inline void makeUnionInPlace(const size_t& i1, const size_t& i2) {return merge(i1,i2);}
61 };
62 
67 class GTSAM_EXPORT DSFVector: public DSFBase {
68 
69 private:
70  std::vector<size_t> keys_;
71 
72 public:
74  DSFVector(const size_t numNodes);
75 
77  DSFVector(const std::vector<size_t>& keys);
78 
80  DSFVector(const boost::shared_ptr<V>& v_in, const std::vector<size_t>& keys);
81 
82  // all operations below loop over all keys and hence are *at least* O(n)
83 
85  bool isSingleton(const size_t& label) const;
86 
88  std::set<size_t> set(const size_t& label) const;
89 
91  std::map<size_t, std::set<size_t> > sets() const;
92 
94  std::map<size_t, std::vector<size_t> > arrays() const;
95 };
96 
97 }
Definition: DSFVector.h:35
void makeUnionInPlace(const size_t &i1, const size_t &i2)
Definition: DSFVector.h:60
Included from all GTSAM files.
std::vector< size_t > V
Vector of ints.
Definition: DSFVector.h:38
Definition: DSFVector.h:67
size_t findSet(size_t key) const
Definition: DSFVector.h:57