Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / include / ext / pb_assoc / detail / cc_ht_map_ / constructor_destructor_fn_imps.hpp
blob4dedb91259d8afff15790109373728f372212bff
1 // -*- C++ -*-
3 // Copyright (C) 2005 Free Software Foundation, Inc.
4 //
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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
40 /**
41 * @file constructor_destructor_fn_imps.hpp
42 * Contains implementations of cc_ht_map_'s constructors, destructor,
43 * and related functions.
46 PB_ASSOC_CLASS_T_DEC
47 typename PB_ASSOC_CLASS_C_DEC::entry_allocator
48 PB_ASSOC_CLASS_C_DEC::s_entry_allocator;
50 PB_ASSOC_CLASS_T_DEC
51 typename PB_ASSOC_CLASS_C_DEC::entry_pointer_allocator
52 PB_ASSOC_CLASS_C_DEC::s_entry_pointer_allocator;
54 PB_ASSOC_CLASS_T_DEC
55 template<class It>
56 void
57 PB_ASSOC_CLASS_C_DEC::
58 copy_from_range(It first_it, It last_it)
60 while (first_it != last_it)
61 insert(*(first_it++));
64 PB_ASSOC_CLASS_T_DEC
65 PB_ASSOC_CLASS_C_DEC::
66 PB_ASSOC_CLASS_NAME() :
67 my_ranged_hash_fn_base(Resize_Policy::get_init_size()),
68 m_a_p_entries(s_entry_pointer_allocator.allocate(
69 Resize_Policy::get_init_size())),
70 m_num_e_p(Resize_Policy::get_init_size()),
71 m_num_used_e(0)
73 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
75 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
78 PB_ASSOC_CLASS_T_DEC
79 PB_ASSOC_CLASS_C_DEC::
80 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn) :
81 my_ranged_hash_fn_base(Resize_Policy::get_init_size(),
82 r_hash_fn),
83 m_a_p_entries(s_entry_pointer_allocator.allocate(
84 Resize_Policy::get_init_size())),
85 m_num_e_p(Resize_Policy::get_init_size()),
86 m_num_used_e(0)
88 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
90 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
93 PB_ASSOC_CLASS_T_DEC
94 PB_ASSOC_CLASS_C_DEC::
95 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
96 PB_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn),
97 my_ranged_hash_fn_base(Resize_Policy::get_init_size(),
98 r_hash_fn),
99 m_a_p_entries(s_entry_pointer_allocator.allocate(
100 Resize_Policy::get_init_size())),
101 m_num_e_p(Resize_Policy::get_init_size()),
102 m_num_used_e(0)
104 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
106 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
109 PB_ASSOC_CLASS_T_DEC
110 PB_ASSOC_CLASS_C_DEC::
111 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) :
112 PB_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn),
113 my_ranged_hash_fn_base(Resize_Policy::get_init_size(),
114 r_hash_fn, r_comb_hash_fn),
115 m_a_p_entries(s_entry_pointer_allocator.allocate(
116 Resize_Policy::get_init_size())),
117 m_num_e_p(Resize_Policy::get_init_size()),
118 m_num_used_e(0)
120 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
122 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
125 PB_ASSOC_CLASS_T_DEC
126 PB_ASSOC_CLASS_C_DEC::
127 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn, const Resize_Policy& r_resize_policy) :
128 PB_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn),
129 Resize_Policy(r_resize_policy),
130 my_ranged_hash_fn_base(Resize_Policy::get_init_size(),
131 r_hash_fn, r_comb_hash_fn),
132 m_a_p_entries(s_entry_pointer_allocator.allocate(
133 Resize_Policy::get_init_size())),
134 m_num_e_p(Resize_Policy::get_init_size()),
135 m_num_used_e(0)
137 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
139 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
142 PB_ASSOC_CLASS_T_DEC
143 PB_ASSOC_CLASS_C_DEC::
144 PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) :
145 PB_ASSOC_HASH_EQ_FN_C_DEC(r_other),
146 my_resize_base(r_other),
147 my_ranged_hash_fn_base(r_other),
148 m_a_p_entries(s_entry_pointer_allocator.allocate(
149 r_other.m_num_e_p)),
150 m_num_e_p(r_other.m_num_e_p),
151 m_num_used_e(r_other.m_num_used_e)
153 PB_ASSOC_DBG_ONLY(r_other.assert_valid();)
155 std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
159 for (size_type i = 0; i < m_num_e_p; ++i)
161 entry_pointer p_e = r_other.m_a_p_entries[i];
163 while (p_e != NULL)
165 constructor_insert_new_imp(
166 const_mapped_reference(p_e->m_value), i,
167 my_hash_traits_base::s_store_hash_indicator);
169 p_e = p_e->m_p_next;
173 catch(...)
175 deallocate_all();
177 throw;
180 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
183 PB_ASSOC_CLASS_T_DEC
184 PB_ASSOC_CLASS_C_DEC::
185 ~PB_ASSOC_CLASS_NAME()
187 deallocate_all();
190 PB_ASSOC_CLASS_T_DEC
191 void
192 PB_ASSOC_CLASS_C_DEC::
193 swap(PB_ASSOC_CLASS_C_DEC& r_other)
195 PB_ASSOC_DBG_ONLY(assert_valid());
196 PB_ASSOC_DBG_ONLY(r_other.assert_valid());
198 std::swap(m_a_p_entries, r_other.m_a_p_entries);
200 std::swap(m_num_e_p, r_other.m_num_e_p);
202 std::swap(m_num_used_e, r_other.m_num_used_e);
204 my_ranged_hash_fn_base::swap(r_other);
206 my_hash_eq_fn_base::swap(r_other);
208 my_resize_base::swap(r_other);
210 PB_ASSOC_DBG_ONLY(my_map_debug_base::swap(r_other));
212 PB_ASSOC_DBG_ONLY(assert_valid());
213 PB_ASSOC_DBG_ONLY(r_other.assert_valid());
216 PB_ASSOC_CLASS_T_DEC
217 void
218 PB_ASSOC_CLASS_C_DEC::
219 deallocate_all()
221 clear();
223 s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p);
226 #include <ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp>
227 #include <ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp>