73class const_iterator_base
75 typedef Hdl handler_type;
78 typedef FstType fst_type;
82 std::add_const_t<typename fst_type::key_type>, std::add_const_t<typename fst_type::value_type>>;
83 using pointer = value_type*;
84 using reference = value_type&;
85 using difference_type = ptrdiff_t;
86 using iterator_category = ::std::bidirectional_iterator_tag;
88 explicit const_iterator_base(
const fst_type* _db,
bool _end) : m_db(_db), m_end_pos(_end)
93 m_pos = handler_type::init_pos(_db, _end);
96 explicit const_iterator_base(
const fst_type* _db,
const typename fst_type::node* pos) : m_db(_db), m_pos(pos)
99 const_iterator_base(
const const_iterator_base& r) : m_db(r.m_db), m_pos(r.m_pos), m_end_pos(r.m_end_pos)
102 const_iterator_base& operator=(
const const_iterator_base& r)
106 m_end_pos = r.m_end_pos;
110 const_iterator_base& operator++()
113 handler_type::inc(m_db, m_pos, m_end_pos);
117 const_iterator_base& operator--()
120 handler_type::dec(m_pos, m_end_pos);
124 bool operator==(
const const_iterator_base& r)
const
129 return (m_pos == r.m_pos) && (m_end_pos == r.m_end_pos);
132 bool operator!=(
const const_iterator_base& r)
const
134 return !operator==(r);
137 value_type operator*()
139 return value_type(m_pos->key, m_pos->value_leaf.value);
142 value_type operator->()
144 return value_type(m_pos->key, m_pos->value_leaf.value);
148 const typename fst_type::node* get_pos()
const
153 const fst_type* get_parent()
const
158 bool is_end_pos()
const
164 const fst_type* m_db =
nullptr;
165 const typename fst_type::node* m_pos =
nullptr;
166 bool m_end_pos =
false;
170class const_segment_iterator
172 typedef FstType fst_type;
175 const_segment_iterator(
const typename fst_type::node* start,
const typename fst_type::node* end)
176 : m_start(start), m_end(end)
184 typename fst_type::key_type start;
185 typename fst_type::key_type end;
186 typename fst_type::value_type value;
188 value_type() : start(), end(), value()
192 typename fst_type::key_type _start,
typename fst_type::key_type _end,
typename fst_type::value_type _value)
193 : start(std::move(_start)), end(std::move(_end)), value(std::move(_value))
196 bool operator==(
const value_type& other)
const
198 return start == other.start && end == other.end && value == other.value;
201 bool operator!=(
const value_type& other)
const
203 return !operator==(other);
207 const_segment_iterator() : m_start(nullptr), m_end(nullptr)
214 const_segment_iterator(const_segment_iterator&& other)
215 : m_start(std::move(other.m_start)), m_end(std::move(other.m_end))
221 ~const_segment_iterator()
224 bool operator==(
const const_segment_iterator& other)
const
226 return m_start == other.m_start && m_end == other.m_end;
229 bool operator!=(
const const_segment_iterator& other)
const
231 return !operator==(other);
234 const_segment_iterator& operator=(
const const_segment_iterator& other)
236 m_start = other.m_start;
243 const_segment_iterator& operator=(const_segment_iterator&& other)
245 m_start = std::move(other.m_start);
246 m_end = std::move(other.m_end);
262 const_segment_iterator& operator++()
265 m_start = m_start->next.get();
266 m_end = m_start->next.get();
271 const_segment_iterator operator++(
int)
274 const_segment_iterator ret = *
this;
275 m_start = m_start->next.get();
276 m_end = m_start->next.get();
281 const_segment_iterator& operator--()
284 m_start = m_start->prev.get();
285 m_end = m_start->next.get();
290 const_segment_iterator operator--(
int)
293 const_segment_iterator ret = *
this;
294 m_start = m_start->prev.get();
295 m_end = m_start->next.get();
307 m_node.start = m_start->key;
308 m_node.end = m_end->key;
309 m_node.value = m_start->value_leaf.value;
313 const typename fst_type::node* m_start;
314 const typename fst_type::node* m_end;