ClusterBiMap.hpp
Go to the documentation of this file.
1 
28 /*
29  * ClusterBiMap.hpp
30  *
31  * @date 17.06.2017
32  * @author Johan M. von Behren <johan@vonbehren.eu>
33  */
34 
35 #ifndef LVR2_UTIL_CLUSTERBIMAP_H_
36 #define LVR2_UTIL_CLUSTERBIMAP_H_
37 
39 #include "lvr2/util/Cluster.hpp"
40 
43 
44 namespace lvr2
45 {
46 
53  template<typename HandleT>
55 {
56 public:
59  bool operator==(const ClusterBiMapIterator& other) const;
60  bool operator!=(const ClusterBiMapIterator& other) const;
61  ClusterHandle operator*() const;
62 
63 private:
65 };
66 
71 template<typename HandleT>
73 {
74 public:
75  ClusterBiMap() : m_numHandles(0) {};
76 
78  ClusterHandle createCluster();
79 
88  void removeCluster(ClusterHandle clusterHandle);
89 
97  ClusterHandle addToCluster(ClusterHandle clusterHandle, HandleT handle);
98 
106  ClusterHandle removeFromCluster(ClusterHandle clusterHandle, HandleT handle);
107 
115  ClusterHandle getClusterH(HandleT handle) const;
116 
124  OptionalClusterHandle getClusterOf(HandleT handle) const;
125 
127  size_t numCluster() const;
128 
129  ClusterBiMapIterator<HandleT> begin() const;
130  ClusterBiMapIterator<HandleT> end() const;
131 
133  const Cluster<HandleT>& getCluster(ClusterHandle clusterHandle) const;
134 
136  const Cluster<HandleT>& operator[](ClusterHandle clusterHandle) const;
137 
141  void reserve(size_t newCap);
142 
144  size_t numHandles() const;
145 
146 private:
148  size_t m_numHandles;
149 
152 
155 
157  Cluster<HandleT>& getC(ClusterHandle clusterHandle);
158 };
159 
160 } // namespace lvr2
161 
162 #include "lvr2/util/ClusterBiMap.tcc"
163 
164 #endif /* LVR2_UTIL_CLUSTERBIMAP_H_ */
A vector which guarantees stable indices and features O(1) deletion.
bool operator!=(const ClusterBiMapIterator &other) const
bool operator==(const ClusterBiMapIterator &other) const
ClusterHandle operator*() const
Iterator over handles in this vector, which skips deleted elements.
Semantically equivalent to boost::optional<ClusterHandle>
Definition: Handles.hpp:182
A map of clusters, which also saves a back-reference from handle to cluster.
Handle to access Cluster of the ClusterBiMap.
Definition: Handles.hpp:152
size_t m_numHandles
Number of handels in all clusters.
Represents a group of handles, which are somehow connected.
Definition: Cluster.hpp:50
StableVector< ClusterHandle, Cluster< HandleT > > m_cluster
Clusters.
Iterator over cluster handles in this cluster map.
ClusterBiMapIterator(StableVectorIterator< ClusterHandle, Cluster< HandleT >> iterator)
DenseAttrMap< HandleT, ClusterHandle > m_clusterMap
Map from handle -> cluster to save the back-reference for stored handles.
ClusterBiMapIterator & operator++()
StableVectorIterator< ClusterHandle, Cluster< HandleT > > m_iterator
A map with constant lookup overhead using small-ish integer-keys.
Definition: VectorMap.hpp:60


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06