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