Fix -Wshadow warnings in GCC renaming "node" arguments with "n".

This commit is contained in:
Ion Gaztañaga
2022-08-23 07:58:45 +02:00
parent bf072b5f24
commit c0377800b2
8 changed files with 129 additions and 128 deletions

View File

@@ -218,13 +218,13 @@ class avltree_algorithms
} }
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr)
static void unlink(node_ptr node) BOOST_NOEXCEPT static void unlink(node_ptr n) BOOST_NOEXCEPT
{ {
node_ptr x = NodeTraits::get_parent(node); node_ptr x = NodeTraits::get_parent(n);
if(x){ if(x){
while(!is_header(x)) while(!is_header(x))
x = NodeTraits::get_parent(x); x = NodeTraits::get_parent(x);
erase(x, node); erase(x, n);
} }
} }
@@ -233,22 +233,22 @@ class avltree_algorithms
static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT; static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr)
static bool unique(const_node_ptr node) BOOST_NOEXCEPT; static bool unique(const_node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr)
static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT; static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr)
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr)
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr)
static void init(node_ptr node) BOOST_NOEXCEPT; static void init(node_ptr n) BOOST_NOEXCEPT;
#endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
//! <b>Requires</b>: node must not be part of any tree. //! <b>Requires</b>: header must not be part of any tree.
//! //!
//! <b>Effects</b>: Initializes the header to represent an empty tree. //! <b>Effects</b>: Initializes the header to represent an empty tree.
//! unique(header) == true. //! unique(header) == true.
@@ -257,7 +257,7 @@ class avltree_algorithms
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. //! <b>Nodes</b>: If header is inserted in a tree, this function corrupts the tree.
static void init_header(node_ptr header) BOOST_NOEXCEPT static void init_header(node_ptr header) BOOST_NOEXCEPT
{ {
bstree_algo::init_header(header); bstree_algo::init_header(header);

View File

@@ -239,7 +239,7 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
return p ? p : detail::uncast(header); return p ? p : detail::uncast(header);
} }
//! <b>Requires</b>: 'node' is a node of the tree or a node initialized //! <b>Requires</b>: 'n' is a node of the tree or a node initialized
//! by init(...) or init_node. //! by init(...) or init_node.
//! //!
//! <b>Effects</b>: Returns true if the node is initialized by init() or init_node(). //! <b>Effects</b>: Returns true if the node is initialized by init() or init_node().
@@ -247,18 +247,18 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! <b>Complexity</b>: Constant time. //! <b>Complexity</b>: Constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr node) BOOST_NOEXCEPT BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr n) BOOST_NOEXCEPT
{ return !NodeTraits::get_parent(node); } { return !NodeTraits::get_parent(n); }
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
//! <b>Requires</b>: 'node' is a node of the tree or a header node. //! <b>Requires</b>: 'n' is a node of the tree or a header node.
//! //!
//! <b>Effects</b>: Returns the header of the tree. //! <b>Effects</b>: Returns the header of the tree.
//! //!
//! <b>Complexity</b>: Logarithmic. //! <b>Complexity</b>: Logarithmic.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr get_header(const_node_ptr node); static node_ptr get_header(const_node_ptr n);
#endif #endif
//! <b>Requires</b>: node1 and node2 can't be header nodes //! <b>Requires</b>: node1 and node2 can't be header nodes
@@ -518,44 +518,44 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
} }
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
//! <b>Requires</b>: 'node' is a node from the tree except the header. //! <b>Requires</b>: 'n' is a node from the tree except the header.
//! //!
//! <b>Effects</b>: Returns the next node of the tree. //! <b>Effects</b>: Returns the next node of the tree.
//! //!
//! <b>Complexity</b>: Average constant time. //! <b>Complexity</b>: Average constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! <b>Requires</b>: 'node' is a node from the tree except the leftmost node. //! <b>Requires</b>: 'n' is a node from the tree except the leftmost node.
//! //!
//! <b>Effects</b>: Returns the previous node of the tree. //! <b>Effects</b>: Returns the previous node of the tree.
//! //!
//! <b>Complexity</b>: Average constant time. //! <b>Complexity</b>: Average constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! <b>Requires</b>: 'node' is a node of a tree but not the header. //! <b>Requires</b>: 'n' is a node of a tree but not the header.
//! //!
//! <b>Effects</b>: Returns the minimum node of the subtree starting at p. //! <b>Effects</b>: Returns the minimum node of the subtree starting at p.
//! //!
//! <b>Complexity</b>: Logarithmic to the size of the subtree. //! <b>Complexity</b>: Logarithmic to the size of the subtree.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr minimum(node_ptr node); static node_ptr minimum(node_ptr n);
//! <b>Requires</b>: 'node' is a node of a tree but not the header. //! <b>Requires</b>: 'n' is a node of a tree but not the header.
//! //!
//! <b>Effects</b>: Returns the maximum node of the subtree starting at p. //! <b>Effects</b>: Returns the maximum node of the subtree starting at p.
//! //!
//! <b>Complexity</b>: Logarithmic to the size of the subtree. //! <b>Complexity</b>: Logarithmic to the size of the subtree.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr maximum(node_ptr node); static node_ptr maximum(node_ptr n);
#endif #endif
//! <b>Requires</b>: 'node' must not be part of any tree. //! <b>Requires</b>: 'n' must not be part of any tree.
//! //!
//! <b>Effects</b>: After the function unique(node) == true. //! <b>Effects</b>: After the function unique(node) == true.
//! //!
@@ -564,11 +564,11 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
static void init(node_ptr node) BOOST_NOEXCEPT static void init(node_ptr n) BOOST_NOEXCEPT
{ {
NodeTraits::set_parent(node, node_ptr()); NodeTraits::set_parent(n, node_ptr());
NodeTraits::set_left(node, node_ptr()); NodeTraits::set_left(n, node_ptr());
NodeTraits::set_right(node, node_ptr()); NodeTraits::set_right(n, node_ptr());
} }
//! <b>Effects</b>: Returns true if node is in the same state as if called init(node) //! <b>Effects</b>: Returns true if node is in the same state as if called init(node)
@@ -576,14 +576,14 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! <b>Complexity</b>: Constant. //! <b>Complexity</b>: Constant.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static bool inited(const_node_ptr node) static bool inited(const_node_ptr n)
{ {
return !NodeTraits::get_parent(node) && return !NodeTraits::get_parent(n) &&
!NodeTraits::get_left(node) && !NodeTraits::get_left(n) &&
!NodeTraits::get_right(node) ; !NodeTraits::get_right(n) ;
} }
//! <b>Requires</b>: node must not be part of any tree. //! <b>Requires</b>: header must not be part of any tree.
//! //!
//! <b>Effects</b>: Initializes the header to represent an empty tree. //! <b>Effects</b>: Initializes the header to represent an empty tree.
//! unique(header) == true. //! unique(header) == true.
@@ -592,7 +592,7 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. //! <b>Nodes</b>: If header is inserted in a tree, this function corrupts the tree.
static void init_header(node_ptr header) BOOST_NOEXCEPT static void init_header(node_ptr header) BOOST_NOEXCEPT
{ {
NodeTraits::set_parent(header, node_ptr()); NodeTraits::set_parent(header, node_ptr());
@@ -664,9 +664,9 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
return leftmost; return leftmost;
} }
//! <b>Requires</b>: node is a node of the tree but it's not the header. //! <b>Requires</b>: 'header' the header of the tree.
//! //!
//! <b>Effects</b>: Returns the number of nodes of the subtree. //! <b>Effects</b>: Returns the number of nodes of the tree.
//! //!
//! <b>Complexity</b>: Linear time. //! <b>Complexity</b>: Linear time.
//! //!
@@ -1259,7 +1259,7 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
insert_commit(header, new_node, commit_data); insert_commit(header, new_node, commit_data);
} }
//! <b>Requires</b>: 'node' can't be a header node. //! <b>Requires</b>: 'n' can't be a header node.
//! //!
//! <b>Effects</b>: Calculates the depth of a node: the depth of a //! <b>Effects</b>: Calculates the depth of a node: the depth of a
//! node is the length (number of edges) of the path from the root //! node is the length (number of edges) of the path from the root
@@ -1268,13 +1268,13 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! <b>Complexity</b>: Logarithmic to the number of nodes in the tree. //! <b>Complexity</b>: Logarithmic to the number of nodes in the tree.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static std::size_t depth(const_node_ptr node) BOOST_NOEXCEPT static std::size_t depth(const_node_ptr n) BOOST_NOEXCEPT
{ {
std::size_t depth = 0; std::size_t depth = 0;
node_ptr p_parent; node_ptr p_parent;
while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){ while(n != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(n))){
++depth; ++depth;
node = p_parent; n = p_parent;
} }
return depth; return depth;
} }
@@ -1365,20 +1365,20 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
transfer_equal(header1, comp, header2, z, ignored); transfer_equal(header1, comp, header2, z, ignored);
} }
//! <b>Requires</b>: node is a tree node but not the header. //! <b>Requires</b>: 'n' is a tree node but not the header.
//! //!
//! <b>Effects</b>: Unlinks the node and rebalances the tree. //! <b>Effects</b>: Unlinks the node and rebalances the tree.
//! //!
//! <b>Complexity</b>: Average complexity is constant time. //! <b>Complexity</b>: Average complexity is constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static void unlink(node_ptr node) BOOST_NOEXCEPT static void unlink(node_ptr n) BOOST_NOEXCEPT
{ {
node_ptr x = NodeTraits::get_parent(node); node_ptr x = NodeTraits::get_parent(n);
if(x){ if(x){
while(!base_type::is_header(x)) while(!base_type::is_header(x))
x = NodeTraits::get_parent(x); x = NodeTraits::get_parent(x);
erase(x, node); erase(x, n);
} }
} }
@@ -1585,7 +1585,7 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
info.x_parent = x_parent; info.x_parent = x_parent;
} }
//! <b>Requires</b>: node is a node of the tree but it's not the header. //! <b>Requires</b>: 'subtree' is a node of the tree but it's not the header.
//! //!
//! <b>Effects</b>: Returns the number of nodes of the subtree. //! <b>Effects</b>: Returns the number of nodes of the subtree.
//! //!
@@ -1916,10 +1916,10 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
//! <b>Complexity</b>: Logarithmic. //! <b>Complexity</b>: Logarithmic.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr get_root(node_ptr node) BOOST_NOEXCEPT static node_ptr get_root(node_ptr n) BOOST_NOEXCEPT
{ {
BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(node))); BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(n)));
node_ptr x = NodeTraits::get_parent(node); node_ptr x = NodeTraits::get_parent(n);
if(x){ if(x){
while(!base_type::is_header(x)){ while(!base_type::is_header(x)){
x = NodeTraits::get_parent(x); x = NodeTraits::get_parent(x);
@@ -1927,7 +1927,7 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
return x; return x;
} }
else{ else{
return node; return n;
} }
} }
@@ -2059,23 +2059,23 @@ class bstree_algorithms : public bstree_algorithms_base<NodeTraits>
} }
template<class Checker> template<class Checker>
static void check_subtree(const_node_ptr node, Checker checker, typename Checker::return_type& check_return) static void check_subtree(const_node_ptr n, Checker checker, typename Checker::return_type& check_return)
{ {
const_node_ptr left = NodeTraits::get_left(node); const_node_ptr left = NodeTraits::get_left(n);
const_node_ptr right = NodeTraits::get_right(node); const_node_ptr right = NodeTraits::get_right(n);
typename Checker::return_type check_return_left; typename Checker::return_type check_return_left;
typename Checker::return_type check_return_right; typename Checker::return_type check_return_right;
if (left) if (left)
{ {
BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(left) == node); BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(left) == n);
check_subtree(left, checker, check_return_left); check_subtree(left, checker, check_return_left);
} }
if (right) if (right)
{ {
BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(right) == node); BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(right) == n);
check_subtree(right, checker, check_return_right); check_subtree(right, checker, check_return_right);
} }
checker(node, check_return_left, check_return_right, check_return); checker(n, check_return_left, check_return_right, check_return);
} }
}; };

