3 #include <wordring/trie/trie_heap.hpp>
9 template <
typename Container>
13 using difference_type = std::ptrdiff_t;
14 using value_type = std::uint8_t;
15 using pointer = value_type*;
16 using reference = value_type&;
17 using iterator_category = std::input_iterator_tag;
20 using index_type =
typename trie_node::index_type;
22 using container = Container
const;
24 static constexpr std::uint16_t null_value = 256;
34 : m_c(std::addressof(c))
43 assert(
base() <= m_index && m_index <
base() + null_value);
45 return m_index -
base();
54 index_type
base = (d + m_index)->m_base;
59 index_type i =
base + label;
60 if (i <
limit() && (d + i)->m_check == m_index) idx = i;
77 return (m_c->data() + m_index)->m_check;
88 index_type idx = (m_c->data() + m_index)->m_base;
90 ?
find(idx, idx + null_value, m_index)
94 index_type end_index()
const {
return 0; }
102 index_type
find(index_type first, index_type last, index_type check)
const
104 index_type tail = std::min(last,
limit());
105 for (; first < tail; ++first)
if ((m_c->data() + first)->m_check == check)
break;
107 return (first != tail) ? first : 0;
114 assert(1 <= m_index && m_index <
limit());
117 index_type parent = (d + m_index)->m_check;
131 index_type parent =
mother();
134 index_type idx = (parent != 0) ? (d + parent)->m_base : 0;
143 index_type
limit()
const {
return m_c->size(); }
149 if (m_index == 1)
return false;
152 index_type idx = (d + m_index)->m_base + null_value;
154 return (idx <
limit() && (d + idx)->m_check == m_index);
161 if (m_index == 1)
return false;
163 index_type check = (m_c->data() + m_index)->m_check;
165 index_type first =
base();
166 index_type last = first + null_value;
170 first =
find(first, last, check);
171 if (first == 0)
return false;
172 if (first != m_index)
return true;