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_MAP_H
|
williamr@2
|
21 |
#define _STLP_INTERNAL_UNORDERED_MAP_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(UnorderedMapTraitsT, traits)
|
williamr@2
|
31 |
|
williamr@2
|
32 |
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
|
williamr@2
|
33 |
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
|
williamr@2
|
34 |
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
|
williamr@2
|
35 |
class unordered_map
|
williamr@2
|
36 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@2
|
37 |
: public __stlport_class<unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
|
williamr@2
|
38 |
#endif
|
williamr@2
|
39 |
{
|
williamr@2
|
40 |
private:
|
williamr@2
|
41 |
typedef unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
|
williamr@2
|
42 |
public:
|
williamr@2
|
43 |
typedef _Key key_type;
|
williamr@2
|
44 |
typedef _Tp data_type;
|
williamr@2
|
45 |
typedef _Tp mapped_type;
|
williamr@2
|
46 |
#if !defined (__DMC__)
|
williamr@2
|
47 |
typedef pair<const key_type, data_type> value_type;
|
williamr@2
|
48 |
#else
|
williamr@2
|
49 |
typedef pair<key_type, data_type> value_type;
|
williamr@2
|
50 |
#endif
|
williamr@2
|
51 |
private:
|
williamr@2
|
52 |
//Specific iterator traits creation
|
williamr@2
|
53 |
typedef _STLP_PRIV _UnorderedMapTraitsT<value_type> _UnorderedMapTraits;
|
williamr@2
|
54 |
|
williamr@2
|
55 |
public:
|
williamr@2
|
56 |
typedef hashtable<value_type, key_type, _HashFcn, _UnorderedMapTraits,
|
williamr@2
|
57 |
_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
|
williamr@2
|
58 |
|
williamr@2
|
59 |
typedef typename _Ht::hasher hasher;
|
williamr@2
|
60 |
typedef typename _Ht::key_equal key_equal;
|
williamr@2
|
61 |
|
williamr@2
|
62 |
typedef typename _Ht::size_type size_type;
|
williamr@2
|
63 |
typedef typename _Ht::difference_type difference_type;
|
williamr@2
|
64 |
typedef typename _Ht::pointer pointer;
|
williamr@2
|
65 |
typedef typename _Ht::const_pointer const_pointer;
|
williamr@2
|
66 |
typedef typename _Ht::reference reference;
|
williamr@2
|
67 |
typedef typename _Ht::const_reference const_reference;
|
williamr@2
|
68 |
|
williamr@2
|
69 |
typedef typename _Ht::iterator iterator;
|
williamr@2
|
70 |
typedef typename _Ht::const_iterator const_iterator;
|
williamr@2
|
71 |
typedef typename _Ht::local_iterator local_iterator;
|
williamr@2
|
72 |
typedef typename _Ht::const_local_iterator const_local_iterator;
|
williamr@2
|
73 |
|
williamr@2
|
74 |
typedef typename _Ht::allocator_type allocator_type;
|
williamr@2
|
75 |
|
williamr@2
|
76 |
hasher hash_function() const { return _M_ht.hash_funct(); }
|
williamr@2
|
77 |
key_equal key_eq() const { return _M_ht.key_eq(); }
|
williamr@2
|
78 |
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
williamr@2
|
79 |
|
williamr@2
|
80 |
private:
|
williamr@2
|
81 |
_Ht _M_ht;
|
williamr@2
|
82 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@2
|
83 |
|
williamr@2
|
84 |
public:
|
williamr@2
|
85 |
explicit unordered_map(size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
86 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
87 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
88 |
: _M_ht(__n, __hf, __eql, __a) {}
|
williamr@2
|
89 |
|
williamr@2
|
90 |
unordered_map(__move_source<_Self> src)
|
williamr@2
|
91 |
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
williamr@2
|
92 |
|
williamr@2
|
93 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
94 |
template <class _InputIterator>
|
williamr@2
|
95 |
unordered_map(_InputIterator __f, _InputIterator __l,
|
williamr@2
|
96 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
97 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
98 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
99 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
100 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
101 |
#else
|
williamr@2
|
102 |
unordered_map(const value_type* __f, const value_type* __l,
|
williamr@2
|
103 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
104 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
105 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
106 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
107 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
108 |
|
williamr@2
|
109 |
unordered_map(const_iterator __f, const_iterator __l,
|
williamr@2
|
110 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
111 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
112 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
113 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
114 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
115 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
116 |
|
williamr@2
|
117 |
_Self& operator = (const _Self& __other)
|
williamr@2
|
118 |
{ _M_ht = __other._M_ht; return *this; }
|
williamr@2
|
119 |
|
williamr@2
|
120 |
size_type size() const { return _M_ht.size(); }
|
williamr@2
|
121 |
size_type max_size() const { return _M_ht.max_size(); }
|
williamr@2
|
122 |
bool empty() const { return _M_ht.empty(); }
|
williamr@2
|
123 |
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
williamr@2
|
124 |
|
williamr@2
|
125 |
iterator begin() { return _M_ht.begin(); }
|
williamr@2
|
126 |
iterator end() { return _M_ht.end(); }
|
williamr@2
|
127 |
const_iterator begin() const { return _M_ht.begin(); }
|
williamr@2
|
128 |
const_iterator end() const { return _M_ht.end(); }
|
williamr@2
|
129 |
|
williamr@2
|
130 |
pair<iterator,bool> insert(const value_type& __obj)
|
williamr@2
|
131 |
{ return _M_ht.insert_unique(__obj); }
|
williamr@2
|
132 |
iterator insert(const_iterator /*__hint*/, const value_type& __obj)
|
williamr@2
|
133 |
{ return _M_ht.insert_unique(__obj); }
|
williamr@2
|
134 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
135 |
template <class _InputIterator>
|
williamr@2
|
136 |
void insert(_InputIterator __f, _InputIterator __l)
|
williamr@2
|
137 |
#else
|
williamr@2
|
138 |
void insert(const value_type* __f, const value_type* __l)
|
williamr@2
|
139 |
{ _M_ht.insert_unique(__f,__l); }
|
williamr@2
|
140 |
void insert(const_iterator __f, const_iterator __l)
|
williamr@2
|
141 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
142 |
{ _M_ht.insert_unique(__f, __l); }
|
williamr@2
|
143 |
|
williamr@2
|
144 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
145 |
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
williamr@2
|
146 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
147 |
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
williamr@2
|
148 |
|
williamr@2
|
149 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
150 |
_Tp& operator[](const _KT& __key) {
|
williamr@2
|
151 |
iterator __it = _M_ht.find(__key);
|
williamr@2
|
152 |
return (__it == _M_ht.end() ?
|
williamr@2
|
153 |
_M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second :
|
williamr@2
|
154 |
(*__it).second );
|
williamr@2
|
155 |
}
|
williamr@2
|
156 |
|
williamr@2
|
157 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
158 |
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
williamr@2
|
159 |
|
williamr@2
|
160 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
161 |
pair<iterator, iterator> equal_range(const _KT& __key)
|
williamr@2
|
162 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
163 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
164 |
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
williamr@2
|
165 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
166 |
|
williamr@2
|
167 |
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
williamr@2
|
168 |
void erase(const_iterator __it) { _M_ht.erase(__it); }
|
williamr@2
|
169 |
void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); }
|
williamr@2
|
170 |
void clear() { _M_ht.clear(); }
|
williamr@2
|
171 |
|
williamr@2
|
172 |
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
williamr@2
|
173 |
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
williamr@2
|
174 |
size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); }
|
williamr@2
|
175 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
176 |
size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); }
|
williamr@2
|
177 |
local_iterator begin(size_type __n) { return _M_ht.begin(__n); }
|
williamr@2
|
178 |
local_iterator end(size_type __n) { return _M_ht.end(__n); }
|
williamr@2
|
179 |
const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); }
|
williamr@2
|
180 |
const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }
|
williamr@2
|
181 |
|
williamr@2
|
182 |
float load_factor() const { return _M_ht.load_factor(); }
|
williamr@2
|
183 |
float max_load_factor() const { return _M_ht.max_load_factor(); }
|
williamr@2
|
184 |
void max_load_factor(float __val) { _M_ht.max_load_factor(__val); }
|
williamr@2
|
185 |
void rehash(size_type __hint) { _M_ht.rehash(__hint); }
|
williamr@2
|
186 |
};
|
williamr@2
|
187 |
|
williamr@2
|
188 |
//Specific iterator traits creation
|
williamr@2
|
189 |
_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultimapTraitsT, traits)
|
williamr@2
|
190 |
|
williamr@2
|
191 |
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
|
williamr@2
|
192 |
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
|
williamr@2
|
193 |
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
|
williamr@2
|
194 |
class unordered_multimap
|
williamr@2
|
195 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@2
|
196 |
: public __stlport_class<unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
|
williamr@2
|
197 |
#endif
|
williamr@2
|
198 |
{
|
williamr@2
|
199 |
private:
|
williamr@2
|
200 |
typedef unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
|
williamr@2
|
201 |
public:
|
williamr@2
|
202 |
typedef _Key key_type;
|
williamr@2
|
203 |
typedef _Tp data_type;
|
williamr@2
|
204 |
typedef _Tp mapped_type;
|
williamr@2
|
205 |
#if !defined (__DMC__)
|
williamr@2
|
206 |
typedef pair<const key_type, data_type> value_type;
|
williamr@2
|
207 |
#else
|
williamr@2
|
208 |
typedef pair<key_type, data_type> value_type;
|
williamr@2
|
209 |
#endif
|
williamr@2
|
210 |
private:
|
williamr@2
|
211 |
//Specific iterator traits creation
|
williamr@2
|
212 |
typedef _STLP_PRIV _UnorderedMultimapTraitsT<value_type> _UnorderedMultimapTraits;
|
williamr@2
|
213 |
|
williamr@2
|
214 |
public:
|
williamr@2
|
215 |
typedef hashtable<value_type, key_type, _HashFcn, _UnorderedMultimapTraits,
|
williamr@2
|
216 |
_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
|
williamr@2
|
217 |
|
williamr@2
|
218 |
typedef typename _Ht::hasher hasher;
|
williamr@2
|
219 |
typedef typename _Ht::key_equal key_equal;
|
williamr@2
|
220 |
|
williamr@2
|
221 |
typedef typename _Ht::size_type size_type;
|
williamr@2
|
222 |
typedef typename _Ht::difference_type difference_type;
|
williamr@2
|
223 |
typedef typename _Ht::pointer pointer;
|
williamr@2
|
224 |
typedef typename _Ht::const_pointer const_pointer;
|
williamr@2
|
225 |
typedef typename _Ht::reference reference;
|
williamr@2
|
226 |
typedef typename _Ht::const_reference const_reference;
|
williamr@2
|
227 |
|
williamr@2
|
228 |
typedef typename _Ht::iterator iterator;
|
williamr@2
|
229 |
typedef typename _Ht::const_iterator const_iterator;
|
williamr@2
|
230 |
typedef typename _Ht::local_iterator local_iterator;
|
williamr@2
|
231 |
typedef typename _Ht::const_local_iterator const_local_iterator;
|
williamr@2
|
232 |
|
williamr@2
|
233 |
typedef typename _Ht::allocator_type allocator_type;
|
williamr@2
|
234 |
|
williamr@2
|
235 |
hasher hash_function() const { return _M_ht.hash_funct(); }
|
williamr@2
|
236 |
key_equal key_eq() const { return _M_ht.key_eq(); }
|
williamr@2
|
237 |
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
williamr@2
|
238 |
|
williamr@2
|
239 |
private:
|
williamr@2
|
240 |
_Ht _M_ht;
|
williamr@2
|
241 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@2
|
242 |
|
williamr@2
|
243 |
public:
|
williamr@2
|
244 |
explicit unordered_multimap(size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
245 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
246 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
247 |
: _M_ht(__n, __hf, __eql, __a) {}
|
williamr@2
|
248 |
|
williamr@2
|
249 |
unordered_multimap(__move_source<_Self> src)
|
williamr@2
|
250 |
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
williamr@2
|
251 |
|
williamr@2
|
252 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
253 |
template <class _InputIterator>
|
williamr@2
|
254 |
unordered_multimap(_InputIterator __f, _InputIterator __l,
|
williamr@2
|
255 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
256 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
257 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
258 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
259 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
260 |
#else
|
williamr@2
|
261 |
unordered_multimap(const value_type* __f, const value_type* __l,
|
williamr@2
|
262 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
263 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
264 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
265 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
266 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
267 |
|
williamr@2
|
268 |
unordered_multimap(const_iterator __f, const_iterator __l,
|
williamr@2
|
269 |
size_type __n = 100, const hasher& __hf = hasher(),
|
williamr@2
|
270 |
const key_equal& __eql = key_equal(),
|
williamr@2
|
271 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
272 |
: _M_ht(__n, __hf, __eql, __a)
|
williamr@2
|
273 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
274 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
275 |
|
williamr@2
|
276 |
_Self& operator = (const _Self& __other)
|
williamr@2
|
277 |
{ _M_ht = __other._M_ht; return *this; }
|
williamr@2
|
278 |
|
williamr@2
|
279 |
size_type size() const { return _M_ht.size(); }
|
williamr@2
|
280 |
size_type max_size() const { return _M_ht.max_size(); }
|
williamr@2
|
281 |
bool empty() const { return _M_ht.empty(); }
|
williamr@2
|
282 |
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
williamr@2
|
283 |
|
williamr@2
|
284 |
iterator begin() { return _M_ht.begin(); }
|
williamr@2
|
285 |
iterator end() { return _M_ht.end(); }
|
williamr@2
|
286 |
const_iterator begin() const { return _M_ht.begin(); }
|
williamr@2
|
287 |
const_iterator end() const { return _M_ht.end(); }
|
williamr@2
|
288 |
|
williamr@2
|
289 |
iterator insert(const value_type& __obj)
|
williamr@2
|
290 |
{ return _M_ht.insert_equal(__obj); }
|
williamr@2
|
291 |
iterator insert(const_iterator /*__hint*/, const value_type& __obj)
|
williamr@2
|
292 |
{ return _M_ht.insert_equal(__obj); }
|
williamr@2
|
293 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@2
|
294 |
template <class _InputIterator>
|
williamr@2
|
295 |
void insert(_InputIterator __f, _InputIterator __l)
|
williamr@2
|
296 |
#else
|
williamr@2
|
297 |
void insert(const value_type* __f, const value_type* __l)
|
williamr@2
|
298 |
{ _M_ht.insert_equal(__f,__l); }
|
williamr@2
|
299 |
void insert(const_iterator __f, const_iterator __l)
|
williamr@2
|
300 |
#endif /*_STLP_MEMBER_TEMPLATES */
|
williamr@2
|
301 |
{ _M_ht.insert_equal(__f, __l); }
|
williamr@2
|
302 |
|
williamr@2
|
303 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
304 |
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
williamr@2
|
305 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
306 |
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
williamr@2
|
307 |
|
williamr@2
|
308 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
309 |
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
williamr@2
|
310 |
|
williamr@2
|
311 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
312 |
pair<iterator, iterator> equal_range(const _KT& __key)
|
williamr@2
|
313 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
314 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
315 |
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
williamr@2
|
316 |
{ return _M_ht.equal_range(__key); }
|
williamr@2
|
317 |
|
williamr@2
|
318 |
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
|
williamr@2
|
319 |
void erase(const_iterator __it) { _M_ht.erase(__it); }
|
williamr@2
|
320 |
void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); }
|
williamr@2
|
321 |
void clear() { _M_ht.clear(); }
|
williamr@2
|
322 |
|
williamr@2
|
323 |
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
williamr@2
|
324 |
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
williamr@2
|
325 |
size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); }
|
williamr@2
|
326 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@2
|
327 |
size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); }
|
williamr@2
|
328 |
local_iterator begin(size_type __n) { return _M_ht.begin(__n); }
|
williamr@2
|
329 |
local_iterator end(size_type __n) { return _M_ht.end(__n); }
|
williamr@2
|
330 |
const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); }
|
williamr@2
|
331 |
const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }
|
williamr@2
|
332 |
|
williamr@2
|
333 |
float load_factor() const { return _M_ht.load_factor(); }
|
williamr@2
|
334 |
float max_load_factor() const { return _M_ht.max_load_factor(); }
|
williamr@2
|
335 |
void max_load_factor(float __val) { _M_ht.max_load_factor(__val); }
|
williamr@2
|
336 |
void rehash(size_type __hint) { _M_ht.rehash(__hint); }
|
williamr@2
|
337 |
};
|
williamr@2
|
338 |
|
williamr@2
|
339 |
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
|
williamr@2
|
340 |
#define _STLP_TEMPLATE_CONTAINER unordered_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
|
williamr@2
|
341 |
|
williamr@2
|
342 |
#include <stl/_relops_hash_cont.h>
|
williamr@2
|
343 |
|
williamr@2
|
344 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@2
|
345 |
#define _STLP_TEMPLATE_CONTAINER unordered_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
|
williamr@2
|
346 |
|
williamr@2
|
347 |
#include <stl/_relops_hash_cont.h>
|
williamr@2
|
348 |
|
williamr@2
|
349 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@2
|
350 |
#undef _STLP_TEMPLATE_HEADER
|
williamr@2
|
351 |
|
williamr@2
|
352 |
// Specialization of insert_iterator so that it will work for unordered_map
|
williamr@2
|
353 |
// and unordered_multimap.
|
williamr@2
|
354 |
|
williamr@2
|
355 |
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
williamr@2
|
356 |
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
williamr@2
|
357 |
struct __move_traits<unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
|
williamr@2
|
358 |
_STLP_PRIV __move_traits_help<typename unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
|
williamr@2
|
359 |
{};
|
williamr@2
|
360 |
|
williamr@2
|
361 |
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
williamr@2
|
362 |
struct __move_traits<unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
|
williamr@2
|
363 |
_STLP_PRIV __move_traits_help<typename unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
|
williamr@2
|
364 |
{};
|
williamr@2
|
365 |
|
williamr@2
|
366 |
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
williamr@2
|
367 |
class insert_iterator<unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
|
williamr@2
|
368 |
protected:
|
williamr@2
|
369 |
typedef unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
|
williamr@2
|
370 |
_Container* container;
|
williamr@2
|
371 |
public:
|
williamr@2
|
372 |
typedef _Container container_type;
|
williamr@2
|
373 |
typedef output_iterator_tag iterator_category;
|
williamr@2
|
374 |
typedef void value_type;
|
williamr@2
|
375 |
typedef void difference_type;
|
williamr@2
|
376 |
typedef void pointer;
|
williamr@2
|
377 |
typedef void reference;
|
williamr@2
|
378 |
|
williamr@2
|
379 |
insert_iterator(_Container& __x) : container(&__x) {}
|
williamr@2
|
380 |
insert_iterator(_Container& __x, typename _Container::iterator)
|
williamr@2
|
381 |
: container(&__x) {}
|
williamr@2
|
382 |
insert_iterator<_Container>&
|
williamr@2
|
383 |
operator=(const typename _Container::value_type& __val) {
|
williamr@2
|
384 |
container->insert(__val);
|
williamr@2
|
385 |
return *this;
|
williamr@2
|
386 |
}
|
williamr@2
|
387 |
insert_iterator<_Container>& operator*() { return *this; }
|
williamr@2
|
388 |
insert_iterator<_Container>& operator++() { return *this; }
|
williamr@2
|
389 |
insert_iterator<_Container>& operator++(int) { return *this; }
|
williamr@2
|
390 |
};
|
williamr@2
|
391 |
|
williamr@2
|
392 |
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
williamr@2
|
393 |
class insert_iterator<unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
|
williamr@2
|
394 |
protected:
|
williamr@2
|
395 |
typedef unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
|
williamr@2
|
396 |
_Container* container;
|
williamr@2
|
397 |
typename _Container::iterator iter;
|
williamr@2
|
398 |
public:
|
williamr@2
|
399 |
typedef _Container container_type;
|
williamr@2
|
400 |
typedef output_iterator_tag iterator_category;
|
williamr@2
|
401 |
typedef void value_type;
|
williamr@2
|
402 |
typedef void difference_type;
|
williamr@2
|
403 |
typedef void pointer;
|
williamr@2
|
404 |
typedef void reference;
|
williamr@2
|
405 |
|
williamr@2
|
406 |
insert_iterator(_Container& __x) : container(&__x) {}
|
williamr@2
|
407 |
insert_iterator(_Container& __x, typename _Container::iterator)
|
williamr@2
|
408 |
: container(&__x) {}
|
williamr@2
|
409 |
insert_iterator<_Container>&
|
williamr@2
|
410 |
operator=(const typename _Container::value_type& __val) {
|
williamr@2
|
411 |
container->insert(__val);
|
williamr@2
|
412 |
return *this;
|
williamr@2
|
413 |
}
|
williamr@2
|
414 |
insert_iterator<_Container>& operator*() { return *this; }
|
williamr@2
|
415 |
insert_iterator<_Container>& operator++() { return *this; }
|
williamr@2
|
416 |
insert_iterator<_Container>& operator++(int) { return *this; }
|
williamr@2
|
417 |
};
|
williamr@2
|
418 |
|
williamr@2
|
419 |
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
williamr@2
|
420 |
|
williamr@2
|
421 |
_STLP_END_NAMESPACE
|
williamr@2
|
422 |
|
williamr@2
|
423 |
#endif /* _STLP_INTERNAL_UNORDERED_MAP_H */
|
williamr@2
|
424 |
|
williamr@2
|
425 |
// Local Variables:
|
williamr@2
|
426 |
// mode:C++
|
williamr@2
|
427 |
// End:
|