41 #ifndef PB_DS_PAT_TRIE_BASE
42 #define PB_DS_PAT_TRIE_BASE
66 template<
typename Metadata,
typename _Alloc>
69 typedef Metadata metadata_type;
70 typedef _Alloc allocator_type;
71 typedef typename detail::rebind_traits<_Alloc, Metadata>::const_reference
76 {
return m_metadata; }
78 metadata_type m_metadata;
82 template<
typename _Alloc>
86 typedef _Alloc allocator_type;
91 template<
typename _ATraits,
typename Metadata>
96 typedef typename Metadata::allocator_type _Alloc;
99 typedef _Alloc allocator_type;
100 typedef _ATraits access_traits;
101 typedef typename _ATraits::type_traits type_traits;
105 node_pointer m_p_parent;
113 typedef typename _ATraits::const_iterator a_const_iterator;
115 #ifdef _GLIBCXX_DEBUG
119 assert_valid(a_const_pointer p_traits,
120 const char* __file,
int __line)
const
121 { assert_valid_imp(p_traits, __file, __line); }
123 virtual node_debug_info
124 assert_valid_imp(a_const_pointer,
const char*,
int)
const = 0;
130 template<
typename _ATraits,
typename Metadata>
135 typedef typename base_type::type_traits type_traits;
136 typedef typename base_type::node_pointer node_pointer;
138 node_pointer m_p_min;
139 node_pointer m_p_max;
143 #ifdef _GLIBCXX_DEBUG
144 typedef typename base_type::node_debug_info node_debug_info;
145 typedef typename base_type::a_const_pointer a_const_pointer;
147 virtual node_debug_info
148 assert_valid_imp(a_const_pointer,
const char* __file,
int __line)
const
150 _GLIBCXX_DEBUG_VERIFY_AT(
false,
151 _M_message(
"Assertion from %1;:%2;")
152 ._M_string(__FILE__)._M_integer(__LINE__),
154 return node_debug_info();
161 template<
typename _ATraits,
typename Metadata>
166 typedef typename base_type::type_traits type_traits;
167 typedef typename type_traits::value_type value_type;
168 typedef typename type_traits::reference reference;
169 typedef typename type_traits::const_reference const_reference;
177 _Leaf(const_reference other)
178 :
base_type(leaf_node), m_value(other) { }
188 #ifdef _GLIBCXX_DEBUG
189 typedef typename base_type::node_debug_info node_debug_info;
190 typedef typename base_type::a_const_pointer a_const_pointer;
192 virtual node_debug_info
193 assert_valid_imp(a_const_pointer p_traits,
194 const char* __file,
int __line)
const
196 PB_DS_DEBUG_VERIFY(base_type::m_type == leaf_node);
198 const_reference r_val = value();
199 return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
200 p_traits->end(p_traits->extract_key(r_val)));
210 template<
typename _ATraits,
typename Metadata>
215 typedef typename base_type::type_traits type_traits;
216 typedef typename base_type::access_traits access_traits;
217 typedef typename type_traits::value_type value_type;
218 typedef typename base_type::allocator_type _Alloc;
219 typedef _Alloc allocator_type;
220 typedef typename _Alloc::size_type size_type;
223 typedef typename base_type::a_const_pointer a_const_pointer;
224 typedef typename base_type::a_const_iterator a_const_iterator;
226 typedef typename base_type::node_pointer node_pointer;
232 typedef typename __rebind_l::pointer leaf_pointer;
233 typedef typename __rebind_l::const_pointer leaf_const_pointer;
236 typedef typename __rebind_in::pointer inode_pointer;
237 typedef typename __rebind_in::const_pointer inode_const_pointer;
240 get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer)
const;
244 typedef typename __rebind_np::pointer node_pointer_pointer;
245 typedef typename __rebind_np::reference node_pointer_reference;
249 arr_size = _ATraits::max_size + 1
251 PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2);
257 node_pointer_pointer m_p_p_cur;
258 node_pointer_pointer m_p_p_end;
261 typedef typename _Alloc::difference_type difference_type;
262 typedef node_pointer value_type;
263 typedef node_pointer_pointer pointer;
264 typedef node_pointer_reference reference;
267 node_pointer_pointer p_p_end = 0)
268 : m_p_p_cur(p_p_cur), m_p_p_end(p_p_end)
273 {
return m_p_p_cur == other.m_p_p_cur; }
277 {
return m_p_p_cur != other.m_p_p_cur; }
284 while (m_p_p_cur != m_p_p_end && *m_p_p_cur == 0);
296 const node_pointer_pointer
299 _GLIBCXX_DEBUG_ONLY(assert_referencible();)
306 _GLIBCXX_DEBUG_ONLY(assert_referencible();)
311 #ifdef _GLIBCXX_DEBUG
313 assert_referencible()
const
314 { _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end && *m_p_p_cur != 0); }
324 typedef typename _Alloc::difference_type difference_type;
325 typedef node_pointer value_type;
326 typedef node_pointer_pointer pointer;
327 typedef node_pointer_reference reference;
330 iterator(node_pointer_pointer p_p_cur = 0,
331 node_pointer_pointer p_p_end = 0)
335 operator==(
const iterator& other)
const
336 {
return const_iterator::m_p_p_cur == other.m_p_p_cur; }
339 operator!=(
const iterator& other)
const
340 {
return const_iterator::m_p_p_cur != other.m_p_p_cur; }
345 const_iterator::operator++();
360 _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
361 return const_iterator::m_p_p_cur;
367 _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
368 return *const_iterator::m_p_p_cur;
373 _Inode(size_type,
const a_const_iterator);
376 update_prefixes(a_const_pointer);
391 get_child_node(a_const_iterator, a_const_iterator, a_const_pointer);
393 inline node_const_pointer
394 get_child_node(a_const_iterator, a_const_iterator, a_const_pointer)
const;
397 get_child_it(a_const_iterator, a_const_iterator, a_const_pointer);
400 get_lower_bound_child_node(a_const_iterator, a_const_iterator,
401 size_type, a_const_pointer);
404 add_child(node_pointer, a_const_iterator, a_const_iterator,
407 inline node_const_pointer
408 get_join_child(node_const_pointer, a_const_pointer)
const;
411 get_join_child(node_pointer, a_const_pointer);
414 remove_child(node_pointer);
420 replace_child(node_pointer, a_const_iterator, a_const_iterator,
423 inline a_const_iterator
426 inline a_const_iterator
430 should_be_mine(a_const_iterator, a_const_iterator, size_type,
431 a_const_pointer)
const;
434 leftmost_descendant();
437 leftmost_descendant()
const;
440 rightmost_descendant();
443 rightmost_descendant()
const;
445 #ifdef _GLIBCXX_DEBUG
446 typedef typename base_type::node_debug_info node_debug_info;
448 virtual node_debug_info
449 assert_valid_imp(a_const_pointer,
const char*,
int)
const;
460 get_begin_pos()
const;
462 static __rebind_l s_leaf_alloc;
463 static __rebind_in s_inode_alloc;
465 const size_type m_e_ind;
466 a_const_iterator m_pref_b_it;
467 a_const_iterator m_pref_e_it;
468 node_pointer m_a_p_children[arr_size];
471 #define PB_DS_CONST_IT_C_DEC \
472 _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
474 #define PB_DS_CONST_ODIR_IT_C_DEC \
475 _CIter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
477 #define PB_DS_IT_C_DEC \
478 _Iter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
480 #define PB_DS_ODIR_IT_C_DEC \
481 _Iter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
485 template<
typename Node,
typename Leaf,
typename Head,
typename Inode,
486 bool Is_Forward_Iterator>
491 typedef typename Node::allocator_type allocator_type;
492 typedef typename Node::type_traits type_traits;
495 typedef typename allocator_type::difference_type difference_type;
496 typedef typename type_traits::value_type value_type;
497 typedef typename type_traits::pointer pointer;
498 typedef typename type_traits::reference reference;
499 typedef typename type_traits::const_pointer const_pointer;
500 typedef typename type_traits::const_reference const_reference;
502 typedef allocator_type _Alloc;
509 typedef typename Inode::iterator inode_iterator;
513 _CIter(node_pointer p_nd = 0) : m_p_nd(p_nd)
516 _CIter(
const PB_DS_CONST_ODIR_IT_C_DEC& other)
517 : m_p_nd(other.m_p_nd)
521 operator=(
const _CIter& other)
523 m_p_nd = other.m_p_nd;
528 operator=(
const PB_DS_CONST_ODIR_IT_C_DEC& other)
530 m_p_nd = other.m_p_nd;
537 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
538 return &
static_cast<leaf_pointer
>(m_p_nd)->value();
544 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
545 return static_cast<leaf_pointer
>(m_p_nd)->value();
549 operator==(
const _CIter& other)
const
550 {
return m_p_nd == other.m_p_nd; }
553 operator==(
const PB_DS_CONST_ODIR_IT_C_DEC& other)
const
554 {
return m_p_nd == other.m_p_nd; }
557 operator!=(
const _CIter& other)
const
558 {
return m_p_nd != other.m_p_nd; }
561 operator!=(
const PB_DS_CONST_ODIR_IT_C_DEC& other)
const
562 {
return m_p_nd != other.m_p_nd; }
567 inc(integral_constant<int, Is_Forward_Iterator>());
582 dec(integral_constant<int, Is_Forward_Iterator>());
602 if (m_p_nd->m_type == head_node)
604 m_p_nd =
static_cast<head_pointer
>(m_p_nd)->m_p_min;
608 node_pointer p_y = m_p_nd->m_p_parent;
609 while (p_y->m_type != head_node && get_larger_sibling(m_p_nd) == 0)
612 p_y = p_y->m_p_parent;
615 if (p_y->m_type == head_node)
620 m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd));
630 if (m_p_nd->m_type == head_node)
632 m_p_nd =
static_cast<head_pointer
>(m_p_nd)->m_p_max;
636 node_pointer p_y = m_p_nd->m_p_parent;
637 while (p_y->m_type != head_node && get_smaller_sibling(m_p_nd) == 0)
640 p_y = p_y->m_p_parent;
643 if (p_y->m_type == head_node)
648 m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd));
652 get_larger_sibling(node_pointer p_nd)
654 inode_pointer p_parent =
static_cast<inode_pointer
>(p_nd->m_p_parent);
656 inode_iterator it = p_parent->begin();
660 inode_iterator next_it = it;
662 return (next_it == p_parent->end())? 0 : *next_it;
666 get_smaller_sibling(node_pointer p_nd)
668 inode_pointer p_parent =
static_cast<inode_pointer
>(p_nd->m_p_parent);
670 inode_iterator it = p_parent->begin();
674 inode_iterator prev_it;
684 _GLIBCXX_DEBUG_ASSERT(
false);
689 leftmost_descendant(node_pointer p_nd)
691 if (p_nd->m_type == leaf_node)
692 return static_cast<leaf_pointer
>(p_nd);
693 return static_cast<inode_pointer
>(p_nd)->leftmost_descendant();
697 rightmost_descendant(node_pointer p_nd)
699 if (p_nd->m_type == leaf_node)
700 return static_cast<leaf_pointer
>(p_nd);
701 return static_cast<inode_pointer
>(p_nd)->rightmost_descendant();
707 template<
typename Node,
typename Leaf,
typename Head,
typename Inode,
708 bool Is_Forward_Iterator>
710 :
public _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
715 typedef typename base_type::allocator_type allocator_type;
716 typedef typename base_type::type_traits type_traits;
717 typedef typename type_traits::value_type value_type;
718 typedef typename type_traits::pointer pointer;
719 typedef typename type_traits::reference reference;
721 typedef typename base_type::node_pointer node_pointer;
722 typedef typename base_type::leaf_pointer leaf_pointer;
723 typedef typename base_type::leaf_const_pointer leaf_const_pointer;
724 typedef typename base_type::head_pointer head_pointer;
725 typedef typename base_type::inode_pointer inode_pointer;
727 _Iter(node_pointer p_nd = 0)
730 _Iter(
const PB_DS_ODIR_IT_C_DEC& other)
734 operator=(
const _Iter& other)
736 base_type::m_p_nd = other.m_p_nd;
741 operator=(
const PB_DS_ODIR_IT_C_DEC& other)
743 base_type::m_p_nd = other.m_p_nd;
750 _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
751 return &
static_cast<leaf_pointer
>(base_type::m_p_nd)->value();
757 _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
758 return static_cast<leaf_pointer
>(base_type::m_p_nd)->value();
764 base_type::operator++();
771 _Iter ret(base_type::m_p_nd);
779 base_type::operator--();
786 _Iter ret(base_type::m_p_nd);
792 #undef PB_DS_CONST_ODIR_IT_C_DEC
793 #undef PB_DS_ODIR_IT_C_DEC
796 #define PB_DS_PAT_TRIE_NODE_CONST_ITERATOR_C_DEC \
797 _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
799 #define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \
800 _Node_iter<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
803 template<
typename Node,
821 typedef typename Node::a_const_pointer a_const_pointer;
822 typedef typename Node::a_const_iterator a_const_iterator;
828 if (m_p_nd->m_type == leaf_node)
830 leaf_const_pointer lcp =
static_cast<leaf_const_pointer
>(m_p_nd);
831 return m_p_traits->begin(m_p_traits->extract_key(lcp->value()));
833 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
834 return static_cast<inode_const_pointer
>(m_p_nd)->pref_b_it();
840 if (m_p_nd->m_type == leaf_node)
842 leaf_const_pointer lcp =
static_cast<leaf_const_pointer
>(m_p_nd);
843 return m_p_traits->end(m_p_traits->extract_key(lcp->value()));
845 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
846 return static_cast<inode_const_pointer
>(m_p_nd)->pref_e_it();
852 typedef typename _Alloc::size_type size_type;
854 typedef _CIterator value_type;
855 typedef value_type reference;
856 typedef value_type const_reference;
865 _Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
866 : m_p_nd(const_cast<node_pointer>(p_nd)), m_p_traits(p_traits)
872 {
return std::make_pair(pref_begin(), pref_end()); }
880 return _CIterator(m_p_nd);
886 {
return m_p_nd->get_metadata(); }
892 if (m_p_nd->m_type == leaf_node)
894 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
895 inode_pointer inp =
static_cast<inode_pointer
>(m_p_nd);
904 _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
905 inode_pointer inp =
static_cast<inode_pointer
>(m_p_nd);
906 typename Inode::iterator it = inp->begin();
914 {
return m_p_nd == other.m_p_nd; }
919 {
return m_p_nd != other.m_p_nd; }
922 a_const_pointer m_p_traits;
927 template<
typename Node,
935 :
public _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc>
941 typedef typename base_type::inode_pointer inode_pointer;
942 typedef typename base_type::a_const_pointer a_const_pointer;
943 typedef Iterator iterator;
946 typedef typename base_type::size_type size_type;
948 typedef Iterator value_type;
949 typedef value_type reference;
950 typedef value_type const_reference;
952 _Node_iter(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
961 return iterator(base_type::m_p_nd);
968 _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == i_node);
970 typename Inode::iterator it =
971 static_cast<inode_pointer
>(base_type::m_p_nd)->
begin();
974 return _Node_iter(*it, base_type::m_p_traits);
980 #define PB_DS_CLASS_T_DEC \
981 template<typename _ATraits, typename Metadata>
983 #define PB_DS_CLASS_C_DEC \
984 pat_trie_base::_Inode<_ATraits, Metadata>
987 typename PB_DS_CLASS_C_DEC::__rebind_l
988 PB_DS_CLASS_C_DEC::s_leaf_alloc;
991 typename PB_DS_CLASS_C_DEC::__rebind_in
992 PB_DS_CLASS_C_DEC::s_inode_alloc;
995 inline typename PB_DS_CLASS_C_DEC::size_type
997 get_pref_pos(a_const_iterator b_it, a_const_iterator e_it,
998 a_const_pointer p_traits)
const
1000 if (
static_cast<std::size_t
>(
std::distance(b_it, e_it)) <= m_e_ind)
1003 return 1 + p_traits->e_pos(*b_it);
1008 _Inode(size_type len,
const a_const_iterator it)
1009 : base_type(i_node), m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it)
1012 std::fill(m_a_p_children, m_a_p_children + arr_size,
1013 static_cast<node_pointer
>(0));
1019 update_prefixes(a_const_pointer p_traits)
1021 node_pointer p_first = *
begin();
1022 if (p_first->m_type == leaf_node)
1024 leaf_const_pointer p =
static_cast<leaf_const_pointer
>(p_first);
1025 m_pref_b_it = p_traits->begin(access_traits::extract_key(p->value()));
1029 inode_pointer p =
static_cast<inode_pointer
>(p_first);
1030 _GLIBCXX_DEBUG_ASSERT(p_first->m_type == i_node);
1031 m_pref_b_it = p->pref_b_it();
1033 m_pref_e_it = m_pref_b_it;
1038 typename PB_DS_CLASS_C_DEC::const_iterator
1042 typedef node_pointer_pointer pointer_type;
1043 pointer_type p =
const_cast<pointer_type
>(m_a_p_children);
1044 return const_iterator(p + get_begin_pos(), p + arr_size);
1048 typename PB_DS_CLASS_C_DEC::iterator
1052 return iterator(m_a_p_children + get_begin_pos(),
1053 m_a_p_children + arr_size);
1057 typename PB_DS_CLASS_C_DEC::const_iterator
1061 typedef node_pointer_pointer pointer_type;
1062 pointer_type p =
const_cast<pointer_type
>(m_a_p_children) + arr_size;
1063 return const_iterator(p, p);
1067 typename PB_DS_CLASS_C_DEC::iterator
1070 {
return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); }
1073 inline typename PB_DS_CLASS_C_DEC::node_pointer
1075 get_child_node(a_const_iterator b_it, a_const_iterator e_it,
1076 a_const_pointer p_traits)
1078 const size_type i = get_pref_pos(b_it, e_it, p_traits);
1079 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1080 return m_a_p_children[i];
1084 inline typename PB_DS_CLASS_C_DEC::iterator
1086 get_child_it(a_const_iterator b_it, a_const_iterator e_it,
1087 a_const_pointer p_traits)
1089 const size_type i = get_pref_pos(b_it, e_it, p_traits);
1090 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1091 _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0);
1092 return iterator(m_a_p_children + i, m_a_p_children + i);
1096 inline typename PB_DS_CLASS_C_DEC::node_const_pointer
1098 get_child_node(a_const_iterator b_it, a_const_iterator e_it,
1099 a_const_pointer p_traits)
const
1100 {
return const_cast<node_pointer
>(get_child_node(b_it, e_it, p_traits)); }
1103 typename PB_DS_CLASS_C_DEC::node_pointer
1105 get_lower_bound_child_node(a_const_iterator b_it, a_const_iterator e_it,
1106 size_type checked_ind,
1107 a_const_pointer p_traits)
1109 if (!should_be_mine(b_it, e_it, checked_ind, p_traits))
1111 if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it,
1113 return leftmost_descendant();
1114 return rightmost_descendant();
1117 size_type i = get_pref_pos(b_it, e_it, p_traits);
1118 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1120 if (m_a_p_children[i] != 0)
1121 return m_a_p_children[i];
1123 while (++i < arr_size)
1124 if (m_a_p_children[i] != 0)
1126 const node_type& __nt = m_a_p_children[i]->m_type;
1127 node_pointer ret = m_a_p_children[i];
1129 if (__nt == leaf_node)
1132 _GLIBCXX_DEBUG_ASSERT(__nt == i_node);
1133 inode_pointer inp =
static_cast<inode_pointer
>(ret);
1134 return inp->leftmost_descendant();
1137 return rightmost_descendant();
1141 inline typename PB_DS_CLASS_C_DEC::node_pointer
1143 add_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
1144 a_const_pointer p_traits)
1146 const size_type i = get_pref_pos(b_it, e_it, p_traits);
1147 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1148 if (m_a_p_children[i] == 0)
1150 m_a_p_children[i] = p_nd;
1151 p_nd->m_p_parent =
this;
1154 return m_a_p_children[i];
1158 typename PB_DS_CLASS_C_DEC::node_const_pointer
1160 get_join_child(node_const_pointer p_nd,
1161 a_const_pointer p_tr)
const
1163 node_pointer p =
const_cast<node_pointer
>(p_nd);
1164 return const_cast<inode_pointer
>(
this)->get_join_child(p, p_tr);
1168 typename PB_DS_CLASS_C_DEC::node_pointer
1170 get_join_child(node_pointer p_nd, a_const_pointer p_traits)
1173 a_const_iterator b_it;
1174 a_const_iterator e_it;
1175 if (p_nd->m_type == leaf_node)
1177 leaf_const_pointer p =
static_cast<leaf_const_pointer
>(p_nd);
1179 typedef typename type_traits::key_const_reference kcr;
1180 kcr r_key = access_traits::extract_key(p->value());
1181 b_it = p_traits->begin(r_key);
1182 e_it = p_traits->end(r_key);
1186 b_it =
static_cast<inode_pointer
>(p_nd)->pref_b_it();
1187 e_it =
static_cast<inode_pointer
>(p_nd)->pref_e_it();
1189 i = get_pref_pos(b_it, e_it, p_traits);
1190 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1191 return m_a_p_children[i];
1197 remove_child(node_pointer p_nd)
1200 for (; i < arr_size; ++i)
1201 if (m_a_p_children[i] == p_nd)
1203 m_a_p_children[i] = 0;
1206 _GLIBCXX_DEBUG_ASSERT(i != arr_size);
1212 remove_child(iterator it)
1213 { *it.m_p_p_cur = 0; }
1218 replace_child(node_pointer p_nd, a_const_iterator b_it,
1219 a_const_iterator e_it,
1220 a_const_pointer p_traits)
1222 const size_type i = get_pref_pos(b_it, e_it, p_traits);
1223 _GLIBCXX_DEBUG_ASSERT(i < arr_size);
1224 m_a_p_children[i] = p_nd;
1225 p_nd->m_p_parent =
this;
1229 inline typename PB_DS_CLASS_C_DEC::a_const_iterator
1232 {
return m_pref_b_it; }
1235 inline typename PB_DS_CLASS_C_DEC::a_const_iterator
1238 {
return m_pref_e_it; }
1243 should_be_mine(a_const_iterator b_it, a_const_iterator e_it,
1244 size_type checked_ind,
1245 a_const_pointer p_traits)
const
1251 if (num_es < m_e_ind)
1254 a_const_iterator key_b_it = b_it;
1256 a_const_iterator key_e_it = b_it;
1259 a_const_iterator value_b_it = m_pref_b_it;
1261 a_const_iterator value_e_it = m_pref_b_it;
1264 return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it,
1269 typename PB_DS_CLASS_C_DEC::leaf_pointer
1271 leftmost_descendant()
1273 node_pointer p_pot = *
begin();
1274 if (p_pot->m_type == leaf_node)
1275 return (
static_cast<leaf_pointer
>(p_pot));
1276 _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
1277 return static_cast<inode_pointer
>(p_pot)->leftmost_descendant();
1281 typename PB_DS_CLASS_C_DEC::leaf_const_pointer
1283 leftmost_descendant()
const
1284 {
return const_cast<inode_pointer
>(
this)->leftmost_descendant(); }
1287 typename PB_DS_CLASS_C_DEC::leaf_pointer
1289 rightmost_descendant()
1292 _GLIBCXX_DEBUG_ASSERT(num_children >= 2);
1294 iterator it =
begin();
1296 node_pointer p_pot =* it;
1297 if (p_pot->m_type == leaf_node)
1298 return static_cast<leaf_pointer
>(p_pot);
1299 _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
1300 return static_cast<inode_pointer
>(p_pot)->rightmost_descendant();
1304 typename PB_DS_CLASS_C_DEC::leaf_const_pointer
1306 rightmost_descendant()
const
1307 {
return const_cast<inode_pointer
>(
this)->rightmost_descendant(); }
1310 typename PB_DS_CLASS_C_DEC::size_type
1312 get_begin_pos()
const
1315 for (; i < arr_size && m_a_p_children[i] == 0; ++i)
1320 #ifdef _GLIBCXX_DEBUG
1322 typename PB_DS_CLASS_C_DEC::node_debug_info
1324 assert_valid_imp(a_const_pointer p_traits,
1325 const char* __file,
int __line)
const
1327 PB_DS_DEBUG_VERIFY(base_type::m_type == i_node);
1328 PB_DS_DEBUG_VERIFY(
static_cast<size_type
>(
std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
1331 for (
typename _Inode::const_iterator it =
begin(); it !=
end(); ++it)
1333 node_const_pointer p_nd = *it;
1334 PB_DS_DEBUG_VERIFY(p_nd->m_p_parent ==
this);
1335 node_debug_info child_ret = p_nd->assert_valid_imp(p_traits,
1338 PB_DS_DEBUG_VERIFY(
static_cast<size_type
>(
std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
1339 PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
1340 PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) ==
static_cast<size_type
>(it.m_p_p_cur - m_a_p_children));
1342 return std::make_pair(pref_b_it(), pref_e_it());
1346 #undef PB_DS_CLASS_T_DEC
1347 #undef PB_DS_CLASS_C_DEC
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
void trivial_iterator_difference_type
Prohibit moving trivial iterators.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
GNU extensions for policy-based data structures for public use.
Forward iterators support a superset of input iterator operations.
Bidirectional iterators support a superset of forward iterator operations.
Struct holding two objects of arbitrary type.
A trivial iterator tag. Signifies that the iterators has none of std::iterators's movement abilities.
Represents no type, or absence of type, for template tricks.
Consistent API for accessing allocator-related types.
Base type for PATRICIA trees.
node_type
Three types of nodes.
Metadata base primary template.
Head node for PATRICIA tree.
Leaf node for PATRICIA tree.
Internal node type, PATRICIA tree.
std::pair< a_const_iterator, a_const_iterator > valid_prefix() const
Subtree valid prefix.
bool operator!=(const _Node_citer &other) const
Compares content (negatively) to a different iterator object.
Node::metadata_type metadata_type
Metadata type.
bool operator==(const _Node_citer &other) const
Compares content to a different iterator object.
_Node_citer get_child(size_type i) const
Returns a __const node __iterator to the corresponding node's i-th child.
size_type num_children() const
Returns the number of children in the corresponding node.
const_reference operator*() const
Const access; returns the __const iterator* associated with the current leaf.
metadata_const_reference get_metadata() const
Metadata access.
rebind_traits< _Alloc, metadata_type >::const_reference metadata_const_reference
Const metadata reference type.
reference operator*() const
Access; returns the iterator* associated with the current leaf.
_Node_iter get_child(size_type i) const
Returns a node __iterator to the corresponding node's i-th child.