44 rotate_left(node_pointer p_x)
46 node_pointer p_y = p_x->m_p_right;
47 p_x->m_p_right = p_y->m_p_left;
49 if (p_y->m_p_left != 0)
50 p_y->m_p_left->m_p_parent = p_x;
52 p_y->m_p_parent = p_x->m_p_parent;
53 if (p_x == m_p_head->m_p_parent)
54 m_p_head->m_p_parent = p_y;
55 else if (p_x == p_x->m_p_parent->m_p_left)
56 p_x->m_p_parent->m_p_left = p_y;
58 p_x->m_p_parent->m_p_right = p_y;
61 p_x->m_p_parent = p_y;
63 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
64 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
66 apply_update(p_x, (Node_Update*)
this);
67 apply_update(p_x->m_p_parent, (Node_Update*)
this);
73 rotate_right(node_pointer p_x)
75 node_pointer p_y = p_x->m_p_left;
76 p_x->m_p_left = p_y->m_p_right;
78 if (p_y->m_p_right != 0)
79 p_y->m_p_right->m_p_parent = p_x;
81 p_y->m_p_parent = p_x->m_p_parent;
82 if (p_x == m_p_head->m_p_parent)
83 m_p_head->m_p_parent = p_y;
84 else if (p_x == p_x->m_p_parent->m_p_right)
85 p_x->m_p_parent->m_p_right = p_y;
87 p_x->m_p_parent->m_p_left = p_y;
90 p_x->m_p_parent = p_y;
92 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
93 _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
95 apply_update(p_x, (Node_Update*)
this);
96 apply_update(p_x->m_p_parent, (Node_Update*)
this);
102 rotate_parent(node_pointer p_nd)
104 node_pointer p_parent = p_nd->m_p_parent;
105 if (p_nd == p_parent->m_p_left)
106 rotate_right(p_parent);
108 rotate_left(p_parent);
109 _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
110 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent);
120 template<
typename Node_Update_>
123 apply_update(node_pointer p_nd, Node_Update_* p_update)
125 p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == 0) ?
127 & PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == 0) ?
129 & PB_DS_V2F(p_nd->m_p_right->m_value));
133 template<
typename Node_Update_>
136 update_to_top(node_pointer p_nd, Node_Update_* p_update)
138 while (p_nd != m_p_head)
140 apply_update(p_nd, p_update);
141 p_nd = p_nd->m_p_parent;
A null node updator, indicating that no node updates are required.