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