constructor_destructor_fn_imps.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00031 
00032 // Permission to use, copy, modify, sell, and distribute this software
00033 // is hereby granted without fee, provided that the above copyright
00034 // notice appears in all copies, and that both that copyright notice and
00035 // this permission notice appear in supporting documentation. None of
00036 // the above authors, nor IBM Haifa Research Laboratories, make any
00037 // representation about the suitability of this software for any
00038 // purpose. It is provided "as is" without express or implied warranty.
00039 
00046 PB_ASSOC_CLASS_T_DEC
00047 typename PB_ASSOC_CLASS_C_DEC::entry_allocator
00048 PB_ASSOC_CLASS_C_DEC::s_entry_allocator;
00049 
00050 PB_ASSOC_CLASS_T_DEC
00051 template<class It>
00052 void
00053 PB_ASSOC_CLASS_C_DEC::
00054 copy_from_range(It first_it, It last_it)
00055 {
00056   while (first_it != last_it)
00057     insert(*(first_it++));
00058 }
00059 
00060 PB_ASSOC_CLASS_T_DEC
00061 PB_ASSOC_CLASS_C_DEC::
00062 PB_ASSOC_CLASS_NAME() :
00063   my_ranged_probe_fn_base(Resize_Policy::get_init_size()),
00064   m_a_entries(s_entry_allocator.allocate(
00065                      Resize_Policy::get_init_size())),
00066   m_num_e(Resize_Policy::get_init_size()),
00067   m_num_used_e(0)
00068 {
00069   initialize();
00070 
00071   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00072     }
00073 
00074 PB_ASSOC_CLASS_T_DEC
00075 PB_ASSOC_CLASS_C_DEC::
00076 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn)  :
00077   my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn),
00078   m_a_entries(s_entry_allocator.allocate(
00079                      Resize_Policy::get_init_size())),
00080   m_num_e(Resize_Policy::get_init_size()),
00081   m_num_used_e(0)
00082 {
00083   initialize();
00084 
00085   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00086     }
00087 
00088 PB_ASSOC_CLASS_T_DEC
00089 PB_ASSOC_CLASS_C_DEC::
00090 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
00091   my_hash_eq_fn_base(r_eq_fn),
00092   my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn),
00093   m_a_entries(s_entry_allocator.allocate(
00094                      Resize_Policy::get_init_size())),
00095   m_num_e(Resize_Policy::get_init_size()),
00096   m_num_used_e(0)
00097 {
00098   initialize();
00099 
00100   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00101     }
00102 
00103 PB_ASSOC_CLASS_T_DEC
00104 PB_ASSOC_CLASS_C_DEC::
00105 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) :
00106   my_hash_eq_fn_base(r_eq_fn),
00107   my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
00108               r_hash_fn, r_comb_hash_fn),
00109   m_a_entries(s_entry_allocator.allocate(
00110                      Resize_Policy::get_init_size())),
00111   m_num_e(Resize_Policy::get_init_size()),
00112   m_num_used_e(0)
00113 {
00114   initialize();
00115 
00116   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00117     }
00118 
00119 PB_ASSOC_CLASS_T_DEC
00120 PB_ASSOC_CLASS_C_DEC::
00121 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn) :
00122   my_hash_eq_fn_base(r_eq_fn),
00123   my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
00124               r_hash_fn, r_comb_hash_fn, r_probe_fn),
00125   m_a_entries(s_entry_allocator.allocate(
00126                      Resize_Policy::get_init_size())),
00127   m_num_e(Resize_Policy::get_init_size()),
00128   m_num_used_e(0)
00129 {
00130   initialize();
00131 
00132   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00133     }
00134 
00135 PB_ASSOC_CLASS_T_DEC
00136 PB_ASSOC_CLASS_C_DEC::
00137 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy) :
00138   my_hash_eq_fn_base(r_eq_fn),
00139   my_resize_base(r_resize_policy),
00140   my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
00141               r_hash_fn, r_comb_hash_fn, r_probe_fn),
00142   m_a_entries(s_entry_allocator.allocate(
00143                      Resize_Policy::get_init_size())),
00144   m_num_e(Resize_Policy::get_init_size()),
00145   m_num_used_e(0)
00146 {
00147   initialize();
00148 
00149   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_r_valid();)
00150     }
00151 
00152 PB_ASSOC_CLASS_T_DEC
00153 PB_ASSOC_CLASS_C_DEC::
00154 PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) :
00155   my_hash_eq_fn_base(r_other),
00156   my_resize_base(r_other),
00157   my_ranged_probe_fn_base(r_other),
00158   m_a_entries(s_entry_allocator.allocate(
00159                      r_other.m_num_e)),
00160   m_num_e(r_other.m_num_e),
00161   m_num_used_e(r_other.m_num_used_e)
00162 {
00163   initialize();
00164 
00165   try
00166     {
00167       for (size_type i = 0; i < m_num_e; ++i)
00168     {
00169       entry_pointer p_e =& r_other.m_a_entries[i];
00170       if (p_e->m_stat == VALID_ENTRY_STATUS)
00171         constructor_insert_new_imp((const_mapped_reference)p_e->m_value,
00172                        i,
00173                        my_hash_traits_base::s_store_hash_indicator);
00174     }
00175     }
00176   catch(...)
00177     {
00178       deallocate_all();
00179 
00180       throw;
00181     }
00182 
00183   PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
00184     }
00185 
00186 PB_ASSOC_CLASS_T_DEC
00187 PB_ASSOC_CLASS_C_DEC::
00188 ~PB_ASSOC_CLASS_NAME()
00189 {
00190   deallocate_all();
00191 }
00192 
00193 PB_ASSOC_CLASS_T_DEC
00194 void
00195 PB_ASSOC_CLASS_C_DEC::
00196 swap(PB_ASSOC_CLASS_C_DEC& r_other)
00197 {
00198   PB_ASSOC_DBG_ONLY(assert_valid());
00199   PB_ASSOC_DBG_ONLY(r_other.assert_valid());
00200 
00201   std::swap(m_a_entries, r_other.m_a_entries);
00202 
00203   std::swap(m_num_e, r_other.m_num_e);
00204 
00205   std::swap(m_num_used_e, r_other.m_num_used_e);
00206 
00207   my_ranged_probe_fn_base::swap(r_other);
00208 
00209   my_hash_eq_fn_base::swap(r_other);
00210 
00211   my_resize_base::swap(r_other);
00212 
00213   PB_ASSOC_DBG_ONLY(my_cntnr_debug_base::swap(r_other));
00214 
00215   PB_ASSOC_DBG_ONLY(assert_valid());
00216   PB_ASSOC_DBG_ONLY(r_other.assert_valid());
00217 }
00218 
00219 PB_ASSOC_CLASS_T_DEC
00220 void
00221 PB_ASSOC_CLASS_C_DEC::
00222 deallocate_all()
00223 {
00224   clear();
00225 
00226   erase_all_valid_entries(m_a_entries, m_num_e);
00227 
00228   s_entry_allocator.deallocate(m_a_entries, m_num_e);
00229 }
00230 
00231 PB_ASSOC_CLASS_T_DEC
00232 void
00233 PB_ASSOC_CLASS_C_DEC::
00234 erase_all_valid_entries(entry_array a_entries_resized, size_type size)
00235 {
00236   for (size_type pos = 0; pos < size; ++pos)
00237     {
00238       entry_pointer p_e =& a_entries_resized[pos];
00239 
00240       if (p_e->m_stat == VALID_ENTRY_STATUS)
00241     p_e->m_value.~value_type();
00242     }
00243 }
00244 
00245 PB_ASSOC_CLASS_T_DEC
00246 void
00247 PB_ASSOC_CLASS_C_DEC::
00248 initialize()
00249 {
00250   for (size_type i = 0; i < m_num_e; ++i)
00251     m_a_entries[i].m_stat = (entry_status)EMPTY_ENTRY_STATUS;
00252 }
00253 
00254 #include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp>
00255 #include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp>

Generated on Tue Feb 2 16:55:51 2010 for GNU C++ STL by  doxygen 1.4.7