41#ifdef PB_DS_CLASS_C_DEC
46erase(key_const_reference r_key)
48 node_pointer p_nd = find_imp(r_key);
49 if (p_nd == 0 || p_nd->m_type == i_node)
51 PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
55 _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
56 if (!synth_access_traits::equal_keys(PB_DS_V2F(
reinterpret_cast<leaf_pointer
>(p_nd)->value()), r_key))
58 PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
62 PB_DS_CHECK_KEY_EXISTS(r_key)
63 erase_leaf(
static_cast<leaf_pointer
>(p_nd));
64 PB_DS_ASSERT_VALID((*
this))
71erase_fixup(inode_pointer p_nd)
73 _GLIBCXX_DEBUG_ASSERT(
std::distance(p_nd->begin(), p_nd->end()) >= 1);
76 node_pointer p_parent = p_nd->m_p_parent;
77 if (p_parent == m_p_head)
78 m_p_head->m_p_parent = *p_nd->begin();
81 _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
82 node_pointer p_new_child = *p_nd->begin();
84 typedef inode_pointer inode_ptr;
85 inode_ptr p_internal =
static_cast<inode_ptr
>(p_parent);
86 p_internal->replace_child(p_new_child, pref_begin(p_new_child),
87 pref_end(p_new_child),
this);
89 (*p_nd->begin())->m_p_parent = p_nd->m_p_parent;
91 s_inode_allocator.deallocate(p_nd, 1);
93 if (p_parent == m_p_head)
96 _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
97 p_nd =
static_cast<inode_pointer
>(p_parent);
102 _GLIBCXX_DEBUG_ASSERT(
std::distance(p_nd->begin(), p_nd->end()) > 1);
103 p_nd->update_prefixes(
this);
104 apply_update(p_nd, (node_update*)
this);
105 PB_DS_ASSERT_NODE_VALID(p_nd)
106 if (p_nd->m_p_parent->m_type == head_node)
109 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == i_node);
111 p_nd =
static_cast<inode_pointer
>(p_nd->m_p_parent);
118actual_erase_leaf(leaf_pointer p_l)
120 _GLIBCXX_DEBUG_ASSERT(m_size > 0);
122 _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->value())));
124 s_leaf_allocator.deallocate(p_l, 1);
134 clear_imp(m_p_head->m_p_parent);
137 _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
138 PB_DS_ASSERT_VALID((*
this))
145clear_imp(node_pointer p_nd)
147 if (p_nd->m_type == i_node)
149 _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
150 for (
typename inode::iterator it =
151 static_cast<inode_pointer
>(p_nd)->
begin();
152 it !=
static_cast<inode_pointer
>(p_nd)->
end();
155 node_pointer p_child =* it;
158 s_inode_allocator.deallocate(
static_cast<inode_pointer
>(p_nd), 1);
162 _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
163 static_cast<leaf_pointer
>(p_nd)->~leaf();
164 s_leaf_allocator.deallocate(
static_cast<leaf_pointer
>(p_nd), 1);
168inline typename PB_DS_CLASS_C_DEC::const_iterator
170erase(const_iterator it)
172 PB_DS_ASSERT_VALID((*
this))
177 const_iterator ret_it = it;
179 _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
180 erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
181 PB_DS_ASSERT_VALID((*this))
185#ifdef PB_DS_DATA_TRUE_INDICATOR
187inline typename PB_DS_CLASS_C_DEC::iterator
191 PB_DS_ASSERT_VALID((*
this))
195 iterator ret_it = it;
197 _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
198 erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
199 PB_DS_ASSERT_VALID((*this))
205inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
207erase(const_reverse_iterator it)
209 PB_DS_ASSERT_VALID((*
this))
211 if (it.m_p_nd == m_p_head)
213 const_reverse_iterator ret_it = it;
216 _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
217 erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
218 PB_DS_ASSERT_VALID((*this))
222#ifdef PB_DS_DATA_TRUE_INDICATOR
224inline typename PB_DS_CLASS_C_DEC::reverse_iterator
226erase(reverse_iterator it)
228 PB_DS_ASSERT_VALID((*
this))
230 if (it.m_p_nd == m_p_head)
232 reverse_iterator ret_it = it;
235 _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
236 erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
237 PB_DS_ASSERT_VALID((*this))
243template<
typename Pred>
244inline typename PB_DS_CLASS_C_DEC::size_type
248 size_type num_ersd = 0;
249 PB_DS_ASSERT_VALID((*
this))
251 iterator it = begin();
254 PB_DS_ASSERT_VALID((*
this))
264 PB_DS_ASSERT_VALID((*
this))
271erase_leaf(leaf_pointer p_l)
273 update_min_max_for_erased_leaf(p_l);
274 if (p_l->m_p_parent->m_type == head_node)
276 _GLIBCXX_DEBUG_ASSERT(
size() == 1);
281 _GLIBCXX_DEBUG_ASSERT(
size() > 1);
282 _GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == i_node);
284 inode_pointer p_parent =
static_cast<inode_pointer
>(p_l->m_p_parent);
286 p_parent->remove_child(p_l);
287 erase_fixup(p_parent);
288 actual_erase_leaf(p_l);
294update_min_max_for_erased_leaf(leaf_pointer p_l)
298 m_p_head->m_p_min = m_p_head;
299 m_p_head->m_p_max = m_p_head;
303 if (p_l ==
static_cast<leaf_const_pointer
>(m_p_head->m_p_min))
307 m_p_head->m_p_min = it.m_p_nd;
311 if (p_l ==
static_cast<leaf_const_pointer
>(m_p_head->m_p_max))
315 m_p_head->m_p_max = it.m_p_nd;
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.