View File

@@ -243,7 +243,7 @@ class any_algorithms
typedef typename node::const_node_ptr const_node_ptr; typedef typename node::const_node_ptr const_node_ptr;
typedef any_node_traits<VoidPointer> node_traits; typedef any_node_traits<VoidPointer> node_traits;
//! <b>Requires</b>: node must not be part of any tree. //! <b>Requires</b>: 'n' must not be part of any tree.
//! //!
//! <b>Effects</b>: After the function unique(node) == true. //! <b>Effects</b>: After the function unique(node) == true.
//! //!
@@ -252,19 +252,19 @@ class any_algorithms
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree. //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
BOOST_INTRUSIVE_FORCEINLINE static void init(node_ptr node) BOOST_NOEXCEPT BOOST_INTRUSIVE_FORCEINLINE static void init(node_ptr n) BOOST_NOEXCEPT
{ node->node_ptr_1 = node_ptr(); }; { n->node_ptr_1 = node_ptr(); };
//! <b>Effects</b>: Returns true if node is in the same state as if called init(node) //! <b>Effects</b>: Returns true if 'n' is in the same state as if called init(node)
//! //!
//! <b>Complexity</b>: Constant. //! <b>Complexity</b>: Constant.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
BOOST_INTRUSIVE_FORCEINLINE static bool inited(const_node_ptr node) BOOST_INTRUSIVE_FORCEINLINE static bool inited(const_node_ptr n)
{ return !node->node_ptr_1; }; { return !n->node_ptr_1; };
BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr node) BOOST_NOEXCEPT BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr n) BOOST_NOEXCEPT
{ return !node->node_ptr_1; } { return !n->node_ptr_1; }
static void unlink(node_ptr) static void unlink(node_ptr)
{ {

View File

@@ -35,21 +35,20 @@ class bstree_algorithms_base
typedef typename NodeTraits::node_ptr node_ptr; typedef typename NodeTraits::node_ptr node_ptr;
typedef typename NodeTraits::const_node_ptr const_node_ptr; typedef typename NodeTraits::const_node_ptr const_node_ptr;
//! <b>Requires</b>: 'node' is a node from the tree except the header. //! <b>Requires</b>: 'n' is a node from the tree except the header.
//! //!
//! <b>Effects</b>: Returns the next node of the tree. //! <b>Effects</b>: Returns the next node of the tree.
//! //!
//! <b>Complexity</b>: Average constant time. //! <b>Complexity</b>: Average constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT
{ {
node_ptr const n_right(NodeTraits::get_right(node)); node_ptr const n_right(NodeTraits::get_right(n));
if(n_right){ if(n_right){
return minimum(n_right); return minimum(n_right);
} }
else { else {
node_ptr n(node);
node_ptr p(NodeTraits::get_parent(n)); node_ptr p(NodeTraits::get_parent(n));
while(n == NodeTraits::get_right(p)){ while(n == NodeTraits::get_right(p)){
n = p; n = p;
@@ -59,23 +58,23 @@ class bstree_algorithms_base
} }
} }
//! <b>Requires</b>: 'node' is a node from the tree except the leftmost node. //! <b>Requires</b>: 'n' is a node from the tree except the leftmost node.
//! //!
//! <b>Effects</b>: Returns the previous node of the tree. //! <b>Effects</b>: Returns the previous node of the tree.
//! //!
//! <b>Complexity</b>: Average constant time. //! <b>Complexity</b>: Average constant time.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT
{ {
if(is_header(node)){ if(is_header(n)){
return NodeTraits::get_right(node); return NodeTraits::get_right(n);
} }
else if(NodeTraits::get_left(node)){ else if(NodeTraits::get_left(n)){
return maximum(NodeTraits::get_left(node)); return maximum(NodeTraits::get_left(n));
} }
else { else {
node_ptr p(node); node_ptr p(n);
node_ptr x = NodeTraits::get_parent(p); node_ptr x = NodeTraits::get_parent(p);
while(p == NodeTraits::get_left(x)){ while(p == NodeTraits::get_left(x)){
p = x; p = x;
@@ -85,38 +84,38 @@ class bstree_algorithms_base
} }
} }
//! <b>Requires</b>: 'node' is a node of a tree but not the header. //! <b>Requires</b>: 'n' is a node of a tree but not the header.
//! //!
//! <b>Effects</b>: Returns the minimum node of the subtree starting at p. //! <b>Effects</b>: Returns the minimum node of the subtree starting at p.
//! //!
//! <b>Complexity</b>: Logarithmic to the size of the subtree. //! <b>Complexity</b>: Logarithmic to the size of the subtree.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr minimum(node_ptr node) static node_ptr minimum(node_ptr n)
{ {
for(node_ptr p_left = NodeTraits::get_left(node) for(node_ptr p_left = NodeTraits::get_left(n)
;p_left ;p_left
;p_left = NodeTraits::get_left(node)){ ;p_left = NodeTraits::get_left(n)){
node = p_left; n = p_left;
} }
return node; return n;
} }
//! <b>Requires</b>: 'node' is a node of a tree but not the header. //! <b>Requires</b>: 'n' is a node of a tree but not the header.
//! //!
//! <b>Effects</b>: Returns the maximum node of the subtree starting at p. //! <b>Effects</b>: Returns the maximum node of the subtree starting at p.
//! //!
//! <b>Complexity</b>: Logarithmic to the size of the subtree. //! <b>Complexity</b>: Logarithmic to the size of the subtree.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr maximum(node_ptr node) static node_ptr maximum(node_ptr n)
{ {
for(node_ptr p_right = NodeTraits::get_right(node) for(node_ptr p_right = NodeTraits::get_right(n)
;p_right ;p_right
;p_right = NodeTraits::get_right(node)){ ;p_right = NodeTraits::get_right(n)){
node = p_right; n = p_right;
} }
return node; return n;
} }
//! <b>Requires</b>: p is a node of a tree. //! <b>Requires</b>: p is a node of a tree.
@@ -143,37 +142,37 @@ class bstree_algorithms_base
return false; return false;
} }
//! <b>Requires</b>: 'node' is a node of the tree or a header node. //! <b>Requires</b>: 'n' is a node of the tree or a header node.
//! //!
//! <b>Effects</b>: Returns the header of the tree. //! <b>Effects</b>: Returns the header of the tree.
//! //!
//! <b>Complexity</b>: Logarithmic. //! <b>Complexity</b>: Logarithmic.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
static node_ptr get_header(const_node_ptr node) static node_ptr get_header(const_node_ptr n)
{ {
node_ptr n(detail::uncast(node)); node_ptr nn(detail::uncast(n));
node_ptr p(NodeTraits::get_parent(node)); node_ptr p(NodeTraits::get_parent(n));
//If p is null, then n is the header of an empty tree //If p is null, then nn is the header of an empty tree
if(p){ if(p){
//Non-empty tree, check if n is neither root nor header //Non-empty tree, check if nn is neither root nor header
node_ptr pp(NodeTraits::get_parent(p)); node_ptr pp(NodeTraits::get_parent(p));
//If granparent is not equal to n, then n is neither root nor header, //If granparent is not equal to nn, then nn is neither root nor header,
//the try the fast path //the try the fast path
if(n != pp){ if(nn != pp){
do{ do{
n = p; nn = p;
p = pp; p = pp;
pp = NodeTraits::get_parent(pp); pp = NodeTraits::get_parent(pp);
}while(n != pp); }while(nn != pp);
n = p; nn = p;
} }
//Check if n is root or header when size() > 0 //Check if nn is root or header when size() > 0
else if(!bstree_algorithms_base::is_header(n)){ else if(!bstree_algorithms_base::is_header(nn)){
n = p; nn = p;
} }
} }
return n; return nn;
} }
}; };

View File

@@ -242,13 +242,13 @@ class rbtree_algorithms
} }
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr)
static void unlink(node_ptr node) BOOST_NOEXCEPT static void unlink(node_ptr n) BOOST_NOEXCEPT
{ {
node_ptr x = NodeTraits::get_parent(node); node_ptr x = NodeTraits::get_parent(n);
if(x){ if(x){
while(!is_header(x)) while(!is_header(x))
x = NodeTraits::get_parent(x); x = NodeTraits::get_parent(x);
erase(x, node); erase(x, n);
} }
} }
@@ -257,19 +257,19 @@ class rbtree_algorithms
static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT; static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr)
static bool unique(const_node_ptr node) BOOST_NOEXCEPT; static bool unique(const_node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr)
static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT; static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::next_node(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(const_node_ptr)
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(const_node_ptr)
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr)
static void init(node_ptr node) BOOST_NOEXCEPT; static void init(node_ptr n) BOOST_NOEXCEPT;
#endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
//! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr)

