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 2, 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 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file tr1_impl/unordered_set
31 * This is an internal header file, included by other library headers.
32 * You should not attempt to use it directly.
37 _GLIBCXX_BEGIN_NAMESPACE_TR1
39 // XXX When we get typedef templates these class definitions
40 // will be unnecessary.
41 template<class _Value,
42 class _Hash = hash<_Value>,
43 class _Pred = std::equal_to<_Value>,
44 class _Alloc = std::allocator<_Value>,
45 bool __cache_hash_code = false>
47 : public _Hashtable<_Value, _Value, _Alloc,
48 std::_Identity<_Value>, _Pred,
49 _Hash, __detail::_Mod_range_hashing,
50 __detail::_Default_ranged_hash,
51 __detail::_Prime_rehash_policy,
52 __cache_hash_code, true, true>
54 typedef _Hashtable<_Value, _Value, _Alloc,
55 std::_Identity<_Value>, _Pred,
56 _Hash, __detail::_Mod_range_hashing,
57 __detail::_Default_ranged_hash,
58 __detail::_Prime_rehash_policy,
59 __cache_hash_code, true, true>
63 typedef typename _Base::size_type size_type;
64 typedef typename _Base::hasher hasher;
65 typedef typename _Base::key_equal key_equal;
66 typedef typename _Base::allocator_type allocator_type;
69 __unordered_set(size_type __n = 10,
70 const hasher& __hf = hasher(),
71 const key_equal& __eql = key_equal(),
72 const allocator_type& __a = allocator_type())
73 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
74 __detail::_Default_ranged_hash(), __eql,
75 std::_Identity<_Value>(), __a)
78 template<typename _InputIterator>
79 __unordered_set(_InputIterator __f, _InputIterator __l,
81 const hasher& __hf = hasher(),
82 const key_equal& __eql = key_equal(),
83 const allocator_type& __a = allocator_type())
84 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
85 __detail::_Default_ranged_hash(), __eql,
86 std::_Identity<_Value>(), __a)
89 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
90 __unordered_set(__unordered_set&& __x)
91 : _Base(std::forward<_Base>(__x)) { }
95 template<class _Value,
96 class _Hash = hash<_Value>,
97 class _Pred = std::equal_to<_Value>,
98 class _Alloc = std::allocator<_Value>,
99 bool __cache_hash_code = false>
100 class __unordered_multiset
101 : public _Hashtable<_Value, _Value, _Alloc,
102 std::_Identity<_Value>, _Pred,
103 _Hash, __detail::_Mod_range_hashing,
104 __detail::_Default_ranged_hash,
105 __detail::_Prime_rehash_policy,
106 __cache_hash_code, true, false>
108 typedef _Hashtable<_Value, _Value, _Alloc,
109 std::_Identity<_Value>, _Pred,
110 _Hash, __detail::_Mod_range_hashing,
111 __detail::_Default_ranged_hash,
112 __detail::_Prime_rehash_policy,
113 __cache_hash_code, true, false>
117 typedef typename _Base::size_type size_type;
118 typedef typename _Base::hasher hasher;
119 typedef typename _Base::key_equal key_equal;
120 typedef typename _Base::allocator_type allocator_type;
123 __unordered_multiset(size_type __n = 10,
124 const hasher& __hf = hasher(),
125 const key_equal& __eql = key_equal(),
126 const allocator_type& __a = allocator_type())
127 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
128 __detail::_Default_ranged_hash(), __eql,
129 std::_Identity<_Value>(), __a)
133 template<typename _InputIterator>
134 __unordered_multiset(_InputIterator __f, _InputIterator __l,
135 typename _Base::size_type __n = 0,
136 const hasher& __hf = hasher(),
137 const key_equal& __eql = key_equal(),
138 const allocator_type& __a = allocator_type())
139 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
140 __detail::_Default_ranged_hash(), __eql,
141 std::_Identity<_Value>(), __a)
144 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
145 __unordered_multiset(__unordered_multiset&& __x)
146 : _Base(std::forward<_Base>(__x)) { }
150 template<class _Value, class _Hash, class _Pred, class _Alloc,
151 bool __cache_hash_code>
153 swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
154 __unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
157 template<class _Value, class _Hash, class _Pred, class _Alloc,
158 bool __cache_hash_code>
160 swap(__unordered_multiset<_Value, _Hash, _Pred,
161 _Alloc, __cache_hash_code>& __x,
162 __unordered_multiset<_Value, _Hash, _Pred,
163 _Alloc, __cache_hash_code>& __y)
168 * @brief A standard container composed of unique keys (containing
169 * at most one of each key value) in which the elements' keys are
170 * the elements themselves.
172 * @ingroup unordered_associative_containers
174 * Meets the requirements of a <a href="tables.html#65">container</a>, and
175 * <a href="tables.html#xx">unordered associative container</a>
177 * @param Value Type of key objects.
178 * @param Hash Hashing function object type, defaults to hash<Value>.
179 * @param Pred Predicate function object type, defaults to equal_to<Value>.
180 * @param Alloc Allocator type, defaults to allocator<Key>.
182 template<class _Value,
183 class _Hash = hash<_Value>,
184 class _Pred = std::equal_to<_Value>,
185 class _Alloc = std::allocator<_Value> >
187 : public __unordered_set<_Value, _Hash, _Pred, _Alloc>
189 typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base;
192 typedef typename _Base::value_type value_type;
193 typedef typename _Base::size_type size_type;
194 typedef typename _Base::hasher hasher;
195 typedef typename _Base::key_equal key_equal;
196 typedef typename _Base::allocator_type allocator_type;
199 unordered_set(size_type __n = 10,
200 const hasher& __hf = hasher(),
201 const key_equal& __eql = key_equal(),
202 const allocator_type& __a = allocator_type())
203 : _Base(__n, __hf, __eql, __a)
206 template<typename _InputIterator>
207 unordered_set(_InputIterator __f, _InputIterator __l,
209 const hasher& __hf = hasher(),
210 const key_equal& __eql = key_equal(),
211 const allocator_type& __a = allocator_type())
212 : _Base(__f, __l, __n, __hf, __eql, __a)
215 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
216 unordered_set(unordered_set&& __x)
217 : _Base(std::forward<_Base>(__x)) { }
219 unordered_set(initializer_list<value_type> __l,
221 const hasher& __hf = hasher(),
222 const key_equal& __eql = key_equal(),
223 const allocator_type& __a = allocator_type())
224 : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
228 operator=(unordered_set&& __x)
237 operator=(initializer_list<value_type> __l)
240 this->insert(__l.begin(), __l.end());
247 * @brief A standard container composed of equivalent keys
248 * (possibly containing multiple of each key value) in which the
249 * elements' keys are the elements themselves.
251 * @ingroup unordered_associative_containers
253 * Meets the requirements of a <a href="tables.html#65">container</a>, and
254 * <a href="tables.html#xx">unordered associative container</a>
256 * @param Value Type of key objects.
257 * @param Hash Hashing function object type, defaults to hash<Value>.
258 * @param Pred Predicate function object type, defaults to equal_to<Value>.
259 * @param Alloc Allocator type, defaults to allocator<Key>.
261 template<class _Value,
262 class _Hash = hash<_Value>,
263 class _Pred = std::equal_to<_Value>,
264 class _Alloc = std::allocator<_Value> >
265 class unordered_multiset
266 : public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
268 typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base;
271 typedef typename _Base::value_type value_type;
272 typedef typename _Base::size_type size_type;
273 typedef typename _Base::hasher hasher;
274 typedef typename _Base::key_equal key_equal;
275 typedef typename _Base::allocator_type allocator_type;
278 unordered_multiset(size_type __n = 10,
279 const hasher& __hf = hasher(),
280 const key_equal& __eql = key_equal(),
281 const allocator_type& __a = allocator_type())
282 : _Base(__n, __hf, __eql, __a)
286 template<typename _InputIterator>
287 unordered_multiset(_InputIterator __f, _InputIterator __l,
288 typename _Base::size_type __n = 0,
289 const hasher& __hf = hasher(),
290 const key_equal& __eql = key_equal(),
291 const allocator_type& __a = allocator_type())
292 : _Base(__f, __l, __n, __hf, __eql, __a)
295 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
296 unordered_multiset(unordered_multiset&& __x)
297 : _Base(std::forward<_Base>(__x)) { }
299 unordered_multiset(initializer_list<value_type> __l,
301 const hasher& __hf = hasher(),
302 const key_equal& __eql = key_equal(),
303 const allocator_type& __a = allocator_type())
304 : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
308 operator=(unordered_multiset&& __x)
317 operator=(initializer_list<value_type> __l)
320 this->insert(__l.begin(), __l.end());
326 template<class _Value, class _Hash, class _Pred, class _Alloc>
328 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
329 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
332 template<class _Value, class _Hash, class _Pred, class _Alloc>
334 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
335 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
338 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
339 template<class _Value, class _Hash, class _Pred, class _Alloc>
341 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
342 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
345 template<class _Value, class _Hash, class _Pred, class _Alloc>
347 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
348 unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
351 template<class _Value, class _Hash, class _Pred, class _Alloc>
353 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
354 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
357 template<class _Value, class _Hash, class _Pred, class _Alloc>
359 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
360 unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
364 _GLIBCXX_END_NAMESPACE_TR1