28#ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_AOS_ITERATOR_HPP
29#define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_AOS_ITERATOR_HPP
31#include "../iterator_node.hpp"
35namespace mdds {
namespace mtv {
namespace aos {
namespace detail {
42template<
typename Traits>
46 typedef typename Traits::parent parent_type;
47 typedef typename Traits::blocks blocks_type;
48 typedef typename Traits::base_iterator base_iterator_type;
50 typedef typename parent_type::size_type size_type;
57 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
58 : m_cur_node(parent, block_index), m_pos(pos), m_end(end)
65 : m_cur_node(other.m_cur_node), m_pos(other.m_pos), m_end(other.m_end)
70#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
72 throw general_error(
"Current node position should never equal the end position during node update.");
75 const typename blocks_type::value_type& blk = *m_pos;
77 m_cur_node.type = mdds::mtv::get_block_type(*blk.data);
79 m_cur_node.type = mdds::mtv::element_type_empty;
81 m_cur_node.position = blk.position;
82 m_cur_node.size = blk.size;
83 m_cur_node.data = blk.data;
104 base_iterator_type m_pos;
105 base_iterator_type m_end;
110 if (m_pos != m_end && other.m_pos != other.m_end)
114 if (m_cur_node != other.m_cur_node)
117 return m_pos == other.m_pos && m_end == other.m_end;
122 return !operator==(other);
127 m_cur_node = other.m_cur_node;
135 m_cur_node.swap(other.m_cur_node);
136 std::swap(m_pos, other.m_pos);
137 std::swap(m_end, other.m_end);
140 const node& get_node()
const
144 const base_iterator_type& get_pos()
const
148 const base_iterator_type& get_end()
const
154template<
typename Traits,
typename NodeUpdateFunc>
157 using parent_type =
typename Traits::parent;
158 typedef NodeUpdateFunc node_update_func;
161 typedef typename Traits::base_iterator base_iterator_type;
162 typedef typename common_base::size_type size_type;
164 using common_base::dec;
165 using common_base::inc;
166 using common_base::m_cur_node;
169 using common_base::get_end;
170 using common_base::get_pos;
176 typedef ptrdiff_t difference_type;
177 typedef std::bidirectional_iterator_tag iterator_category;
183 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
209 node_update_func::inc(m_cur_node);
217 node_update_func::dec(m_cur_node);
222template<
typename Traits,
typename NodeUpdateFunc,
typename NonConstItrBase>
225 using parent_type =
typename Traits::parent;
226 typedef NodeUpdateFunc node_update_func;
229 typedef typename Traits::base_iterator base_iterator_type;
230 typedef typename common_base::size_type size_type;
232 using common_base::dec;
233 using common_base::inc;
234 using common_base::m_cur_node;
237 using common_base::get_end;
238 using common_base::get_pos;
240 typedef NonConstItrBase iterator_base;
246 typedef ptrdiff_t difference_type;
247 typedef std::bidirectional_iterator_tag iterator_category;
253 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
262 other.get_pos(), other.get_end(), other.get_node().__private_data.parent,
263 other.get_node().__private_data.block_index)
266 const value_type& operator*()
const
271 const value_type* operator->()
const
276 const_iterator_base& operator++()
278 node_update_func::inc(m_cur_node);
283 const_iterator_base& operator--()
286 node_update_func::dec(m_cur_node);
290 bool operator==(
const const_iterator_base& other)
const
292 return iterator_common_base<Traits>::operator==(other);
295 bool operator!=(
const const_iterator_base& other)
const
297 return iterator_common_base<Traits>::operator!=(other);
Definition: global.hpp:84
Definition: aos/iterator.hpp:224
const_iterator_base(const iterator_base &other)
Definition: aos/iterator.hpp:260
Definition: aos/iterator.hpp:156
Definition: aos/iterator.hpp:44