Ignore:
Timestamp:
Aug 26, 2021, 6:07:09 AM (19 months ago)
Author:
Peter
Message:

implement insert with hint; refs #710

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/kendall-score/yat/utility/ranking/Impl.cc

    r4075 r4077  
    189189
    190190  void Impl::insert_and_rebalance(std::unique_ptr<NodeBase>&& element,
    191                                   NodeBase& parent, NodeBase*& child)
    192   {
    193     assert(child == nullptr);
    194     child = element.release();
     191                                  NodeBase& parent, bool left)
     192  {
     193    NodeBase* child = nullptr;
     194    if (left) {
     195      parent.left_ = element.release();
     196      child = parent.left_;
     197      if (&parent == left_most())
     198        left_most() = child;
     199    }
     200    else {
     201      parent.right_ = element.release();
     202      child = parent.right_;
     203    }
     204
    195205    child->parent_ = &parent;
    196206    parent.increment_size();
    197207    parent.update_height_recursively();
    198 
    199208    insert_rebalance(&parent, child);
    200209  }
     
    458467
    459468
     469  NodeBase* Impl::right_most(void)
     470  {
     471    // FIXME this scaled logN, make it constant time
     472    return root_node()->right_most();
     473  }
     474
     475
     476  const NodeBase* Impl::right_most(void) const
     477  {
     478    // FIXME this scaled logN, make it constant time
     479    return root_node()->right_most();
     480  }
     481
     482
    460483  NodeBase*& Impl::root_node(void)
    461484  {
Note: See TracChangeset for help on using the changeset viewer.