]>
Commit | Line | Data |
---|---|---|
36fed23c | 1 | // -*- C++ -*- |
2 | ||
fbd26352 | 3 | // Copyright (C) 2005-2019 Free Software Foundation, Inc. |
36fed23c | 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 | |
6bc9506f | 8 | // Foundation; either version 3, or (at your option) any later |
36fed23c | 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 | ||
6bc9506f | 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/>. | |
36fed23c | 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 | /** | |
4f4a327e | 37 | * @file list_update_map_/constructor_destructor_fn_imps.hpp |
36fed23c | 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 | |
4f4a327e | 48 | null_type PB_DS_CLASS_C_DEC::s_null_type; |
36fed23c | 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:: | |
4f4a327e | 69 | PB_DS_LU_NAME() : m_p_l(0) |
2548203e | 70 | { PB_DS_ASSERT_VALID((*this)) } |
36fed23c | 71 | |
72 | PB_DS_CLASS_T_DEC | |
73 | template<typename It> | |
74 | PB_DS_CLASS_C_DEC:: | |
4f4a327e | 75 | PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0) |
36fed23c | 76 | { |
77 | copy_from_range(first_it, last_it); | |
2548203e | 78 | PB_DS_ASSERT_VALID((*this)); |
36fed23c | 79 | } |
80 | ||
81 | PB_DS_CLASS_T_DEC | |
82 | PB_DS_CLASS_C_DEC:: | |
4f4a327e | 83 | PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) : |
e4bb1925 | 84 | m_p_l(0) |
36fed23c | 85 | { |
b1a09c64 | 86 | __try |
36fed23c | 87 | { |
36fed23c | 88 | for (const_iterator it = other.begin(); it != other.end(); ++it) |
4f4a327e | 89 | { |
90 | entry_pointer p_l = allocate_new_entry(*it, | |
91 | traits_base::m_no_throw_copies_indicator); | |
36fed23c | 92 | |
93 | p_l->m_p_next = m_p_l; | |
36fed23c | 94 | m_p_l = p_l; |
4f4a327e | 95 | } |
36fed23c | 96 | } |
b1a09c64 | 97 | __catch(...) |
36fed23c | 98 | { |
99 | deallocate_all(); | |
c4f08cc0 | 100 | __throw_exception_again; |
36fed23c | 101 | } |
2548203e | 102 | PB_DS_ASSERT_VALID((*this)) |
2b31bec4 | 103 | } |
36fed23c | 104 | |
105 | PB_DS_CLASS_T_DEC | |
106 | void | |
107 | PB_DS_CLASS_C_DEC:: | |
108 | swap(PB_DS_CLASS_C_DEC& other) | |
109 | { | |
2548203e | 110 | PB_DS_ASSERT_VALID((*this)) |
111 | PB_DS_ASSERT_VALID(other) | |
6c9bd031 | 112 | _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) |
2b31bec4 | 113 | std::swap(m_p_l, other.m_p_l); |
2548203e | 114 | PB_DS_ASSERT_VALID((*this)) |
115 | PB_DS_ASSERT_VALID(other) | |
2b31bec4 | 116 | } |
36fed23c | 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; | |
e4bb1925 | 124 | while (p_l != 0) |
36fed23c | 125 | { |
126 | entry_pointer p_next_l = p_l->m_p_next; | |
36fed23c | 127 | actual_erase_entry(p_l); |
36fed23c | 128 | p_l = p_next_l; |
129 | } | |
e4bb1925 | 130 | m_p_l = 0; |
36fed23c | 131 | } |
132 | ||
133 | PB_DS_CLASS_T_DEC | |
134 | PB_DS_CLASS_C_DEC:: | |
4f4a327e | 135 | ~PB_DS_LU_NAME() |
2b31bec4 | 136 | { deallocate_all(); } |