41#ifdef PB_DS_CLASS_C_DEC
44inline typename PB_DS_CLASS_C_DEC::iterator
46find_by_order(size_type order)
52 node_iterator nd_it = node_begin();
56 if (order > nd_it.get_metadata())
57 return ++base_type::rightmost_it(nd_it);
59 const size_type num_children = nd_it.num_children();
60 if (num_children == 0)
63 for (size_type i = 0; i < num_children; ++i)
65 node_iterator child_nd_it = nd_it.get_child(i);
66 if (order <= child_nd_it.get_metadata())
72 order -= child_nd_it.get_metadata();
78inline typename PB_DS_CLASS_C_DEC::const_iterator
80find_by_order(size_type order)
const
81{
return const_cast<PB_DS_CLASS_C_DEC*
>(
this)->find_by_order(order); }
84inline typename PB_DS_CLASS_C_DEC::size_type
86order_of_key(key_const_reference r_key)
const
88 const _ATraits& r_traits =
89 const_cast<PB_DS_CLASS_C_DEC*
>(
this)->get_access_traits();
91 return order_of_prefix(r_traits.begin(r_key), r_traits.end(r_key));
95inline typename PB_DS_CLASS_C_DEC::size_type
97order_of_prefix(
typename access_traits::const_iterator b,
98 typename access_traits::const_iterator e)
const
103 const _ATraits& r_traits =
104 const_cast<PB_DS_CLASS_C_DEC*
>(
this)->get_access_traits();
106 node_const_iterator nd_it = node_begin();
107 node_const_iterator end_nd_it = node_end();
112 const size_type num_children = nd_it.num_children();
113 if (num_children == 0)
115 key_const_reference r_key = base_type::extract_key(*(*nd_it));
116 typename access_traits::const_iterator key_b =
117 r_traits.begin(r_key);
119 typename access_traits::const_iterator key_e =
122 return (base_type::less(key_b, key_e, b, e, r_traits)) ?
126 node_const_iterator next_nd_it = end_nd_it;
127 size_type i = num_children - 1;
131 node_const_iterator child_nd_it = nd_it.get_child(i);
133 if (next_nd_it != end_nd_it)
134 ord += child_nd_it.get_metadata();
135 else if (!base_type::less(b, e,
136 child_nd_it.valid_prefix().first,
137 child_nd_it.valid_prefix().second,
139 next_nd_it = child_nd_it;
143 if (next_nd_it == end_nd_it)
153operator()(node_iterator nd_it, node_const_iterator )
const
155 const size_type num_children = nd_it.num_children();
156 size_type children_rank = 0;
157 for (size_type i = 0; i < num_children; ++i)
158 children_rank += nd_it.get_child(i).get_metadata();
160 const size_type res = (num_children == 0) ? 1 : children_rank;
161 const_cast<size_type&
>(nd_it.get_metadata()) = res;
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.