28 #ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_ITR_HPP 29 #define INCLUDED_MDDS_MULTI_TYPE_VECTOR_ITR_HPP 31 #include "multi_type_vector_types.hpp" 35 namespace mdds {
namespace detail {
namespace mtv {
43 template<
typename _SizeT,
typename _ElemBlkT>
46 typedef _SizeT size_type;
47 typedef _ElemBlkT element_block_type;
49 mdds::mtv::element_t type;
52 element_block_type* data;
55 type(mdds::mtv::element_type_empty), position(start_pos), size(0), data(
nullptr), __private_data(block_index) {}
59 std::swap(type, other.type);
60 std::swap(position, other.position);
61 std::swap(size, other.size);
62 std::swap(data, other.data);
64 __private_data.swap(other.__private_data);
69 size_type block_index;
73 block_index(_block_index) {}
75 block_index(other.block_index) {}
79 std::swap(block_index, other.block_index);
86 return type == other.type && position == other.position && size == other.size && data == other.data &&
87 __private_data.block_index == other.__private_data.block_index;
92 return !operator== (other);
96 template<
typename _NodeT>
99 typedef _NodeT node_type;
101 static void inc(node_type&) {}
102 static void dec(node_type&) {}
105 template<
typename _NodeT>
108 typedef _NodeT node_type;
110 static void inc(node_type& nd)
113 ++nd.__private_data.block_index;
114 nd.position += nd.size;
117 static void dec(node_type& nd)
120 --nd.__private_data.block_index;
121 nd.position -= nd.size;
130 template<
typename _Trait>
134 typedef typename _Trait::parent parent_type;
135 typedef typename _Trait::blocks blocks_type;
136 typedef typename _Trait::base_iterator base_iterator_type;
138 typedef typename parent_type::size_type size_type;
144 const base_iterator_type& pos,
const base_iterator_type& end,
145 size_type start_pos, size_type block_index) :
146 m_cur_node(start_pos, block_index),
155 m_cur_node(other.m_cur_node),
163 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG 165 throw general_error(
"Current node position should never equal the end position during node update.");
168 const typename blocks_type::value_type& blk = *m_pos;
170 m_cur_node.type = mdds::mtv::get_block_type(*blk.mp_data);
172 m_cur_node.type = mdds::mtv::element_type_empty;
174 m_cur_node.size = blk.m_size;
175 m_cur_node.data = blk.mp_data;
196 base_iterator_type m_pos;
197 base_iterator_type m_end;
202 if (m_pos != m_end && other.m_pos != other.m_end)
206 if (m_cur_node != other.m_cur_node)
209 return m_pos == other.m_pos && m_end == other.m_end;
214 return !operator==(other);
219 m_cur_node = other.m_cur_node;
227 m_cur_node.swap(other.m_cur_node);
228 std::swap(m_pos, other.m_pos);
229 std::swap(m_end, other.m_end);
232 const node& get_node()
const {
return m_cur_node; }
233 const base_iterator_type& get_pos()
const {
return m_pos; }
234 const base_iterator_type& get_end()
const {
return m_end; }
237 template<
typename _Trait,
typename _NodeUpdateFunc>
240 typedef _Trait trait;
241 typedef _NodeUpdateFunc node_update_func;
244 typedef typename trait::base_iterator base_iterator_type;
245 typedef typename common_base::size_type size_type;
247 using common_base::inc;
248 using common_base::dec;
249 using common_base::m_cur_node;
250 using common_base::m_pos;
251 using common_base::m_end;
255 using common_base::get_pos;
256 using common_base::get_end;
262 typedef ptrdiff_t difference_type;
263 typedef std::bidirectional_iterator_tag iterator_category;
268 const base_iterator_type& pos,
const base_iterator_type& end,
269 size_type start_pos, size_type block_index) :
270 common_base(pos, end, start_pos, block_index) {}
272 value_type& operator*()
277 const value_type& operator*()
const 282 value_type* operator->()
287 const value_type* operator->()
const 294 node_update_func::inc(m_cur_node);
302 node_update_func::dec(m_cur_node);
307 template<
typename _Trait,
typename _NodeUpdateFunc,
typename _NonConstItrBase>
310 typedef _Trait trait;
311 typedef _NodeUpdateFunc node_update_func;
314 typedef typename trait::base_iterator base_iterator_type;
315 typedef typename common_base::size_type size_type;
317 using common_base::inc;
318 using common_base::dec;
319 using common_base::m_cur_node;
323 using common_base::get_pos;
324 using common_base::get_end;
326 typedef _NonConstItrBase iterator_base;
332 typedef ptrdiff_t difference_type;
333 typedef std::bidirectional_iterator_tag iterator_category;
338 const base_iterator_type& pos,
const base_iterator_type& end,
339 size_type start_pos, size_type block_index) :
340 common_base(pos, end, start_pos, block_index) {}
347 other.get_pos(), other.get_end(),
348 other.get_node().position,
349 other.get_node().__private_data.block_index) {}
351 const value_type& operator*()
const 356 const value_type* operator->()
const 363 node_update_func::inc(m_cur_node);
371 node_update_func::dec(m_cur_node);
Definition: multi_type_vector_itr.hpp:131
Definition: multi_type_vector_itr.hpp:44
const_iterator_base(const iterator_base &other)
Definition: multi_type_vector_itr.hpp:345
Definition: multi_type_vector_itr.hpp:106
Definition: multi_type_vector_itr.hpp:308
Definition: global.hpp:58
Definition: multi_type_vector_itr.hpp:97
Definition: flat_segment_tree.hpp:46
Definition: multi_type_vector_itr.hpp:238
Definition: multi_type_vector_itr.hpp:67