41#ifdef PB_DS_CLASS_C_DEC
46erase(key_const_reference r_key)
48 point_iterator it = this->find(r_key);
49 if (it == base_type::end())
56inline typename PB_DS_CLASS_C_DEC::iterator
60 PB_DS_ASSERT_VALID((*
this))
61 if (it == base_type::end())
66 erase_node(it.m_p_nd);
67 PB_DS_ASSERT_VALID((*this))
72inline typename PB_DS_CLASS_C_DEC::reverse_iterator
74erase(reverse_iterator it)
76 PB_DS_ASSERT_VALID((*
this))
77 if (it.m_p_nd == base_type::m_p_head)
80 reverse_iterator ret_it = it;
82 erase_node(it.m_p_nd);
83 PB_DS_ASSERT_VALID((*this))
88template<typename Pred>
89inline typename PB_DS_CLASS_C_DEC::size_type
93 PB_DS_ASSERT_VALID((*
this))
94 size_type num_ersd = 0;
95 iterator it = base_type::begin();
96 while (it != base_type::end())
107 PB_DS_ASSERT_VALID((*
this))
114erase_node(node_pointer p_nd)
117 base_type::actual_erase_node(p_nd);
118 PB_DS_ASSERT_VALID((*
this))
124remove_node(node_pointer p_z)
126 this->update_min_max_for_erased_node(p_z);
127 node_pointer p_y = p_z;
128 node_pointer p_x = 0;
129 node_pointer p_new_x_parent = 0;
131 if (p_y->m_p_left == 0)
132 p_x = p_y->m_p_right;
133 else if (p_y->m_p_right == 0)
137 p_y = p_y->m_p_right;
138 while (p_y->m_p_left != 0)
140 p_x = p_y->m_p_right;
145 p_new_x_parent = p_y->m_p_parent;
147 p_x->m_p_parent = p_y->m_p_parent;
149 if (base_type::m_p_head->m_p_parent == p_z)
150 base_type::m_p_head->m_p_parent = p_x;
151 else if (p_z->m_p_parent->m_p_left == p_z)
153 p_y->m_p_left = p_z->m_p_parent;
154 p_z->m_p_parent->m_p_left = p_x;
159 p_z->m_p_parent->m_p_right = p_x;
164 p_z->m_p_left->m_p_parent = p_y;
165 p_y->m_p_left = p_z->m_p_left;
166 if (p_y != p_z->m_p_right)
168 p_new_x_parent = p_y->m_p_parent;
170 p_x->m_p_parent = p_y->m_p_parent;
171 p_y->m_p_parent->m_p_left = p_x;
172 p_y->m_p_right = p_z->m_p_right;
173 p_z->m_p_right->m_p_parent = p_y;
176 p_new_x_parent = p_y;
178 if (base_type::m_p_head->m_p_parent == p_z)
179 base_type::m_p_head->m_p_parent = p_y;
180 else if (p_z->m_p_parent->m_p_left == p_z)
181 p_z->m_p_parent->m_p_left = p_y;
183 p_z->m_p_parent->m_p_right = p_y;
185 p_y->m_p_parent = p_z->m_p_parent;
190 this->update_to_top(p_new_x_parent, (node_update* )
this);
195 remove_fixup(p_x, p_new_x_parent);
201remove_fixup(node_pointer p_x, node_pointer p_new_x_parent)
203 _GLIBCXX_DEBUG_ASSERT(p_x == 0 || p_x->m_p_parent == p_new_x_parent);
205 while (p_x != base_type::m_p_head->m_p_parent && is_effectively_black(p_x))
206 if (p_x == p_new_x_parent->m_p_left)
208 node_pointer p_w = p_new_x_parent->m_p_right;
212 p_new_x_parent->m_red =
true;
213 base_type::rotate_left(p_new_x_parent);
214 p_w = p_new_x_parent->m_p_right;
217 if (is_effectively_black(p_w->m_p_left)
218 && is_effectively_black(p_w->m_p_right))
221 p_x = p_new_x_parent;
222 p_new_x_parent = p_new_x_parent->m_p_parent;
226 if (is_effectively_black(p_w->m_p_right))
228 if (p_w->m_p_left != 0)
229 p_w->m_p_left->m_red =
false;
232 base_type::rotate_right(p_w);
233 p_w = p_new_x_parent->m_p_right;
236 p_w->m_red = p_new_x_parent->m_red;
237 p_new_x_parent->m_red =
false;
239 if (p_w->m_p_right != 0)
240 p_w->m_p_right->m_red =
false;
242 base_type::rotate_left(p_new_x_parent);
243 this->update_to_top(p_new_x_parent, (node_update* )
this);
249 node_pointer p_w = p_new_x_parent->m_p_left;
250 if (p_w->m_red ==
true)
253 p_new_x_parent->m_red =
true;
254 base_type::rotate_right(p_new_x_parent);
255 p_w = p_new_x_parent->m_p_left;
258 if (is_effectively_black(p_w->m_p_right)
259 && is_effectively_black(p_w->m_p_left))
262 p_x = p_new_x_parent;
263 p_new_x_parent = p_new_x_parent->m_p_parent;
267 if (is_effectively_black(p_w->m_p_left))
269 if (p_w->m_p_right != 0)
270 p_w->m_p_right->m_red =
false;
273 base_type::rotate_left(p_w);
274 p_w = p_new_x_parent->m_p_left;
277 p_w->m_red = p_new_x_parent->m_red;
278 p_new_x_parent->m_red =
false;
280 if (p_w->m_p_left != 0)
281 p_w->m_p_left->m_red =
false;
283 base_type::rotate_right(p_new_x_parent);
284 this->update_to_top(p_new_x_parent, (node_update* )
this);
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.