Home | History | Annotate | Download | only in list_update_map_
      1 // -*- C++ -*-
      2 
      3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
      4 // Free Software Foundation, Inc.
      5 //
      6 // This file is part of the GNU ISO C++ Library.  This library is free
      7 // software; you can redistribute it and/or modify it under the terms
      8 // of the GNU General Public License as published by the Free Software
      9 // Foundation; either version 3, or (at your option) any later
     10 // version.
     11 
     12 // This library is distributed in the hope that it will be useful, but
     13 // WITHOUT ANY WARRANTY; without even the implied warranty of
     14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 // General Public License for more details.
     16 
     17 // Under Section 7 of GPL version 3, you are granted additional
     18 // permissions described in the GCC Runtime Library Exception, version
     19 // 3.1, as published by the Free Software Foundation.
     20 
     21 // You should have received a copy of the GNU General Public License and
     22 // a copy of the GCC Runtime Library Exception along with this program;
     23 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24 // <http://www.gnu.org/licenses/>.
     25 
     26 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
     27 
     28 // Permission to use, copy, modify, sell, and distribute this software
     29 // is hereby granted without fee, provided that the above copyright
     30 // notice appears in all copies, and that both that copyright notice
     31 // and this permission notice appear in supporting documentation. None
     32 // of the above authors, nor IBM Haifa Research Laboratories, make any
     33 // representation about the suitability of this software for any
     34 // purpose. It is provided "as is" without express or implied
     35 // warranty.
     36 
     37 /**
     38  * @file list_update_map_/constructor_destructor_fn_imps.hpp
     39  */
     40 
     41 PB_DS_CLASS_T_DEC
     42 typename PB_DS_CLASS_C_DEC::entry_allocator
     43 PB_DS_CLASS_C_DEC::s_entry_allocator;
     44 
     45 PB_DS_CLASS_T_DEC
     46 Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn;
     47 
     48 PB_DS_CLASS_T_DEC
     49 null_type PB_DS_CLASS_C_DEC::s_null_type;
     50 
     51 PB_DS_CLASS_T_DEC
     52 Update_Policy PB_DS_CLASS_C_DEC::s_update_policy;
     53 
     54 PB_DS_CLASS_T_DEC
     55 type_to_type<
     56   typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator;
     57 
     58 PB_DS_CLASS_T_DEC
     59 template<typename It>
     60 void
     61 PB_DS_CLASS_C_DEC::
     62 copy_from_range(It first_it, It last_it)
     63 {
     64   while (first_it != last_it)
     65     insert(*(first_it++));
     66 }
     67 
     68 PB_DS_CLASS_T_DEC
     69 PB_DS_CLASS_C_DEC::
     70 PB_DS_LU_NAME() : m_p_l(0)
     71 { PB_DS_ASSERT_VALID((*this)) }
     72 
     73 PB_DS_CLASS_T_DEC
     74 template<typename It>
     75 PB_DS_CLASS_C_DEC::
     76 PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0)
     77 {
     78   copy_from_range(first_it, last_it);
     79   PB_DS_ASSERT_VALID((*this));
     80 }
     81 
     82 PB_DS_CLASS_T_DEC
     83 PB_DS_CLASS_C_DEC::
     84 PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) :
     85 m_p_l(0)
     86 {
     87   __try
     88     {
     89       for (const_iterator it = other.begin(); it != other.end(); ++it)
     90 	{
     91 	  entry_pointer p_l = allocate_new_entry(*it,
     92 				      traits_base::m_no_throw_copies_indicator);
     93 
     94 	  p_l->m_p_next = m_p_l;
     95 	  m_p_l = p_l;
     96 	}
     97     }
     98   __catch(...)
     99     {
    100       deallocate_all();
    101       __throw_exception_again;
    102     }
    103   PB_DS_ASSERT_VALID((*this))
    104 }
    105 
    106 PB_DS_CLASS_T_DEC
    107 void
    108 PB_DS_CLASS_C_DEC::
    109 swap(PB_DS_CLASS_C_DEC& other)
    110 {
    111   PB_DS_ASSERT_VALID((*this))
    112   PB_DS_ASSERT_VALID(other)
    113   _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
    114   std::swap(m_p_l, other.m_p_l);
    115   PB_DS_ASSERT_VALID((*this))
    116   PB_DS_ASSERT_VALID(other)
    117 }
    118 
    119 PB_DS_CLASS_T_DEC
    120 void
    121 PB_DS_CLASS_C_DEC::
    122 deallocate_all()
    123 {
    124   entry_pointer p_l = m_p_l;
    125   while (p_l != 0)
    126     {
    127       entry_pointer p_next_l = p_l->m_p_next;
    128       actual_erase_entry(p_l);
    129       p_l = p_next_l;
    130     }
    131   m_p_l = 0;
    132 }
    133 
    134 PB_DS_CLASS_T_DEC
    135 PB_DS_CLASS_C_DEC::
    136 ~PB_DS_LU_NAME()
    137 { deallocate_all(); }
    138