Adjust Doxygen processing of pb_ds containers
[official-gcc.git] / libstdc++-v3 / include / ext / pb_ds / detail / list_update_map_ / erase_fn_imps.hpp
blob6e7c576c505bd789807c2beb5cdebb349423dd0d
1 // -*- C++ -*-
3 // Copyright (C) 2005-2019 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.
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.
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.
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/>.
25 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
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.
36 /**
37 * @file list_update_map_/erase_fn_imps.hpp
38 * Contains implementations of lu_map_.
41 #ifdef PB_DS_CLASS_C_DEC
43 PB_DS_CLASS_T_DEC
44 inline bool
45 PB_DS_CLASS_C_DEC::
46 erase(key_const_reference r_key)
48 PB_DS_ASSERT_VALID((*this))
49 if (m_p_l == 0)
50 return false;
52 if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value)))
54 entry_pointer p_next = m_p_l->m_p_next;
55 actual_erase_entry(m_p_l);
56 m_p_l = p_next;
57 return true;
60 entry_pointer p_l = m_p_l;
61 while (p_l->m_p_next != 0)
62 if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value)))
64 erase_next(p_l);
65 return true;
67 else
68 p_l = p_l->m_p_next;
69 return false;
72 PB_DS_CLASS_T_DEC
73 void
74 PB_DS_CLASS_C_DEC::
75 clear()
77 deallocate_all();
80 PB_DS_CLASS_T_DEC
81 template<typename Pred>
82 inline typename PB_DS_CLASS_C_DEC::size_type
83 PB_DS_CLASS_C_DEC::
84 erase_if(Pred pred)
86 PB_DS_ASSERT_VALID((*this))
87 size_type num_ersd = 0;
88 while (m_p_l != 0 && pred(m_p_l->m_value))
90 entry_pointer p_next = m_p_l->m_p_next;
91 ++num_ersd;
92 actual_erase_entry(m_p_l);
93 m_p_l = p_next;
96 if (m_p_l == 0)
97 return num_ersd;
99 entry_pointer p_l = m_p_l;
100 while (p_l->m_p_next != 0)
102 if (pred(p_l->m_p_next->m_value))
104 ++num_ersd;
105 erase_next(p_l);
107 else
108 p_l = p_l->m_p_next;
111 PB_DS_ASSERT_VALID((*this))
112 return num_ersd;
115 PB_DS_CLASS_T_DEC
116 void
117 PB_DS_CLASS_C_DEC::
118 erase_next(entry_pointer p_l)
120 _GLIBCXX_DEBUG_ASSERT(p_l != 0);
121 _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0);
122 entry_pointer p_next_l = p_l->m_p_next->m_p_next;
123 actual_erase_entry(p_l->m_p_next);
124 p_l->m_p_next = p_next_l;
127 PB_DS_CLASS_T_DEC
128 void
129 PB_DS_CLASS_C_DEC::
130 actual_erase_entry(entry_pointer p_l)
132 _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->m_value));)
133 p_l->~entry();
134 s_entry_allocator.deallocate(p_l, 1);
137 #endif