3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 2, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
31 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
33 // Permission to use, copy, modify, sell, and distribute this software
34 // is hereby granted without fee, provided that the above copyright
35 // notice appears in all copies, and that both that copyright notice
36 // and this permission notice appear in supporting documentation. None
37 // of the above authors, nor IBM Haifa Research Laboratories, make any
38 // representation about the suitability of this software for any
39 // purpose. It is provided "as is" without express or implied
43 * @file erase_fn_imps.hpp
44 * Contains an implementation class for ov_tree_.
52 _GLIBCXX_DEBUG_ONLY(assert_valid();)
55 _GLIBCXX_DEBUG_ONLY(assert_valid();)
60 reallocate_metadata((node_update* )this, 0);
61 cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
64 _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
67 m_end_it = m_a_values;
68 _GLIBCXX_DEBUG_ONLY(assert_valid();)
72 template<typename Pred>
73 inline typename PB_DS_CLASS_C_DEC::size_type
77 _GLIBCXX_DEBUG_ONLY(assert_valid();)
79 #ifdef PB_DS_REGRESSION
80 typename Allocator::group_throw_prob_adjustor adjust(m_size);
83 size_type new_size = 0;
84 size_type num_val_ersd = 0;
85 iterator source_it = m_a_values;
86 for (source_it = begin(); source_it != m_end_it; ++source_it)
87 if (!pred(*source_it))
98 value_vector a_new_values = s_value_alloc.allocate(new_size);
99 iterator target_it = a_new_values;
100 cond_dtor<size_type> cd(a_new_values, target_it, new_size);
101 _GLIBCXX_DEBUG_ONLY(map_debug_base::clear());
102 for (source_it = begin(); source_it != m_end_it; ++source_it)
104 if (!pred(*source_it))
106 new (const_cast<void*>(static_cast<const void* >(target_it)))
107 value_type(*source_it);
109 _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(*source_it)));
114 reallocate_metadata((node_update* )this, new_size);
118 cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
121 m_a_values = a_new_values;
123 m_end_it = target_it;
124 update(node_begin(), (node_update* )this);
125 _GLIBCXX_DEBUG_ONLY(assert_valid();)
130 template<typename It>
135 _GLIBCXX_DEBUG_ONLY(assert_valid();)
139 _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));)
141 #ifdef PB_DS_REGRESSION
142 typename Allocator::group_throw_prob_adjustor adjust(m_size);
145 _GLIBCXX_DEBUG_ASSERT(m_size > 0);
146 value_vector a_values = s_value_alloc.allocate(m_size - 1);
147 iterator source_it = begin();
148 iterator source_end_it = end();
149 iterator target_it = a_values;
150 iterator ret_it = end();
152 cond_dtor<size_type> cd(a_values, target_it, m_size - 1);
154 _GLIBCXX_DEBUG_ONLY(size_type cnt = 0;)
156 while (source_it != source_end_it)
160 _GLIBCXX_DEBUG_ONLY(++cnt;)
161 _GLIBCXX_DEBUG_ASSERT(cnt != m_size);
162 new (const_cast<void* >(static_cast<const void* >(target_it)))
163 value_type(*source_it);
172 _GLIBCXX_DEBUG_ASSERT(m_size > 0);
173 reallocate_metadata((node_update* )this, m_size - 1);
175 _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::erase_existing(PB_DS_V2F(*it));)
177 cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
180 m_a_values = a_values;
182 m_end_it = m_a_values + m_size;
183 update(node_begin(), (node_update* )this);
184 _GLIBCXX_DEBUG_ONLY(assert_valid();)
191 erase(const_key_reference r_key)
193 point_iterator it = find(r_key);