/usr/include/boost/intrusive/detail
NameSizeModeActions
algorithm.hpp28800644editdlrm
algo_type.hpp13030644editdlrm
any_node_and_algorithms.hpp94670644editdlrm
array_initializer.hpp22350644editdlrm
assert.hpp15200644editdlrm
avltree_node.hpp67140644editdlrm
bstree_algorithms_base.hpp55230644editdlrm
common_slist_algorithms.hpp59740644editdlrm
config_begin.hpp24560644editdlrm
config_end.hpp4960644editdlrm
default_header_holder.hpp22430644editdlrm
ebo_functor_holder.hpp80050644editdlrm
empty_node_checker.hpp12430644editdlrm
equal_to_value.hpp12170644editdlrm
exception_disposer.hpp21320644editdlrm
function_detector.hpp34560644editdlrm
generic_hook.hpp65880644editdlrm
get_value_traits.hpp70980644editdlrm
hashtable_node.hpp102340644editdlrm
has_member_function_callable_with.hpp184380644editdlrm
hook_traits.hpp84380644editdlrm
iiterator.hpp44460644editdlrm
is_stateful_value_traits.hpp25240644editdlrm
iterator.hpp76120644editdlrm
key_nodeptr_comp.hpp48820644editdlrm
list_iterator.hpp52300644editdlrm
list_node.hpp21520644editdlrm
math.hpp80590644editdlrm
minimal_less_equal_header.hpp9320644editdlrm
minimal_pair_header.hpp9040644editdlrm
mpl.hpp85920644editdlrm
node_cloner_disposer.hpp39730644editdlrm
node_holder.hpp8830644editdlrm
node_to_value.hpp39940644editdlrm
parent_from_member.hpp41910644editdlrm
rbtree_node.hpp69520644editdlrm
reverse_iterator.hpp46440644editdlrm
simple_disposers.hpp11770644editdlrm
size_holder.hpp22610644editdlrm
slist_iterator.hpp49680644editdlrm
slist_node.hpp19070644editdlrm
std_fwd.hpp12260644editdlrm
transform_iterator.hpp57890644editdlrm
tree_iterator.hpp66050644editdlrm
tree_node.hpp23070644editdlrm
tree_value_compare.hpp77110644editdlrm
uncast.hpp16460644editdlrm
workaround.hpp20610644editdlrm
Edit: /usr/include/boost/intrusive/detail/bstree_algorithms_base.hpp (5523B)
///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2014-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTRUSIVE_BSTREE_ALGORITHMS_BASE_HPP #define BOOST_INTRUSIVE_BSTREE_ALGORITHMS_BASE_HPP #ifndef BOOST_CONFIG_HPP # include #endif #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include namespace boost { namespace intrusive { template class bstree_algorithms_base { public: typedef typename NodeTraits::node node; typedef NodeTraits node_traits; typedef typename NodeTraits::node_ptr node_ptr; typedef typename NodeTraits::const_node_ptr const_node_ptr; //! Requires: 'node' is a node from the tree except the header. //! //! Effects: Returns the next node of the tree. //! //! Complexity: Average constant time. //! //! Throws: Nothing. static node_ptr next_node(const node_ptr & node) { node_ptr const n_right(NodeTraits::get_right(node)); if(n_right){ return minimum(n_right); } else { node_ptr n(node); node_ptr p(NodeTraits::get_parent(n)); while(n == NodeTraits::get_right(p)){ n = p; p = NodeTraits::get_parent(p); } return NodeTraits::get_right(n) != p ? p : n; } } //! Requires: 'node' is a node from the tree except the leftmost node. //! //! Effects: Returns the previous node of the tree. //! //! Complexity: Average constant time. //! //! Throws: Nothing. static node_ptr prev_node(const node_ptr & node) { if(is_header(node)){ //return NodeTraits::get_right(node); return maximum(NodeTraits::get_parent(node)); } else if(NodeTraits::get_left(node)){ return maximum(NodeTraits::get_left(node)); } else { node_ptr p(node); node_ptr x = NodeTraits::get_parent(p); while(p == NodeTraits::get_left(x)){ p = x; x = NodeTraits::get_parent(x); } return x; } } //! Requires: 'node' is a node of a tree but not the header. //! //! Effects: Returns the minimum node of the subtree starting at p. //! //! Complexity: Logarithmic to the size of the subtree. //! //! Throws: Nothing. static node_ptr minimum(node_ptr node) { for(node_ptr p_left = NodeTraits::get_left(node) ;p_left ;p_left = NodeTraits::get_left(node)){ node = p_left; } return node; } //! Requires: 'node' is a node of a tree but not the header. //! //! Effects: Returns the maximum node of the subtree starting at p. //! //! Complexity: Logarithmic to the size of the subtree. //! //! Throws: Nothing. static node_ptr maximum(node_ptr node) { for(node_ptr p_right = NodeTraits::get_right(node) ;p_right ;p_right = NodeTraits::get_right(node)){ node = p_right; } return node; } //! Requires: p is a node of a tree. //! //! Effects: Returns true if p is the header of the tree. //! //! Complexity: Constant. //! //! Throws: Nothing. static bool is_header(const const_node_ptr & p) { node_ptr p_left (NodeTraits::get_left(p)); node_ptr p_right(NodeTraits::get_right(p)); if(!NodeTraits::get_parent(p) || //Header condition when empty tree (p_left && p_right && //Header always has leftmost and rightmost (p_left == p_right || //Header condition when only node (NodeTraits::get_parent(p_left) != p || NodeTraits::get_parent(p_right) != p )) //When tree size > 1 headers can't be leftmost's //and rightmost's parent )){ return true; } return false; } //! Requires: 'node' is a node of the tree or a header node. //! //! Effects: Returns the header of the tree. //! //! Complexity: Logarithmic. //! //! Throws: Nothing. static node_ptr get_header(const const_node_ptr & node) { node_ptr n(detail::uncast(node)); node_ptr p(NodeTraits::get_parent(node)); //If p is null, then n is the header of an empty tree if(p){ //Non-empty tree, check if n is neither root nor header node_ptr pp(NodeTraits::get_parent(p)); //If granparent is not equal to n, then n is neither root nor header, //the try the fast path if(n != pp){ do{ n = p; p = pp; pp = NodeTraits::get_parent(pp); }while(n != pp); n = p; } //Check if n is root or header when size() > 0 else if(!bstree_algorithms_base::is_header(n)){ n = p; } } return n; } }; } //namespace intrusive } //namespace boost #endif //BOOST_INTRUSIVE_BSTREE_ALGORITHMS_BASE_HPP