1 // TR1 unordered_set -*- C++ -*-
3 // Copyright (C) 2007, 2009 Free Software Foundation, Inc.
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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU 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 /** @file tr1_impl/unordered_set
26 * This is an internal header file, included by other library headers.
27 * You should not attempt to use it directly.
32 _GLIBCXX_BEGIN_NAMESPACE_TR1
34 // XXX When we get typedef templates these class definitions
35 // will be unnecessary.
36 template<class _Value,
37 class _Hash = hash<_Value>,
38 class _Pred = std::equal_to<_Value>,
39 class _Alloc = std::allocator<_Value>,
40 bool __cache_hash_code = false>
42 : public _Hashtable<_Value, _Value, _Alloc,
43 std::_Identity<_Value>, _Pred,
44 _Hash, __detail::_Mod_range_hashing,
45 __detail::_Default_ranged_hash,
46 __detail::_Prime_rehash_policy,
47 __cache_hash_code, true, true>
49 typedef _Hashtable<_Value, _Value, _Alloc,
50 std::_Identity<_Value>, _Pred,
51 _Hash, __detail::_Mod_range_hashing,
52 __detail::_Default_ranged_hash,
53 __detail::_Prime_rehash_policy,
54 __cache_hash_code, true, true>
58 typedef typename _Base::size_type size_type;
59 typedef typename _Base::hasher hasher;
60 typedef typename _Base::key_equal key_equal;
61 typedef typename _Base::allocator_type allocator_type;
64 __unordered_set(size_type __n = 10,
65 const hasher& __hf = hasher(),
66 const key_equal& __eql = key_equal(),
67 const allocator_type& __a = allocator_type())
68 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
69 __detail::_Default_ranged_hash(), __eql,
70 std::_Identity<_Value>(), __a)
73 template<typename _InputIterator>
74 __unordered_set(_InputIterator __f, _InputIterator __l,
76 const hasher& __hf = hasher(),
77 const key_equal& __eql = key_equal(),
78 const allocator_type& __a = allocator_type())
79 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
80 __detail::_Default_ranged_hash(), __eql,
81 std::_Identity<_Value>(), __a)
84 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
85 __unordered_set(__unordered_set&& __x)
86 : _Base(std::forward<_Base>(__x)) { }
90 template<class _Value,
91 class _Hash = hash<_Value>,
92 class _Pred = std::equal_to<_Value>,
93 class _Alloc = std::allocator<_Value>,
94 bool __cache_hash_code = false>
95 class __unordered_multiset
96 : public _Hashtable<_Value, _Value, _Alloc,
97 std::_Identity<_Value>, _Pred,
98 _Hash, __detail::_Mod_range_hashing,
99 __detail::_Default_ranged_hash,
100 __detail::_Prime_rehash_policy,
101 __cache_hash_code, true, false>
103 typedef _Hashtable<_Value, _Value, _Alloc,
104 std::_Identity<_Value>, _Pred,
105 _Hash, __detail::_Mod_range_hashing,
106 __detail::_Default_ranged_hash,
107 __detail::_Prime_rehash_policy,
108 __cache_hash_code, true, false>
112 typedef typename _Base::size_type size_type;
113 typedef typename _Base::hasher hasher;
114 typedef typename _Base::key_equal key_equal;
115 typedef typename _Base::allocator_type allocator_type;
118 __unordered_multiset(size_type __n = 10,
119 const hasher& __hf = hasher(),
120 const key_equal& __eql = key_equal(),
121 const allocator_type& __a = allocator_type())
122 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
123 __detail::_Default_ranged_hash(), __eql,
124 std::_Identity<_Value>(), __a)
128 template<typename _InputIterator>
129 __unordered_multiset(_InputIterator __f, _InputIterator __l,
130 typename _Base::size_type __n = 0,
131 const hasher& __hf = hasher(),
132 const key_equal& __eql = key_equal(),
133 const allocator_type& __a = allocator_type())
134 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
135 __detail::_Default_ranged_hash(), __eql,
136 std::_Identity<_Value>(), __a)
139 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
140 __unordered_multiset(__unordered_multiset&& __x)
141 : _Base(std::forward<_Base>(__x)) { }
145 template<class _Value, class _Hash, class _Pred, class _Alloc,
146 bool __cache_hash_code>
148 swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
149 __unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
152 template<class _Value, class _Hash, class _Pred, class _Alloc,
153 bool __cache_hash_code>
155 swap(__unordered_multiset<_Value, _Hash, _Pred,
156 _Alloc, __cache_hash_code>& __x,
157 __unordered_multiset<_Value, _Hash, _Pred,
158 _Alloc, __cache_hash_code>& __y)
163 * @brief A standard container composed of unique keys (containing
164 * at most one of each key value) in which the elements' keys are
165 * the elements themselves.
167 * @ingroup unordered_associative_containers
169 * Meets the requirements of a <a href="tables.html#65">container</a>, and
170 * <a href="tables.html#xx">unordered associative container</a>
172 * @param Value Type of key objects.
173 * @param Hash Hashing function object type, defaults to hash<Value>.
174 * @param Pred Predicate function object type, defaults to equal_to<Value>.
175 * @param Alloc Allocator type, defaults to allocator<Key>.
177 template<class _Value,
178 class _Hash = hash<_Value>,
179 class _Pred = std::equal_to<_Value>,
180 class _Alloc = std::allocator<_Value> >
182 : public __unordered_set<_Value, _Hash, _Pred, _Alloc>
184 typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base;
187 typedef typename _Base::value_type value_type;
188 typedef typename _Base::size_type size_type;
189 typedef typename _Base::hasher hasher;
190 typedef typename _Base::key_equal key_equal;
191 typedef typename _Base::allocator_type allocator_type;
194 unordered_set(size_type __n = 10,
195 const hasher& __hf = hasher(),
196 const key_equal& __eql = key_equal(),
197 const allocator_type& __a = allocator_type())
198 : _Base(__n, __hf, __eql, __a)
201 template<typename _InputIterator>
202 unordered_set(_InputIterator __f, _InputIterator __l,
204 const hasher& __hf = hasher(),
205 const key_equal& __eql = key_equal(),
206 const allocator_type& __a = allocator_type())
207 : _Base(__f, __l, __n, __hf, __eql, __a)
210 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
211 unordered_set(unordered_set&& __x)
212 : _Base(std::forward<_Base>(__x)) { }
214 unordered_set(initializer_list<value_type> __l,
216 const hasher& __hf = hasher(),
217 const key_equal& __eql = key_equal(),
218 const allocator_type& __a = allocator_type())
219 : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
223 operator=(unordered_set&& __x)
232 operator=(initializer_list<value_type> __l)
235 this->insert(__l.begin(), __l.end());
242 * @brief A standard container composed of equivalent keys
243 * (possibly containing multiple of each key value) in which the
244 * elements' keys are the elements themselves.
246 * @ingroup unordered_associative_containers
248 * Meets the requirements of a <a href="tables.html#65">container</a>, and
249 * <a href="tables.html#xx">unordered associative container</a>
251 * @param Value Type of key objects.
252 * @param Hash Hashing function object type, defaults to hash<Value>.
253 * @param Pred Predicate function object type, defaults to equal_to<Value>.
254 * @param Alloc Allocator type, defaults to allocator<Key>.
256 template<class _Value,
257 class _Hash = hash<_Value>,
258 class _Pred = std::equal_to<_Value>,
259 class _Alloc = std::allocator<_Value> >
260 class unordered_multiset
261 : public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
263 typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base;
266 typedef typename _Base::value_type value_type;
267 typedef typename _Base::size_type size_type;
268 typedef typename _Base::hasher hasher;
269 typedef typename _Base::key_equal key_equal;
270 typedef typename _Base::allocator_type allocator_type;
273 unordered_multiset(size_type __n = 10,
274 const hasher& __hf = hasher(),
275 const key_equal& __eql = key_equal(),
276 const allocator_type& __a = allocator_type())
277 : _Base(__n, __hf, __eql, __a)
281 template<typename _InputIterator>
282 unordered_multiset(_InputIterator __f, _InputIterator __l,
283 typename _Base::size_type __n = 0,
284 const hasher& __hf = hasher(),
285 const key_equal& __eql = key_equal(),
286 const allocator_type& __a = allocator_type())
287 : _Base(__f, __l, __n, __hf, __eql, __a)
290 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
291 unordered_multiset(unordered_multiset&& __x)
292 : _Base(std::forward<_Base>(__x)) { }
294 unordered_multiset(initializer_list<value_type> __l,
296 const hasher& __hf = hasher(),
297 const key_equal& __eql = key_equal(),
298 const allocator_type& __a = allocator_type())
299 : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
303 operator=(unordered_multiset&& __x)
312 operator=(initializer_list<value_type> __l)
315 this->insert(__l.begin(), __l.end());
321 template<class _Value, class _Hash, class _Pred, class _Alloc>
323 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
324 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
327 template<class _Value, class _Hash, class _Pred, class _Alloc>
329 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
330 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
333 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
334 template<class _Value, class _Hash, class _Pred, class _Alloc>
336 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
337 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
340 template<class _Value, class _Hash, class _Pred, class _Alloc>
342 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
343 unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
346 template<class _Value, class _Hash, class _Pred, class _Alloc>
348 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
349 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
352 template<class _Value, class _Hash, class _Pred, class _Alloc>
354 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
355 unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
359 _GLIBCXX_END_NAMESPACE_TR1