41#ifdef PB_DS_CLASS_C_DEC
46rotate_left(node_pointer p_x)
48 node_pointer p_y = p_x->m_p_right;
49 p_x->m_p_right = p_y->m_p_left;
51 if (p_y->m_p_left != 0)
52 p_y->m_p_left->m_p_parent = p_x;
54 p_y->m_p_parent = p_x->m_p_parent;
55 if (p_x == m_p_head->m_p_parent)
56 m_p_head->m_p_parent = p_y;
57 else if (p_x == p_x->m_p_parent->m_p_left)
58 p_x->m_p_parent->m_p_left = p_y;
60 p_x->m_p_parent->m_p_right = p_y;
63 p_x->m_p_parent = p_y;
65 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
66 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
68 apply_update(p_x, (Node_Update*)
this);
69 apply_update(p_x->m_p_parent, (Node_Update*)
this);
75rotate_right(node_pointer p_x)
77 node_pointer p_y = p_x->m_p_left;
78 p_x->m_p_left = p_y->m_p_right;
80 if (p_y->m_p_right != 0)
81 p_y->m_p_right->m_p_parent = p_x;
83 p_y->m_p_parent = p_x->m_p_parent;
84 if (p_x == m_p_head->m_p_parent)
85 m_p_head->m_p_parent = p_y;
86 else if (p_x == p_x->m_p_parent->m_p_right)
87 p_x->m_p_parent->m_p_right = p_y;
89 p_x->m_p_parent->m_p_left = p_y;
92 p_x->m_p_parent = p_y;
94 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
95 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
97 apply_update(p_x, (Node_Update*)
this);
98 apply_update(p_x->m_p_parent, (Node_Update*)
this);
104rotate_parent(node_pointer p_nd)
106 node_pointer p_parent = p_nd->m_p_parent;
107 if (p_nd == p_parent->m_p_left)
108 rotate_right(p_parent);
110 rotate_left(p_parent);
111 _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
112 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent);
122template<
typename Node_Update_>
125apply_update(node_pointer p_nd, Node_Update_* p_update)
127 p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == 0) ?
129 & PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == 0) ?
131 & PB_DS_V2F(p_nd->m_p_right->m_value));
135template<
typename Node_Update_>
138update_to_top(node_pointer p_nd, Node_Update_* p_update)
140 while (p_nd != m_p_head)
142 apply_update(p_nd, p_update);
143 p_nd = p_nd->m_p_parent;
A null node updator, indicating that no node updates are required.