View File

@@ -110,25 +110,25 @@ class sgtree_algorithms
static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node) BOOST_NOEXCEPT; static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node) BOOST_NOEXCEPT;
//Unlink is not possible since tree metadata is needed to update the tree //Unlink is not possible since tree metadata is needed to update the tree
//!static void unlink(node_ptr node) BOOST_NOEXCEPT; //!static void unlink(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance //! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance
static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT; static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr)
static bool unique(const_node_ptr node) BOOST_NOEXCEPT; static bool unique(const_node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr)
static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT; static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr)
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr)
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr)
static void init(node_ptr node) BOOST_NOEXCEPT; static void init(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr)
static void init_header(node_ptr header) BOOST_NOEXCEPT; static void init_header(node_ptr header) BOOST_NOEXCEPT;

View File

@@ -200,25 +200,25 @@ class splaytree_algorithms
static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node) BOOST_NOEXCEPT; static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr)
static void unlink(node_ptr node) BOOST_NOEXCEPT; static void unlink(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance //! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance
static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT; static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr)
static bool unique(const_node_ptr node) BOOST_NOEXCEPT; static bool unique(const_node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr)
static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT; static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr)
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr)
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr)
static void init(node_ptr node) BOOST_NOEXCEPT; static void init(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr)
static void init_header(node_ptr header) BOOST_NOEXCEPT; static void init_header(node_ptr header) BOOST_NOEXCEPT;
@@ -521,8 +521,8 @@ class splaytree_algorithms
#endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
// bottom-up splay, use data_ as parent for n | complexity : logarithmic | exception : nothrow // bottom-up splay, use data_ as parent for n | complexity : logarithmic | exception : nothrow
static void splay_up(node_ptr node, node_ptr header) BOOST_NOEXCEPT static void splay_up(node_ptr n, node_ptr header) BOOST_NOEXCEPT
{ priv_splay_up<true>(node, header); } { priv_splay_up<true>(n, header); }
// top-down splay | complexity : logarithmic | exception : strong, note A // top-down splay | complexity : logarithmic | exception : strong, note A
template<class KeyType, class KeyNodePtrCompare> template<class KeyType, class KeyNodePtrCompare>
@@ -535,12 +535,14 @@ class splaytree_algorithms
// bottom-up splay, use data_ as parent for n | complexity : logarithmic | exception : nothrow // bottom-up splay, use data_ as parent for n | complexity : logarithmic | exception : nothrow
template<bool SimpleSplay> template<bool SimpleSplay>
static void priv_splay_up(node_ptr node, node_ptr header) BOOST_NOEXCEPT static void priv_splay_up(node_ptr n, node_ptr header) BOOST_NOEXCEPT
{ {
// If (node == header) do a splay for the right most node instead // If (node == header) do a splay for the right most node instead
// this is to boost performance of equal_range/count on equivalent containers in the case // this is to boost performance of equal_range/count on equivalent containers in the case
// where there are many equal elements at the end // where there are many equal elements at the end
node_ptr n((node == header) ? NodeTraits::get_right(header) : node); if(n == header)
n = NodeTraits::get_right(header);
node_ptr t(header); node_ptr t(header);
if( n == t ) return; if( n == t ) return;

View File

@@ -205,13 +205,13 @@ class treap_algorithms
//! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(node_ptr)
template<class NodePtrPriorityCompare> template<class NodePtrPriorityCompare>
static void unlink(node_ptr node, NodePtrPriorityCompare pcomp) static void unlink(node_ptr n, NodePtrPriorityCompare pcomp)
{ {
node_ptr x = NodeTraits::get_parent(node); node_ptr x = NodeTraits::get_parent(n);
if(x){ if(x){
while(!bstree_algo::is_header(x)) while(!bstree_algo::is_header(x))
x = NodeTraits::get_parent(x); x = NodeTraits::get_parent(x);
erase(x, node, pcomp); erase(x, n, pcomp);
} }
} }
@@ -220,19 +220,19 @@ class treap_algorithms
static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT; static node_ptr unlink_leftmost_without_rebalance(node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const_node_ptr)
static bool unique(const_node_ptr node) BOOST_NOEXCEPT; static bool unique(const_node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::size(const_node_ptr)
static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT; static std::size_t size(const_node_ptr header) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(node_ptr)
static node_ptr next_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr next_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(node_ptr)
static node_ptr prev_node(node_ptr node) BOOST_NOEXCEPT; static node_ptr prev_node(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init(node_ptr)
static void init(node_ptr node) BOOST_NOEXCEPT; static void init(node_ptr n) BOOST_NOEXCEPT;
//! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr) //! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr)
static void init_header(node_ptr header) BOOST_NOEXCEPT; static void init_header(node_ptr header) BOOST_NOEXCEPT;