1 // TR1 unordered_set -*- C++ -*-
3 // Copyright (C) 2007 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)
167 /// class unordered_set
168 template<class _Value,
169 class _Hash = hash<_Value>,
170 class _Pred = std::equal_to<_Value>,
171 class _Alloc = std::allocator<_Value> >
173 : public __unordered_set<_Value, _Hash, _Pred, _Alloc>
175 typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base;
178 typedef typename _Base::size_type size_type;
179 typedef typename _Base::hasher hasher;
180 typedef typename _Base::key_equal key_equal;
181 typedef typename _Base::allocator_type allocator_type;
184 unordered_set(size_type __n = 10,
185 const hasher& __hf = hasher(),
186 const key_equal& __eql = key_equal(),
187 const allocator_type& __a = allocator_type())
188 : _Base(__n, __hf, __eql, __a)
191 template<typename _InputIterator>
192 unordered_set(_InputIterator __f, _InputIterator __l,
194 const hasher& __hf = hasher(),
195 const key_equal& __eql = key_equal(),
196 const allocator_type& __a = allocator_type())
197 : _Base(__f, __l, __n, __hf, __eql, __a)
200 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
201 unordered_set(unordered_set&& __x)
202 : _Base(std::forward<_Base>(__x)) { }
205 operator=(unordered_set&& __x)
215 /// class unordered_multiset
216 template<class _Value,
217 class _Hash = hash<_Value>,
218 class _Pred = std::equal_to<_Value>,
219 class _Alloc = std::allocator<_Value> >
220 class unordered_multiset
221 : public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
223 typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base;
226 typedef typename _Base::size_type size_type;
227 typedef typename _Base::hasher hasher;
228 typedef typename _Base::key_equal key_equal;
229 typedef typename _Base::allocator_type allocator_type;
232 unordered_multiset(size_type __n = 10,
233 const hasher& __hf = hasher(),
234 const key_equal& __eql = key_equal(),
235 const allocator_type& __a = allocator_type())
236 : _Base(__n, __hf, __eql, __a)
240 template<typename _InputIterator>
241 unordered_multiset(_InputIterator __f, _InputIterator __l,
242 typename _Base::size_type __n = 0,
243 const hasher& __hf = hasher(),
244 const key_equal& __eql = key_equal(),
245 const allocator_type& __a = allocator_type())
246 : _Base(__f, __l, __n, __hf, __eql, __a)
249 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
250 unordered_multiset(unordered_multiset&& __x)
251 : _Base(std::forward<_Base>(__x)) { }
254 operator=(unordered_multiset&& __x)
264 template<class _Value, class _Hash, class _Pred, class _Alloc>
266 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
267 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
270 template<class _Value, class _Hash, class _Pred, class _Alloc>
272 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
273 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
276 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
277 template<class _Value, class _Hash, class _Pred, class _Alloc>
279 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
280 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
283 template<class _Value, class _Hash, class _Pred, class _Alloc>
285 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
286 unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
289 template<class _Value, class _Hash, class _Pred, class _Alloc>
291 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
292 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
295 template<class _Value, class _Hash, class _Pred, class _Alloc>
297 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
298 unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
302 _GLIBCXX_END_NAMESPACE_TR1