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