williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2004
|
williamr@2
|
3 |
* Francois Dumont
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@2
|
6 |
* or implied. Any use is at your own risk.
|
williamr@2
|
7 |
*
|
williamr@2
|
8 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@2
|
9 |
* without fee, provided the above notices are retained on all copies.
|
williamr@2
|
10 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@2
|
11 |
* provided the above notices are retained, and a notice that the code was
|
williamr@2
|
12 |
* modified is included with the above copyright notice.
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
*/
|
williamr@2
|
15 |
|
williamr@2
|
16 |
/* NOTE: This is an internal header file, included by other STL headers.
|
williamr@2
|
17 |
* You should not attempt to use it directly.
|
williamr@2
|
18 |
*/
|
williamr@2
|
19 |
|
williamr@2
|
20 |
#ifndef _STLP_INTERNAL_UNORDERED_SET_H
|
williamr@2
|
21 |
#define _STLP_INTERNAL_UNORDERED_SET_H
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#ifndef _STLP_INTERNAL_HASHTABLE_H
|
williamr@2
|
24 |
# include <stl/_hashtable.h>
|
williamr@2
|
25 |
#endif
|
williamr@2
|
26 |
|
williamr@2
|
27 |
_STLP_BEGIN_NAMESPACE
|
williamr@2
|
28 |
|
williamr@2
|
29 |
//Specific iterator traits creation
|
williamr@2
|
30 |
_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedSetTraitsT, Const_traits)
|
williamr@2
|
31 |
|
williamr@2
|
32 |
template <class _Value, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Value>),
|
williamr@2
|
33 |
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Value>),
|
williamr@2
|
34 |
_STLP_DEFAULT_ALLOCATOR_SELECT(_Value) >
|
williamr@2
|
35 |
class unordered_set
|
williamr@2
|
36 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@2
|
37 |
: public __stlport_class<unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> >
|
williamr@2
|
38 |
#endif
|
williamr@2
|
39 |
{
|
williamr@2
|
40 |
typedef unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> _Self;
|
williamr@2
|
41 |
//Specific iterator traits creation
|
williamr@2
|
42 |
typedef _STLP_PRIV _UnorderedSetTraitsT<_Value> _UnorderedSetTraits;
|
williamr@2
|
43 |
public:
|
williamr@2
|
44 |
typedef hashtable<_Value, _Value, _HashFcn,
|
williamr@2
|
45 |
_UnorderedSetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht;
|
williamr@2
|
46 |
public:
|
williamr@2
|
47 |
typedef typename _Ht::key_type key_type;
|
williamr@2
|
48 |
typedef typename _Ht::value_type value_type;
|
williamr@2
|
49 |
typedef typename _Ht::hasher hasher;
|
williamr@2
|
50 |
typedef typename _Ht::key_equal key_equal;
|
williamr@2
|
51 |
|
williamr@2
|
52 |
typedef typename _Ht::size_type size_type;
|
williamr@2
|
53 |
typedef typename _Ht::difference_type difference_type;
|
williamr@2
|
54 |
typedef typename _Ht::pointer pointer;
|
williamr@2
|
55 |
typedef typename _Ht::const_pointer const_pointer;
|
williamr@2
|
56 |
typedef typename _Ht::reference reference;
|
williamr@2
|
57 |
typedef typename _Ht::const_reference const_reference;
|
williamr@2
|
58 |
|
williamr@2
|
59 |
typedef typename _Ht::iterator iterator;
|
williamr@2
|
60 |
typedef typename _Ht::const_iterator const_iterator;
|
williamr@2
|
61 |
typedef typename _Ht::local_iterator local_iterator;
|
williamr@2
|
62 |
typedef typename _Ht::const_local_iterator const_local_iterator;
|
williamr@2
|
63 |
|
williamr@2
|
64 |
typedef typename _Ht::allocator_type allocator_type;
|
williamr@2
|
65 |
|
williamr@2
|
66 |
hasher hash_function() const { return _M_ht.hash_funct(); }
|
williamr@2
|
67 |
key_equal key_eq() const { return _M_ht.key_eq(); }
|
williamr@2
|
68 |
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
williamr@2
|
69 |
|
williamr@2
|
70 |
private:
|
williamr@2
|
71 |
_Ht _M_ht;
|
williamr@2
|
72 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@2
|
73 |
|
williamr@2
|
74 |
public:
|
williamr@2
|
75 |
explicit unordered_set(size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
76 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
77 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
78 |
: _M_ht(__n, __hf, __eql, __a) {}
|
williamr@2
|
79 |
|
williamr@2
|
80 |
unordered_set(__move_source<_Self> src)
|
williamr@2
|
81 |
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
williamr@2
|
82 |
|
williamr@2
|
83 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
84 |
template <class _InputIterator>
|
williamr@2
|
85 |
unordered_set(_InputIterator __f, _InputIterator __l,
|
williamr@2
|
86 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
87 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
88 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
89 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
90 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
91 |
#else
|
williamr@2
|
92 |
unordered_set(const value_type* __f, const value_type* __l,
|
williamr@2
|
93 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
94 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
95 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
96 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
97 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
98 |
|
williamr@2
|
99 |
unordered_set(const_iterator __f, const_iterator __l,
|
williamr@2
|
100 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
101 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
102 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
103 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
104 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
105 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
106 |
|
williamr@2
|
107 |
_Self& operator = (const _Self& __other)
|
williamr@2
|
108 |
{ _M_ht = __other._M_ht; return *this; }
|
williamr@2
|
109 |
|
williamr@2
|
110 |
size_type size() const { return _M_ht.size(); }
|
williamr@2
|
111 |
size_type max_size() const { return _M_ht.max_size(); }
|
williamr@2
|
112 |
bool empty() const { return _M_ht.empty(); }
|
williamr@2
|
113 |
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
williamr@2
|
114 |
|
williamr@2
|
115 |
iterator begin() { return _M_ht.begin(); }
|
williamr@2
|
116 |
iterator end() { return _M_ht.end(); }
|
williamr@2
|
117 |
const_iterator begin() const { return _M_ht.begin(); }
|
williamr@2
|
118 |
const_iterator end() const { return _M_ht.end(); }
|
williamr@2
|
119 |
|
williamr@2
|
120 |
pair<iterator, bool> insert(const value_type& __obj)
|
williamr@2
|
121 |
{ return _M_ht.insert_unique(__obj); }
|
williamr@2
|
122 |
iterator insert(const_iterator /*__hint*/, const value_type& __obj)
|
williamr@2
|
123 |
{ return _M_ht.insert_unique(__obj); }
|
williamr@2
|
124 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
125 |
template <class _InputIterator>
|
williamr@2
|
126 |
void insert(_InputIterator __f, _InputIterator __l)
|
williamr@2
|
127 |
#else
|
williamr@2
|
128 |
void insert(const_iterator __f, const_iterator __l)
|
williamr@2
|
129 |
{_M_ht.insert_unique(__f, __l); }
|
williamr@2
|
130 |
void insert(const value_type* __f, const value_type* __l)
|
williamr@2
|
131 |
#endif
|
williamr@2
|
132 |
{ _M_ht.insert_unique(__f,__l); }
|
williamr@2
|
133 |
|
williamr@2
|
134 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
135 |
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
williamr@2
|
136 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
137 |
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
williamr@2
|
138 |
|
williamr@2
|
139 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
140 |
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
williamr@2
|
141 |
|
williamr@2
|
142 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
143 |
pair<iterator, iterator> equal_range(const _KT& __key)
|
williamr@2
|
144 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
145 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
146 |
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
williamr@2
|
147 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
148 |
|
williamr@2
|
149 |
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
williamr@2
|
150 |
void erase(const_iterator __it) { _M_ht.erase(__it); }
|
williamr@2
|
151 |
void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); }
|
williamr@2
|
152 |
void clear() { _M_ht.clear(); }
|
williamr@2
|
153 |
|
williamr@2
|
154 |
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
williamr@2
|
155 |
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
williamr@2
|
156 |
size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); }
|
williamr@2
|
157 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
158 |
size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); }
|
williamr@2
|
159 |
local_iterator begin(size_type __n) { return _M_ht.begin(__n); }
|
williamr@2
|
160 |
local_iterator end(size_type __n) { return _M_ht.end(__n); }
|
williamr@2
|
161 |
const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); }
|
williamr@2
|
162 |
const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }
|
williamr@2
|
163 |
|
williamr@2
|
164 |
float load_factor() const { return _M_ht.load_factor(); }
|
williamr@2
|
165 |
float max_load_factor() const { return _M_ht.max_load_factor(); }
|
williamr@2
|
166 |
void max_load_factor(float __val) { _M_ht.max_load_factor(__val); }
|
williamr@2
|
167 |
void rehash(size_type __hint) { _M_ht.rehash(__hint); }
|
williamr@2
|
168 |
};
|
williamr@2
|
169 |
|
williamr@2
|
170 |
//Specific iterator traits creation
|
williamr@2
|
171 |
_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultisetTraitsT, Const_traits)
|
williamr@2
|
172 |
|
williamr@2
|
173 |
template <class _Value, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Value>),
|
williamr@2
|
174 |
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Value>),
|
williamr@2
|
175 |
_STLP_DEFAULT_ALLOCATOR_SELECT(_Value) >
|
williamr@2
|
176 |
class unordered_multiset
|
williamr@2
|
177 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@2
|
178 |
: public __stlport_class<unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> >
|
williamr@2
|
179 |
#endif
|
williamr@2
|
180 |
{
|
williamr@2
|
181 |
typedef unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Self;
|
williamr@2
|
182 |
//Specific iterator traits creation
|
williamr@2
|
183 |
typedef _STLP_PRIV _UnorderedMultisetTraitsT<_Value> _UnorderedMultisetTraits;
|
williamr@2
|
184 |
public:
|
williamr@2
|
185 |
typedef hashtable<_Value, _Value, _HashFcn,
|
williamr@2
|
186 |
_UnorderedMultisetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht;
|
williamr@2
|
187 |
|
williamr@2
|
188 |
typedef typename _Ht::key_type key_type;
|
williamr@2
|
189 |
typedef typename _Ht::value_type value_type;
|
williamr@2
|
190 |
typedef typename _Ht::hasher hasher;
|
williamr@2
|
191 |
typedef typename _Ht::key_equal key_equal;
|
williamr@2
|
192 |
|
williamr@2
|
193 |
typedef typename _Ht::size_type size_type;
|
williamr@2
|
194 |
typedef typename _Ht::difference_type difference_type;
|
williamr@2
|
195 |
typedef typename _Ht::pointer pointer;
|
williamr@2
|
196 |
typedef typename _Ht::const_pointer const_pointer;
|
williamr@2
|
197 |
typedef typename _Ht::reference reference;
|
williamr@2
|
198 |
typedef typename _Ht::const_reference const_reference;
|
williamr@2
|
199 |
|
williamr@2
|
200 |
typedef typename _Ht::iterator iterator;
|
williamr@2
|
201 |
typedef typename _Ht::const_iterator const_iterator;
|
williamr@2
|
202 |
typedef typename _Ht::local_iterator local_iterator;
|
williamr@2
|
203 |
typedef typename _Ht::const_local_iterator const_local_iterator;
|
williamr@2
|
204 |
|
williamr@2
|
205 |
typedef typename _Ht::allocator_type allocator_type;
|
williamr@2
|
206 |
|
williamr@2
|
207 |
hasher hash_function() const { return _M_ht.hash_funct(); }
|
williamr@2
|
208 |
key_equal key_eq() const { return _M_ht.key_eq(); }
|
williamr@2
|
209 |
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
williamr@2
|
210 |
|
williamr@2
|
211 |
private:
|
williamr@2
|
212 |
_Ht _M_ht;
|
williamr@2
|
213 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@2
|
214 |
|
williamr@2
|
215 |
public:
|
williamr@2
|
216 |
explicit unordered_multiset(size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
217 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
218 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
219 |
: _M_ht(__n, __hf, __eql, __a) {}
|
williamr@2
|
220 |
|
williamr@2
|
221 |
unordered_multiset(__move_source<_Self> src)
|
williamr@2
|
222 |
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
williamr@2
|
223 |
|
williamr@2
|
224 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
225 |
template <class _InputIterator>
|
williamr@2
|
226 |
unordered_multiset(_InputIterator __f, _InputIterator __l,
|
williamr@2
|
227 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
228 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
229 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
230 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
231 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
232 |
#else
|
williamr@2
|
233 |
unordered_multiset(const value_type* __f, const value_type* __l,
|
williamr@2
|
234 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
235 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
236 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
237 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
238 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
239 |
|
williamr@2
|
240 |
unordered_multiset(const_iterator __f, const_iterator __l,
|
williamr@2
|
241 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
242 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
243 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
244 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
245 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
246 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
247 |
|
williamr@2
|
248 |
_Self& operator = (const _Self& __other)
|
williamr@2
|
249 |
{ _M_ht = __other._M_ht; return *this; }
|
williamr@2
|
250 |
|
williamr@2
|
251 |
size_type size() const { return _M_ht.size(); }
|
williamr@2
|
252 |
size_type max_size() const { return _M_ht.max_size(); }
|
williamr@2
|
253 |
bool empty() const { return _M_ht.empty(); }
|
williamr@2
|
254 |
void swap(_Self& hs) { _M_ht.swap(hs._M_ht); }
|
williamr@2
|
255 |
|
williamr@2
|
256 |
iterator begin() { return _M_ht.begin(); }
|
williamr@2
|
257 |
iterator end() { return _M_ht.end(); }
|
williamr@2
|
258 |
const_iterator begin() const { return _M_ht.begin(); }
|
williamr@2
|
259 |
const_iterator end() const { return _M_ht.end(); }
|
williamr@2
|
260 |
|
williamr@2
|
261 |
iterator insert(const value_type& __obj)
|
williamr@2
|
262 |
{ return _M_ht.insert_equal(__obj); }
|
williamr@2
|
263 |
iterator insert(const_iterator /*__hint*/, const value_type& __obj)
|
williamr@2
|
264 |
{ return _M_ht.insert_equal(__obj); }
|
williamr@2
|
265 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
266 |
template <class _InputIterator>
|
williamr@2
|
267 |
void insert(_InputIterator __f, _InputIterator __l)
|
williamr@2
|
268 |
#else
|
williamr@2
|
269 |
void insert(const value_type* __f, const value_type* __l)
|
williamr@2
|
270 |
{ _M_ht.insert_equal(__f,__l); }
|
williamr@2
|
271 |
void insert(const_iterator __f, const_iterator __l)
|
williamr@2
|
272 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
273 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
274 |
|
williamr@2
|
275 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
276 |
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
williamr@2
|
277 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
278 |
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
williamr@2
|
279 |
|
williamr@2
|
280 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
281 |
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
williamr@2
|
282 |
|
williamr@2
|
283 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
284 |
pair<iterator, iterator> equal_range(const _KT& __key)
|
williamr@2
|
285 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
286 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
287 |
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
williamr@2
|
288 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
289 |
|
williamr@2
|
290 |
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
williamr@2
|
291 |
void erase(const_iterator __it) { _M_ht.erase(__it); }
|
williamr@2
|
292 |
void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); }
|
williamr@2
|
293 |
void clear() { _M_ht.clear(); }
|
williamr@2
|
294 |
|
williamr@2
|
295 |
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
williamr@2
|
296 |
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
williamr@2
|
297 |
size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); }
|
williamr@2
|
298 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
299 |
size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); }
|
williamr@2
|
300 |
local_iterator begin(size_type __n) { return _M_ht.begin(__n); }
|
williamr@2
|
301 |
local_iterator end(size_type __n) { return _M_ht.end(__n); }
|
williamr@2
|
302 |
const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); }
|
williamr@2
|
303 |
const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }
|
williamr@2
|
304 |
|
williamr@2
|
305 |
float load_factor() const { return _M_ht.load_factor(); }
|
williamr@2
|
306 |
float max_load_factor() const { return _M_ht.max_load_factor(); }
|
williamr@2
|
307 |
void max_load_factor(float __val) { _M_ht.max_load_factor(__val); }
|
williamr@2
|
308 |
void rehash(size_type __hint) { _M_ht.rehash(__hint); }
|
williamr@2
|
309 |
};
|
williamr@2
|
310 |
|
williamr@2
|
311 |
#define _STLP_TEMPLATE_HEADER template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
williamr@2
|
312 |
#define _STLP_TEMPLATE_CONTAINER unordered_set<_Value,_HashFcn,_EqualKey,_Alloc>
|
williamr@2
|
313 |
|
williamr@2
|
314 |
#include <stl/_relops_hash_cont.h>
|
williamr@2
|
315 |
|
williamr@2
|
316 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@2
|
317 |
#define _STLP_TEMPLATE_CONTAINER unordered_multiset<_Value,_HashFcn,_EqualKey,_Alloc>
|
williamr@2
|
318 |
#include <stl/_relops_hash_cont.h>
|
williamr@2
|
319 |
|
williamr@2
|
320 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@2
|
321 |
#undef _STLP_TEMPLATE_HEADER
|
williamr@2
|
322 |
|
williamr@2
|
323 |
// Specialization of insert_iterator so that it will work for unordered_set
|
williamr@2
|
324 |
// and unordered_multiset.
|
williamr@2
|
325 |
|
williamr@2
|
326 |
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
williamr@2
|
327 |
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
williamr@2
|
328 |
struct __move_traits<unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> > :
|
williamr@2
|
329 |
_STLP_PRIV __move_traits_aux<typename unordered_set<_Value, _HashFcn, _EqualKey, _Alloc>::_Ht>
|
williamr@2
|
330 |
{};
|
williamr@2
|
331 |
|
williamr@2
|
332 |
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
williamr@2
|
333 |
struct __move_traits<unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > :
|
williamr@2
|
334 |
_STLP_PRIV __move_traits_aux<typename unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc>::_Ht>
|
williamr@2
|
335 |
{};
|
williamr@2
|
336 |
|
williamr@2
|
337 |
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
williamr@2
|
338 |
class insert_iterator<unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> > {
|
williamr@2
|
339 |
protected:
|
williamr@2
|
340 |
typedef unordered_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
|
williamr@2
|
341 |
_Container* container;
|
williamr@2
|
342 |
public:
|
williamr@2
|
343 |
typedef _Container container_type;
|
williamr@2
|
344 |
typedef output_iterator_tag iterator_category;
|
williamr@2
|
345 |
typedef void value_type;
|
williamr@2
|
346 |
typedef void difference_type;
|
williamr@2
|
347 |
typedef void pointer;
|
williamr@2
|
348 |
typedef void reference;
|
williamr@2
|
349 |
|
williamr@2
|
350 |
insert_iterator(_Container& __x) : container(&__x) {}
|
williamr@2
|
351 |
insert_iterator(_Container& __x, typename _Container::iterator)
|
williamr@2
|
352 |
: container(&__x) {}
|
williamr@2
|
353 |
insert_iterator<_Container>&
|
williamr@2
|
354 |
operator=(const typename _Container::value_type& __val) {
|
williamr@2
|
355 |
container->insert(__val);
|
williamr@2
|
356 |
return *this;
|
williamr@2
|
357 |
}
|
williamr@2
|
358 |
insert_iterator<_Container>& operator*() { return *this; }
|
williamr@2
|
359 |
insert_iterator<_Container>& operator++() { return *this; }
|
williamr@2
|
360 |
insert_iterator<_Container>& operator++(int) { return *this; }
|
williamr@2
|
361 |
};
|
williamr@2
|
362 |
|
williamr@2
|
363 |
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
williamr@2
|
364 |
class insert_iterator<unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > {
|
williamr@2
|
365 |
protected:
|
williamr@2
|
366 |
typedef unordered_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
|
williamr@2
|
367 |
_Container* container;
|
williamr@2
|
368 |
typename _Container::iterator iter;
|
williamr@2
|
369 |
public:
|
williamr@2
|
370 |
typedef _Container container_type;
|
williamr@2
|
371 |
typedef output_iterator_tag iterator_category;
|
williamr@2
|
372 |
typedef void value_type;
|
williamr@2
|
373 |
typedef void difference_type;
|
williamr@2
|
374 |
typedef void pointer;
|
williamr@2
|
375 |
typedef void reference;
|
williamr@2
|
376 |
|
williamr@2
|
377 |
insert_iterator(_Container& __x) : container(&__x) {}
|
williamr@2
|
378 |
insert_iterator(_Container& __x, typename _Container::iterator)
|
williamr@2
|
379 |
: container(&__x) {}
|
williamr@2
|
380 |
insert_iterator<_Container>&
|
williamr@2
|
381 |
operator=(const typename _Container::value_type& __val) {
|
williamr@2
|
382 |
container->insert(__val);
|
williamr@2
|
383 |
return *this;
|
williamr@2
|
384 |
}
|
williamr@2
|
385 |
insert_iterator<_Container>& operator*() { return *this; }
|
williamr@2
|
386 |
insert_iterator<_Container>& operator++() { return *this; }
|
williamr@2
|
387 |
insert_iterator<_Container>& operator++(int) { return *this; }
|
williamr@2
|
388 |
};
|
williamr@2
|
389 |
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
williamr@2
|
390 |
|
williamr@2
|
391 |
_STLP_END_NAMESPACE
|
williamr@2
|
392 |
|
williamr@2
|
393 |
#endif /* _STLP_INTERNAL_UNORDERED_SET_H */
|
williamr@2
|
394 |
|
williamr@2
|
395 |
// Local Variables:
|
williamr@2
|
396 |
// mode:C++
|
williamr@2
|
397 |
// End:
|
williamr@2
|
398 |
|