42 inline typename PB_DS_CLASS_C_DEC::point_iterator
44 find(key_const_reference r_key)
47 node_pointer p_nd = find_imp(r_key);
49 if (p_nd == 0 || p_nd->m_type != leaf_node)
55 if (synth_access_traits::equal_keys(
PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
68 find(key_const_reference r_key)
const
74 if (p_nd == 0 || p_nd->m_type != leaf_node)
80 if (synth_access_traits::equal_keys(
PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
83 return const_iterator(const_cast<node_pointer>(p_nd));
93 find_imp(key_const_reference r_key)
98 typename synth_access_traits::const_iterator b_it =
99 synth_access_traits::begin(r_key);
100 typename synth_access_traits::const_iterator e_it =
101 synth_access_traits::end(r_key);
103 node_pointer p_nd = m_p_head->m_p_parent;
106 while (p_nd->m_type != leaf_node)
109 node_pointer p_next_nd =
static_cast<inode_pointer
>(p_nd)->get_child_node(b_it, e_it,
this);
119 inline typename PB_DS_CLASS_C_DEC::node_pointer
121 lower_bound_imp(key_const_reference r_key)
126 node_pointer p_nd = m_p_head->m_p_parent;
129 typename PB_DS_CLASS_C_DEC::a_const_iterator b_it =
130 synth_access_traits::begin(r_key);
132 typename PB_DS_CLASS_C_DEC::a_const_iterator e_it =
133 synth_access_traits::end(r_key);
135 size_type checked_ind = 0;
138 if (p_nd->m_type == leaf_node)
140 if (!synth_access_traits::cmp_keys(
PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
148 const size_type new_checked_ind =
149 static_cast<inode_pointer
>(p_nd)->get_e_ind();
152 static_cast<inode_pointer
>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind,
this);
153 checked_ind = new_checked_ind;
158 inline typename PB_DS_CLASS_C_DEC::point_iterator
160 lower_bound(key_const_reference r_key)
161 {
return point_iterator(lower_bound_imp(r_key)); }
164 inline typename PB_DS_CLASS_C_DEC::point_const_iterator
166 lower_bound(key_const_reference r_key)
const
168 return point_const_iterator(const_cast<PB_DS_CLASS_C_DEC* >(
this)->lower_bound_imp(r_key));
172 inline typename PB_DS_CLASS_C_DEC::point_iterator
174 upper_bound(key_const_reference r_key)
176 point_iterator l_bound_it = lower_bound(r_key);
179 !synth_access_traits::cmp_keys(
PB_DS_V2F(*l_bound_it),
182 if (l_bound_it == end() ||
183 synth_access_traits::cmp_keys(r_key,
PB_DS_V2F(*l_bound_it)))
190 inline typename PB_DS_CLASS_C_DEC::point_const_iterator
192 upper_bound(key_const_reference r_key)
const
194 point_const_iterator l_bound_it = lower_bound(r_key);
197 !synth_access_traits::cmp_keys(
PB_DS_V2F(*l_bound_it),
200 if (l_bound_it == end() ||
201 synth_access_traits::cmp_keys(r_key,
PB_DS_V2F(*l_bound_it)))
207 inline typename PB_DS_CLASS_C_DEC::a_const_iterator
209 pref_begin(node_const_pointer p_nd)
211 if (p_nd->m_type == leaf_node)
212 return (synth_access_traits::begin(
PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
215 return static_cast<inode_const_pointer
>(p_nd)->pref_b_it();
219 inline typename PB_DS_CLASS_C_DEC::a_const_iterator
221 pref_end(node_const_pointer p_nd)
223 if (p_nd->m_type == leaf_node)
224 return (synth_access_traits::end(
PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
227 return static_cast<inode_const_pointer
>(p_nd)->pref_e_it();
231 inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
233 leftmost_descendant(node_const_pointer p_nd)
235 if (p_nd->m_type == leaf_node)
236 return static_cast<leaf_const_pointer
>(p_nd);
237 return static_cast<inode_const_pointer
>(p_nd)->leftmost_descendant();
241 inline typename PB_DS_CLASS_C_DEC::leaf_pointer
243 leftmost_descendant(node_pointer p_nd)
245 if (p_nd->m_type == leaf_node)
246 return static_cast<leaf_pointer
>(p_nd);
247 return static_cast<inode_pointer
>(p_nd)->leftmost_descendant();
251 inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
253 rightmost_descendant(node_const_pointer p_nd)
255 if (p_nd->m_type == leaf_node)
256 return static_cast<leaf_const_pointer
>(p_nd);
257 return static_cast<inode_const_pointer
>(p_nd)->rightmost_descendant();
261 inline typename PB_DS_CLASS_C_DEC::leaf_pointer
263 rightmost_descendant(node_pointer p_nd)
265 if (p_nd->m_type == leaf_node)
266 return static_cast<leaf_pointer
>(p_nd);
267 return static_cast<inode_pointer
>(p_nd)->rightmost_descendant();
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
#define PB_DS_CLASS_C_DEC
Definition: bin_search_tree_.hpp:71
#define PB_DS_CLASS_T_DEC
Definition: bin_search_tree_.hpp:67
return(unsigned int) __res
#define PB_DS_CHECK_KEY_EXISTS(_Key)
Definition: container_base_dispatch.hpp:55
#define PB_DS_ASSERT_VALID(X)
Definition: binary_heap_.hpp:324
#define PB_DS_V2F(X)
Definition: container_base_dispatch.hpp:80
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key)
Definition: container_base_dispatch.hpp:58