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_MAP_H
|
williamr@4
|
31 |
#define _STLP_INTERNAL_MAP_H
|
williamr@4
|
32 |
|
williamr@4
|
33 |
#ifndef _STLP_INTERNAL_TREE_H
|
williamr@4
|
34 |
# include <stl/_tree.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_ITERATOR_TRAITS(MapTraitsT, traits)
|
williamr@4
|
41 |
|
williamr@4
|
42 |
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ),
|
williamr@4
|
43 |
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
|
williamr@4
|
44 |
class map
|
williamr@4
|
45 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@4
|
46 |
: public __stlport_class<map<_Key, _Tp, _Compare, _Alloc> >
|
williamr@4
|
47 |
#endif
|
williamr@4
|
48 |
{
|
williamr@4
|
49 |
typedef map<_Key, _Tp, _Compare, _Alloc> _Self;
|
williamr@4
|
50 |
public:
|
williamr@4
|
51 |
|
williamr@4
|
52 |
// typedefs:
|
williamr@4
|
53 |
|
williamr@4
|
54 |
typedef _Key key_type;
|
williamr@4
|
55 |
typedef _Tp data_type;
|
williamr@4
|
56 |
typedef _Tp mapped_type;
|
williamr@4
|
57 |
typedef pair<const _Key, _Tp> value_type;
|
williamr@4
|
58 |
typedef _Compare key_compare;
|
williamr@4
|
59 |
|
williamr@4
|
60 |
class value_compare
|
williamr@4
|
61 |
: public binary_function<value_type, value_type, bool> {
|
williamr@4
|
62 |
friend class map<_Key,_Tp,_Compare,_Alloc>;
|
williamr@4
|
63 |
protected :
|
williamr@4
|
64 |
//c is a Standard name (23.3.1), do no make it STLport naming convention compliant.
|
williamr@4
|
65 |
_Compare comp;
|
williamr@4
|
66 |
value_compare(_Compare __c) : comp(__c) {}
|
williamr@4
|
67 |
public:
|
williamr@4
|
68 |
bool operator()(const value_type& __x, const value_type& __y) const
|
williamr@4
|
69 |
{ return comp(__x.first, __y.first); }
|
williamr@4
|
70 |
};
|
williamr@4
|
71 |
|
williamr@4
|
72 |
protected:
|
williamr@4
|
73 |
typedef _STLP_PRIV _MapTraitsT<value_type> _MapTraits;
|
williamr@4
|
74 |
|
williamr@4
|
75 |
public:
|
williamr@4
|
76 |
//Following typedef have to be public for __move_traits specialization.
|
williamr@4
|
77 |
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
williamr@4
|
78 |
value_type, _STLP_SELECT1ST(value_type, _Key),
|
williamr@4
|
79 |
_MapTraits, _Alloc> _Rep_type;
|
williamr@4
|
80 |
|
williamr@4
|
81 |
typedef typename _Rep_type::pointer pointer;
|
williamr@4
|
82 |
typedef typename _Rep_type::const_pointer const_pointer;
|
williamr@4
|
83 |
typedef typename _Rep_type::reference reference;
|
williamr@4
|
84 |
typedef typename _Rep_type::const_reference const_reference;
|
williamr@4
|
85 |
typedef typename _Rep_type::iterator iterator;
|
williamr@4
|
86 |
typedef typename _Rep_type::const_iterator const_iterator;
|
williamr@4
|
87 |
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
williamr@4
|
88 |
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
williamr@4
|
89 |
typedef typename _Rep_type::size_type size_type;
|
williamr@4
|
90 |
typedef typename _Rep_type::difference_type difference_type;
|
williamr@4
|
91 |
typedef typename _Rep_type::allocator_type allocator_type;
|
williamr@4
|
92 |
|
williamr@4
|
93 |
private:
|
williamr@4
|
94 |
_Rep_type _M_t; // red-black tree representing map
|
williamr@4
|
95 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@4
|
96 |
|
williamr@4
|
97 |
public:
|
williamr@4
|
98 |
// allocation/deallocation
|
williamr@4
|
99 |
map() : _M_t(_Compare(), allocator_type()) {}
|
williamr@4
|
100 |
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
williamr@4
|
101 |
explicit map(const _Compare& __comp,
|
williamr@4
|
102 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
103 |
#else
|
williamr@4
|
104 |
explicit map(const _Compare& __comp)
|
williamr@4
|
105 |
: _M_t(__comp, allocator_type()) {}
|
williamr@4
|
106 |
explicit map(const _Compare& __comp, const allocator_type& __a)
|
williamr@4
|
107 |
#endif
|
williamr@4
|
108 |
: _M_t(__comp, __a) {}
|
williamr@4
|
109 |
|
williamr@4
|
110 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@4
|
111 |
template <class _InputIterator>
|
williamr@4
|
112 |
map(_InputIterator __first, _InputIterator __last)
|
williamr@4
|
113 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
114 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
115 |
|
williamr@4
|
116 |
template <class _InputIterator>
|
williamr@4
|
117 |
map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
williamr@4
|
118 |
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
williamr@4
|
119 |
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
williamr@4
|
120 |
|
williamr@4
|
121 |
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
williamr@4
|
122 |
template <class _InputIterator>
|
williamr@4
|
123 |
map(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
|
williamr@4
|
124 |
: _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); }
|
williamr@4
|
125 |
# endif
|
williamr@4
|
126 |
|
williamr@4
|
127 |
#else
|
williamr@4
|
128 |
map(const value_type* __first, const value_type* __last)
|
williamr@4
|
129 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
130 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
131 |
|
williamr@4
|
132 |
map(const value_type* __first,
|
williamr@4
|
133 |
const value_type* __last, const _Compare& __comp,
|
williamr@4
|
134 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
135 |
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
williamr@4
|
136 |
|
williamr@4
|
137 |
map(const_iterator __first, const_iterator __last)
|
williamr@4
|
138 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
139 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
140 |
|
williamr@4
|
141 |
map(const_iterator __first, const_iterator __last, const _Compare& __comp,
|
williamr@4
|
142 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
143 |
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
williamr@4
|
144 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@4
|
145 |
|
williamr@4
|
146 |
map(const _Self& __x) : _M_t(__x._M_t) {}
|
williamr@4
|
147 |
|
williamr@4
|
148 |
map(__move_source<_Self> src)
|
williamr@4
|
149 |
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
williamr@4
|
150 |
|
williamr@4
|
151 |
_Self& operator=(const _Self& __x) {
|
williamr@4
|
152 |
_M_t = __x._M_t;
|
williamr@4
|
153 |
return *this;
|
williamr@4
|
154 |
}
|
williamr@4
|
155 |
|
williamr@4
|
156 |
// accessors:
|
williamr@4
|
157 |
key_compare key_comp() const { return _M_t.key_comp(); }
|
williamr@4
|
158 |
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
williamr@4
|
159 |
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
williamr@4
|
160 |
|
williamr@4
|
161 |
iterator begin() { return _M_t.begin(); }
|
williamr@4
|
162 |
const_iterator begin() const { return _M_t.begin(); }
|
williamr@4
|
163 |
iterator end() { return _M_t.end(); }
|
williamr@4
|
164 |
const_iterator end() const { return _M_t.end(); }
|
williamr@4
|
165 |
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
williamr@4
|
166 |
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
williamr@4
|
167 |
reverse_iterator rend() { return _M_t.rend(); }
|
williamr@4
|
168 |
const_reverse_iterator rend() const { return _M_t.rend(); }
|
williamr@4
|
169 |
bool empty() const { return _M_t.empty(); }
|
williamr@4
|
170 |
size_type size() const { return _M_t.size(); }
|
williamr@4
|
171 |
size_type max_size() const { return _M_t.max_size(); }
|
williamr@4
|
172 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
173 |
_Tp& operator[](const _KT& __k) {
|
williamr@4
|
174 |
iterator __i = lower_bound(__k);
|
williamr@4
|
175 |
// __i->first is greater than or equivalent to __k.
|
williamr@4
|
176 |
if (__i == end() || key_comp()(__k, (*__i).first))
|
williamr@4
|
177 |
__i = insert(__i, value_type(__k, _STLP_DEFAULT_CONSTRUCTED(_Tp)));
|
williamr@4
|
178 |
return (*__i).second;
|
williamr@4
|
179 |
}
|
williamr@4
|
180 |
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
williamr@4
|
181 |
|
williamr@4
|
182 |
// insert/erase
|
williamr@4
|
183 |
pair<iterator,bool> insert(const value_type& __x)
|
williamr@4
|
184 |
{ return _M_t.insert_unique(__x); }
|
williamr@4
|
185 |
iterator insert(iterator __pos, const value_type& __x)
|
williamr@4
|
186 |
{ return _M_t.insert_unique(__pos, __x); }
|
williamr@4
|
187 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@4
|
188 |
template <class _InputIterator>
|
williamr@4
|
189 |
void insert(_InputIterator __first, _InputIterator __last)
|
williamr@4
|
190 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
191 |
#else
|
williamr@4
|
192 |
void insert(const value_type* __first, const value_type* __last)
|
williamr@4
|
193 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
194 |
void insert(const_iterator __first, const_iterator __last)
|
williamr@4
|
195 |
{ _M_t.insert_unique(__first, __last); }
|
williamr@4
|
196 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@4
|
197 |
|
williamr@4
|
198 |
void erase(iterator __pos) { _M_t.erase(__pos); }
|
williamr@4
|
199 |
size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); }
|
williamr@4
|
200 |
void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
|
williamr@4
|
201 |
void clear() { _M_t.clear(); }
|
williamr@4
|
202 |
|
williamr@4
|
203 |
// map operations:
|
williamr@4
|
204 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
205 |
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
williamr@4
|
206 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
207 |
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
williamr@4
|
208 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
209 |
size_type count(const _KT& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
|
williamr@4
|
210 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
211 |
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
williamr@4
|
212 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
213 |
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
williamr@4
|
214 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
215 |
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
williamr@4
|
216 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
217 |
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
williamr@4
|
218 |
|
williamr@4
|
219 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
220 |
pair<iterator,iterator> equal_range(const _KT& __x)
|
williamr@4
|
221 |
{ return _M_t.equal_range_unique(__x); }
|
williamr@4
|
222 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
223 |
pair<const_iterator,const_iterator> equal_range(const _KT& __x) const
|
williamr@4
|
224 |
{ return _M_t.equal_range_unique(__x); }
|
williamr@4
|
225 |
};
|
williamr@4
|
226 |
|
williamr@4
|
227 |
//Specific iterator traits creation
|
williamr@4
|
228 |
_STLP_CREATE_ITERATOR_TRAITS(MultimapTraitsT, traits)
|
williamr@4
|
229 |
|
williamr@4
|
230 |
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ),
|
williamr@4
|
231 |
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
|
williamr@4
|
232 |
class multimap
|
williamr@4
|
233 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@4
|
234 |
: public __stlport_class<multimap<_Key, _Tp, _Compare, _Alloc> >
|
williamr@4
|
235 |
#endif
|
williamr@4
|
236 |
{
|
williamr@4
|
237 |
typedef multimap<_Key, _Tp, _Compare, _Alloc> _Self;
|
williamr@4
|
238 |
public:
|
williamr@4
|
239 |
|
williamr@4
|
240 |
// typedefs:
|
williamr@4
|
241 |
|
williamr@4
|
242 |
typedef _Key key_type;
|
williamr@4
|
243 |
typedef _Tp data_type;
|
williamr@4
|
244 |
typedef _Tp mapped_type;
|
williamr@4
|
245 |
typedef pair<const _Key, _Tp> value_type;
|
williamr@4
|
246 |
typedef _Compare key_compare;
|
williamr@4
|
247 |
|
williamr@4
|
248 |
class value_compare : public binary_function<value_type, value_type, bool> {
|
williamr@4
|
249 |
friend class multimap<_Key,_Tp,_Compare,_Alloc>;
|
williamr@4
|
250 |
protected:
|
williamr@4
|
251 |
//comp is a Standard name (23.3.2), do no make it STLport naming convention compliant.
|
williamr@4
|
252 |
_Compare comp;
|
williamr@4
|
253 |
value_compare(_Compare __c) : comp(__c) {}
|
williamr@4
|
254 |
public:
|
williamr@4
|
255 |
bool operator()(const value_type& __x, const value_type& __y) const
|
williamr@4
|
256 |
{ return comp(__x.first, __y.first); }
|
williamr@4
|
257 |
};
|
williamr@4
|
258 |
|
williamr@4
|
259 |
protected:
|
williamr@4
|
260 |
//Specific iterator traits creation
|
williamr@4
|
261 |
typedef _STLP_PRIV _MultimapTraitsT<value_type> _MultimapTraits;
|
williamr@4
|
262 |
|
williamr@4
|
263 |
public:
|
williamr@4
|
264 |
//Following typedef have to be public for __move_traits specialization.
|
williamr@4
|
265 |
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
williamr@4
|
266 |
value_type, _STLP_SELECT1ST(value_type, _Key),
|
williamr@4
|
267 |
_MultimapTraits, _Alloc> _Rep_type;
|
williamr@4
|
268 |
|
williamr@4
|
269 |
typedef typename _Rep_type::pointer pointer;
|
williamr@4
|
270 |
typedef typename _Rep_type::const_pointer const_pointer;
|
williamr@4
|
271 |
typedef typename _Rep_type::reference reference;
|
williamr@4
|
272 |
typedef typename _Rep_type::const_reference const_reference;
|
williamr@4
|
273 |
typedef typename _Rep_type::iterator iterator;
|
williamr@4
|
274 |
typedef typename _Rep_type::const_iterator const_iterator;
|
williamr@4
|
275 |
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
williamr@4
|
276 |
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
williamr@4
|
277 |
typedef typename _Rep_type::size_type size_type;
|
williamr@4
|
278 |
typedef typename _Rep_type::difference_type difference_type;
|
williamr@4
|
279 |
typedef typename _Rep_type::allocator_type allocator_type;
|
williamr@4
|
280 |
|
williamr@4
|
281 |
private:
|
williamr@4
|
282 |
_Rep_type _M_t; // red-black tree representing multimap
|
williamr@4
|
283 |
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
williamr@4
|
284 |
|
williamr@4
|
285 |
public:
|
williamr@4
|
286 |
// allocation/deallocation
|
williamr@4
|
287 |
multimap() : _M_t(_Compare(), allocator_type()) { }
|
williamr@4
|
288 |
explicit multimap(const _Compare& __comp,
|
williamr@4
|
289 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
290 |
: _M_t(__comp, __a) { }
|
williamr@4
|
291 |
|
williamr@4
|
292 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@4
|
293 |
template <class _InputIterator>
|
williamr@4
|
294 |
multimap(_InputIterator __first, _InputIterator __last)
|
williamr@4
|
295 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
296 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
297 |
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
williamr@4
|
298 |
template <class _InputIterator>
|
williamr@4
|
299 |
multimap(_InputIterator __first, _InputIterator __last,
|
williamr@4
|
300 |
const _Compare& __comp)
|
williamr@4
|
301 |
: _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); }
|
williamr@4
|
302 |
# endif
|
williamr@4
|
303 |
template <class _InputIterator>
|
williamr@4
|
304 |
multimap(_InputIterator __first, _InputIterator __last,
|
williamr@4
|
305 |
const _Compare& __comp,
|
williamr@4
|
306 |
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
williamr@4
|
307 |
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
williamr@4
|
308 |
#else
|
williamr@4
|
309 |
multimap(const value_type* __first, const value_type* __last)
|
williamr@4
|
310 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
311 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
312 |
multimap(const value_type* __first, const value_type* __last,
|
williamr@4
|
313 |
const _Compare& __comp,
|
williamr@4
|
314 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
315 |
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
williamr@4
|
316 |
|
williamr@4
|
317 |
multimap(const_iterator __first, const_iterator __last)
|
williamr@4
|
318 |
: _M_t(_Compare(), allocator_type())
|
williamr@4
|
319 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
320 |
multimap(const_iterator __first, const_iterator __last,
|
williamr@4
|
321 |
const _Compare& __comp,
|
williamr@4
|
322 |
const allocator_type& __a = allocator_type())
|
williamr@4
|
323 |
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
williamr@4
|
324 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@4
|
325 |
|
williamr@4
|
326 |
multimap(const _Self& __x) : _M_t(__x._M_t) {}
|
williamr@4
|
327 |
|
williamr@4
|
328 |
multimap(__move_source<_Self> src)
|
williamr@4
|
329 |
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
williamr@4
|
330 |
|
williamr@4
|
331 |
_Self& operator=(const _Self& __x) {
|
williamr@4
|
332 |
_M_t = __x._M_t;
|
williamr@4
|
333 |
return *this;
|
williamr@4
|
334 |
}
|
williamr@4
|
335 |
|
williamr@4
|
336 |
// accessors:
|
williamr@4
|
337 |
|
williamr@4
|
338 |
key_compare key_comp() const { return _M_t.key_comp(); }
|
williamr@4
|
339 |
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
williamr@4
|
340 |
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
williamr@4
|
341 |
|
williamr@4
|
342 |
iterator begin() { return _M_t.begin(); }
|
williamr@4
|
343 |
const_iterator begin() const { return _M_t.begin(); }
|
williamr@4
|
344 |
iterator end() { return _M_t.end(); }
|
williamr@4
|
345 |
const_iterator end() const { return _M_t.end(); }
|
williamr@4
|
346 |
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
williamr@4
|
347 |
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
williamr@4
|
348 |
reverse_iterator rend() { return _M_t.rend(); }
|
williamr@4
|
349 |
const_reverse_iterator rend() const { return _M_t.rend(); }
|
williamr@4
|
350 |
bool empty() const { return _M_t.empty(); }
|
williamr@4
|
351 |
size_type size() const { return _M_t.size(); }
|
williamr@4
|
352 |
size_type max_size() const { return _M_t.max_size(); }
|
williamr@4
|
353 |
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
williamr@4
|
354 |
|
williamr@4
|
355 |
// insert/erase
|
williamr@4
|
356 |
iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
|
williamr@4
|
357 |
iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_equal(__pos, __x); }
|
williamr@4
|
358 |
#if defined (_STLP_MEMBER_TEMPLATES)
|
williamr@4
|
359 |
template <class _InputIterator>
|
williamr@4
|
360 |
void insert(_InputIterator __first, _InputIterator __last)
|
williamr@4
|
361 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
362 |
#else
|
williamr@4
|
363 |
void insert(const value_type* __first, const value_type* __last)
|
williamr@4
|
364 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
365 |
void insert(const_iterator __first, const_iterator __last)
|
williamr@4
|
366 |
{ _M_t.insert_equal(__first, __last); }
|
williamr@4
|
367 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@4
|
368 |
void erase(iterator __pos) { _M_t.erase(__pos); }
|
williamr@4
|
369 |
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
williamr@4
|
370 |
void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
|
williamr@4
|
371 |
void clear() { _M_t.clear(); }
|
williamr@4
|
372 |
|
williamr@4
|
373 |
// multimap operations:
|
williamr@4
|
374 |
|
williamr@4
|
375 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
376 |
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
williamr@4
|
377 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
378 |
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
williamr@4
|
379 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
380 |
size_type count(const _KT& __x) const { return _M_t.count(__x); }
|
williamr@4
|
381 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
382 |
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
williamr@4
|
383 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
384 |
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
williamr@4
|
385 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
386 |
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
williamr@4
|
387 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
388 |
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
williamr@4
|
389 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
390 |
pair<iterator,iterator> equal_range(const _KT& __x)
|
williamr@4
|
391 |
{ return _M_t.equal_range(__x); }
|
williamr@4
|
392 |
_STLP_TEMPLATE_FOR_CONT_EXT
|
williamr@4
|
393 |
pair<const_iterator,const_iterator> equal_range(const _KT& __x) const
|
williamr@4
|
394 |
{ return _M_t.equal_range(__x); }
|
williamr@4
|
395 |
};
|
williamr@4
|
396 |
|
williamr@4
|
397 |
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _Compare, class _Alloc>
|
williamr@4
|
398 |
#define _STLP_TEMPLATE_CONTAINER map<_Key,_Tp,_Compare,_Alloc>
|
williamr@4
|
399 |
#include <stl/_relops_cont.h>
|
williamr@4
|
400 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@4
|
401 |
#define _STLP_TEMPLATE_CONTAINER multimap<_Key,_Tp,_Compare,_Alloc>
|
williamr@4
|
402 |
#include <stl/_relops_cont.h>
|
williamr@4
|
403 |
#undef _STLP_TEMPLATE_CONTAINER
|
williamr@4
|
404 |
#undef _STLP_TEMPLATE_HEADER
|
williamr@4
|
405 |
|
williamr@4
|
406 |
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
williamr@4
|
407 |
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
williamr@4
|
408 |
struct __move_traits<map<_Key,_Tp,_Compare,_Alloc> > :
|
williamr@4
|
409 |
_STLP_PRIV __move_traits_aux<typename map<_Key,_Tp,_Compare,_Alloc>::_Rep_type>
|
williamr@4
|
410 |
{};
|
williamr@4
|
411 |
|
williamr@4
|
412 |
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
williamr@4
|
413 |
struct __move_traits<multimap<_Key,_Tp,_Compare,_Alloc> > :
|
williamr@4
|
414 |
_STLP_PRIV __move_traits_aux<typename multimap<_Key,_Tp,_Compare,_Alloc>::_Rep_type>
|
williamr@4
|
415 |
{};
|
williamr@4
|
416 |
#endif
|
williamr@4
|
417 |
|
williamr@4
|
418 |
_STLP_END_NAMESPACE
|
williamr@4
|
419 |
|
williamr@4
|
420 |
#endif /* _STLP_INTERNAL_MAP_H */
|
williamr@4
|
421 |
|
williamr@4
|
422 |
// Local Variables:
|
williamr@4
|
423 |
// mode:C++
|
williamr@4
|
424 |
// End:
|
williamr@4
|
425 |
|