49 leaf_pointer p_split_lf = split_prep(r_key, other, bag);
61 m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf),
62 pref_end(p_split_lf), other, bag);
64 m_p_head->m_p_parent->m_p_parent = m_p_head;
66 head_pointer __ohead = other.m_p_head;
67 __ohead->m_p_max = m_p_head->m_p_max;
68 m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
69 __ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent);
73 m_size -= other.m_size;
93 if (synth_access_traits::cmp_keys(r_key,
94 PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
103 if (!synth_access_traits::cmp_keys(r_key,
104 PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value())))
111 iterator it = lower_bound(r_key);
113 if (!synth_access_traits::equal_keys(
PB_DS_V2F(*it), r_key))
116 node_pointer p_nd = it.m_p_nd;
118 leaf_pointer p_ret_l = static_cast<leaf_pointer>(p_nd);
119 while (p_nd->m_type != head_node)
122 p_nd = p_nd->m_p_parent;
130 typename PB_DS_CLASS_C_DEC::node_pointer
132 rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
135 if (p_nd->m_type == leaf_node)
142 inode_pointer p_ind =
static_cast<inode_pointer
>(p_nd);
144 node_pointer pfirst = p_ind->get_child_node(b_it, e_it,
this);
145 node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag);
147 p_ind->replace_child(p_child_ret, b_it, e_it, this);
148 apply_update(p_ind, (node_update*)this);
150 inode_iterator child_it = p_ind->get_child_it(b_it, e_it, this);
151 const size_type lhs_dist = std::distance(p_ind->begin(), child_it);
152 const size_type lhs_num_children = lhs_dist + 1;
155 const size_type rhs_dist = std::distance(p_ind->begin(), p_ind->end());
156 size_type rhs_num_children = rhs_dist - lhs_num_children;
157 if (rhs_num_children == 0)
159 apply_update(p_ind, (node_update*)
this);
163 other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it,
164 rhs_num_children, r_bag);
166 child_it = p_ind->get_child_it(b_it, e_it,
this);
167 while (rhs_num_children != 0)
170 p_ind->remove_child(child_it);
173 apply_update(p_ind, (node_update*)
this);
175 const size_type int_dist = std::distance(p_ind->begin(), p_ind->end());
179 p_ind->update_prefixes(
this);
181 apply_update(p_ind, (node_update*)this);
185 node_pointer p_ret = *p_ind->begin();
187 s_inode_allocator.deallocate(p_ind, 1);
188 apply_update(p_ret, (node_update*)this);
195 split_insert_branch(size_type e_ind, a_const_iterator b_it,
196 inode_iterator child_b_it,
197 size_type num_children, branch_bag& r_bag)
199 #ifdef _GLIBCXX_DEBUG
200 if (m_p_head->m_p_parent != 0)
204 const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1;
205 const size_type total_num_children = start + num_children;
206 if (total_num_children == 0)
212 if (total_num_children == 1)
214 if (m_p_head->m_p_parent != 0)
222 m_p_head->m_p_parent = *child_b_it;
223 m_p_head->m_p_parent->m_p_parent = m_p_head;
224 apply_update(m_p_head->m_p_parent, (node_update*)this);
230 inode_pointer p_new_root = r_bag.get_branch();
231 new (p_new_root) inode(e_ind, b_it);
232 size_type num_inserted = 0;
233 while (num_inserted++ < num_children)
237 p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
238 pref_end(*child_b_it), this);
241 if (m_p_head->m_p_parent != 0)
242 p_new_root->add_child(m_p_head->m_p_parent,
243 pref_begin(m_p_head->m_p_parent),
244 pref_end(m_p_head->m_p_parent), this);
246 m_p_head->m_p_parent = p_new_root;
247 p_new_root->m_p_parent = m_p_head;
248 apply_update(m_p_head->m_p_parent, (node_update*)this);
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
#define _GLIBCXX_DEBUG_ONLY(_Statement)
Definition: debug.h:63
#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_ASSERT_NODE_VALID(X)
Definition: pat_trie_.hpp:570
#define PB_DS_ASSERT_VALID(X)
Definition: binary_heap_.hpp:324
#define PB_DS_V2F(X)
Definition: container_base_dispatch.hpp:80