41#ifdef PB_DS_CLASS_C_DEC
44inline typename PB_DS_CLASS_C_DEC::point_iterator
46push(const_reference r_val)
48 PB_DS_ASSERT_VALID((*
this))
49 node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
51 p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
52 if (base_type::m_p_root == 0)
54 p_nd->m_p_next_sibling = 0;
55 m_p_max = base_type::m_p_root = p_nd;
56 PB_DS_ASSERT_VALID((*
this))
57 return point_iterator(p_nd);
60 p_nd->m_p_next_sibling = base_type::m_p_root;
61 base_type::m_p_root->m_p_prev_or_parent = 0;
62 base_type::m_p_root = p_nd;
64 PB_DS_ASSERT_VALID((*this))
65 return point_iterator(p_nd);
71make_root(node_pointer p_nd)
73 p_nd->m_metadata = p_nd->m_p_l_child == 0
74 ? 0 : 1 + p_nd->m_p_l_child->m_metadata;
80make_root_and_link(node_pointer p_nd)
83 p_nd->m_p_prev_or_parent = 0;
84 p_nd->m_p_next_sibling = base_type::m_p_root;
85 if (base_type::m_p_root != 0)
86 base_type::m_p_root->m_p_prev_or_parent = 0;
88 base_type::m_p_root = p_nd;
99 if (p_y->m_p_prev_or_parent == 0)
104 else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0)
106 if (p_y->m_p_l_child != 0)
108 fix_sibling_rank_1_unmarked(p_y);
112 fix_sibling_rank_1_marked(p_y);
113 p_y = p_y->m_p_prev_or_parent;
115 else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1)
117 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0);
118 if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2)
120 fix_sibling_general_unmarked(p_y);
124 fix_sibling_general_marked(p_y);
125 p_y = p_y->m_p_prev_or_parent;
127 else if ((p_y->m_p_l_child == 0&&
128 p_y->m_metadata == 2) ||(p_y->m_p_l_child != 0&&
129 p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3))
131 node_pointer p_z = p_y->m_p_prev_or_parent;
143fix_root(node_pointer p_y)
145 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0);
147 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
true)
153fix_sibling_rank_1_unmarked(node_pointer p_y)
155 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
157 _GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;)
158 _GLIBCXX_DEBUG_ASSERT(p_w != 0);
159 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0);
160 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0);
162 p_y->m_p_next_sibling = p_y->m_p_l_child;
163 p_y->m_p_next_sibling->m_p_prev_or_parent = p_y;
164 p_y->m_p_l_child = 0;
165 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
171fix_sibling_rank_1_marked(node_pointer p_y)
173 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
174 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0);
176 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
182fix_sibling_general_unmarked(node_pointer p_y)
184 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
186 node_pointer p_w = p_y->m_p_l_child;
187 _GLIBCXX_DEBUG_ASSERT(p_w != 0);
188 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
190 p_y->m_p_l_child = p_w->m_p_next_sibling;
191 p_w->m_p_next_sibling->m_p_prev_or_parent = p_y;
193 p_w->m_p_next_sibling = p_y->m_p_next_sibling;
194 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
195 p_w->m_p_next_sibling->m_p_prev_or_parent = p_w;
197 p_y->m_p_next_sibling = p_w;
198 p_w->m_p_prev_or_parent = p_y;
200 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
206fix_sibling_general_marked(node_pointer p_y)
208 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
210 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
216fix_child(node_pointer p_y)
218 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
220 if (p_y->m_p_next_sibling != 0)
221 p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent;
223 if (p_y->m_p_prev_or_parent->m_p_l_child == p_y)
224 p_y->m_p_prev_or_parent->m_p_l_child = p_y->m_p_next_sibling;
226 p_y->m_p_prev_or_parent->m_p_next_sibling = p_y->m_p_next_sibling;
228 make_root_and_link(p_y);
234modify(point_iterator it, const_reference r_new_val)
236 PB_DS_ASSERT_VALID((*
this))
237 node_pointer p_nd = it.m_p_nd;
238 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
240 const
bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value);
241 p_nd->m_value = r_new_val;
245 p_nd->m_p_l_child = 0;
246 make_root_and_link(p_nd);
247 PB_DS_ASSERT_VALID((*
this))
251 if (p_nd->m_p_prev_or_parent == 0)
254 PB_DS_ASSERT_VALID((*
this))
258 node_pointer p_y = p_nd->m_p_prev_or_parent;
259 _GLIBCXX_DEBUG_ASSERT(p_y != 0);
261 if (p_nd->m_p_next_sibling != 0)
262 p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y;
264 if (p_y->m_p_l_child == p_nd)
265 p_y->m_p_l_child = p_nd->m_p_next_sibling;
267 p_y->m_p_next_sibling = p_nd->m_p_next_sibling;
270 make_root_and_link(p_nd);
271 PB_DS_ASSERT_VALID((*this))
277update_max(node_pointer p_nd)
279 if (m_p_max == 0 || Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))