3 // Copyright (C) 2005 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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
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,
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.
41 * @file constructor_destructor_fn_imps.hpp
42 * Contains implementations of cc_ht_map_'s constructors, destructor,
43 * and related functions.
47 typename
PB_ASSOC_CLASS_C_DEC::entry_allocator
48 PB_ASSOC_CLASS_C_DEC::s_entry_allocator
;
51 typename
PB_ASSOC_CLASS_C_DEC::entry_pointer_allocator
52 PB_ASSOC_CLASS_C_DEC::s_entry_pointer_allocator
;
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
++));
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()),
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();)
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(),
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()),
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();)
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(),
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()),
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();)
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()),
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();)
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()),
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();)
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(
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
];
165 constructor_insert_new_imp(
166 const_mapped_reference(p_e
->m_value
), i
,
167 my_hash_traits_base::s_store_hash_indicator
);
180 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
184 PB_ASSOC_CLASS_C_DEC::
185 ~PB_ASSOC_CLASS_NAME()
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());
218 PB_ASSOC_CLASS_C_DEC::
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>