YkESet 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +68 -0
- data/Rakefile +13 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Yk/EMMap/Iterator.html +626 -0
- data/docs/Yk/EMMap.html +1504 -0
- data/docs/Yk/EMSet/Iterator.html +626 -0
- data/docs/Yk/EMSet.html +1472 -0
- data/docs/Yk/EMap/Iterator.html +626 -0
- data/docs/Yk/EMap.html +1730 -0
- data/docs/Yk/ESet/Iterator.html +626 -0
- data/docs/Yk/ESet.html +1472 -0
- data/docs/Yk.html +126 -0
- data/docs/_index.html +170 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file_list.html +51 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +170 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +571 -0
- data/docs/top-level-namespace.html +110 -0
- data/eset.gemspec +29 -0
- data/ext/Yk/.ruby-version +1 -0
- data/ext/Yk/.yardoc/checksums +1 -0
- data/ext/Yk/.yardoc/complete +0 -0
- data/ext/Yk/.yardoc/object_types +0 -0
- data/ext/Yk/.yardoc/objects/root.dat +0 -0
- data/ext/Yk/.yardoc/proxy_types +0 -0
- data/ext/Yk/Makefile +267 -0
- data/ext/Yk/depend +2 -0
- data/ext/Yk/extconf.rb +7 -0
- data/ext/Yk/for_yard.rb +192 -0
- data/ext/Yk/for_yard_product.rb +397 -0
- data/ext/Yk/map_tz +78 -0
- data/ext/Yk/set_tz +77 -0
- data/ext/Yk/stl_map_tz.h +1026 -0
- data/ext/Yk/stl_multimap_tz.h +927 -0
- data/ext/Yk/stl_multiset_tz.h +805 -0
- data/ext/Yk/stl_set_tz.h +815 -0
- data/ext/Yk/stl_set_tz_ruby.cpp +575 -0
- data/ext/Yk/stl_tree_tz.h +1865 -0
- data/ext/Yk/test_set.rb +115 -0
- data/ext/Yk/tree_tz.cc +489 -0
- data/ext/Yk/tz_stl_auto.cpp +84 -0
- data/lib/eset/version.rb +3 -0
- data/lib/eset.rb +7 -0
- metadata +101 -0
data/ext/Yk/stl_map_tz.h
ADDED
|
@@ -0,0 +1,1026 @@
|
|
|
1
|
+
// Map implementation -*- C++ -*-
|
|
2
|
+
|
|
3
|
+
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
|
4
|
+
//
|
|
5
|
+
// This file is part of the GNU ISO C++ Library. This library is free
|
|
6
|
+
// software; you can redistribute it and/or modify it under the
|
|
7
|
+
// terms of the GNU General Public License as published by the
|
|
8
|
+
// Free Software Foundation; either version 3, or (at your option)
|
|
9
|
+
// any later version.
|
|
10
|
+
|
|
11
|
+
// This library is distributed in the hope that it will be useful,
|
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
// GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
// Under Section 7 of GPL version 3, you are granted additional
|
|
17
|
+
// permissions described in the GCC Runtime Library Exception, version
|
|
18
|
+
// 3.1, as published by the Free Software Foundation.
|
|
19
|
+
|
|
20
|
+
// You should have received a copy of the GNU General Public License and
|
|
21
|
+
// a copy of the GCC Runtime Library Exception along with this program;
|
|
22
|
+
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
23
|
+
// <http://www.gnu.org/licenses/>.
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
*
|
|
27
|
+
* Copyright (c) 1994
|
|
28
|
+
* Hewlett-Packard Company
|
|
29
|
+
*
|
|
30
|
+
* Permission to use, copy, modify, distribute and sell this software
|
|
31
|
+
* and its documentation for any purpose is hereby granted without fee,
|
|
32
|
+
* provided that the above copyright notice appear in all copies and
|
|
33
|
+
* that both that copyright notice and this permission notice appear
|
|
34
|
+
* in supporting documentation. Hewlett-Packard Company makes no
|
|
35
|
+
* representations about the suitability of this software for any
|
|
36
|
+
* purpose. It is provided "as is" without express or implied warranty.
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) 1996,1997
|
|
40
|
+
* Silicon Graphics Computer Systems, Inc.
|
|
41
|
+
*
|
|
42
|
+
* Permission to use, copy, modify, distribute and sell this software
|
|
43
|
+
* and its documentation for any purpose is hereby granted without fee,
|
|
44
|
+
* provided that the above copyright notice appear in all copies and
|
|
45
|
+
* that both that copyright notice and this permission notice appear
|
|
46
|
+
* in supporting documentation. Silicon Graphics makes no
|
|
47
|
+
* representations about the suitability of this software for any
|
|
48
|
+
* purpose. It is provided "as is" without express or implied warranty.
|
|
49
|
+
*
|
|
50
|
+
* Copyright (c) 2020
|
|
51
|
+
*
|
|
52
|
+
* Yougaein@github (Kokeji Yougain)
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/** @file bits/stl_map.h
|
|
57
|
+
* This is an internal header file, included by other library headers.
|
|
58
|
+
* Do not attempt to use it directly. @headername{map}
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
#ifndef _STL_MAP_TZ_H
|
|
62
|
+
#define _STL_MAP_TZ_H 1
|
|
63
|
+
|
|
64
|
+
#include <bits/functexcept.h>
|
|
65
|
+
#include <bits/concept_check.h>
|
|
66
|
+
#if __cplusplus >= 201103L
|
|
67
|
+
#include <initializer_list>
|
|
68
|
+
#include <tuple>
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
namespace tz _GLIBCXX_VISIBILITY(default)
|
|
72
|
+
{
|
|
73
|
+
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @brief A standard container made up of (key,value) pairs, which can be
|
|
77
|
+
* retrieved based on a key, in logarithmic time.
|
|
78
|
+
*
|
|
79
|
+
* @ingroup associative_containers
|
|
80
|
+
*
|
|
81
|
+
* @tparam _Key Type of key objects.
|
|
82
|
+
* @tparam _Tp Type of mapped objects.
|
|
83
|
+
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
|
|
84
|
+
* @tparam _Alloc Allocator type, defaults to
|
|
85
|
+
* allocator<pair<const _Key, _Tp>.
|
|
86
|
+
*
|
|
87
|
+
* Meets the requirements of a <a href="tables.html#65">container</a>, a
|
|
88
|
+
* <a href="tables.html#66">reversible container</a>, and an
|
|
89
|
+
* <a href="tables.html#69">associative container</a> (using unique keys).
|
|
90
|
+
* For a @c map<Key,T> the key_type is Key, the mapped_type is T, and the
|
|
91
|
+
* value_type is std::pair<const Key,T>.
|
|
92
|
+
*
|
|
93
|
+
* Maps support bidirectional iterators.
|
|
94
|
+
*
|
|
95
|
+
* The private tree data is declared exactly the same way for map and
|
|
96
|
+
* multimap; the distinction is made entirely in how the tree functions are
|
|
97
|
+
* called (*_unique versus *_equal, same as the standard).
|
|
98
|
+
*/
|
|
99
|
+
template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
|
|
100
|
+
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
|
101
|
+
class map
|
|
102
|
+
{
|
|
103
|
+
public:
|
|
104
|
+
typedef _Key key_type;
|
|
105
|
+
typedef _Tp mapped_type;
|
|
106
|
+
typedef std::pair<const _Key, _Tp> value_type;
|
|
107
|
+
typedef _Compare key_compare;
|
|
108
|
+
typedef _Alloc allocator_type;
|
|
109
|
+
|
|
110
|
+
private:
|
|
111
|
+
// concept requirements
|
|
112
|
+
typedef typename _Alloc::value_type _Alloc_value_type;
|
|
113
|
+
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
|
|
114
|
+
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
|
|
115
|
+
_BinaryFunctionConcept)
|
|
116
|
+
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
|
|
117
|
+
|
|
118
|
+
public:
|
|
119
|
+
class value_compare
|
|
120
|
+
: public std::binary_function<value_type, value_type, bool>
|
|
121
|
+
{
|
|
122
|
+
friend class map<_Key, _Tp, _Compare, _Alloc>;
|
|
123
|
+
protected:
|
|
124
|
+
_Compare comp;
|
|
125
|
+
|
|
126
|
+
value_compare(_Compare __c)
|
|
127
|
+
: comp(__c) { }
|
|
128
|
+
|
|
129
|
+
public:
|
|
130
|
+
bool operator()(const value_type& __x, const value_type& __y) const
|
|
131
|
+
{ return comp(__x.first, __y.first); }
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
private:
|
|
135
|
+
/// This turns a red-black tree into a [multi]map.
|
|
136
|
+
typedef typename _Alloc::template rebind<value_type>::other
|
|
137
|
+
_Pair_alloc_type;
|
|
138
|
+
|
|
139
|
+
typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
|
|
140
|
+
key_compare, _Pair_alloc_type> _Rep_type;
|
|
141
|
+
|
|
142
|
+
/// The actual tree structure.
|
|
143
|
+
public:
|
|
144
|
+
_Rep_type _M_t;
|
|
145
|
+
|
|
146
|
+
// many of these are specified differently in ISO, but the following are
|
|
147
|
+
// "functionally equivalent"
|
|
148
|
+
typedef typename _Pair_alloc_type::pointer pointer;
|
|
149
|
+
typedef typename _Pair_alloc_type::const_pointer const_pointer;
|
|
150
|
+
typedef typename _Pair_alloc_type::reference reference;
|
|
151
|
+
typedef typename _Pair_alloc_type::const_reference const_reference;
|
|
152
|
+
typedef typename _Rep_type::iterator iterator;
|
|
153
|
+
typedef typename _Rep_type::const_iterator const_iterator;
|
|
154
|
+
typedef typename _Rep_type::size_type size_type;
|
|
155
|
+
typedef typename _Rep_type::difference_type difference_type;
|
|
156
|
+
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
|
157
|
+
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
|
158
|
+
|
|
159
|
+
// [23.3.1.1] construct/copy/destroy
|
|
160
|
+
// (get_allocator() is normally listed in this section, but seems to have
|
|
161
|
+
// been accidentally omitted in the printed standard)
|
|
162
|
+
/**
|
|
163
|
+
* @brief Default constructor creates no elements.
|
|
164
|
+
*/
|
|
165
|
+
map()
|
|
166
|
+
: _M_t() { }
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @brief Creates a %map with no elements.
|
|
170
|
+
* @param __comp A comparison object.
|
|
171
|
+
* @param __a An allocator object.
|
|
172
|
+
*/
|
|
173
|
+
explicit
|
|
174
|
+
map(const _Compare& __comp,
|
|
175
|
+
const allocator_type& __a = allocator_type())
|
|
176
|
+
: _M_t(__comp, _Pair_alloc_type(__a)) { }
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @brief %Map copy constructor.
|
|
180
|
+
* @param __x A %map of identical element and allocator types.
|
|
181
|
+
*
|
|
182
|
+
* The newly-created %map uses a copy of the allocation object
|
|
183
|
+
* used by @a __x.
|
|
184
|
+
*/
|
|
185
|
+
map(const map& __x)
|
|
186
|
+
: _M_t(__x._M_t) { }
|
|
187
|
+
|
|
188
|
+
#if __cplusplus >= 201103L
|
|
189
|
+
/**
|
|
190
|
+
* @brief %Map move constructor.
|
|
191
|
+
* @param __x A %map of identical element and allocator types.
|
|
192
|
+
*
|
|
193
|
+
* The newly-created %map contains the exact contents of @a __x.
|
|
194
|
+
* The contents of @a __x are a valid, but unspecified %map.
|
|
195
|
+
*/
|
|
196
|
+
map(map&& __x)
|
|
197
|
+
noexcept(is_nothrow_copy_constructible<_Compare>::value)
|
|
198
|
+
: _M_t(std::move(__x._M_t)) { }
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @brief Builds a %map from an initializer_list.
|
|
202
|
+
* @param __l An initializer_list.
|
|
203
|
+
* @param __comp A comparison object.
|
|
204
|
+
* @param __a An allocator object.
|
|
205
|
+
*
|
|
206
|
+
* Create a %map consisting of copies of the elements in the
|
|
207
|
+
* initializer_list @a __l.
|
|
208
|
+
* This is linear in N if the range is already sorted, and NlogN
|
|
209
|
+
* otherwise (where N is @a __l.size()).
|
|
210
|
+
*/
|
|
211
|
+
map(initializer_list<value_type> __l,
|
|
212
|
+
const _Compare& __comp = _Compare(),
|
|
213
|
+
const allocator_type& __a = allocator_type())
|
|
214
|
+
: _M_t(__comp, _Pair_alloc_type(__a))
|
|
215
|
+
{ _M_t._M_insert_unique(__l.begin(), __l.end()); }
|
|
216
|
+
#endif
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @brief Builds a %map from a range.
|
|
220
|
+
* @param __first An input iterator.
|
|
221
|
+
* @param __last An input iterator.
|
|
222
|
+
*
|
|
223
|
+
* Create a %map consisting of copies of the elements from
|
|
224
|
+
* [__first,__last). This is linear in N if the range is
|
|
225
|
+
* already sorted, and NlogN otherwise (where N is
|
|
226
|
+
* distance(__first,__last)).
|
|
227
|
+
*/
|
|
228
|
+
template<typename _InputIterator>
|
|
229
|
+
map(_InputIterator __first, _InputIterator __last)
|
|
230
|
+
: _M_t()
|
|
231
|
+
{ _M_t._M_insert_unique(__first, __last); }
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @brief Builds a %map from a range.
|
|
235
|
+
* @param __first An input iterator.
|
|
236
|
+
* @param __last An input iterator.
|
|
237
|
+
* @param __comp A comparison functor.
|
|
238
|
+
* @param __a An allocator object.
|
|
239
|
+
*
|
|
240
|
+
* Create a %map consisting of copies of the elements from
|
|
241
|
+
* [__first,__last). This is linear in N if the range is
|
|
242
|
+
* already sorted, and NlogN otherwise (where N is
|
|
243
|
+
* distance(__first,__last)).
|
|
244
|
+
*/
|
|
245
|
+
template<typename _InputIterator>
|
|
246
|
+
map(_InputIterator __first, _InputIterator __last,
|
|
247
|
+
const _Compare& __comp,
|
|
248
|
+
const allocator_type& __a = allocator_type())
|
|
249
|
+
: _M_t(__comp, _Pair_alloc_type(__a))
|
|
250
|
+
{ _M_t._M_insert_unique(__first, __last); }
|
|
251
|
+
|
|
252
|
+
// FIXME There is no dtor declared, but we should have something
|
|
253
|
+
// generated by Doxygen. I don't know what tags to add to this
|
|
254
|
+
// paragraph to make that happen:
|
|
255
|
+
/**
|
|
256
|
+
* The dtor only erases the elements, and note that if the elements
|
|
257
|
+
* themselves are pointers, the pointed-to memory is not touched in any
|
|
258
|
+
* way. Managing the pointer is the user's responsibility.
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @brief %Map assignment operator.
|
|
263
|
+
* @param __x A %map of identical element and allocator types.
|
|
264
|
+
*
|
|
265
|
+
* All the elements of @a __x are copied, but unlike the copy
|
|
266
|
+
* constructor, the allocator object is not copied.
|
|
267
|
+
*/
|
|
268
|
+
map&
|
|
269
|
+
operator=(const map& __x)
|
|
270
|
+
{
|
|
271
|
+
_M_t = __x._M_t;
|
|
272
|
+
return *this;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#if __cplusplus >= 201103L
|
|
276
|
+
/**
|
|
277
|
+
* @brief %Map move assignment operator.
|
|
278
|
+
* @param __x A %map of identical element and allocator types.
|
|
279
|
+
*
|
|
280
|
+
* The contents of @a __x are moved into this map (without copying).
|
|
281
|
+
* @a __x is a valid, but unspecified %map.
|
|
282
|
+
*/
|
|
283
|
+
map&
|
|
284
|
+
operator=(map&& __x)
|
|
285
|
+
{
|
|
286
|
+
// NB: DR 1204.
|
|
287
|
+
// NB: DR 675.
|
|
288
|
+
this->clear();
|
|
289
|
+
this->swap(__x);
|
|
290
|
+
return *this;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @brief %Map list assignment operator.
|
|
295
|
+
* @param __l An initializer_list.
|
|
296
|
+
*
|
|
297
|
+
* This function fills a %map with copies of the elements in the
|
|
298
|
+
* initializer list @a __l.
|
|
299
|
+
*
|
|
300
|
+
* Note that the assignment completely changes the %map and
|
|
301
|
+
* that the resulting %map's size is the same as the number
|
|
302
|
+
* of elements assigned. Old data may be lost.
|
|
303
|
+
*/
|
|
304
|
+
map&
|
|
305
|
+
operator=(initializer_list<value_type> __l)
|
|
306
|
+
{
|
|
307
|
+
this->clear();
|
|
308
|
+
this->insert(__l.begin(), __l.end());
|
|
309
|
+
return *this;
|
|
310
|
+
}
|
|
311
|
+
#endif
|
|
312
|
+
|
|
313
|
+
/// Get a copy of the memory allocation object.
|
|
314
|
+
allocator_type
|
|
315
|
+
get_allocator() const _GLIBCXX_NOEXCEPT
|
|
316
|
+
{ return allocator_type(_M_t.get_allocator()); }
|
|
317
|
+
|
|
318
|
+
// iterators
|
|
319
|
+
/**
|
|
320
|
+
* Returns a read/write iterator that points to the first pair in the
|
|
321
|
+
* %map.
|
|
322
|
+
* Iteration is done in ascending order according to the keys.
|
|
323
|
+
*/
|
|
324
|
+
iterator
|
|
325
|
+
begin() _GLIBCXX_NOEXCEPT
|
|
326
|
+
{ return _M_t.begin(); }
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Returns a read-only (constant) iterator that points to the first pair
|
|
330
|
+
* in the %map. Iteration is done in ascending order according to the
|
|
331
|
+
* keys.
|
|
332
|
+
*/
|
|
333
|
+
const_iterator
|
|
334
|
+
begin() const _GLIBCXX_NOEXCEPT
|
|
335
|
+
{ return _M_t.begin(); }
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Returns a read/write iterator that points one past the last
|
|
339
|
+
* pair in the %map. Iteration is done in ascending order
|
|
340
|
+
* according to the keys.
|
|
341
|
+
*/
|
|
342
|
+
iterator
|
|
343
|
+
end() _GLIBCXX_NOEXCEPT
|
|
344
|
+
{ return _M_t.end(); }
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Returns a read-only (constant) iterator that points one past the last
|
|
348
|
+
* pair in the %map. Iteration is done in ascending order according to
|
|
349
|
+
* the keys.
|
|
350
|
+
*/
|
|
351
|
+
const_iterator
|
|
352
|
+
end() const _GLIBCXX_NOEXCEPT
|
|
353
|
+
{ return _M_t.end(); }
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Returns a read/write reverse iterator that points to the last pair in
|
|
357
|
+
* the %map. Iteration is done in descending order according to the
|
|
358
|
+
* keys.
|
|
359
|
+
*/
|
|
360
|
+
reverse_iterator
|
|
361
|
+
rbegin() _GLIBCXX_NOEXCEPT
|
|
362
|
+
{ return _M_t.rbegin(); }
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Returns a read-only (constant) reverse iterator that points to the
|
|
366
|
+
* last pair in the %map. Iteration is done in descending order
|
|
367
|
+
* according to the keys.
|
|
368
|
+
*/
|
|
369
|
+
const_reverse_iterator
|
|
370
|
+
rbegin() const _GLIBCXX_NOEXCEPT
|
|
371
|
+
{ return _M_t.rbegin(); }
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Returns a read/write reverse iterator that points to one before the
|
|
375
|
+
* first pair in the %map. Iteration is done in descending order
|
|
376
|
+
* according to the keys.
|
|
377
|
+
*/
|
|
378
|
+
reverse_iterator
|
|
379
|
+
rend() _GLIBCXX_NOEXCEPT
|
|
380
|
+
{ return _M_t.rend(); }
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Returns a read-only (constant) reverse iterator that points to one
|
|
384
|
+
* before the first pair in the %map. Iteration is done in descending
|
|
385
|
+
* order according to the keys.
|
|
386
|
+
*/
|
|
387
|
+
const_reverse_iterator
|
|
388
|
+
rend() const _GLIBCXX_NOEXCEPT
|
|
389
|
+
{ return _M_t.rend(); }
|
|
390
|
+
|
|
391
|
+
#if __cplusplus >= 201103L
|
|
392
|
+
/**
|
|
393
|
+
* Returns a read-only (constant) iterator that points to the first pair
|
|
394
|
+
* in the %map. Iteration is done in ascending order according to the
|
|
395
|
+
* keys.
|
|
396
|
+
*/
|
|
397
|
+
const_iterator
|
|
398
|
+
cbegin() const noexcept
|
|
399
|
+
{ return _M_t.begin(); }
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Returns a read-only (constant) iterator that points one past the last
|
|
403
|
+
* pair in the %map. Iteration is done in ascending order according to
|
|
404
|
+
* the keys.
|
|
405
|
+
*/
|
|
406
|
+
const_iterator
|
|
407
|
+
cend() const noexcept
|
|
408
|
+
{ return _M_t.end(); }
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Returns a read-only (constant) reverse iterator that points to the
|
|
412
|
+
* last pair in the %map. Iteration is done in descending order
|
|
413
|
+
* according to the keys.
|
|
414
|
+
*/
|
|
415
|
+
const_reverse_iterator
|
|
416
|
+
crbegin() const noexcept
|
|
417
|
+
{ return _M_t.rbegin(); }
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Returns a read-only (constant) reverse iterator that points to one
|
|
421
|
+
* before the first pair in the %map. Iteration is done in descending
|
|
422
|
+
* order according to the keys.
|
|
423
|
+
*/
|
|
424
|
+
const_reverse_iterator
|
|
425
|
+
crend() const noexcept
|
|
426
|
+
{ return _M_t.rend(); }
|
|
427
|
+
#endif
|
|
428
|
+
|
|
429
|
+
// capacity
|
|
430
|
+
/** Returns true if the %map is empty. (Thus begin() would equal
|
|
431
|
+
* end().)
|
|
432
|
+
*/
|
|
433
|
+
bool
|
|
434
|
+
empty() const _GLIBCXX_NOEXCEPT
|
|
435
|
+
{ return _M_t.empty(); }
|
|
436
|
+
|
|
437
|
+
/** Returns the size of the %map. */
|
|
438
|
+
size_type
|
|
439
|
+
size() const _GLIBCXX_NOEXCEPT
|
|
440
|
+
{ return _M_t.size(); }
|
|
441
|
+
|
|
442
|
+
/** Returns the maximum size of the %map. */
|
|
443
|
+
size_type
|
|
444
|
+
max_size() const _GLIBCXX_NOEXCEPT
|
|
445
|
+
{ return _M_t.max_size(); }
|
|
446
|
+
|
|
447
|
+
// [23.3.1.2] element access
|
|
448
|
+
/**
|
|
449
|
+
* @brief Subscript ( @c [] ) access to %map data.
|
|
450
|
+
* @param __k The key for which data should be retrieved.
|
|
451
|
+
* @return A reference to the data of the (key,data) %pair.
|
|
452
|
+
*
|
|
453
|
+
* Allows for easy lookup with the subscript ( @c [] )
|
|
454
|
+
* operator. Returns data associated with the key specified in
|
|
455
|
+
* subscript. If the key does not exist, a pair with that key
|
|
456
|
+
* is created using default values, which is then returned.
|
|
457
|
+
*
|
|
458
|
+
* Lookup requires logarithmic time.
|
|
459
|
+
*/
|
|
460
|
+
mapped_type&
|
|
461
|
+
operator[](const key_type& __k)
|
|
462
|
+
{
|
|
463
|
+
// concept requirements
|
|
464
|
+
__glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
|
|
465
|
+
|
|
466
|
+
iterator __i = lower_bound(__k);
|
|
467
|
+
// __i->first is greater than or equivalent to __k.
|
|
468
|
+
if (__i == end() || key_comp()(__k, (*__i).first))
|
|
469
|
+
#if __cplusplus >= 201103L
|
|
470
|
+
__i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct,
|
|
471
|
+
std::tuple<const key_type&>(__k),
|
|
472
|
+
std::tuple<>());
|
|
473
|
+
#else
|
|
474
|
+
__i = insert(__i, value_type(__k, mapped_type()));
|
|
475
|
+
#endif
|
|
476
|
+
return (*__i).second;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
#if __cplusplus >= 201103L
|
|
480
|
+
mapped_type&
|
|
481
|
+
operator[](key_type&& __k)
|
|
482
|
+
{
|
|
483
|
+
// concept requirements
|
|
484
|
+
__glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
|
|
485
|
+
|
|
486
|
+
iterator __i = lower_bound(__k);
|
|
487
|
+
// __i->first is greater than or equivalent to __k.
|
|
488
|
+
if (__i == end() || key_comp()(__k, (*__i).first))
|
|
489
|
+
__i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct,
|
|
490
|
+
std::forward_as_tuple(std::move(__k)),
|
|
491
|
+
std::tuple<>());
|
|
492
|
+
return (*__i).second;
|
|
493
|
+
}
|
|
494
|
+
#endif
|
|
495
|
+
|
|
496
|
+
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
497
|
+
// DR 464. Suggestion for new member functions in standard containers.
|
|
498
|
+
/**
|
|
499
|
+
* @brief Access to %map data.
|
|
500
|
+
* @param __k The key for which data should be retrieved.
|
|
501
|
+
* @return A reference to the data whose key is equivalent to @a __k, if
|
|
502
|
+
* such a data is present in the %map.
|
|
503
|
+
* @throw std::out_of_range If no such data is present.
|
|
504
|
+
*/
|
|
505
|
+
mapped_type&
|
|
506
|
+
at(const key_type& __k)
|
|
507
|
+
{
|
|
508
|
+
iterator __i = lower_bound(__k);
|
|
509
|
+
if (__i == end() || key_comp()(__k, (*__i).first))
|
|
510
|
+
__throw_out_of_range(__N("map::at"));
|
|
511
|
+
return (*__i).second;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const mapped_type&
|
|
515
|
+
at(const key_type& __k) const
|
|
516
|
+
{
|
|
517
|
+
const_iterator __i = lower_bound(__k);
|
|
518
|
+
if (__i == end() || key_comp()(__k, (*__i).first))
|
|
519
|
+
__throw_out_of_range(__N("map::at"));
|
|
520
|
+
return (*__i).second;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// modifiers
|
|
524
|
+
#if __cplusplus >= 201103L
|
|
525
|
+
/**
|
|
526
|
+
* @brief Attempts to build and insert a std::pair into the %map.
|
|
527
|
+
*
|
|
528
|
+
* @param __args Arguments used to generate a new pair instance (see
|
|
529
|
+
* std::piecewise_contruct for passing arguments to each
|
|
530
|
+
* part of the pair constructor).
|
|
531
|
+
*
|
|
532
|
+
* @return A pair, of which the first element is an iterator that points
|
|
533
|
+
* to the possibly inserted pair, and the second is a bool that
|
|
534
|
+
* is true if the pair was actually inserted.
|
|
535
|
+
*
|
|
536
|
+
* This function attempts to build and insert a (key, value) %pair into
|
|
537
|
+
* the %map.
|
|
538
|
+
* A %map relies on unique keys and thus a %pair is only inserted if its
|
|
539
|
+
* first element (the key) is not already present in the %map.
|
|
540
|
+
*
|
|
541
|
+
* Insertion requires logarithmic time.
|
|
542
|
+
*/
|
|
543
|
+
template<typename... _Args>
|
|
544
|
+
std::pair<iterator, bool>
|
|
545
|
+
emplace(_Args&&... __args)
|
|
546
|
+
{ return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @brief Attempts to build and insert a std::pair into the %map.
|
|
550
|
+
*
|
|
551
|
+
* @param __pos An iterator that serves as a hint as to where the pair
|
|
552
|
+
* should be inserted.
|
|
553
|
+
* @param __args Arguments used to generate a new pair instance (see
|
|
554
|
+
* std::piecewise_contruct for passing arguments to each
|
|
555
|
+
* part of the pair constructor).
|
|
556
|
+
* @return An iterator that points to the element with key of the
|
|
557
|
+
* std::pair built from @a __args (may or may not be that
|
|
558
|
+
* std::pair).
|
|
559
|
+
*
|
|
560
|
+
* This function is not concerned about whether the insertion took place,
|
|
561
|
+
* and thus does not return a boolean like the single-argument emplace()
|
|
562
|
+
* does.
|
|
563
|
+
* Note that the first parameter is only a hint and can potentially
|
|
564
|
+
* improve the performance of the insertion process. A bad hint would
|
|
565
|
+
* cause no gains in efficiency.
|
|
566
|
+
*
|
|
567
|
+
* See
|
|
568
|
+
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
|
|
569
|
+
* for more on @a hinting.
|
|
570
|
+
*
|
|
571
|
+
* Insertion requires logarithmic time (if the hint is not taken).
|
|
572
|
+
*/
|
|
573
|
+
template<typename... _Args>
|
|
574
|
+
iterator
|
|
575
|
+
emplace_hint(const_iterator __pos, _Args&&... __args)
|
|
576
|
+
{
|
|
577
|
+
return _M_t._M_emplace_hint_unique(__pos,
|
|
578
|
+
std::forward<_Args>(__args)...);
|
|
579
|
+
}
|
|
580
|
+
#endif
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* @brief Attempts to insert a std::pair into the %map.
|
|
584
|
+
|
|
585
|
+
* @param __x Pair to be inserted (see std::make_pair for easy
|
|
586
|
+
* creation of pairs).
|
|
587
|
+
*
|
|
588
|
+
* @return A pair, of which the first element is an iterator that
|
|
589
|
+
* points to the possibly inserted pair, and the second is
|
|
590
|
+
* a bool that is true if the pair was actually inserted.
|
|
591
|
+
*
|
|
592
|
+
* This function attempts to insert a (key, value) %pair into the %map.
|
|
593
|
+
* A %map relies on unique keys and thus a %pair is only inserted if its
|
|
594
|
+
* first element (the key) is not already present in the %map.
|
|
595
|
+
*
|
|
596
|
+
* Insertion requires logarithmic time.
|
|
597
|
+
*/
|
|
598
|
+
std::pair<iterator, bool>
|
|
599
|
+
insert(const value_type& __x)
|
|
600
|
+
{ return _M_t._M_insert_unique(__x); }
|
|
601
|
+
|
|
602
|
+
#if __cplusplus >= 201103L
|
|
603
|
+
template<typename _Pair, typename = typename
|
|
604
|
+
std::enable_if<std::is_constructible<value_type,
|
|
605
|
+
_Pair&&>::value>::type>
|
|
606
|
+
std::pair<iterator, bool>
|
|
607
|
+
insert(_Pair&& __x)
|
|
608
|
+
{ return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
|
|
609
|
+
#endif
|
|
610
|
+
|
|
611
|
+
#if __cplusplus >= 201103L
|
|
612
|
+
/**
|
|
613
|
+
* @brief Attempts to insert a list of std::pairs into the %map.
|
|
614
|
+
* @param __list A std::initializer_list<value_type> of pairs to be
|
|
615
|
+
* inserted.
|
|
616
|
+
*
|
|
617
|
+
* Complexity similar to that of the range constructor.
|
|
618
|
+
*/
|
|
619
|
+
void
|
|
620
|
+
insert(std::initializer_list<value_type> __list)
|
|
621
|
+
{ insert(__list.begin(), __list.end()); }
|
|
622
|
+
#endif
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* @brief Attempts to insert a std::pair into the %map.
|
|
626
|
+
* @param __position An iterator that serves as a hint as to where the
|
|
627
|
+
* pair should be inserted.
|
|
628
|
+
* @param __x Pair to be inserted (see std::make_pair for easy creation
|
|
629
|
+
* of pairs).
|
|
630
|
+
* @return An iterator that points to the element with key of
|
|
631
|
+
* @a __x (may or may not be the %pair passed in).
|
|
632
|
+
*
|
|
633
|
+
|
|
634
|
+
* This function is not concerned about whether the insertion
|
|
635
|
+
* took place, and thus does not return a boolean like the
|
|
636
|
+
* single-argument insert() does. Note that the first
|
|
637
|
+
* parameter is only a hint and can potentially improve the
|
|
638
|
+
* performance of the insertion process. A bad hint would
|
|
639
|
+
* cause no gains in efficiency.
|
|
640
|
+
*
|
|
641
|
+
* See
|
|
642
|
+
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
|
|
643
|
+
* for more on @a hinting.
|
|
644
|
+
*
|
|
645
|
+
* Insertion requires logarithmic time (if the hint is not taken).
|
|
646
|
+
*/
|
|
647
|
+
iterator
|
|
648
|
+
#if __cplusplus >= 201103L
|
|
649
|
+
insert(const_iterator __position, const value_type& __x)
|
|
650
|
+
#else
|
|
651
|
+
insert(iterator __position, const value_type& __x)
|
|
652
|
+
#endif
|
|
653
|
+
{ return _M_t._M_insert_unique_(__position, __x); }
|
|
654
|
+
|
|
655
|
+
#if __cplusplus >= 201103L
|
|
656
|
+
template<typename _Pair, typename = typename
|
|
657
|
+
std::enable_if<std::is_constructible<value_type,
|
|
658
|
+
_Pair&&>::value>::type>
|
|
659
|
+
iterator
|
|
660
|
+
insert(const_iterator __position, _Pair&& __x)
|
|
661
|
+
{ return _M_t._M_insert_unique_(__position,
|
|
662
|
+
std::forward<_Pair>(__x)); }
|
|
663
|
+
#endif
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* @brief Template function that attempts to insert a range of elements.
|
|
667
|
+
* @param __first Iterator pointing to the start of the range to be
|
|
668
|
+
* inserted.
|
|
669
|
+
* @param __last Iterator pointing to the end of the range.
|
|
670
|
+
*
|
|
671
|
+
* Complexity similar to that of the range constructor.
|
|
672
|
+
*/
|
|
673
|
+
template<typename _InputIterator>
|
|
674
|
+
void
|
|
675
|
+
insert(_InputIterator __first, _InputIterator __last)
|
|
676
|
+
{ _M_t._M_insert_unique(__first, __last); }
|
|
677
|
+
|
|
678
|
+
#if __cplusplus >= 201103L
|
|
679
|
+
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
680
|
+
// DR 130. Associative erase should return an iterator.
|
|
681
|
+
/**
|
|
682
|
+
* @brief Erases an element from a %map.
|
|
683
|
+
* @param __position An iterator pointing to the element to be erased.
|
|
684
|
+
* @return An iterator pointing to the element immediately following
|
|
685
|
+
* @a position prior to the element being erased. If no such
|
|
686
|
+
* element exists, end() is returned.
|
|
687
|
+
*
|
|
688
|
+
* This function erases an element, pointed to by the given
|
|
689
|
+
* iterator, from a %map. Note that this function only erases
|
|
690
|
+
* the element, and that if the element is itself a pointer,
|
|
691
|
+
* the pointed-to memory is not touched in any way. Managing
|
|
692
|
+
* the pointer is the user's responsibility.
|
|
693
|
+
*/
|
|
694
|
+
iterator
|
|
695
|
+
erase(const_iterator __position)
|
|
696
|
+
{ return _M_t.erase(__position); }
|
|
697
|
+
|
|
698
|
+
// LWG 2059
|
|
699
|
+
_GLIBCXX_ABI_TAG_CXX11
|
|
700
|
+
iterator
|
|
701
|
+
erase(iterator __position)
|
|
702
|
+
{ return _M_t.erase(__position); }
|
|
703
|
+
#else
|
|
704
|
+
/**
|
|
705
|
+
* @brief Erases an element from a %map.
|
|
706
|
+
* @param __position An iterator pointing to the element to be erased.
|
|
707
|
+
*
|
|
708
|
+
* This function erases an element, pointed to by the given
|
|
709
|
+
* iterator, from a %map. Note that this function only erases
|
|
710
|
+
* the element, and that if the element is itself a pointer,
|
|
711
|
+
* the pointed-to memory is not touched in any way. Managing
|
|
712
|
+
* the pointer is the user's responsibility.
|
|
713
|
+
*/
|
|
714
|
+
void
|
|
715
|
+
erase(iterator __position)
|
|
716
|
+
{ _M_t.erase(__position); }
|
|
717
|
+
#endif
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* @brief Erases elements according to the provided key.
|
|
721
|
+
* @param __x Key of element to be erased.
|
|
722
|
+
* @return The number of elements erased.
|
|
723
|
+
*
|
|
724
|
+
* This function erases all the elements located by the given key from
|
|
725
|
+
* a %map.
|
|
726
|
+
* Note that this function only erases the element, and that if
|
|
727
|
+
* the element is itself a pointer, the pointed-to memory is not touched
|
|
728
|
+
* in any way. Managing the pointer is the user's responsibility.
|
|
729
|
+
*/
|
|
730
|
+
size_type
|
|
731
|
+
erase(const key_type& __x)
|
|
732
|
+
{ return _M_t.erase(__x); }
|
|
733
|
+
|
|
734
|
+
#if __cplusplus >= 201103L
|
|
735
|
+
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
736
|
+
// DR 130. Associative erase should return an iterator.
|
|
737
|
+
/**
|
|
738
|
+
* @brief Erases a [first,last) range of elements from a %map.
|
|
739
|
+
* @param __first Iterator pointing to the start of the range to be
|
|
740
|
+
* erased.
|
|
741
|
+
* @param __last Iterator pointing to the end of the range to
|
|
742
|
+
* be erased.
|
|
743
|
+
* @return The iterator @a __last.
|
|
744
|
+
*
|
|
745
|
+
* This function erases a sequence of elements from a %map.
|
|
746
|
+
* Note that this function only erases the element, and that if
|
|
747
|
+
* the element is itself a pointer, the pointed-to memory is not touched
|
|
748
|
+
* in any way. Managing the pointer is the user's responsibility.
|
|
749
|
+
*/
|
|
750
|
+
iterator
|
|
751
|
+
erase(const_iterator __first, const_iterator __last)
|
|
752
|
+
{ return _M_t.erase(__first, __last); }
|
|
753
|
+
#else
|
|
754
|
+
/**
|
|
755
|
+
* @brief Erases a [__first,__last) range of elements from a %map.
|
|
756
|
+
* @param __first Iterator pointing to the start of the range to be
|
|
757
|
+
* erased.
|
|
758
|
+
* @param __last Iterator pointing to the end of the range to
|
|
759
|
+
* be erased.
|
|
760
|
+
*
|
|
761
|
+
* This function erases a sequence of elements from a %map.
|
|
762
|
+
* Note that this function only erases the element, and that if
|
|
763
|
+
* the element is itself a pointer, the pointed-to memory is not touched
|
|
764
|
+
* in any way. Managing the pointer is the user's responsibility.
|
|
765
|
+
*/
|
|
766
|
+
void
|
|
767
|
+
erase(iterator __first, iterator __last)
|
|
768
|
+
{ _M_t.erase(__first, __last); }
|
|
769
|
+
#endif
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* @brief Swaps data with another %map.
|
|
773
|
+
* @param __x A %map of the same element and allocator types.
|
|
774
|
+
*
|
|
775
|
+
* This exchanges the elements between two maps in constant
|
|
776
|
+
* time. (It is only swapping a pointer, an integer, and an
|
|
777
|
+
* instance of the @c Compare type (which itself is often
|
|
778
|
+
* stateless and empty), so it should be quite fast.) Note
|
|
779
|
+
* that the global std::swap() function is specialized such
|
|
780
|
+
* that std::swap(m1,m2) will feed to this function.
|
|
781
|
+
*/
|
|
782
|
+
void
|
|
783
|
+
swap(map& __x)
|
|
784
|
+
{ _M_t.swap(__x._M_t); }
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Erases all elements in a %map. Note that this function only
|
|
788
|
+
* erases the elements, and that if the elements themselves are
|
|
789
|
+
* pointers, the pointed-to memory is not touched in any way.
|
|
790
|
+
* Managing the pointer is the user's responsibility.
|
|
791
|
+
*/
|
|
792
|
+
void
|
|
793
|
+
clear() _GLIBCXX_NOEXCEPT
|
|
794
|
+
{ _M_t.clear(); }
|
|
795
|
+
|
|
796
|
+
// observers
|
|
797
|
+
/**
|
|
798
|
+
* Returns the key comparison object out of which the %map was
|
|
799
|
+
* constructed.
|
|
800
|
+
*/
|
|
801
|
+
key_compare
|
|
802
|
+
key_comp() const
|
|
803
|
+
{ return _M_t.key_comp(); }
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Returns a value comparison object, built from the key comparison
|
|
807
|
+
* object out of which the %map was constructed.
|
|
808
|
+
*/
|
|
809
|
+
value_compare
|
|
810
|
+
value_comp() const
|
|
811
|
+
{ return value_compare(_M_t.key_comp()); }
|
|
812
|
+
|
|
813
|
+
// [23.3.1.3] map operations
|
|
814
|
+
/**
|
|
815
|
+
* @brief Tries to locate an element in a %map.
|
|
816
|
+
* @param __x Key of (key, value) %pair to be located.
|
|
817
|
+
* @return Iterator pointing to sought-after element, or end() if not
|
|
818
|
+
* found.
|
|
819
|
+
*
|
|
820
|
+
* This function takes a key and tries to locate the element with which
|
|
821
|
+
* the key matches. If successful the function returns an iterator
|
|
822
|
+
* pointing to the sought after %pair. If unsuccessful it returns the
|
|
823
|
+
* past-the-end ( @c end() ) iterator.
|
|
824
|
+
*/
|
|
825
|
+
iterator
|
|
826
|
+
find(const key_type& __x)
|
|
827
|
+
{ return _M_t.find(__x); }
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* @brief Tries to locate an element in a %map.
|
|
831
|
+
* @param __x Key of (key, value) %pair to be located.
|
|
832
|
+
* @return Read-only (constant) iterator pointing to sought-after
|
|
833
|
+
* element, or end() if not found.
|
|
834
|
+
*
|
|
835
|
+
* This function takes a key and tries to locate the element with which
|
|
836
|
+
* the key matches. If successful the function returns a constant
|
|
837
|
+
* iterator pointing to the sought after %pair. If unsuccessful it
|
|
838
|
+
* returns the past-the-end ( @c end() ) iterator.
|
|
839
|
+
*/
|
|
840
|
+
const_iterator
|
|
841
|
+
find(const key_type& __x) const
|
|
842
|
+
{ return _M_t.find(__x); }
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* @brief Finds the number of elements with given key.
|
|
846
|
+
* @param __x Key of (key, value) pairs to be located.
|
|
847
|
+
* @return Number of elements with specified key.
|
|
848
|
+
*
|
|
849
|
+
* This function only makes sense for multimaps; for map the result will
|
|
850
|
+
* either be 0 (not present) or 1 (present).
|
|
851
|
+
*/
|
|
852
|
+
size_type
|
|
853
|
+
count(const key_type& __x) const
|
|
854
|
+
{ return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* @brief Finds the beginning of a subsequence matching given key.
|
|
858
|
+
* @param __x Key of (key, value) pair to be located.
|
|
859
|
+
* @return Iterator pointing to first element equal to or greater
|
|
860
|
+
* than key, or end().
|
|
861
|
+
*
|
|
862
|
+
* This function returns the first element of a subsequence of elements
|
|
863
|
+
* that matches the given key. If unsuccessful it returns an iterator
|
|
864
|
+
* pointing to the first element that has a greater value than given key
|
|
865
|
+
* or end() if no such element exists.
|
|
866
|
+
*/
|
|
867
|
+
iterator
|
|
868
|
+
lower_bound(const key_type& __x)
|
|
869
|
+
{ return _M_t.lower_bound(__x); }
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* @brief Finds the beginning of a subsequence matching given key.
|
|
873
|
+
* @param __x Key of (key, value) pair to be located.
|
|
874
|
+
* @return Read-only (constant) iterator pointing to first element
|
|
875
|
+
* equal to or greater than key, or end().
|
|
876
|
+
*
|
|
877
|
+
* This function returns the first element of a subsequence of elements
|
|
878
|
+
* that matches the given key. If unsuccessful it returns an iterator
|
|
879
|
+
* pointing to the first element that has a greater value than given key
|
|
880
|
+
* or end() if no such element exists.
|
|
881
|
+
*/
|
|
882
|
+
const_iterator
|
|
883
|
+
lower_bound(const key_type& __x) const
|
|
884
|
+
{ return _M_t.lower_bound(__x); }
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* @brief Finds the end of a subsequence matching given key.
|
|
888
|
+
* @param __x Key of (key, value) pair to be located.
|
|
889
|
+
* @return Iterator pointing to the first element
|
|
890
|
+
* greater than key, or end().
|
|
891
|
+
*/
|
|
892
|
+
iterator
|
|
893
|
+
upper_bound(const key_type& __x)
|
|
894
|
+
{ return _M_t.upper_bound(__x); }
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* @brief Finds the end of a subsequence matching given key.
|
|
898
|
+
* @param __x Key of (key, value) pair to be located.
|
|
899
|
+
* @return Read-only (constant) iterator pointing to first iterator
|
|
900
|
+
* greater than key, or end().
|
|
901
|
+
*/
|
|
902
|
+
const_iterator
|
|
903
|
+
upper_bound(const key_type& __x) const
|
|
904
|
+
{ return _M_t.upper_bound(__x); }
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @brief Finds a subsequence matching given key.
|
|
908
|
+
* @param __x Key of (key, value) pairs to be located.
|
|
909
|
+
* @return Pair of iterators that possibly points to the subsequence
|
|
910
|
+
* matching given key.
|
|
911
|
+
*
|
|
912
|
+
* This function is equivalent to
|
|
913
|
+
* @code
|
|
914
|
+
* std::make_pair(c.lower_bound(val),
|
|
915
|
+
* c.upper_bound(val))
|
|
916
|
+
* @endcode
|
|
917
|
+
* (but is faster than making the calls separately).
|
|
918
|
+
*
|
|
919
|
+
* This function probably only makes sense for multimaps.
|
|
920
|
+
*/
|
|
921
|
+
std::pair<iterator, iterator>
|
|
922
|
+
equal_range(const key_type& __x)
|
|
923
|
+
{ return _M_t.equal_range(__x); }
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* @brief Finds a subsequence matching given key.
|
|
927
|
+
* @param __x Key of (key, value) pairs to be located.
|
|
928
|
+
* @return Pair of read-only (constant) iterators that possibly points
|
|
929
|
+
* to the subsequence matching given key.
|
|
930
|
+
*
|
|
931
|
+
* This function is equivalent to
|
|
932
|
+
* @code
|
|
933
|
+
* std::make_pair(c.lower_bound(val),
|
|
934
|
+
* c.upper_bound(val))
|
|
935
|
+
* @endcode
|
|
936
|
+
* (but is faster than making the calls separately).
|
|
937
|
+
*
|
|
938
|
+
* This function probably only makes sense for multimaps.
|
|
939
|
+
*/
|
|
940
|
+
std::pair<const_iterator, const_iterator>
|
|
941
|
+
equal_range(const key_type& __x) const
|
|
942
|
+
{ return _M_t.equal_range(__x); }
|
|
943
|
+
|
|
944
|
+
template<typename _K1, typename _T1, typename _C1, typename _A1>
|
|
945
|
+
friend bool
|
|
946
|
+
operator==(const map<_K1, _T1, _C1, _A1>&,
|
|
947
|
+
const map<_K1, _T1, _C1, _A1>&);
|
|
948
|
+
|
|
949
|
+
template<typename _K1, typename _T1, typename _C1, typename _A1>
|
|
950
|
+
friend bool
|
|
951
|
+
operator<(const map<_K1, _T1, _C1, _A1>&,
|
|
952
|
+
const map<_K1, _T1, _C1, _A1>&);
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* @brief Map equality comparison.
|
|
957
|
+
* @param __x A %map.
|
|
958
|
+
* @param __y A %map of the same type as @a x.
|
|
959
|
+
* @return True iff the size and elements of the maps are equal.
|
|
960
|
+
*
|
|
961
|
+
* This is an equivalence relation. It is linear in the size of the
|
|
962
|
+
* maps. Maps are considered equivalent if their sizes are equal,
|
|
963
|
+
* and if corresponding elements compare equal.
|
|
964
|
+
*/
|
|
965
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
966
|
+
inline bool
|
|
967
|
+
operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
968
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
969
|
+
{ return __x._M_t == __y._M_t; }
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* @brief Map ordering relation.
|
|
973
|
+
* @param __x A %map.
|
|
974
|
+
* @param __y A %map of the same type as @a x.
|
|
975
|
+
* @return True iff @a x is lexicographically less than @a y.
|
|
976
|
+
*
|
|
977
|
+
* This is a total ordering relation. It is linear in the size of the
|
|
978
|
+
* maps. The elements must be comparable with @c <.
|
|
979
|
+
*
|
|
980
|
+
* See std::lexicographical_compare() for how the determination is made.
|
|
981
|
+
*/
|
|
982
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
983
|
+
inline bool
|
|
984
|
+
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
985
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
986
|
+
{ return __x._M_t < __y._M_t; }
|
|
987
|
+
|
|
988
|
+
/// Based on operator==
|
|
989
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
990
|
+
inline bool
|
|
991
|
+
operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
992
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
993
|
+
{ return !(__x == __y); }
|
|
994
|
+
|
|
995
|
+
/// Based on operator<
|
|
996
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
997
|
+
inline bool
|
|
998
|
+
operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
999
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
1000
|
+
{ return __y < __x; }
|
|
1001
|
+
|
|
1002
|
+
/// Based on operator<
|
|
1003
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
1004
|
+
inline bool
|
|
1005
|
+
operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
1006
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
1007
|
+
{ return !(__y < __x); }
|
|
1008
|
+
|
|
1009
|
+
/// Based on operator<
|
|
1010
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
1011
|
+
inline bool
|
|
1012
|
+
operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
1013
|
+
const map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
1014
|
+
{ return !(__x < __y); }
|
|
1015
|
+
|
|
1016
|
+
/// See std::map::swap().
|
|
1017
|
+
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
|
1018
|
+
inline void
|
|
1019
|
+
swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
|
|
1020
|
+
map<_Key, _Tp, _Compare, _Alloc>& __y)
|
|
1021
|
+
{ __x.swap(__y); }
|
|
1022
|
+
|
|
1023
|
+
_GLIBCXX_END_NAMESPACE_CONTAINER
|
|
1024
|
+
} // namespace std
|
|
1025
|
+
|
|
1026
|
+
#endif /* _STL_MAP_H */
|