UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
container_bucket_iterator.hpp
1
42#ifndef UFO_CONTAINER_TREE_CONTAINER_BUCKET_ITERATOR_HPP
43#define UFO_CONTAINER_TREE_CONTAINER_BUCKET_ITERATOR_HPP
44
45// STL
46#include <iterator>
47#include <type_traits>
48
49namespace ufo
50{
51// Forward declare
52template <class... Ts>
53class TreeContainer;
54
55template <class T, bool Const, class... Ts>
57{
58 private:
59 //
60 // Friends
61 //
62
63 friend class TreeContainterBucketIterator<T, !Const, Ts...>;
64
65 friend class TreeContainer<Ts...>;
66
67 public:
68 //
69 // Tags
70 //
71
72 using iterator_category = std::random_access_iterator_tag;
73 using difference_type = std::ptrdiff_t;
74 using value_type = typename TreeContainer<Ts...>::template bucket_type<T>;
75 using pointer = std::conditional_t<Const, value_type const*, value_type*>;
76 using reference = std::conditional_t<Const, value_type const&, value_type&>;
77
79
81
82 template <bool Const2, class = std::enable_if_t<Const && !Const2>>
85 : container_(other.container_), idx_(other.idx_)
86 {
87 }
88
90 {
91 ++idx_;
92 return *this;
93 }
94
96 {
97 --idx_;
98 return *this;
99 }
100
101 TreeContainterBucketIterator operator++(int)
102 {
104 ++*this;
105 return tmp;
106 }
107
108 TreeContainterBucketIterator operator--(int)
109 {
111 --*this;
112 return tmp;
113 }
114
115 TreeContainterBucketIterator& operator+=(difference_type n)
116 {
117 idx_ += n;
118 return *this;
119 }
120
121 TreeContainterBucketIterator& operator-=(difference_type n)
122 {
123 idx_ -= n;
124 return *this;
125 }
126
127 TreeContainterBucketIterator operator+(difference_type n)
128 {
130 tmp += n;
131 return tmp;
132 }
133
134 TreeContainterBucketIterator operator-(difference_type n)
135 {
137 tmp -= n;
138 return tmp;
139 }
140
141 reference operator[](difference_type pos) const
142 {
143 return container_->template bucket<T>((idx_ + pos) *
144 container_->numBlocksPerBucket());
145 }
146
147 reference operator*() const
148 {
149 return container_->template bucket<T>(idx_ * container_->numBlocksPerBucket());
150 }
151
152 pointer operator->() const
153 {
154 return &(container_->template bucket<T>(idx_ * container_->numBlocksPerBucket()));
155 }
156
157 template <bool Const1, bool Const2>
158 friend difference_type operator-(
161 {
162 return lhs.idx_ - rhs.idx_;
163 }
164
165 template <bool Const1, bool Const2>
166 friend bool operator==(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
168 {
169 return lhs.idx_ == rhs.idx_;
170 }
171
172 template <bool Const1, bool Const2>
173 friend bool operator!=(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
175 {
176 return lhs.idx_ != rhs.idx_;
177 }
178
179 template <bool Const1, bool Const2>
180 friend bool operator<(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
182 {
183 return lhs.idx_ < rhs.idx_;
184 }
185
186 template <bool Const1, bool Const2>
187 friend bool operator<=(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
189 {
190 return lhs.idx_ <= rhs.idx_;
191 }
192
193 template <bool Const1, bool Const2>
194 friend bool operator>(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
196 {
197 return lhs.idx_ > rhs.idx_;
198 }
199
200 template <bool Const1, bool Const2>
201 friend bool operator>=(TreeContainterBucketIterator<T, Const1, Ts...> const& lhs,
203 {
204 return lhs.idx_ >= rhs.idx_;
205 }
206
207 protected:
208 TreeContainterBucketIterator(TreeContainer<Ts...>* container, difference_type idx)
209 : container_(container), idx_(idx)
210 {
211 }
212
213 TreeContainterBucketIterator(TreeContainer<Ts...>& container, difference_type idx)
214 : TreeContainterBucketIterator(&container, idx)
215 {
216 }
217
218 private:
219 TreeContainer<Ts...>* container_ = nullptr;
220
221 difference_type idx_;
222};
223} // namespace ufo
224
225#endif // UFO_CONTAINER_TREE_CONTAINER_BUCKET_ITERATOR_HPP
All vision-related classes and functions.
Definition cloud.hpp:49