42 inline typename PB_DS_CLASS_C_DEC::point_iterator
44 push(const_reference r_val)
46 PB_DS_ASSERT_VALID((*
this))
47 node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
49 p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
50 if (base_type::m_p_root == 0)
52 p_nd->m_p_next_sibling = 0;
53 m_p_max = base_type::m_p_root = p_nd;
54 PB_DS_ASSERT_VALID((*
this))
55 return point_iterator(p_nd);
58 p_nd->m_p_next_sibling = base_type::m_p_root;
59 base_type::m_p_root->m_p_prev_or_parent = 0;
60 base_type::m_p_root = p_nd;
62 PB_DS_ASSERT_VALID((*this))
63 return point_iterator(p_nd);
69 make_root(node_pointer p_nd)
71 p_nd->m_metadata = p_nd->m_p_l_child == 0
72 ? 0 : 1 + p_nd->m_p_l_child->m_metadata;
78 make_root_and_link(node_pointer p_nd)
81 p_nd->m_p_prev_or_parent = 0;
82 p_nd->m_p_next_sibling = base_type::m_p_root;
83 if (base_type::m_p_root != 0)
84 base_type::m_p_root->m_p_prev_or_parent = 0;
86 base_type::m_p_root = p_nd;
97 if (p_y->m_p_prev_or_parent == 0)
102 else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0)
104 if (p_y->m_p_l_child != 0)
106 fix_sibling_rank_1_unmarked(p_y);
110 fix_sibling_rank_1_marked(p_y);
111 p_y = p_y->m_p_prev_or_parent;
113 else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1)
115 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0);
116 if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2)
118 fix_sibling_general_unmarked(p_y);
122 fix_sibling_general_marked(p_y);
123 p_y = p_y->m_p_prev_or_parent;
125 else if ((p_y->m_p_l_child == 0&&
126 p_y->m_metadata == 2) ||(p_y->m_p_l_child != 0&&
127 p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3))
129 node_pointer p_z = p_y->m_p_prev_or_parent;
141 fix_root(node_pointer p_y)
143 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0);
145 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
true)
151 fix_sibling_rank_1_unmarked(node_pointer p_y)
153 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
155 _GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;)
156 _GLIBCXX_DEBUG_ASSERT(p_w != 0);
157 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0);
158 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0);
160 p_y->m_p_next_sibling = p_y->m_p_l_child;
161 p_y->m_p_next_sibling->m_p_prev_or_parent = p_y;
162 p_y->m_p_l_child = 0;
163 PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
169 fix_sibling_rank_1_marked(node_pointer p_y)
171 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
172 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0);
174 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
180 fix_sibling_general_unmarked(node_pointer p_y)
182 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
184 node_pointer p_w = p_y->m_p_l_child;
185 _GLIBCXX_DEBUG_ASSERT(p_w != 0);
186 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
188 p_y->m_p_l_child = p_w->m_p_next_sibling;
189 p_w->m_p_next_sibling->m_p_prev_or_parent = p_y;
191 p_w->m_p_next_sibling = p_y->m_p_next_sibling;
192 _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0);
193 p_w->m_p_next_sibling->m_p_prev_or_parent = p_w;
195 p_y->m_p_next_sibling = p_w;
196 p_w->m_p_prev_or_parent = p_y;
198 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
204 fix_sibling_general_marked(node_pointer p_y)
206 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
208 PB_DS_ASSERT_NODE_CONSISTENT(p_y,
false)
214 fix_child(node_pointer p_y)
216 _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
218 if (p_y->m_p_next_sibling != 0)
219 p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent;
221 if (p_y->m_p_prev_or_parent->m_p_l_child == p_y)
222 p_y->m_p_prev_or_parent->m_p_l_child = p_y->m_p_next_sibling;
224 p_y->m_p_prev_or_parent->m_p_next_sibling = p_y->m_p_next_sibling;
226 make_root_and_link(p_y);
232 modify(point_iterator it, const_reference r_new_val)
234 PB_DS_ASSERT_VALID((*
this))
235 node_pointer p_nd = it.m_p_nd;
236 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
238 const
bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value);
239 p_nd->m_value = r_new_val;
243 p_nd->m_p_l_child = 0;
244 make_root_and_link(p_nd);
245 PB_DS_ASSERT_VALID((*
this))
249 if (p_nd->m_p_prev_or_parent == 0)
252 PB_DS_ASSERT_VALID((*
this))
256 node_pointer p_y = p_nd->m_p_prev_or_parent;
257 _GLIBCXX_DEBUG_ASSERT(p_y != 0);
259 if (p_nd->m_p_next_sibling != 0)
260 p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y;
262 if (p_y->m_p_l_child == p_nd)
263 p_y->m_p_l_child = p_nd->m_p_next_sibling;
265 p_y->m_p_next_sibling = p_nd->m_p_next_sibling;
268 make_root_and_link(p_nd);
269 PB_DS_ASSERT_VALID((*this))
275 update_max(node_pointer p_nd)
277 if (m_p_max == 0 || Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))