41#ifdef PB_DS_CLASS_C_DEC
46rotate_left(node_pointer p_x)
48 node_pointer p_y = p_x->m_p_right;
50 p_x->m_p_right = p_y->m_p_left;
52 if (p_y->m_p_left != 0)
53 p_y->m_p_left->m_p_parent = p_x;
55 p_y->m_p_parent = p_x->m_p_parent;
57 if (p_x == m_p_head->m_p_parent)
58 m_p_head->m_p_parent = p_y;
59 else if (p_x == p_x->m_p_parent->m_p_left)
60 p_x->m_p_parent->m_p_left = p_y;
62 p_x->m_p_parent->m_p_right = p_y;
65 p_x->m_p_parent = p_y;
67 PB_DS_ASSERT_NODE_CONSISTENT(p_x)
68 PB_DS_ASSERT_NODE_CONSISTENT(p_y)
70 apply_update(p_x, (node_update* )
this);
71 apply_update(p_x->m_p_parent, (node_update* )
this);
77rotate_right(node_pointer p_x)
79 node_pointer p_y = p_x->m_p_left;
81 p_x->m_p_left = p_y->m_p_right;
83 if (p_y->m_p_right != 0)
84 p_y->m_p_right->m_p_parent = p_x;
86 p_y->m_p_parent = p_x->m_p_parent;
88 if (p_x == m_p_head->m_p_parent)
89 m_p_head->m_p_parent = p_y;
90 else if (p_x == p_x->m_p_parent->m_p_right)
91 p_x->m_p_parent->m_p_right = p_y;
93 p_x->m_p_parent->m_p_left = p_y;
96 p_x->m_p_parent = p_y;
98 PB_DS_ASSERT_NODE_CONSISTENT(p_x)
99 PB_DS_ASSERT_NODE_CONSISTENT(p_y)
101 apply_update(p_x, (node_update* )
this);
102 apply_update(p_x->m_p_parent, (node_update* )
this);
108rotate_parent(node_pointer p_nd)
110 node_pointer p_parent = p_nd->m_p_parent;
112 if (p_nd == p_parent->m_p_left)
113 rotate_right(p_parent);
115 rotate_left(p_parent);
117 _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
118 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
119 p_nd->m_p_right == p_parent);
125apply_update(node_pointer , null_node_update_pointer )
129template<
typename Node_Update_>
132apply_update(node_pointer p_nd, Node_Update_* )
134 node_update::operator()(node_iterator(p_nd),
135 node_const_iterator(
static_cast<node_pointer
>(0)));
139template<
typename Node_Update_>
142update_to_top(node_pointer p_nd, Node_Update_* p_update)
144 while (p_nd != m_p_head)
146 apply_update(p_nd, p_update);
148 p_nd = p_nd->m_p_parent;
155update_to_top(node_pointer , null_node_update_pointer )