96class const_iterator_base
98 typedef Hdl handler_type;
101 typedef FstType fst_type;
105 std::add_const_t<typename fst_type::key_type>, std::add_const_t<typename fst_type::value_type>>;
106 using pointer = value_type*;
107 using reference = value_type&;
108 using difference_type = ptrdiff_t;
109 using iterator_category = ::std::bidirectional_iterator_tag;
111 explicit const_iterator_base(
const fst_type* _db,
bool _end) : m_db(_db), m_end_pos(_end)
116 m_pos = handler_type::init_pos(_db, _end);
119 explicit const_iterator_base(
const fst_type* _db,
const typename fst_type::node* pos) : m_db(_db), m_pos(pos)
122 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)
125 const_iterator_base& operator=(
const const_iterator_base& r)
129 m_end_pos = r.m_end_pos;
133 const_iterator_base& operator++()
136 handler_type::inc(m_db, m_pos, m_end_pos);
140 const_iterator_base& operator--()
143 handler_type::dec(m_pos, m_end_pos);
147 bool operator==(
const const_iterator_base& r)
const
152 return (m_pos == r.m_pos) && (m_end_pos == r.m_end_pos);
155 bool operator!=(
const const_iterator_base& r)
const
157 return !operator==(r);
160 value_type operator*()
162 return value_type(m_pos->key, m_pos->value_leaf.value);
165 value_type operator->()
167 return value_type(m_pos->key, m_pos->value_leaf.value);
171 const typename fst_type::node* get_pos()
const
176 const fst_type* get_parent()
const
181 bool is_end_pos()
const
187 const fst_type* m_db =
nullptr;
188 const typename fst_type::node* m_pos =
nullptr;
189 bool m_end_pos =
false;
193class const_segment_iterator
195 typedef FstType fst_type;
198 const_segment_iterator(
const typename fst_type::node* start,
const typename fst_type::node* end)
199 : m_start(start), m_end(end)
207 typename fst_type::key_type start;
208 typename fst_type::key_type end;
209 typename fst_type::value_type value;
211 value_type() : start(), end(), value()
215 typename fst_type::key_type _start,
typename fst_type::key_type _end,
typename fst_type::value_type _value)
216 : start(std::move(_start)), end(std::move(_end)), value(std::move(_value))
219 bool operator==(
const value_type& other)
const
221 return start == other.start && end == other.end && value == other.value;
224 bool operator!=(
const value_type& other)
const
226 return !operator==(other);
230 const_segment_iterator() : m_start(nullptr), m_end(nullptr)
237 const_segment_iterator(const_segment_iterator&& other)
238 : m_start(std::move(other.m_start)), m_end(std::move(other.m_end))
244 ~const_segment_iterator()
247 bool operator==(
const const_segment_iterator& other)
const
249 return m_start == other.m_start && m_end == other.m_end;
252 bool operator!=(
const const_segment_iterator& other)
const
254 return !operator==(other);
257 const_segment_iterator& operator=(
const const_segment_iterator& other)
259 m_start = other.m_start;
266 const_segment_iterator& operator=(const_segment_iterator&& other)
268 m_start = std::move(other.m_start);
269 m_end = std::move(other.m_end);
285 const_segment_iterator& operator++()
288 m_start = m_start->next.get();
289 m_end = m_start->next.get();
294 const_segment_iterator operator++(
int)
297 const_segment_iterator ret = *
this;
298 m_start = m_start->next.get();
299 m_end = m_start->next.get();
304 const_segment_iterator& operator--()
307 m_start = m_start->prev.get();
308 m_end = m_start->next.get();
313 const_segment_iterator operator--(
int)
316 const_segment_iterator ret = *
this;
317 m_start = m_start->prev.get();
318 m_end = m_start->next.get();
330 m_node.start = m_start->key;
331 m_node.end = m_end->key;
332 m_node.value = m_start->value_leaf.value;
336 const typename fst_type::node* m_start;
337 const typename fst_type::node* m_end;