44 erase(key_const_reference r_key)
46 point_iterator it = this->find(r_key);
54 inline typename PB_DS_CLASS_C_DEC::iterator
58 PB_DS_ASSERT_VALID((*
this))
59 if (it == base_type::
end())
64 erase_node(it.m_p_nd);
65 PB_DS_ASSERT_VALID((*this))
70 inline typename PB_DS_CLASS_C_DEC::reverse_iterator
72 erase(reverse_iterator it)
74 PB_DS_ASSERT_VALID((*
this))
75 if (it.m_p_nd == base_type::m_p_head)
78 reverse_iterator ret_it = it;
80 erase_node(it.m_p_nd);
81 PB_DS_ASSERT_VALID((*this))
86 template<typename Pred>
87 inline typename PB_DS_CLASS_C_DEC::size_type
91 PB_DS_ASSERT_VALID((*
this))
92 size_type num_ersd = 0;
93 iterator it = base_type::
begin();
94 while (it != base_type::
end())
105 PB_DS_ASSERT_VALID((*
this))
112 erase_node(node_pointer p_nd)
115 base_type::actual_erase_node(p_nd);
116 PB_DS_ASSERT_VALID((*
this))
122 remove_node(node_pointer p_z)
124 this->update_min_max_for_erased_node(p_z);
125 node_pointer p_y = p_z;
126 node_pointer p_x = 0;
127 node_pointer p_new_x_parent = 0;
129 if (p_y->m_p_left == 0)
130 p_x = p_y->m_p_right;
131 else if (p_y->m_p_right == 0)
135 p_y = p_y->m_p_right;
136 while (p_y->m_p_left != 0)
138 p_x = p_y->m_p_right;
143 p_new_x_parent = p_y->m_p_parent;
145 p_x->m_p_parent = p_y->m_p_parent;
147 if (base_type::m_p_head->m_p_parent == p_z)
148 base_type::m_p_head->m_p_parent = p_x;
149 else if (p_z->m_p_parent->m_p_left == p_z)
151 p_y->m_p_left = p_z->m_p_parent;
152 p_z->m_p_parent->m_p_left = p_x;
157 p_z->m_p_parent->m_p_right = p_x;
162 p_z->m_p_left->m_p_parent = p_y;
163 p_y->m_p_left = p_z->m_p_left;
164 if (p_y != p_z->m_p_right)
166 p_new_x_parent = p_y->m_p_parent;
168 p_x->m_p_parent = p_y->m_p_parent;
169 p_y->m_p_parent->m_p_left = p_x;
170 p_y->m_p_right = p_z->m_p_right;
171 p_z->m_p_right->m_p_parent = p_y;
174 p_new_x_parent = p_y;
176 if (base_type::m_p_head->m_p_parent == p_z)
177 base_type::m_p_head->m_p_parent = p_y;
178 else if (p_z->m_p_parent->m_p_left == p_z)
179 p_z->m_p_parent->m_p_left = p_y;
181 p_z->m_p_parent->m_p_right = p_y;
183 p_y->m_p_parent = p_z->m_p_parent;
188 this->update_to_top(p_new_x_parent, (node_update* )
this);
193 remove_fixup(p_x, p_new_x_parent);
199 remove_fixup(node_pointer p_x, node_pointer p_new_x_parent)
201 _GLIBCXX_DEBUG_ASSERT(p_x == 0 || p_x->m_p_parent == p_new_x_parent);
203 while (p_x != base_type::m_p_head->m_p_parent && is_effectively_black(p_x))
204 if (p_x == p_new_x_parent->m_p_left)
206 node_pointer p_w = p_new_x_parent->m_p_right;
210 p_new_x_parent->m_red =
true;
211 base_type::rotate_left(p_new_x_parent);
212 p_w = p_new_x_parent->m_p_right;
215 if (is_effectively_black(p_w->m_p_left)
216 && is_effectively_black(p_w->m_p_right))
219 p_x = p_new_x_parent;
220 p_new_x_parent = p_new_x_parent->m_p_parent;
224 if (is_effectively_black(p_w->m_p_right))
226 if (p_w->m_p_left != 0)
227 p_w->m_p_left->m_red =
false;
230 base_type::rotate_right(p_w);
231 p_w = p_new_x_parent->m_p_right;
234 p_w->m_red = p_new_x_parent->m_red;
235 p_new_x_parent->m_red =
false;
237 if (p_w->m_p_right != 0)
238 p_w->m_p_right->m_red =
false;
240 base_type::rotate_left(p_new_x_parent);
241 this->update_to_top(p_new_x_parent, (node_update* )
this);
247 node_pointer p_w = p_new_x_parent->m_p_left;
248 if (p_w->m_red ==
true)
251 p_new_x_parent->m_red =
true;
252 base_type::rotate_right(p_new_x_parent);
253 p_w = p_new_x_parent->m_p_left;
256 if (is_effectively_black(p_w->m_p_right)
257 && is_effectively_black(p_w->m_p_left))
260 p_x = p_new_x_parent;
261 p_new_x_parent = p_new_x_parent->m_p_parent;
265 if (is_effectively_black(p_w->m_p_left))
267 if (p_w->m_p_right != 0)
268 p_w->m_p_right->m_red =
false;
271 base_type::rotate_left(p_w);
272 p_w = p_new_x_parent->m_p_left;
275 p_w->m_red = p_new_x_parent->m_red;
276 p_new_x_parent->m_red =
false;
278 if (p_w->m_p_left != 0)
279 p_w->m_p_left->m_red =
false;
281 base_type::rotate_right(p_new_x_parent);
282 this->update_to_top(p_new_x_parent, (node_update* )
this);
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.