libstdc++
list_update_map_/constructor_destructor_fn_imps.hpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the terms
00008 // of the GNU General Public License as published by the Free Software
00009 // Foundation; either version 3, or (at your option) any later
00010 // version.
00011 
00012 // This library is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 // General Public License for more details.
00016 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00027 
00028 // Permission to use, copy, modify, sell, and distribute this software
00029 // is hereby granted without fee, provided that the above copyright
00030 // notice appears in all copies, and that both that copyright notice
00031 // and this permission notice appear in supporting documentation. None
00032 // of the above authors, nor IBM Haifa Research Laboratories, make any
00033 // representation about the suitability of this software for any
00034 // purpose. It is provided "as is" without express or implied
00035 // warranty.
00036 
00037 /**
00038  * @file list_update_map_/constructor_destructor_fn_imps.hpp
00039  */
00040 
00041 PB_DS_CLASS_T_DEC
00042 typename PB_DS_CLASS_C_DEC::entry_allocator
00043 PB_DS_CLASS_C_DEC::s_entry_allocator;
00044 
00045 PB_DS_CLASS_T_DEC
00046 Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn;
00047 
00048 PB_DS_CLASS_T_DEC
00049 null_type PB_DS_CLASS_C_DEC::s_null_type;
00050 
00051 PB_DS_CLASS_T_DEC
00052 Update_Policy PB_DS_CLASS_C_DEC::s_update_policy;
00053 
00054 PB_DS_CLASS_T_DEC
00055 type_to_type<
00056   typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator;
00057 
00058 PB_DS_CLASS_T_DEC
00059 template<typename It>
00060 void
00061 PB_DS_CLASS_C_DEC::
00062 copy_from_range(It first_it, It last_it)
00063 {
00064   while (first_it != last_it)
00065     insert(*(first_it++));
00066 }
00067 
00068 PB_DS_CLASS_T_DEC
00069 PB_DS_CLASS_C_DEC::
00070 PB_DS_LU_NAME() : m_p_l(0)
00071 { PB_DS_ASSERT_VALID((*this)) }
00072 
00073 PB_DS_CLASS_T_DEC
00074 template<typename It>
00075 PB_DS_CLASS_C_DEC::
00076 PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0)
00077 {
00078   copy_from_range(first_it, last_it);
00079   PB_DS_ASSERT_VALID((*this));
00080 }
00081 
00082 PB_DS_CLASS_T_DEC
00083 PB_DS_CLASS_C_DEC::
00084 PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) :
00085 m_p_l(0)
00086 {
00087   __try
00088     {
00089       for (const_iterator it = other.begin(); it != other.end(); ++it)
00090     {
00091       entry_pointer p_l = allocate_new_entry(*it,
00092                       traits_base::m_no_throw_copies_indicator);
00093 
00094       p_l->m_p_next = m_p_l;
00095       m_p_l = p_l;
00096     }
00097     }
00098   __catch(...)
00099     {
00100       deallocate_all();
00101       __throw_exception_again;
00102     }
00103   PB_DS_ASSERT_VALID((*this))
00104 }
00105 
00106 PB_DS_CLASS_T_DEC
00107 void
00108 PB_DS_CLASS_C_DEC::
00109 swap(PB_DS_CLASS_C_DEC& other)
00110 {
00111   PB_DS_ASSERT_VALID((*this))
00112   PB_DS_ASSERT_VALID(other)
00113   _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
00114   std::swap(m_p_l, other.m_p_l);
00115   PB_DS_ASSERT_VALID((*this))
00116   PB_DS_ASSERT_VALID(other)
00117 }
00118 
00119 PB_DS_CLASS_T_DEC
00120 void
00121 PB_DS_CLASS_C_DEC::
00122 deallocate_all()
00123 {
00124   entry_pointer p_l = m_p_l;
00125   while (p_l != 0)
00126     {
00127       entry_pointer p_next_l = p_l->m_p_next;
00128       actual_erase_entry(p_l);
00129       p_l = p_next_l;
00130     }
00131   m_p_l = 0;
00132 }
00133 
00134 PB_DS_CLASS_T_DEC
00135 PB_DS_CLASS_C_DEC::
00136 ~PB_DS_LU_NAME()
00137 { deallocate_all(); }