41#ifdef PB_DS_CLASS_C_DEC 
   46split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
 
   48  PB_DS_ASSERT_VALID((*
this))
 
   49  PB_DS_ASSERT_VALID(other)
 
   51  leaf_pointer p_split_lf = split_prep(r_key, other, bag);
 
   54      _GLIBCXX_DEBUG_ASSERT(bag.empty());
 
   55      PB_DS_ASSERT_VALID((*
this))
 
   56      PB_DS_ASSERT_VALID(other)
 
   60  _GLIBCXX_DEBUG_ASSERT(!bag.empty());
 
   63  m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf),
 
   64                                   pref_end(p_split_lf), other, bag);
 
   66  m_p_head->m_p_parent->m_p_parent = m_p_head;
 
   68  head_pointer __ohead = other.m_p_head;
 
   69  __ohead->m_p_max = m_p_head->m_p_max;
 
   70  m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
 
   71  __ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent);
 
   73  other.m_size = 
std::distance(other.PB_DS_CLASS_C_DEC::begin(),
 
   74                               other.PB_DS_CLASS_C_DEC::end());
 
   75  m_size -= other.m_size;
 
   76  PB_DS_ASSERT_VALID((*this))
 
   77  PB_DS_ASSERT_VALID(other)
 
   81typename PB_DS_CLASS_C_DEC::leaf_pointer
 
   83split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other,
 
   86  _GLIBCXX_DEBUG_ASSERT(r_bag.empty());
 
   90      PB_DS_ASSERT_VALID((*
this))
 
   91      PB_DS_ASSERT_VALID(other)
 
   95  if (synth_access_traits::cmp_keys(r_key,
 
   96                                    PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
 
  100      PB_DS_ASSERT_VALID((*
this))
 
  101      PB_DS_ASSERT_VALID(other)
 
  105  if (!synth_access_traits::cmp_keys(r_key,
 
  106                                       PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value())))
 
  108      PB_DS_ASSERT_VALID((*
this))
 
  109      PB_DS_ASSERT_VALID(other)
 
  113  iterator it = lower_bound(r_key);
 
  115  if (!synth_access_traits::equal_keys(PB_DS_V2F(*it), r_key))
 
  118  node_pointer p_nd = it.m_p_nd;
 
  119  _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
 
  120  leaf_pointer p_ret_l = static_cast<leaf_pointer>(p_nd);
 
  121  while (p_nd->m_type != head_node)
 
  124      p_nd = p_nd->m_p_parent;
 
  126  _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_access_traits&)(*
this), other);)
 
  132typename PB_DS_CLASS_C_DEC::node_pointer
 
  134rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
 
  135          PB_DS_CLASS_C_DEC& other, branch_bag& r_bag)
 
  137  if (p_nd->m_type == leaf_node)
 
  139      _GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == 0);
 
  143  _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
 
  144  inode_pointer p_ind = 
static_cast<inode_pointer
>(p_nd);
 
  146  node_pointer pfirst = p_ind->get_child_node(b_it, e_it, 
this);
 
  147  node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag);
 
  148  PB_DS_ASSERT_NODE_VALID(p_child_ret)
 
  149  p_ind->replace_child(p_child_ret, b_it, e_it, 
this);
 
  150  apply_update(p_ind, (node_update*)
this);
 
  152  inode_iterator child_it = p_ind->get_child_it(b_it, e_it, 
this);
 
  153  const size_type lhs_dist = 
std::distance(p_ind->begin(), child_it);
 
  154  const size_type lhs_num_children = lhs_dist + 1;
 
  155  _GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0);
 
  157  const size_type rhs_dist =  
std::distance(p_ind->begin(), p_ind->end());
 
  158  size_type rhs_num_children = rhs_dist - lhs_num_children;
 
  159  if (rhs_num_children == 0)
 
  161      apply_update(p_ind, (node_update*)
this);
 
  165  other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it,
 
  166                            rhs_num_children, r_bag);
 
  168  child_it = p_ind->get_child_it(b_it, e_it, 
this);
 
  169  while (rhs_num_children != 0)
 
  172      p_ind->remove_child(child_it);
 
  175  apply_update(p_ind, (node_update*)
this);
 
  177  const size_type int_dist = 
std::distance(p_ind->begin(), p_ind->end());
 
  178  _GLIBCXX_DEBUG_ASSERT(int_dist >= 1);
 
  181      p_ind->update_prefixes(
this);
 
  182      PB_DS_ASSERT_NODE_VALID(p_ind)
 
  183      apply_update(p_ind, (node_update*)
this);
 
  187  node_pointer p_ret = *p_ind->begin();
 
  189  s_inode_allocator.deallocate(p_ind, 1);
 
  190  apply_update(p_ret, (node_update*)
this);
 
  197split_insert_branch(size_type e_ind, a_const_iterator b_it,
 
  198                    inode_iterator child_b_it,
 
  199                    size_type num_children, branch_bag& r_bag)
 
  202  if (m_p_head->m_p_parent != 0)
 
  203    PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
 
  206  const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1;
 
  207  const size_type total_num_children = start + num_children;
 
  208  if (total_num_children == 0)
 
  210      _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
 
  214  if (total_num_children == 1)
 
  216      if (m_p_head->m_p_parent != 0)
 
  218          PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
 
  222      _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
 
  224      m_p_head->m_p_parent = *child_b_it;
 
  225      m_p_head->m_p_parent->m_p_parent = m_p_head;
 
  226      apply_update(m_p_head->m_p_parent, (node_update*)this);
 
  227      PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
 
  231  _GLIBCXX_DEBUG_ASSERT(total_num_children > 1);
 
  232  inode_pointer p_new_root = r_bag.get_branch();
 
  233  new (p_new_root) inode(e_ind, b_it);
 
  234  size_type num_inserted = 0;
 
  235  while (num_inserted++ < num_children)
 
  238      PB_DS_ASSERT_NODE_VALID((*child_b_it))
 
  239      p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
 
  240                            pref_end(*child_b_it), 
this);
 
  243  if (m_p_head->m_p_parent != 0)
 
  244    p_new_root->add_child(m_p_head->m_p_parent,
 
  245                          pref_begin(m_p_head->m_p_parent),
 
  246                          pref_end(m_p_head->m_p_parent), 
this);
 
  248  m_p_head->m_p_parent = p_new_root;
 
  249  p_new_root->m_p_parent = m_p_head;
 
  250  apply_update(m_p_head->m_p_parent, (node_update*)
this);
 
  251  PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
 
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.