]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/include/tr1_impl/unordered_set
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / include / tr1_impl / unordered_set
1 // TR1 unordered_set -*- C++ -*-
2
3 // Copyright (C) 2007 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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
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.
15
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,
19 // USA.
20
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.
29
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.
33  */
34
35 namespace std
36
37 _GLIBCXX_BEGIN_NAMESPACE_TR1
38
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>
46     class __unordered_set
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>
53     {
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>
60         _Base;
61
62     public:
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;
67       
68       explicit
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)
76       { }
77
78       template<typename _InputIterator>
79         __unordered_set(_InputIterator __f, _InputIterator __l, 
80                         size_type __n = 10,
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)
87         { }
88
89 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
90       __unordered_set(__unordered_set&& __x)
91       : _Base(std::forward<_Base>(__x)) { }
92 #endif
93     };
94
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>
107     {
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>
114         _Base;
115
116     public:
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;
121       
122       explicit
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)
130       { }
131
132
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)
142         { }
143
144 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
145       __unordered_multiset(__unordered_multiset&& __x)
146       : _Base(std::forward<_Base>(__x)) { }
147 #endif
148     };
149
150   template<class _Value, class _Hash, class _Pred, class _Alloc,
151            bool __cache_hash_code>
152     inline void
153     swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
154          __unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
155     { __x.swap(__y); }
156
157   template<class _Value, class _Hash, class _Pred, class _Alloc,
158            bool __cache_hash_code>
159     inline void
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)
164     { __x.swap(__y); }
165
166
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> >
172     class unordered_set
173     : public __unordered_set<_Value, _Hash, _Pred, _Alloc>
174     {
175       typedef __unordered_set<_Value, _Hash, _Pred, _Alloc>  _Base;
176
177     public:
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;
182       
183       explicit
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)
189       { }
190
191       template<typename _InputIterator>
192         unordered_set(_InputIterator __f, _InputIterator __l, 
193                       size_type __n = 10,
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)
198         { }
199
200 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
201       unordered_set(unordered_set&& __x)
202       : _Base(std::forward<_Base>(__x)) { }
203
204       unordered_set&
205       operator=(unordered_set&& __x)
206       {
207         // NB: DR 675.
208         this->clear();
209         this->swap(__x); 
210         return *this;   
211       }
212 #endif
213     };
214
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>
222     {
223       typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc>  _Base;
224
225     public:
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;
230       
231       explicit
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)
237       { }
238
239
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)
247         { }
248
249 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
250       unordered_multiset(unordered_multiset&& __x)
251       : _Base(std::forward<_Base>(__x)) { }
252
253       unordered_multiset&
254       operator=(unordered_multiset&& __x)
255       {
256         // NB: DR 675.
257         this->clear();
258         this->swap(__x); 
259         return *this;   
260       }
261 #endif
262     };
263
264   template<class _Value, class _Hash, class _Pred, class _Alloc>
265     inline void
266     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
267          unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
268     { __x.swap(__y); }
269
270   template<class _Value, class _Hash, class _Pred, class _Alloc>
271     inline void
272     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
273          unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
274     { __x.swap(__y); }
275
276 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
277   template<class _Value, class _Hash, class _Pred, class _Alloc>
278     inline void
279     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
280          unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
281     { __x.swap(__y); }
282
283   template<class _Value, class _Hash, class _Pred, class _Alloc>
284     inline void
285     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
286          unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
287     { __x.swap(__y); }
288
289   template<class _Value, class _Hash, class _Pred, class _Alloc>
290     inline void
291     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
292          unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
293     { __x.swap(__y); }
294
295   template<class _Value, class _Hash, class _Pred, class _Alloc>
296     inline void
297     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
298          unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
299     { __x.swap(__y); }
300 #endif
301
302 _GLIBCXX_END_NAMESPACE_TR1
303 }