28 #ifndef MDDS_MULTI_TYPE_VECTOR_ITR_HPP 29 #define MDDS_MULTI_TYPE_VECTOR_ITR_HPP 31 #include "multi_type_vector_types.hpp" 35 namespace mdds {
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) {}
58 type(other.type), position(other.position), size(other.size), data(other.data), __private_data(other.__private_data) {}
62 std::swap(type, other.type);
63 std::swap(position, other.position);
64 std::swap(size, other.size);
65 std::swap(data, other.data);
67 __private_data.swap(other.__private_data);
72 size_type block_index;
76 block_index(_block_index) {}
78 block_index(other.block_index) {}
82 std::swap(block_index, other.block_index);
89 return type == other.type && position == other.position && size == other.size && data == other.data &&
90 __private_data.block_index == other.__private_data.block_index;
95 return !operator== (other);
99 template<
typename _NodeT>
102 typedef _NodeT node_type;
104 static void inc(node_type&) {}
105 static void dec(node_type&) {}
108 template<
typename _NodeT>
111 typedef _NodeT node_type;
113 static void inc(node_type& nd)
116 ++nd.__private_data.block_index;
117 nd.position += nd.size;
120 static void dec(node_type& nd)
123 --nd.__private_data.block_index;
124 nd.position -= nd.size;
133 template<
typename _Trait>
137 typedef typename _Trait::parent parent_type;
138 typedef typename _Trait::blocks blocks_type;
139 typedef typename _Trait::base_iterator base_iterator_type;
141 typedef typename parent_type::size_type size_type;
147 const base_iterator_type& pos,
const base_iterator_type& end,
148 size_type start_pos, size_type block_index) :
149 m_cur_node(start_pos, block_index),
158 m_cur_node(other.m_cur_node),
166 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG 168 throw general_error(
"Current node position should never equal the end position during node update.");
171 typename blocks_type::value_type blk = *m_pos;
173 m_cur_node.type = mdds::mtv::get_block_type(*blk->mp_data);
175 m_cur_node.type = mdds::mtv::element_type_empty;
177 m_cur_node.size = blk->m_size;
178 m_cur_node.data = blk->mp_data;
199 base_iterator_type m_pos;
200 base_iterator_type m_end;
205 if (m_pos != m_end && other.m_pos != other.m_end)
209 if (m_cur_node != other.m_cur_node)
212 return m_pos == other.m_pos && m_end == other.m_end;
217 return !operator==(other);
222 m_cur_node = other.m_cur_node;
230 m_cur_node.swap(other.m_cur_node);
231 std::swap(m_pos, other.m_pos);
232 std::swap(m_end, other.m_end);
235 const node& get_node()
const {
return m_cur_node; }
236 const base_iterator_type& get_pos()
const {
return m_pos; }
237 const base_iterator_type& get_end()
const {
return m_end; }
240 template<
typename _Trait,
typename _NodeUpdateFunc>
243 typedef _Trait trait;
244 typedef _NodeUpdateFunc node_update_func;
247 typedef typename trait::base_iterator base_iterator_type;
248 typedef typename common_base::size_type size_type;
250 using common_base::inc;
251 using common_base::dec;
252 using common_base::m_cur_node;
253 using common_base::m_pos;
254 using common_base::m_end;
258 using common_base::get_pos;
259 using common_base::get_end;
265 typedef ptrdiff_t difference_type;
266 typedef std::bidirectional_iterator_tag iterator_category;
271 const base_iterator_type& pos,
const base_iterator_type& end,
272 size_type start_pos, size_type block_index) :
273 common_base(pos, end, start_pos, block_index) {}
276 common_base(other) {}
278 value_type& operator*()
283 const value_type& operator*()
const 288 value_type* operator->()
293 const value_type* operator->()
const 300 node_update_func::inc(m_cur_node);
308 node_update_func::dec(m_cur_node);
313 template<
typename _Trait,
typename _NodeUpdateFunc,
typename _NonConstItrBase>
316 typedef _Trait trait;
317 typedef _NodeUpdateFunc node_update_func;
320 typedef typename trait::base_iterator base_iterator_type;
321 typedef typename common_base::size_type size_type;
323 using common_base::inc;
324 using common_base::dec;
325 using common_base::m_cur_node;
329 using common_base::get_pos;
330 using common_base::get_end;
332 typedef _NonConstItrBase iterator_base;
338 typedef ptrdiff_t difference_type;
339 typedef std::bidirectional_iterator_tag iterator_category;
344 const base_iterator_type& pos,
const base_iterator_type& end,
345 size_type start_pos, size_type block_index) :
346 common_base(pos, end, start_pos, block_index) {}
349 common_base(other) {}
356 other.get_pos(), other.get_end(),
357 other.get_node().position,
358 other.get_node().__private_data.block_index) {}
360 const value_type& operator*()
const 365 const value_type* operator->()
const 372 node_update_func::inc(m_cur_node);
380 node_update_func::dec(m_cur_node);
Definition: multi_type_vector_itr.hpp:109
Definition: multi_type_vector_itr.hpp:44
Definition: multi_type_vector_itr.hpp:100
Definition: multi_type_vector_itr.hpp:241
Definition: multi_type_vector_itr.hpp:314
Definition: global.hpp:58
Definition: default_deleter.hpp:33
Definition: multi_type_vector_itr.hpp:134
Definition: multi_type_vector_itr.hpp:70
const_iterator_base(const iterator_base &other)
Definition: multi_type_vector_itr.hpp:354