Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
Chris@16
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 //
|
Chris@16
|
7 // See http://www.boost.org/libs/container for documentation.
|
Chris@16
|
8 //
|
Chris@16
|
9 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_CONTAINER_MAP_HPP
|
Chris@16
|
12 #define BOOST_CONTAINER_MAP_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/container/detail/config_begin.hpp>
|
Chris@16
|
19 #include <boost/container/detail/workaround.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/container/container_fwd.hpp>
|
Chris@16
|
22 #include <utility>
|
Chris@16
|
23 #include <functional>
|
Chris@16
|
24 #include <memory>
|
Chris@16
|
25 #include <boost/container/detail/tree.hpp>
|
Chris@16
|
26 #include <boost/container/detail/value_init.hpp>
|
Chris@16
|
27 #include <boost/type_traits/has_trivial_destructor.hpp>
|
Chris@16
|
28 #include <boost/container/detail/mpl.hpp>
|
Chris@16
|
29 #include <boost/container/detail/utilities.hpp>
|
Chris@16
|
30 #include <boost/container/detail/pair.hpp>
|
Chris@16
|
31 #include <boost/container/detail/type_traits.hpp>
|
Chris@16
|
32 #include <boost/container/throw_exception.hpp>
|
Chris@16
|
33 #include <boost/move/utility.hpp>
|
Chris@16
|
34 #include <boost/move/detail/move_helpers.hpp>
|
Chris@16
|
35 #include <boost/static_assert.hpp>
|
Chris@16
|
36 #include <boost/container/detail/value_init.hpp>
|
Chris@16
|
37 #include <boost/detail/no_exceptions_support.hpp>
|
Chris@16
|
38
|
Chris@16
|
39 namespace boost {
|
Chris@16
|
40 namespace container {
|
Chris@16
|
41
|
Chris@16
|
42 /// @cond
|
Chris@16
|
43 // Forward declarations of operators == and <, needed for friend declarations.
|
Chris@16
|
44 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
45 inline bool operator==(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
46 const map<Key,T,Compare,Allocator>& y);
|
Chris@16
|
47
|
Chris@16
|
48 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
49 inline bool operator<(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
50 const map<Key,T,Compare,Allocator>& y);
|
Chris@16
|
51 /// @endcond
|
Chris@16
|
52
|
Chris@16
|
53 //! A map is a kind of associative container that supports unique keys (contains at
|
Chris@16
|
54 //! most one of each key value) and provides for fast retrieval of values of another
|
Chris@16
|
55 //! type T based on the keys. The map class supports bidirectional iterators.
|
Chris@16
|
56 //!
|
Chris@16
|
57 //! A map satisfies all of the requirements of a container and of a reversible
|
Chris@16
|
58 //! container and of an associative container. For a
|
Chris@16
|
59 //! map<Key,T> the key_type is Key and the value_type is std::pair<const Key,T>.
|
Chris@16
|
60 //!
|
Chris@16
|
61 //! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
|
Chris@16
|
62 //!
|
Chris@16
|
63 //! Allocator is the allocator to allocate the value_types
|
Chris@16
|
64 //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
|
Chris@16
|
65 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
66 template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
|
Chris@16
|
67 #else
|
Chris@16
|
68 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
69 #endif
|
Chris@16
|
70 class map
|
Chris@16
|
71 {
|
Chris@16
|
72 /// @cond
|
Chris@16
|
73 private:
|
Chris@16
|
74 BOOST_COPYABLE_AND_MOVABLE(map)
|
Chris@16
|
75
|
Chris@16
|
76 typedef std::pair<const Key, T> value_type_impl;
|
Chris@16
|
77 typedef container_detail::rbtree
|
Chris@16
|
78 <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
|
Chris@16
|
79 typedef container_detail::pair <Key, T> movable_value_type_impl;
|
Chris@16
|
80 typedef container_detail::tree_value_compare
|
Chris@16
|
81 < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
|
Chris@16
|
82 > value_compare_impl;
|
Chris@16
|
83 tree_t m_tree; // red-black tree representing map
|
Chris@16
|
84 /// @endcond
|
Chris@16
|
85
|
Chris@16
|
86 public:
|
Chris@16
|
87 //////////////////////////////////////////////
|
Chris@16
|
88 //
|
Chris@16
|
89 // types
|
Chris@16
|
90 //
|
Chris@16
|
91 //////////////////////////////////////////////
|
Chris@16
|
92
|
Chris@16
|
93 typedef Key key_type;
|
Chris@16
|
94 typedef T mapped_type;
|
Chris@16
|
95 typedef std::pair<const Key, T> value_type;
|
Chris@16
|
96 typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
|
Chris@16
|
97 typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
|
Chris@16
|
98 typedef typename boost::container::allocator_traits<Allocator>::reference reference;
|
Chris@16
|
99 typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
|
Chris@16
|
100 typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
|
Chris@16
|
101 typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
|
Chris@16
|
102 typedef Allocator allocator_type;
|
Chris@16
|
103 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
|
Chris@16
|
104 typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
|
Chris@16
|
105 typedef Compare key_compare;
|
Chris@16
|
106 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
|
Chris@16
|
107 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
|
Chris@16
|
108 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
|
Chris@16
|
109 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
|
Chris@16
|
110 typedef std::pair<key_type, mapped_type> nonconst_value_type;
|
Chris@16
|
111 typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
|
Chris@16
|
112
|
Chris@16
|
113 //////////////////////////////////////////////
|
Chris@16
|
114 //
|
Chris@16
|
115 // construct/copy/destroy
|
Chris@16
|
116 //
|
Chris@16
|
117 //////////////////////////////////////////////
|
Chris@16
|
118
|
Chris@16
|
119 //! <b>Effects</b>: Default constructs an empty map.
|
Chris@16
|
120 //!
|
Chris@16
|
121 //! <b>Complexity</b>: Constant.
|
Chris@16
|
122 map()
|
Chris@16
|
123 : m_tree()
|
Chris@16
|
124 {
|
Chris@16
|
125 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
126 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
127 }
|
Chris@16
|
128
|
Chris@16
|
129 //! <b>Effects</b>: Constructs an empty map using the specified comparison object
|
Chris@16
|
130 //! and allocator.
|
Chris@16
|
131 //!
|
Chris@16
|
132 //! <b>Complexity</b>: Constant.
|
Chris@16
|
133 explicit map(const Compare& comp,
|
Chris@16
|
134 const allocator_type& a = allocator_type())
|
Chris@16
|
135 : m_tree(comp, a)
|
Chris@16
|
136 {
|
Chris@16
|
137 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
138 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
139 }
|
Chris@16
|
140
|
Chris@16
|
141 //! <b>Effects</b>: Constructs an empty map using the specified allocator.
|
Chris@16
|
142 //!
|
Chris@16
|
143 //! <b>Complexity</b>: Constant.
|
Chris@16
|
144 explicit map(const allocator_type& a)
|
Chris@16
|
145 : m_tree(a)
|
Chris@16
|
146 {
|
Chris@16
|
147 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
148 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
149 }
|
Chris@16
|
150
|
Chris@16
|
151 //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
|
Chris@16
|
152 //! allocator, and inserts elements from the range [first ,last ).
|
Chris@16
|
153 //!
|
Chris@16
|
154 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
|
Chris@16
|
155 //! comp and otherwise N logN, where N is last - first.
|
Chris@16
|
156 template <class InputIterator>
|
Chris@16
|
157 map(InputIterator first, InputIterator last, const Compare& comp = Compare(),
|
Chris@16
|
158 const allocator_type& a = allocator_type())
|
Chris@16
|
159 : m_tree(true, first, last, comp, a)
|
Chris@16
|
160 {
|
Chris@16
|
161 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
162 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
163 }
|
Chris@16
|
164
|
Chris@16
|
165 //! <b>Effects</b>: Constructs an empty map using the specified comparison object and
|
Chris@16
|
166 //! allocator, and inserts elements from the ordered unique range [first ,last). This function
|
Chris@16
|
167 //! is more efficient than the normal range creation for ordered ranges.
|
Chris@16
|
168 //!
|
Chris@16
|
169 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
|
Chris@16
|
170 //! unique values.
|
Chris@16
|
171 //!
|
Chris@16
|
172 //! <b>Complexity</b>: Linear in N.
|
Chris@16
|
173 //!
|
Chris@16
|
174 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
175 template <class InputIterator>
|
Chris@16
|
176 map( ordered_unique_range_t, InputIterator first, InputIterator last
|
Chris@16
|
177 , const Compare& comp = Compare(), const allocator_type& a = allocator_type())
|
Chris@16
|
178 : m_tree(ordered_range, first, last, comp, a)
|
Chris@16
|
179 {
|
Chris@16
|
180 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
181 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
182 }
|
Chris@16
|
183
|
Chris@16
|
184 //! <b>Effects</b>: Copy constructs a map.
|
Chris@16
|
185 //!
|
Chris@16
|
186 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
187 map(const map& x)
|
Chris@16
|
188 : m_tree(x.m_tree)
|
Chris@16
|
189 {
|
Chris@16
|
190 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
191 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
192 }
|
Chris@16
|
193
|
Chris@16
|
194 //! <b>Effects</b>: Move constructs a map. Constructs *this using x's resources.
|
Chris@16
|
195 //!
|
Chris@16
|
196 //! <b>Complexity</b>: Constant.
|
Chris@16
|
197 //!
|
Chris@16
|
198 //! <b>Postcondition</b>: x is emptied.
|
Chris@16
|
199 map(BOOST_RV_REF(map) x)
|
Chris@16
|
200 : m_tree(boost::move(x.m_tree))
|
Chris@16
|
201 {
|
Chris@16
|
202 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
203 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
204 }
|
Chris@16
|
205
|
Chris@16
|
206 //! <b>Effects</b>: Copy constructs a map using the specified allocator.
|
Chris@16
|
207 //!
|
Chris@16
|
208 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
209 map(const map& x, const allocator_type &a)
|
Chris@16
|
210 : m_tree(x.m_tree, a)
|
Chris@16
|
211 {
|
Chris@16
|
212 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
213 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
214 }
|
Chris@16
|
215
|
Chris@16
|
216 //! <b>Effects</b>: Move constructs a map using the specified allocator.
|
Chris@16
|
217 //! Constructs *this using x's resources.
|
Chris@16
|
218 //!
|
Chris@16
|
219 //! <b>Complexity</b>: Constant if x == x.get_allocator(), linear otherwise.
|
Chris@16
|
220 //!
|
Chris@16
|
221 //! <b>Postcondition</b>: x is emptied.
|
Chris@16
|
222 map(BOOST_RV_REF(map) x, const allocator_type &a)
|
Chris@16
|
223 : m_tree(boost::move(x.m_tree), a)
|
Chris@16
|
224 {
|
Chris@16
|
225 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
226 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
227 }
|
Chris@16
|
228
|
Chris@16
|
229 //! <b>Effects</b>: Makes *this a copy of x.
|
Chris@16
|
230 //!
|
Chris@16
|
231 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
232 map& operator=(BOOST_COPY_ASSIGN_REF(map) x)
|
Chris@16
|
233 { m_tree = x.m_tree; return *this; }
|
Chris@16
|
234
|
Chris@16
|
235 //! <b>Effects</b>: this->swap(x.get()).
|
Chris@16
|
236 //!
|
Chris@16
|
237 //! <b>Complexity</b>: Constant.
|
Chris@16
|
238 map& operator=(BOOST_RV_REF(map) x)
|
Chris@16
|
239 { m_tree = boost::move(x.m_tree); return *this; }
|
Chris@16
|
240
|
Chris@16
|
241 //! <b>Effects</b>: Returns a copy of the Allocator that
|
Chris@16
|
242 //! was passed to the object's constructor.
|
Chris@16
|
243 //!
|
Chris@16
|
244 //! <b>Complexity</b>: Constant.
|
Chris@16
|
245 allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
246 { return m_tree.get_allocator(); }
|
Chris@16
|
247
|
Chris@16
|
248 //! <b>Effects</b>: Returns a reference to the internal allocator.
|
Chris@16
|
249 //!
|
Chris@16
|
250 //! <b>Throws</b>: Nothing
|
Chris@16
|
251 //!
|
Chris@16
|
252 //! <b>Complexity</b>: Constant.
|
Chris@16
|
253 //!
|
Chris@16
|
254 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
255 stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
256 { return m_tree.get_stored_allocator(); }
|
Chris@16
|
257
|
Chris@16
|
258 //! <b>Effects</b>: Returns a reference to the internal allocator.
|
Chris@16
|
259 //!
|
Chris@16
|
260 //! <b>Throws</b>: Nothing
|
Chris@16
|
261 //!
|
Chris@16
|
262 //! <b>Complexity</b>: Constant.
|
Chris@16
|
263 //!
|
Chris@16
|
264 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
265 const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
266 { return m_tree.get_stored_allocator(); }
|
Chris@16
|
267
|
Chris@16
|
268 //////////////////////////////////////////////
|
Chris@16
|
269 //
|
Chris@16
|
270 // iterators
|
Chris@16
|
271 //
|
Chris@16
|
272 //////////////////////////////////////////////
|
Chris@16
|
273
|
Chris@16
|
274 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
|
Chris@16
|
275 //!
|
Chris@16
|
276 //! <b>Throws</b>: Nothing.
|
Chris@16
|
277 //!
|
Chris@16
|
278 //! <b>Complexity</b>: Constant.
|
Chris@16
|
279 iterator begin() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
280 { return m_tree.begin(); }
|
Chris@16
|
281
|
Chris@16
|
282 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
|
Chris@16
|
283 //!
|
Chris@16
|
284 //! <b>Throws</b>: Nothing.
|
Chris@16
|
285 //!
|
Chris@16
|
286 //! <b>Complexity</b>: Constant.
|
Chris@16
|
287 const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
288 { return this->cbegin(); }
|
Chris@16
|
289
|
Chris@16
|
290 //! <b>Effects</b>: Returns an iterator to the end of the container.
|
Chris@16
|
291 //!
|
Chris@16
|
292 //! <b>Throws</b>: Nothing.
|
Chris@16
|
293 //!
|
Chris@16
|
294 //! <b>Complexity</b>: Constant.
|
Chris@16
|
295 iterator end() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
296 { return m_tree.end(); }
|
Chris@16
|
297
|
Chris@16
|
298 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
|
Chris@16
|
299 //!
|
Chris@16
|
300 //! <b>Throws</b>: Nothing.
|
Chris@16
|
301 //!
|
Chris@16
|
302 //! <b>Complexity</b>: Constant.
|
Chris@16
|
303 const_iterator end() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
304 { return this->cend(); }
|
Chris@16
|
305
|
Chris@16
|
306 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
|
Chris@16
|
307 //! of the reversed container.
|
Chris@16
|
308 //!
|
Chris@16
|
309 //! <b>Throws</b>: Nothing.
|
Chris@16
|
310 //!
|
Chris@16
|
311 //! <b>Complexity</b>: Constant.
|
Chris@16
|
312 reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
313 { return m_tree.rbegin(); }
|
Chris@16
|
314
|
Chris@16
|
315 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
|
Chris@16
|
316 //! of the reversed container.
|
Chris@16
|
317 //!
|
Chris@16
|
318 //! <b>Throws</b>: Nothing.
|
Chris@16
|
319 //!
|
Chris@16
|
320 //! <b>Complexity</b>: Constant.
|
Chris@16
|
321 const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
322 { return this->crbegin(); }
|
Chris@16
|
323
|
Chris@16
|
324 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
|
Chris@16
|
325 //! of the reversed container.
|
Chris@16
|
326 //!
|
Chris@16
|
327 //! <b>Throws</b>: Nothing.
|
Chris@16
|
328 //!
|
Chris@16
|
329 //! <b>Complexity</b>: Constant.
|
Chris@16
|
330 reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
331 { return m_tree.rend(); }
|
Chris@16
|
332
|
Chris@16
|
333 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
|
Chris@16
|
334 //! of the reversed container.
|
Chris@16
|
335 //!
|
Chris@16
|
336 //! <b>Throws</b>: Nothing.
|
Chris@16
|
337 //!
|
Chris@16
|
338 //! <b>Complexity</b>: Constant.
|
Chris@16
|
339 const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
340 { return this->crend(); }
|
Chris@16
|
341
|
Chris@16
|
342 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
|
Chris@16
|
343 //!
|
Chris@16
|
344 //! <b>Throws</b>: Nothing.
|
Chris@16
|
345 //!
|
Chris@16
|
346 //! <b>Complexity</b>: Constant.
|
Chris@16
|
347 const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
348 { return m_tree.begin(); }
|
Chris@16
|
349
|
Chris@16
|
350 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
|
Chris@16
|
351 //!
|
Chris@16
|
352 //! <b>Throws</b>: Nothing.
|
Chris@16
|
353 //!
|
Chris@16
|
354 //! <b>Complexity</b>: Constant.
|
Chris@16
|
355 const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
356 { return m_tree.end(); }
|
Chris@16
|
357
|
Chris@16
|
358 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
|
Chris@16
|
359 //! of the reversed container.
|
Chris@16
|
360 //!
|
Chris@16
|
361 //! <b>Throws</b>: Nothing.
|
Chris@16
|
362 //!
|
Chris@16
|
363 //! <b>Complexity</b>: Constant.
|
Chris@16
|
364 const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
365 { return m_tree.rbegin(); }
|
Chris@16
|
366
|
Chris@16
|
367 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
|
Chris@16
|
368 //! of the reversed container.
|
Chris@16
|
369 //!
|
Chris@16
|
370 //! <b>Throws</b>: Nothing.
|
Chris@16
|
371 //!
|
Chris@16
|
372 //! <b>Complexity</b>: Constant.
|
Chris@16
|
373 const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
374 { return m_tree.rend(); }
|
Chris@16
|
375
|
Chris@16
|
376 //////////////////////////////////////////////
|
Chris@16
|
377 //
|
Chris@16
|
378 // capacity
|
Chris@16
|
379 //
|
Chris@16
|
380 //////////////////////////////////////////////
|
Chris@16
|
381
|
Chris@16
|
382 //! <b>Effects</b>: Returns true if the container contains no elements.
|
Chris@16
|
383 //!
|
Chris@16
|
384 //! <b>Throws</b>: Nothing.
|
Chris@16
|
385 //!
|
Chris@16
|
386 //! <b>Complexity</b>: Constant.
|
Chris@16
|
387 bool empty() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
388 { return m_tree.empty(); }
|
Chris@16
|
389
|
Chris@16
|
390 //! <b>Effects</b>: Returns the number of the elements contained in the container.
|
Chris@16
|
391 //!
|
Chris@16
|
392 //! <b>Throws</b>: Nothing.
|
Chris@16
|
393 //!
|
Chris@16
|
394 //! <b>Complexity</b>: Constant.
|
Chris@16
|
395 size_type size() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
396 { return m_tree.size(); }
|
Chris@16
|
397
|
Chris@16
|
398 //! <b>Effects</b>: Returns the largest possible size of the container.
|
Chris@16
|
399 //!
|
Chris@16
|
400 //! <b>Throws</b>: Nothing.
|
Chris@16
|
401 //!
|
Chris@16
|
402 //! <b>Complexity</b>: Constant.
|
Chris@16
|
403 size_type max_size() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
404 { return m_tree.max_size(); }
|
Chris@16
|
405
|
Chris@16
|
406 //////////////////////////////////////////////
|
Chris@16
|
407 //
|
Chris@16
|
408 // element access
|
Chris@16
|
409 //
|
Chris@16
|
410 //////////////////////////////////////////////
|
Chris@16
|
411
|
Chris@16
|
412 #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@16
|
413 //! Effects: If there is no key equivalent to x in the map, inserts
|
Chris@16
|
414 //! value_type(x, T()) into the map.
|
Chris@16
|
415 //!
|
Chris@16
|
416 //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
|
Chris@16
|
417 //!
|
Chris@16
|
418 //! Complexity: Logarithmic.
|
Chris@16
|
419 mapped_type& operator[](const key_type &k);
|
Chris@16
|
420
|
Chris@16
|
421 //! Effects: If there is no key equivalent to x in the map, inserts
|
Chris@16
|
422 //! value_type(boost::move(x), T()) into the map (the key is move-constructed)
|
Chris@16
|
423 //!
|
Chris@16
|
424 //! Returns: Allocator reference to the mapped_type corresponding to x in *this.
|
Chris@16
|
425 //!
|
Chris@16
|
426 //! Complexity: Logarithmic.
|
Chris@16
|
427 mapped_type& operator[](key_type &&k);
|
Chris@16
|
428 #else
|
Chris@16
|
429 BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript)
|
Chris@16
|
430 #endif
|
Chris@16
|
431
|
Chris@16
|
432 //! Returns: Allocator reference to the element whose key is equivalent to x.
|
Chris@16
|
433 //! Throws: An exception object of type out_of_range if no such element is present.
|
Chris@16
|
434 //! Complexity: logarithmic.
|
Chris@16
|
435 T& at(const key_type& k)
|
Chris@16
|
436 {
|
Chris@16
|
437 iterator i = this->find(k);
|
Chris@16
|
438 if(i == this->end()){
|
Chris@16
|
439 throw_out_of_range("map::at key not found");
|
Chris@16
|
440 }
|
Chris@16
|
441 return i->second;
|
Chris@16
|
442 }
|
Chris@16
|
443
|
Chris@16
|
444 //! Returns: Allocator reference to the element whose key is equivalent to x.
|
Chris@16
|
445 //! Throws: An exception object of type out_of_range if no such element is present.
|
Chris@16
|
446 //! Complexity: logarithmic.
|
Chris@16
|
447 const T& at(const key_type& k) const
|
Chris@16
|
448 {
|
Chris@16
|
449 const_iterator i = this->find(k);
|
Chris@16
|
450 if(i == this->end()){
|
Chris@16
|
451 throw_out_of_range("map::at key not found");
|
Chris@16
|
452 }
|
Chris@16
|
453 return i->second;
|
Chris@16
|
454 }
|
Chris@16
|
455
|
Chris@16
|
456 //////////////////////////////////////////////
|
Chris@16
|
457 //
|
Chris@16
|
458 // modifiers
|
Chris@16
|
459 //
|
Chris@16
|
460 //////////////////////////////////////////////
|
Chris@16
|
461
|
Chris@16
|
462 //! <b>Effects</b>: Inserts x if and only if there is no element in the container
|
Chris@16
|
463 //! with key equivalent to the key of x.
|
Chris@16
|
464 //!
|
Chris@16
|
465 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
466 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
467 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
468 //!
|
Chris@16
|
469 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
470 std::pair<iterator,bool> insert(const value_type& x)
|
Chris@16
|
471 { return m_tree.insert_unique(x); }
|
Chris@16
|
472
|
Chris@16
|
473 //! <b>Effects</b>: Inserts a new value_type created from the pair if and only if
|
Chris@16
|
474 //! there is no element in the container with key equivalent to the key of x.
|
Chris@16
|
475 //!
|
Chris@16
|
476 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
477 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
478 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
479 //!
|
Chris@16
|
480 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
481 std::pair<iterator,bool> insert(const nonconst_value_type& x)
|
Chris@16
|
482 { return m_tree.insert_unique(x); }
|
Chris@16
|
483
|
Chris@16
|
484 //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
|
Chris@16
|
485 //! only if there is no element in the container with key equivalent to the key of x.
|
Chris@16
|
486 //!
|
Chris@16
|
487 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
488 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
489 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
490 //!
|
Chris@16
|
491 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
492 std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
|
Chris@16
|
493 { return m_tree.insert_unique(boost::move(x)); }
|
Chris@16
|
494
|
Chris@16
|
495 //! <b>Effects</b>: Inserts a new value_type move constructed from the pair if and
|
Chris@16
|
496 //! only if there is no element in the container with key equivalent to the key of x.
|
Chris@16
|
497 //!
|
Chris@16
|
498 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
499 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
500 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
501 //!
|
Chris@16
|
502 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
503 std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
|
Chris@16
|
504 { return m_tree.insert_unique(boost::move(x)); }
|
Chris@16
|
505
|
Chris@16
|
506 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
|
Chris@16
|
507 //! no element in the container with key equivalent to the key of x.
|
Chris@16
|
508 //!
|
Chris@16
|
509 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
510 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
511 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
512 //!
|
Chris@16
|
513 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
514 std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
|
Chris@16
|
515 { return m_tree.insert_unique(boost::move(x)); }
|
Chris@16
|
516
|
Chris@16
|
517 //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
|
Chris@16
|
518 //! no element in the container with key equivalent to the key of x.
|
Chris@16
|
519 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
520 //!
|
Chris@16
|
521 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
522 //! to the key of x.
|
Chris@16
|
523 //!
|
Chris@16
|
524 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
525 //! is inserted right before p.
|
Chris@16
|
526 iterator insert(const_iterator position, const value_type& x)
|
Chris@16
|
527 { return m_tree.insert_unique(position, x); }
|
Chris@16
|
528
|
Chris@16
|
529 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
|
Chris@16
|
530 //! no element in the container with key equivalent to the key of x.
|
Chris@16
|
531 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
532 //!
|
Chris@16
|
533 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
534 //! to the key of x.
|
Chris@16
|
535 //!
|
Chris@16
|
536 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
537 //! is inserted right before p.
|
Chris@16
|
538 iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
|
Chris@16
|
539 { return m_tree.insert_unique(position, boost::move(x)); }
|
Chris@16
|
540
|
Chris@16
|
541 //! <b>Effects</b>: Move constructs a new value from x if and only if there is
|
Chris@16
|
542 //! no element in the container with key equivalent to the key of x.
|
Chris@16
|
543 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
544 //!
|
Chris@16
|
545 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
546 //! to the key of x.
|
Chris@16
|
547 //!
|
Chris@16
|
548 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
549 //! is inserted right before p.
|
Chris@16
|
550 iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
|
Chris@16
|
551 { return m_tree.insert_unique(position, boost::move(x)); }
|
Chris@16
|
552
|
Chris@16
|
553 //! <b>Effects</b>: Inserts a copy of x in the container.
|
Chris@16
|
554 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
555 //!
|
Chris@16
|
556 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
|
Chris@16
|
557 //!
|
Chris@16
|
558 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
559 iterator insert(const_iterator position, const nonconst_value_type& x)
|
Chris@16
|
560 { return m_tree.insert_unique(position, x); }
|
Chris@16
|
561
|
Chris@16
|
562 //! <b>Effects</b>: Inserts an element move constructed from x in the container.
|
Chris@16
|
563 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
564 //!
|
Chris@16
|
565 //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
|
Chris@16
|
566 //!
|
Chris@16
|
567 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
568 iterator insert(const_iterator position, BOOST_RV_REF(value_type) x)
|
Chris@16
|
569 { return m_tree.insert_unique(position, boost::move(x)); }
|
Chris@16
|
570
|
Chris@16
|
571 //! <b>Requires</b>: first, last are not iterators into *this.
|
Chris@16
|
572 //!
|
Chris@16
|
573 //! <b>Effects</b>: inserts each element from the range [first,last) if and only
|
Chris@16
|
574 //! if there is no element with key equivalent to the key of that element.
|
Chris@16
|
575 //!
|
Chris@16
|
576 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
Chris@16
|
577 template <class InputIterator>
|
Chris@16
|
578 void insert(InputIterator first, InputIterator last)
|
Chris@16
|
579 { m_tree.insert_unique(first, last); }
|
Chris@16
|
580
|
Chris@16
|
581 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@16
|
582
|
Chris@16
|
583 //! <b>Effects</b>: Inserts an object x of type T constructed with
|
Chris@16
|
584 //! std::forward<Args>(args)... in the container if and only if there is
|
Chris@16
|
585 //! no element in the container with an equivalent key.
|
Chris@16
|
586 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
587 //!
|
Chris@16
|
588 //! <b>Returns</b>: The bool component of the returned pair is true if and only
|
Chris@16
|
589 //! if the insertion takes place, and the iterator component of the pair
|
Chris@16
|
590 //! points to the element with key equivalent to the key of x.
|
Chris@16
|
591 //!
|
Chris@16
|
592 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
593 //! is inserted right before p.
|
Chris@16
|
594 template <class... Args>
|
Chris@16
|
595 std::pair<iterator,bool> emplace(Args&&... args)
|
Chris@16
|
596 { return m_tree.emplace_unique(boost::forward<Args>(args)...); }
|
Chris@16
|
597
|
Chris@16
|
598 //! <b>Effects</b>: Inserts an object of type T constructed with
|
Chris@16
|
599 //! std::forward<Args>(args)... in the container if and only if there is
|
Chris@16
|
600 //! no element in the container with an equivalent key.
|
Chris@16
|
601 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
602 //!
|
Chris@16
|
603 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
604 //! to the key of x.
|
Chris@16
|
605 //!
|
Chris@16
|
606 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
607 //! is inserted right before p.
|
Chris@16
|
608 template <class... Args>
|
Chris@16
|
609 iterator emplace_hint(const_iterator hint, Args&&... args)
|
Chris@16
|
610 { return m_tree.emplace_hint_unique(hint, boost::forward<Args>(args)...); }
|
Chris@16
|
611
|
Chris@16
|
612 #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
Chris@16
|
613
|
Chris@16
|
614 #define BOOST_PP_LOCAL_MACRO(n) \
|
Chris@16
|
615 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
|
Chris@16
|
616 std::pair<iterator,bool> emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
|
Chris@16
|
617 { return m_tree.emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
|
Chris@16
|
618 \
|
Chris@16
|
619 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
|
Chris@16
|
620 iterator emplace_hint(const_iterator hint \
|
Chris@16
|
621 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
|
Chris@16
|
622 { return m_tree.emplace_hint_unique(hint \
|
Chris@16
|
623 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
|
Chris@16
|
624 //!
|
Chris@16
|
625 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
|
Chris@16
|
626 #include BOOST_PP_LOCAL_ITERATE()
|
Chris@16
|
627
|
Chris@16
|
628 #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
Chris@16
|
629
|
Chris@16
|
630 //! <b>Effects</b>: Erases the element pointed to by position.
|
Chris@16
|
631 //!
|
Chris@16
|
632 //! <b>Returns</b>: Returns an iterator pointing to the element immediately
|
Chris@16
|
633 //! following q prior to the element being erased. If no such element exists,
|
Chris@16
|
634 //! returns end().
|
Chris@16
|
635 //!
|
Chris@16
|
636 //! <b>Complexity</b>: Amortized constant time
|
Chris@16
|
637 iterator erase(const_iterator position) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
638 { return m_tree.erase(position); }
|
Chris@16
|
639
|
Chris@16
|
640 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
|
Chris@16
|
641 //!
|
Chris@16
|
642 //! <b>Returns</b>: Returns the number of erased elements.
|
Chris@16
|
643 //!
|
Chris@16
|
644 //! <b>Complexity</b>: log(size()) + count(k)
|
Chris@16
|
645 size_type erase(const key_type& x) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
646 { return m_tree.erase(x); }
|
Chris@16
|
647
|
Chris@16
|
648 //! <b>Effects</b>: Erases all the elements in the range [first, last).
|
Chris@16
|
649 //!
|
Chris@16
|
650 //! <b>Returns</b>: Returns last.
|
Chris@16
|
651 //!
|
Chris@16
|
652 //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
|
Chris@16
|
653 iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
654 { return m_tree.erase(first, last); }
|
Chris@16
|
655
|
Chris@16
|
656 //! <b>Effects</b>: Swaps the contents of *this and x.
|
Chris@16
|
657 //!
|
Chris@16
|
658 //! <b>Throws</b>: Nothing.
|
Chris@16
|
659 //!
|
Chris@16
|
660 //! <b>Complexity</b>: Constant.
|
Chris@16
|
661 void swap(map& x)
|
Chris@16
|
662 { m_tree.swap(x.m_tree); }
|
Chris@16
|
663
|
Chris@16
|
664 //! <b>Effects</b>: erase(a.begin(),a.end()).
|
Chris@16
|
665 //!
|
Chris@16
|
666 //! <b>Postcondition</b>: size() == 0.
|
Chris@16
|
667 //!
|
Chris@16
|
668 //! <b>Complexity</b>: linear in size().
|
Chris@16
|
669 void clear() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
670 { m_tree.clear(); }
|
Chris@16
|
671
|
Chris@16
|
672 //////////////////////////////////////////////
|
Chris@16
|
673 //
|
Chris@16
|
674 // observers
|
Chris@16
|
675 //
|
Chris@16
|
676 //////////////////////////////////////////////
|
Chris@16
|
677
|
Chris@16
|
678 //! <b>Effects</b>: Returns the comparison object out
|
Chris@16
|
679 //! of which a was constructed.
|
Chris@16
|
680 //!
|
Chris@16
|
681 //! <b>Complexity</b>: Constant.
|
Chris@16
|
682 key_compare key_comp() const
|
Chris@16
|
683 { return m_tree.key_comp(); }
|
Chris@16
|
684
|
Chris@16
|
685 //! <b>Effects</b>: Returns an object of value_compare constructed out
|
Chris@16
|
686 //! of the comparison object.
|
Chris@16
|
687 //!
|
Chris@16
|
688 //! <b>Complexity</b>: Constant.
|
Chris@16
|
689 value_compare value_comp() const
|
Chris@16
|
690 { return value_compare(m_tree.key_comp()); }
|
Chris@16
|
691
|
Chris@16
|
692 //////////////////////////////////////////////
|
Chris@16
|
693 //
|
Chris@16
|
694 // map operations
|
Chris@16
|
695 //
|
Chris@16
|
696 //////////////////////////////////////////////
|
Chris@16
|
697
|
Chris@16
|
698 //! <b>Returns</b>: An iterator pointing to an element with the key
|
Chris@16
|
699 //! equivalent to x, or end() if such an element is not found.
|
Chris@16
|
700 //!
|
Chris@16
|
701 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
702 iterator find(const key_type& x)
|
Chris@16
|
703 { return m_tree.find(x); }
|
Chris@16
|
704
|
Chris@16
|
705 //! <b>Returns</b>: Allocator const_iterator pointing to an element with the key
|
Chris@16
|
706 //! equivalent to x, or end() if such an element is not found.
|
Chris@16
|
707 //!
|
Chris@16
|
708 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
709 const_iterator find(const key_type& x) const
|
Chris@16
|
710 { return m_tree.find(x); }
|
Chris@16
|
711
|
Chris@16
|
712 //! <b>Returns</b>: The number of elements with key equivalent to x.
|
Chris@16
|
713 //!
|
Chris@16
|
714 //! <b>Complexity</b>: log(size())+count(k)
|
Chris@16
|
715 size_type count(const key_type& x) const
|
Chris@16
|
716 { return static_cast<size_type>(m_tree.find(x) != m_tree.end()); }
|
Chris@16
|
717
|
Chris@16
|
718 //! <b>Returns</b>: An iterator pointing to the first element with key not less
|
Chris@16
|
719 //! than k, or a.end() if such an element is not found.
|
Chris@16
|
720 //!
|
Chris@16
|
721 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
722 iterator lower_bound(const key_type& x)
|
Chris@16
|
723 { return m_tree.lower_bound(x); }
|
Chris@16
|
724
|
Chris@16
|
725 //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
|
Chris@16
|
726 //! less than k, or a.end() if such an element is not found.
|
Chris@16
|
727 //!
|
Chris@16
|
728 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
729 const_iterator lower_bound(const key_type& x) const
|
Chris@16
|
730 { return m_tree.lower_bound(x); }
|
Chris@16
|
731
|
Chris@16
|
732 //! <b>Returns</b>: An iterator pointing to the first element with key not less
|
Chris@16
|
733 //! than x, or end() if such an element is not found.
|
Chris@16
|
734 //!
|
Chris@16
|
735 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
736 iterator upper_bound(const key_type& x)
|
Chris@16
|
737 { return m_tree.upper_bound(x); }
|
Chris@16
|
738
|
Chris@16
|
739 //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
|
Chris@16
|
740 //! less than x, or end() if such an element is not found.
|
Chris@16
|
741 //!
|
Chris@16
|
742 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
743 const_iterator upper_bound(const key_type& x) const
|
Chris@16
|
744 { return m_tree.upper_bound(x); }
|
Chris@16
|
745
|
Chris@16
|
746 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
|
Chris@16
|
747 //!
|
Chris@16
|
748 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
749 std::pair<iterator,iterator> equal_range(const key_type& x)
|
Chris@16
|
750 { return m_tree.equal_range(x); }
|
Chris@16
|
751
|
Chris@16
|
752 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
|
Chris@16
|
753 //!
|
Chris@16
|
754 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
755 std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
Chris@16
|
756 { return m_tree.equal_range(x); }
|
Chris@16
|
757
|
Chris@16
|
758 /// @cond
|
Chris@16
|
759 template <class K1, class T1, class C1, class A1>
|
Chris@16
|
760 friend bool operator== (const map<K1, T1, C1, A1>&,
|
Chris@16
|
761 const map<K1, T1, C1, A1>&);
|
Chris@16
|
762 template <class K1, class T1, class C1, class A1>
|
Chris@16
|
763 friend bool operator< (const map<K1, T1, C1, A1>&,
|
Chris@16
|
764 const map<K1, T1, C1, A1>&);
|
Chris@16
|
765 private:
|
Chris@16
|
766 mapped_type& priv_subscript(const key_type &k)
|
Chris@16
|
767 {
|
Chris@16
|
768 //we can optimize this
|
Chris@16
|
769 iterator i = lower_bound(k);
|
Chris@16
|
770 // i->first is greater than or equivalent to k.
|
Chris@16
|
771 if (i == end() || key_comp()(k, (*i).first)){
|
Chris@16
|
772 container_detail::value_init<mapped_type> m;
|
Chris@16
|
773 movable_value_type val(k, boost::move(m.m_t));
|
Chris@16
|
774 i = insert(i, boost::move(val));
|
Chris@16
|
775 }
|
Chris@16
|
776 return (*i).second;
|
Chris@16
|
777 }
|
Chris@16
|
778
|
Chris@16
|
779 mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk)
|
Chris@16
|
780 {
|
Chris@16
|
781 key_type &k = mk;
|
Chris@16
|
782 //we can optimize this
|
Chris@16
|
783 iterator i = lower_bound(k);
|
Chris@16
|
784 // i->first is greater than or equivalent to k.
|
Chris@16
|
785 if (i == end() || key_comp()(k, (*i).first)){
|
Chris@16
|
786 container_detail::value_init<mapped_type> m;
|
Chris@16
|
787 movable_value_type val(boost::move(k), boost::move(m.m_t));
|
Chris@16
|
788 i = insert(i, boost::move(val));
|
Chris@16
|
789 }
|
Chris@16
|
790 return (*i).second;
|
Chris@16
|
791 }
|
Chris@16
|
792
|
Chris@16
|
793 /// @endcond
|
Chris@16
|
794 };
|
Chris@16
|
795
|
Chris@16
|
796 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
797 inline bool operator==(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
798 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
799 { return x.m_tree == y.m_tree; }
|
Chris@16
|
800
|
Chris@16
|
801 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
802 inline bool operator<(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
803 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
804 { return x.m_tree < y.m_tree; }
|
Chris@16
|
805
|
Chris@16
|
806 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
807 inline bool operator!=(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
808 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
809 { return !(x == y); }
|
Chris@16
|
810
|
Chris@16
|
811 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
812 inline bool operator>(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
813 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
814 { return y < x; }
|
Chris@16
|
815
|
Chris@16
|
816 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
817 inline bool operator<=(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
818 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
819 { return !(y < x); }
|
Chris@16
|
820
|
Chris@16
|
821 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
822 inline bool operator>=(const map<Key,T,Compare,Allocator>& x,
|
Chris@16
|
823 const map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
824 { return !(x < y); }
|
Chris@16
|
825
|
Chris@16
|
826 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
827 inline void swap(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y)
|
Chris@16
|
828 { x.swap(y); }
|
Chris@16
|
829
|
Chris@16
|
830 /// @cond
|
Chris@16
|
831
|
Chris@16
|
832 // Forward declaration of operators < and ==, needed for friend declaration.
|
Chris@16
|
833
|
Chris@16
|
834 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
835 inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
836 const multimap<Key,T,Compare,Allocator>& y);
|
Chris@16
|
837
|
Chris@16
|
838 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
839 inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
840 const multimap<Key,T,Compare,Allocator>& y);
|
Chris@16
|
841
|
Chris@16
|
842 } //namespace container {
|
Chris@16
|
843
|
Chris@16
|
844 //!has_trivial_destructor_after_move<> == true_type
|
Chris@16
|
845 //!specialization for optimizations
|
Chris@16
|
846 template <class K, class T, class C, class Allocator>
|
Chris@16
|
847 struct has_trivial_destructor_after_move<boost::container::map<K, T, C, Allocator> >
|
Chris@16
|
848 {
|
Chris@16
|
849 static const bool value = has_trivial_destructor_after_move<Allocator>::value && has_trivial_destructor_after_move<C>::value;
|
Chris@16
|
850 };
|
Chris@16
|
851
|
Chris@16
|
852 namespace container {
|
Chris@16
|
853
|
Chris@16
|
854 /// @endcond
|
Chris@16
|
855
|
Chris@16
|
856 //! A multimap is a kind of associative container that supports equivalent keys
|
Chris@16
|
857 //! (possibly containing multiple copies of the same key value) and provides for
|
Chris@16
|
858 //! fast retrieval of values of another type T based on the keys. The multimap class
|
Chris@16
|
859 //! supports bidirectional iterators.
|
Chris@16
|
860 //!
|
Chris@16
|
861 //! A multimap satisfies all of the requirements of a container and of a reversible
|
Chris@16
|
862 //! container and of an associative container. For a
|
Chris@16
|
863 //! map<Key,T> the key_type is Key and the value_type is std::pair<const Key,T>.
|
Chris@16
|
864 //!
|
Chris@16
|
865 //! Compare is the ordering function for Keys (e.g. <i>std::less<Key></i>).
|
Chris@16
|
866 //!
|
Chris@16
|
867 //! Allocator is the allocator to allocate the value_types
|
Chris@16
|
868 //!(e.g. <i>allocator< std::pair<<b>const</b> Key, T> ></i>).
|
Chris@16
|
869 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
Chris@16
|
870 template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
|
Chris@16
|
871 #else
|
Chris@16
|
872 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
873 #endif
|
Chris@16
|
874 class multimap
|
Chris@16
|
875 {
|
Chris@16
|
876 /// @cond
|
Chris@16
|
877 private:
|
Chris@16
|
878 BOOST_COPYABLE_AND_MOVABLE(multimap)
|
Chris@16
|
879
|
Chris@16
|
880 typedef std::pair<const Key, T> value_type_impl;
|
Chris@16
|
881 typedef container_detail::rbtree
|
Chris@16
|
882 <Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
|
Chris@16
|
883 typedef container_detail::pair <Key, T> movable_value_type_impl;
|
Chris@16
|
884 typedef container_detail::tree_value_compare
|
Chris@16
|
885 < Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
|
Chris@16
|
886 > value_compare_impl;
|
Chris@16
|
887 tree_t m_tree; // red-black tree representing map
|
Chris@16
|
888 /// @endcond
|
Chris@16
|
889
|
Chris@16
|
890 public:
|
Chris@16
|
891 //////////////////////////////////////////////
|
Chris@16
|
892 //
|
Chris@16
|
893 // types
|
Chris@16
|
894 //
|
Chris@16
|
895 //////////////////////////////////////////////
|
Chris@16
|
896
|
Chris@16
|
897 typedef Key key_type;
|
Chris@16
|
898 typedef T mapped_type;
|
Chris@16
|
899 typedef std::pair<const Key, T> value_type;
|
Chris@16
|
900 typedef typename boost::container::allocator_traits<Allocator>::pointer pointer;
|
Chris@16
|
901 typedef typename boost::container::allocator_traits<Allocator>::const_pointer const_pointer;
|
Chris@16
|
902 typedef typename boost::container::allocator_traits<Allocator>::reference reference;
|
Chris@16
|
903 typedef typename boost::container::allocator_traits<Allocator>::const_reference const_reference;
|
Chris@16
|
904 typedef typename boost::container::allocator_traits<Allocator>::size_type size_type;
|
Chris@16
|
905 typedef typename boost::container::allocator_traits<Allocator>::difference_type difference_type;
|
Chris@16
|
906 typedef Allocator allocator_type;
|
Chris@16
|
907 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::stored_allocator_type) stored_allocator_type;
|
Chris@16
|
908 typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare;
|
Chris@16
|
909 typedef Compare key_compare;
|
Chris@16
|
910 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::iterator) iterator;
|
Chris@16
|
911 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_iterator) const_iterator;
|
Chris@16
|
912 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::reverse_iterator) reverse_iterator;
|
Chris@16
|
913 typedef typename BOOST_CONTAINER_IMPDEF(tree_t::const_reverse_iterator) const_reverse_iterator;
|
Chris@16
|
914 typedef std::pair<key_type, mapped_type> nonconst_value_type;
|
Chris@16
|
915 typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type;
|
Chris@16
|
916
|
Chris@16
|
917 //////////////////////////////////////////////
|
Chris@16
|
918 //
|
Chris@16
|
919 // construct/copy/destroy
|
Chris@16
|
920 //
|
Chris@16
|
921 //////////////////////////////////////////////
|
Chris@16
|
922
|
Chris@16
|
923 //! <b>Effects</b>: Default constructs an empty multimap.
|
Chris@16
|
924 //!
|
Chris@16
|
925 //! <b>Complexity</b>: Constant.
|
Chris@16
|
926 multimap()
|
Chris@16
|
927 : m_tree()
|
Chris@16
|
928 {
|
Chris@16
|
929 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
930 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
931 }
|
Chris@16
|
932
|
Chris@16
|
933 //! <b>Effects</b>: Constructs an empty multimap using the specified allocator.
|
Chris@16
|
934 //!
|
Chris@16
|
935 //! <b>Complexity</b>: Constant.
|
Chris@16
|
936 explicit multimap(const Compare& comp, const allocator_type& a = allocator_type())
|
Chris@16
|
937 : m_tree(comp, a)
|
Chris@16
|
938 {
|
Chris@16
|
939 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
940 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
941 }
|
Chris@16
|
942
|
Chris@16
|
943 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison
|
Chris@16
|
944 //! object and allocator.
|
Chris@16
|
945 //!
|
Chris@16
|
946 //! <b>Complexity</b>: Constant.
|
Chris@16
|
947 explicit multimap(const allocator_type& a)
|
Chris@16
|
948 : m_tree(a)
|
Chris@16
|
949 {
|
Chris@16
|
950 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
951 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
952 }
|
Chris@16
|
953
|
Chris@16
|
954 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object
|
Chris@16
|
955 //! and allocator, and inserts elements from the range [first ,last ).
|
Chris@16
|
956 //!
|
Chris@16
|
957 //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
|
Chris@16
|
958 //! comp and otherwise N logN, where N is last - first.
|
Chris@16
|
959 template <class InputIterator>
|
Chris@16
|
960 multimap(InputIterator first, InputIterator last,
|
Chris@16
|
961 const Compare& comp = Compare(),
|
Chris@16
|
962 const allocator_type& a = allocator_type())
|
Chris@16
|
963 : m_tree(false, first, last, comp, a)
|
Chris@16
|
964 {
|
Chris@16
|
965 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
966 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
967 }
|
Chris@16
|
968
|
Chris@16
|
969 //! <b>Effects</b>: Constructs an empty multimap using the specified comparison object and
|
Chris@16
|
970 //! allocator, and inserts elements from the ordered range [first ,last). This function
|
Chris@16
|
971 //! is more efficient than the normal range creation for ordered ranges.
|
Chris@16
|
972 //!
|
Chris@16
|
973 //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
|
Chris@16
|
974 //!
|
Chris@16
|
975 //! <b>Complexity</b>: Linear in N.
|
Chris@16
|
976 //!
|
Chris@16
|
977 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
978 template <class InputIterator>
|
Chris@16
|
979 multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare(),
|
Chris@16
|
980 const allocator_type& a = allocator_type())
|
Chris@16
|
981 : m_tree(ordered_range, first, last, comp, a)
|
Chris@16
|
982 {}
|
Chris@16
|
983
|
Chris@16
|
984 //! <b>Effects</b>: Copy constructs a multimap.
|
Chris@16
|
985 //!
|
Chris@16
|
986 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
987 multimap(const multimap& x)
|
Chris@16
|
988 : m_tree(x.m_tree)
|
Chris@16
|
989 {
|
Chris@16
|
990 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
991 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
992 }
|
Chris@16
|
993
|
Chris@16
|
994 //! <b>Effects</b>: Move constructs a multimap. Constructs *this using x's resources.
|
Chris@16
|
995 //!
|
Chris@16
|
996 //! <b>Complexity</b>: Constant.
|
Chris@16
|
997 //!
|
Chris@16
|
998 //! <b>Postcondition</b>: x is emptied.
|
Chris@16
|
999 multimap(BOOST_RV_REF(multimap) x)
|
Chris@16
|
1000 : m_tree(boost::move(x.m_tree))
|
Chris@16
|
1001 {
|
Chris@16
|
1002 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
1003 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
1004 }
|
Chris@16
|
1005
|
Chris@16
|
1006 //! <b>Effects</b>: Copy constructs a multimap.
|
Chris@16
|
1007 //!
|
Chris@16
|
1008 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
1009 multimap(const multimap& x, const allocator_type &a)
|
Chris@16
|
1010 : m_tree(x.m_tree, a)
|
Chris@16
|
1011 {
|
Chris@16
|
1012 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
1013 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
1014 }
|
Chris@16
|
1015
|
Chris@16
|
1016 //! <b>Effects</b>: Move constructs a multimap using the specified allocator.
|
Chris@16
|
1017 //! Constructs *this using x's resources.
|
Chris@16
|
1018 //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
|
Chris@16
|
1019 //!
|
Chris@16
|
1020 //! <b>Postcondition</b>: x is emptied.
|
Chris@16
|
1021 multimap(BOOST_RV_REF(multimap) x, const allocator_type &a)
|
Chris@16
|
1022 : m_tree(boost::move(x.m_tree), a)
|
Chris@16
|
1023 {
|
Chris@16
|
1024 //Allocator type must be std::pair<CONST Key, T>
|
Chris@16
|
1025 BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename Allocator::value_type>::value));
|
Chris@16
|
1026 }
|
Chris@16
|
1027
|
Chris@16
|
1028 //! <b>Effects</b>: Makes *this a copy of x.
|
Chris@16
|
1029 //!
|
Chris@16
|
1030 //! <b>Complexity</b>: Linear in x.size().
|
Chris@16
|
1031 multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x)
|
Chris@16
|
1032 { m_tree = x.m_tree; return *this; }
|
Chris@16
|
1033
|
Chris@16
|
1034 //! <b>Effects</b>: this->swap(x.get()).
|
Chris@16
|
1035 //!
|
Chris@16
|
1036 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1037 multimap& operator=(BOOST_RV_REF(multimap) x)
|
Chris@16
|
1038 { m_tree = boost::move(x.m_tree); return *this; }
|
Chris@16
|
1039
|
Chris@16
|
1040 //! <b>Effects</b>: Returns a copy of the Allocator that
|
Chris@16
|
1041 //! was passed to the object's constructor.
|
Chris@16
|
1042 //!
|
Chris@16
|
1043 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1044 allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1045 { return m_tree.get_allocator(); }
|
Chris@16
|
1046
|
Chris@16
|
1047 //! <b>Effects</b>: Returns a reference to the internal allocator.
|
Chris@16
|
1048 //!
|
Chris@16
|
1049 //! <b>Throws</b>: Nothing
|
Chris@16
|
1050 //!
|
Chris@16
|
1051 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1052 //!
|
Chris@16
|
1053 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
1054 stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1055 { return m_tree.get_stored_allocator(); }
|
Chris@16
|
1056
|
Chris@16
|
1057 //! <b>Effects</b>: Returns a reference to the internal allocator.
|
Chris@16
|
1058 //!
|
Chris@16
|
1059 //! <b>Throws</b>: Nothing
|
Chris@16
|
1060 //!
|
Chris@16
|
1061 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1062 //!
|
Chris@16
|
1063 //! <b>Note</b>: Non-standard extension.
|
Chris@16
|
1064 const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1065 { return m_tree.get_stored_allocator(); }
|
Chris@16
|
1066
|
Chris@16
|
1067 //////////////////////////////////////////////
|
Chris@16
|
1068 //
|
Chris@16
|
1069 // iterators
|
Chris@16
|
1070 //
|
Chris@16
|
1071 //////////////////////////////////////////////
|
Chris@16
|
1072
|
Chris@16
|
1073 //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
|
Chris@16
|
1074 //!
|
Chris@16
|
1075 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1076 //!
|
Chris@16
|
1077 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1078 iterator begin() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1079 { return m_tree.begin(); }
|
Chris@16
|
1080
|
Chris@16
|
1081 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
|
Chris@16
|
1082 //!
|
Chris@16
|
1083 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1084 //!
|
Chris@16
|
1085 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1086 const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1087 { return this->cbegin(); }
|
Chris@16
|
1088
|
Chris@16
|
1089 //! <b>Effects</b>: Returns an iterator to the end of the container.
|
Chris@16
|
1090 //!
|
Chris@16
|
1091 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1092 //!
|
Chris@16
|
1093 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1094 iterator end() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1095 { return m_tree.end(); }
|
Chris@16
|
1096
|
Chris@16
|
1097 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
|
Chris@16
|
1098 //!
|
Chris@16
|
1099 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1100 //!
|
Chris@16
|
1101 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1102 const_iterator end() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1103 { return this->cend(); }
|
Chris@16
|
1104
|
Chris@16
|
1105 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
|
Chris@16
|
1106 //! of the reversed container.
|
Chris@16
|
1107 //!
|
Chris@16
|
1108 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1109 //!
|
Chris@16
|
1110 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1111 reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1112 { return m_tree.rbegin(); }
|
Chris@16
|
1113
|
Chris@16
|
1114 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
|
Chris@16
|
1115 //! of the reversed container.
|
Chris@16
|
1116 //!
|
Chris@16
|
1117 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1118 //!
|
Chris@16
|
1119 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1120 const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1121 { return this->crbegin(); }
|
Chris@16
|
1122
|
Chris@16
|
1123 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
|
Chris@16
|
1124 //! of the reversed container.
|
Chris@16
|
1125 //!
|
Chris@16
|
1126 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1127 //!
|
Chris@16
|
1128 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1129 reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1130 { return m_tree.rend(); }
|
Chris@16
|
1131
|
Chris@16
|
1132 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
|
Chris@16
|
1133 //! of the reversed container.
|
Chris@16
|
1134 //!
|
Chris@16
|
1135 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1136 //!
|
Chris@16
|
1137 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1138 const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1139 { return this->crend(); }
|
Chris@16
|
1140
|
Chris@16
|
1141 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
|
Chris@16
|
1142 //!
|
Chris@16
|
1143 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1144 //!
|
Chris@16
|
1145 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1146 const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1147 { return m_tree.begin(); }
|
Chris@16
|
1148
|
Chris@16
|
1149 //! <b>Effects</b>: Returns a const_iterator to the end of the container.
|
Chris@16
|
1150 //!
|
Chris@16
|
1151 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1152 //!
|
Chris@16
|
1153 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1154 const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1155 { return m_tree.end(); }
|
Chris@16
|
1156
|
Chris@16
|
1157 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
|
Chris@16
|
1158 //! of the reversed container.
|
Chris@16
|
1159 //!
|
Chris@16
|
1160 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1161 //!
|
Chris@16
|
1162 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1163 const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1164 { return m_tree.rbegin(); }
|
Chris@16
|
1165
|
Chris@16
|
1166 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
|
Chris@16
|
1167 //! of the reversed container.
|
Chris@16
|
1168 //!
|
Chris@16
|
1169 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1170 //!
|
Chris@16
|
1171 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1172 const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1173 { return m_tree.rend(); }
|
Chris@16
|
1174
|
Chris@16
|
1175 //////////////////////////////////////////////
|
Chris@16
|
1176 //
|
Chris@16
|
1177 // capacity
|
Chris@16
|
1178 //
|
Chris@16
|
1179 //////////////////////////////////////////////
|
Chris@16
|
1180
|
Chris@16
|
1181 //! <b>Effects</b>: Returns true if the container contains no elements.
|
Chris@16
|
1182 //!
|
Chris@16
|
1183 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1184 //!
|
Chris@16
|
1185 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1186 bool empty() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1187 { return m_tree.empty(); }
|
Chris@16
|
1188
|
Chris@16
|
1189 //! <b>Effects</b>: Returns the number of the elements contained in the container.
|
Chris@16
|
1190 //!
|
Chris@16
|
1191 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1192 //!
|
Chris@16
|
1193 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1194 size_type size() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1195 { return m_tree.size(); }
|
Chris@16
|
1196
|
Chris@16
|
1197 //! <b>Effects</b>: Returns the largest possible size of the container.
|
Chris@16
|
1198 //!
|
Chris@16
|
1199 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1200 //!
|
Chris@16
|
1201 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1202 size_type max_size() const BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1203 { return m_tree.max_size(); }
|
Chris@16
|
1204
|
Chris@16
|
1205 //////////////////////////////////////////////
|
Chris@16
|
1206 //
|
Chris@16
|
1207 // modifiers
|
Chris@16
|
1208 //
|
Chris@16
|
1209 //////////////////////////////////////////////
|
Chris@16
|
1210
|
Chris@16
|
1211 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
Chris@16
|
1212
|
Chris@16
|
1213 //! <b>Effects</b>: Inserts an object of type T constructed with
|
Chris@16
|
1214 //! std::forward<Args>(args)... in the container.
|
Chris@16
|
1215 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1216 //!
|
Chris@16
|
1217 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1218 //! to the key of x.
|
Chris@16
|
1219 //!
|
Chris@16
|
1220 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1221 //! is inserted right before p.
|
Chris@16
|
1222 template <class... Args>
|
Chris@16
|
1223 iterator emplace(Args&&... args)
|
Chris@16
|
1224 { return m_tree.emplace_equal(boost::forward<Args>(args)...); }
|
Chris@16
|
1225
|
Chris@16
|
1226 //! <b>Effects</b>: Inserts an object of type T constructed with
|
Chris@16
|
1227 //! std::forward<Args>(args)... in the container.
|
Chris@16
|
1228 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1229 //!
|
Chris@16
|
1230 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1231 //! to the key of x.
|
Chris@16
|
1232 //!
|
Chris@16
|
1233 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1234 //! is inserted right before p.
|
Chris@16
|
1235 template <class... Args>
|
Chris@16
|
1236 iterator emplace_hint(const_iterator hint, Args&&... args)
|
Chris@16
|
1237 { return m_tree.emplace_hint_equal(hint, boost::forward<Args>(args)...); }
|
Chris@16
|
1238
|
Chris@16
|
1239 #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
Chris@16
|
1240
|
Chris@16
|
1241 #define BOOST_PP_LOCAL_MACRO(n) \
|
Chris@16
|
1242 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
|
Chris@16
|
1243 iterator emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
|
Chris@16
|
1244 { return m_tree.emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \
|
Chris@16
|
1245 \
|
Chris@16
|
1246 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
|
Chris@16
|
1247 iterator emplace_hint(const_iterator hint \
|
Chris@16
|
1248 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
|
Chris@16
|
1249 { return m_tree.emplace_hint_equal(hint \
|
Chris@16
|
1250 BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _));} \
|
Chris@16
|
1251 //!
|
Chris@16
|
1252 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
|
Chris@16
|
1253 #include BOOST_PP_LOCAL_ITERATE()
|
Chris@16
|
1254
|
Chris@16
|
1255 #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
Chris@16
|
1256
|
Chris@16
|
1257 //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
|
Chris@16
|
1258 //! newly inserted element.
|
Chris@16
|
1259 //!
|
Chris@16
|
1260 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1261 iterator insert(const value_type& x)
|
Chris@16
|
1262 { return m_tree.insert_equal(x); }
|
Chris@16
|
1263
|
Chris@16
|
1264 //! <b>Effects</b>: Inserts a new value constructed from x and returns
|
Chris@16
|
1265 //! the iterator pointing to the newly inserted element.
|
Chris@16
|
1266 //!
|
Chris@16
|
1267 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1268 iterator insert(const nonconst_value_type& x)
|
Chris@16
|
1269 { return m_tree.insert_equal(x); }
|
Chris@16
|
1270
|
Chris@16
|
1271 //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
|
Chris@16
|
1272 //! the iterator pointing to the newly inserted element.
|
Chris@16
|
1273 //!
|
Chris@16
|
1274 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1275 iterator insert(BOOST_RV_REF(nonconst_value_type) x)
|
Chris@16
|
1276 { return m_tree.insert_equal(boost::move(x)); }
|
Chris@16
|
1277
|
Chris@16
|
1278 //! <b>Effects</b>: Inserts a new value move-constructed from x and returns
|
Chris@16
|
1279 //! the iterator pointing to the newly inserted element.
|
Chris@16
|
1280 //!
|
Chris@16
|
1281 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1282 iterator insert(BOOST_RV_REF(movable_value_type) x)
|
Chris@16
|
1283 { return m_tree.insert_equal(boost::move(x)); }
|
Chris@16
|
1284
|
Chris@16
|
1285 //! <b>Effects</b>: Inserts a copy of x in the container.
|
Chris@16
|
1286 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1287 //!
|
Chris@16
|
1288 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1289 //! to the key of x.
|
Chris@16
|
1290 //!
|
Chris@16
|
1291 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1292 //! is inserted right before p.
|
Chris@16
|
1293 iterator insert(const_iterator position, const value_type& x)
|
Chris@16
|
1294 { return m_tree.insert_equal(position, x); }
|
Chris@16
|
1295
|
Chris@16
|
1296 //! <b>Effects</b>: Inserts a new value constructed from x in the container.
|
Chris@16
|
1297 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1298 //!
|
Chris@16
|
1299 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1300 //! to the key of x.
|
Chris@16
|
1301 //!
|
Chris@16
|
1302 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1303 //! is inserted right before p.
|
Chris@16
|
1304 iterator insert(const_iterator position, const nonconst_value_type& x)
|
Chris@16
|
1305 { return m_tree.insert_equal(position, x); }
|
Chris@16
|
1306
|
Chris@16
|
1307 //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
|
Chris@16
|
1308 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1309 //!
|
Chris@16
|
1310 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1311 //! to the key of x.
|
Chris@16
|
1312 //!
|
Chris@16
|
1313 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1314 //! is inserted right before p.
|
Chris@16
|
1315 iterator insert(const_iterator position, BOOST_RV_REF(nonconst_value_type) x)
|
Chris@16
|
1316 { return m_tree.insert_equal(position, boost::move(x)); }
|
Chris@16
|
1317
|
Chris@16
|
1318 //! <b>Effects</b>: Inserts a new value move constructed from x in the container.
|
Chris@16
|
1319 //! p is a hint pointing to where the insert should start to search.
|
Chris@16
|
1320 //!
|
Chris@16
|
1321 //! <b>Returns</b>: An iterator pointing to the element with key equivalent
|
Chris@16
|
1322 //! to the key of x.
|
Chris@16
|
1323 //!
|
Chris@16
|
1324 //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
|
Chris@16
|
1325 //! is inserted right before p.
|
Chris@16
|
1326 iterator insert(const_iterator position, BOOST_RV_REF(movable_value_type) x)
|
Chris@16
|
1327 { return m_tree.insert_equal(position, boost::move(x)); }
|
Chris@16
|
1328
|
Chris@16
|
1329 //! <b>Requires</b>: first, last are not iterators into *this.
|
Chris@16
|
1330 //!
|
Chris@16
|
1331 //! <b>Effects</b>: inserts each element from the range [first,last) .
|
Chris@16
|
1332 //!
|
Chris@16
|
1333 //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
Chris@16
|
1334 template <class InputIterator>
|
Chris@16
|
1335 void insert(InputIterator first, InputIterator last)
|
Chris@16
|
1336 { m_tree.insert_equal(first, last); }
|
Chris@16
|
1337
|
Chris@16
|
1338 //! <b>Effects</b>: Erases the element pointed to by position.
|
Chris@16
|
1339 //!
|
Chris@16
|
1340 //! <b>Returns</b>: Returns an iterator pointing to the element immediately
|
Chris@16
|
1341 //! following q prior to the element being erased. If no such element exists,
|
Chris@16
|
1342 //! returns end().
|
Chris@16
|
1343 //!
|
Chris@16
|
1344 //! <b>Complexity</b>: Amortized constant time
|
Chris@16
|
1345 iterator erase(const_iterator position) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1346 { return m_tree.erase(position); }
|
Chris@16
|
1347
|
Chris@16
|
1348 //! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
|
Chris@16
|
1349 //!
|
Chris@16
|
1350 //! <b>Returns</b>: Returns the number of erased elements.
|
Chris@16
|
1351 //!
|
Chris@16
|
1352 //! <b>Complexity</b>: log(size()) + count(k)
|
Chris@16
|
1353 size_type erase(const key_type& x) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1354 { return m_tree.erase(x); }
|
Chris@16
|
1355
|
Chris@16
|
1356 //! <b>Effects</b>: Erases all the elements in the range [first, last).
|
Chris@16
|
1357 //!
|
Chris@16
|
1358 //! <b>Returns</b>: Returns last.
|
Chris@16
|
1359 //!
|
Chris@16
|
1360 //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
|
Chris@16
|
1361 iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1362 { return m_tree.erase(first, last); }
|
Chris@16
|
1363
|
Chris@16
|
1364 //! <b>Effects</b>: Swaps the contents of *this and x.
|
Chris@16
|
1365 //!
|
Chris@16
|
1366 //! <b>Throws</b>: Nothing.
|
Chris@16
|
1367 //!
|
Chris@16
|
1368 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1369 void swap(multimap& x)
|
Chris@16
|
1370 { m_tree.swap(x.m_tree); }
|
Chris@16
|
1371
|
Chris@16
|
1372 //! <b>Effects</b>: erase(a.begin(),a.end()).
|
Chris@16
|
1373 //!
|
Chris@16
|
1374 //! <b>Postcondition</b>: size() == 0.
|
Chris@16
|
1375 //!
|
Chris@16
|
1376 //! <b>Complexity</b>: linear in size().
|
Chris@16
|
1377 void clear() BOOST_CONTAINER_NOEXCEPT
|
Chris@16
|
1378 { m_tree.clear(); }
|
Chris@16
|
1379
|
Chris@16
|
1380 //////////////////////////////////////////////
|
Chris@16
|
1381 //
|
Chris@16
|
1382 // observers
|
Chris@16
|
1383 //
|
Chris@16
|
1384 //////////////////////////////////////////////
|
Chris@16
|
1385
|
Chris@16
|
1386 //! <b>Effects</b>: Returns the comparison object out
|
Chris@16
|
1387 //! of which a was constructed.
|
Chris@16
|
1388 //!
|
Chris@16
|
1389 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1390 key_compare key_comp() const
|
Chris@16
|
1391 { return m_tree.key_comp(); }
|
Chris@16
|
1392
|
Chris@16
|
1393 //! <b>Effects</b>: Returns an object of value_compare constructed out
|
Chris@16
|
1394 //! of the comparison object.
|
Chris@16
|
1395 //!
|
Chris@16
|
1396 //! <b>Complexity</b>: Constant.
|
Chris@16
|
1397 value_compare value_comp() const
|
Chris@16
|
1398 { return value_compare(m_tree.key_comp()); }
|
Chris@16
|
1399
|
Chris@16
|
1400 //////////////////////////////////////////////
|
Chris@16
|
1401 //
|
Chris@16
|
1402 // map operations
|
Chris@16
|
1403 //
|
Chris@16
|
1404 //////////////////////////////////////////////
|
Chris@16
|
1405
|
Chris@16
|
1406 //! <b>Returns</b>: An iterator pointing to an element with the key
|
Chris@16
|
1407 //! equivalent to x, or end() if such an element is not found.
|
Chris@16
|
1408 //!
|
Chris@16
|
1409 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1410 iterator find(const key_type& x)
|
Chris@16
|
1411 { return m_tree.find(x); }
|
Chris@16
|
1412
|
Chris@16
|
1413 //! <b>Returns</b>: Allocator const iterator pointing to an element with the key
|
Chris@16
|
1414 //! equivalent to x, or end() if such an element is not found.
|
Chris@16
|
1415 //!
|
Chris@16
|
1416 //! <b>Complexity</b>: Logarithmic.
|
Chris@16
|
1417 const_iterator find(const key_type& x) const
|
Chris@16
|
1418 { return m_tree.find(x); }
|
Chris@16
|
1419
|
Chris@16
|
1420 //! <b>Returns</b>: The number of elements with key equivalent to x.
|
Chris@16
|
1421 //!
|
Chris@16
|
1422 //! <b>Complexity</b>: log(size())+count(k)
|
Chris@16
|
1423 size_type count(const key_type& x) const
|
Chris@16
|
1424 { return m_tree.count(x); }
|
Chris@16
|
1425
|
Chris@16
|
1426 //! <b>Returns</b>: An iterator pointing to the first element with key not less
|
Chris@16
|
1427 //! than k, or a.end() if such an element is not found.
|
Chris@16
|
1428 //!
|
Chris@16
|
1429 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1430 iterator lower_bound(const key_type& x)
|
Chris@16
|
1431 {return m_tree.lower_bound(x); }
|
Chris@16
|
1432
|
Chris@16
|
1433 //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
|
Chris@16
|
1434 //! less than k, or a.end() if such an element is not found.
|
Chris@16
|
1435 //!
|
Chris@16
|
1436 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1437 const_iterator lower_bound(const key_type& x) const
|
Chris@16
|
1438 { return m_tree.lower_bound(x); }
|
Chris@16
|
1439
|
Chris@16
|
1440 //! <b>Returns</b>: An iterator pointing to the first element with key not less
|
Chris@16
|
1441 //! than x, or end() if such an element is not found.
|
Chris@16
|
1442 //!
|
Chris@16
|
1443 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1444 iterator upper_bound(const key_type& x)
|
Chris@16
|
1445 { return m_tree.upper_bound(x); }
|
Chris@16
|
1446
|
Chris@16
|
1447 //! <b>Returns</b>: Allocator const iterator pointing to the first element with key not
|
Chris@16
|
1448 //! less than x, or end() if such an element is not found.
|
Chris@16
|
1449 //!
|
Chris@16
|
1450 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1451 const_iterator upper_bound(const key_type& x) const
|
Chris@16
|
1452 { return m_tree.upper_bound(x); }
|
Chris@16
|
1453
|
Chris@16
|
1454 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
|
Chris@16
|
1455 //!
|
Chris@16
|
1456 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1457 std::pair<iterator,iterator> equal_range(const key_type& x)
|
Chris@16
|
1458 { return m_tree.equal_range(x); }
|
Chris@16
|
1459
|
Chris@16
|
1460 //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
|
Chris@16
|
1461 //!
|
Chris@16
|
1462 //! <b>Complexity</b>: Logarithmic
|
Chris@16
|
1463 std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
Chris@16
|
1464 { return m_tree.equal_range(x); }
|
Chris@16
|
1465
|
Chris@16
|
1466 /// @cond
|
Chris@16
|
1467 template <class K1, class T1, class C1, class A1>
|
Chris@16
|
1468 friend bool operator== (const multimap<K1, T1, C1, A1>& x,
|
Chris@16
|
1469 const multimap<K1, T1, C1, A1>& y);
|
Chris@16
|
1470
|
Chris@16
|
1471 template <class K1, class T1, class C1, class A1>
|
Chris@16
|
1472 friend bool operator< (const multimap<K1, T1, C1, A1>& x,
|
Chris@16
|
1473 const multimap<K1, T1, C1, A1>& y);
|
Chris@16
|
1474 /// @endcond
|
Chris@16
|
1475 };
|
Chris@16
|
1476
|
Chris@16
|
1477 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1478 inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1479 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1480 { return x.m_tree == y.m_tree; }
|
Chris@16
|
1481
|
Chris@16
|
1482 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1483 inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1484 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1485 { return x.m_tree < y.m_tree; }
|
Chris@16
|
1486
|
Chris@16
|
1487 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1488 inline bool operator!=(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1489 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1490 { return !(x == y); }
|
Chris@16
|
1491
|
Chris@16
|
1492 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1493 inline bool operator>(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1494 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1495 { return y < x; }
|
Chris@16
|
1496
|
Chris@16
|
1497 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1498 inline bool operator<=(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1499 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1500 { return !(y < x); }
|
Chris@16
|
1501
|
Chris@16
|
1502 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1503 inline bool operator>=(const multimap<Key,T,Compare,Allocator>& x,
|
Chris@16
|
1504 const multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1505 { return !(x < y); }
|
Chris@16
|
1506
|
Chris@16
|
1507 template <class Key, class T, class Compare, class Allocator>
|
Chris@16
|
1508 inline void swap(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y)
|
Chris@16
|
1509 { x.swap(y); }
|
Chris@16
|
1510
|
Chris@16
|
1511 /// @cond
|
Chris@16
|
1512
|
Chris@16
|
1513 } //namespace container {
|
Chris@16
|
1514
|
Chris@16
|
1515 //!has_trivial_destructor_after_move<> == true_type
|
Chris@16
|
1516 //!specialization for optimizations
|
Chris@16
|
1517 template <class K, class T, class C, class Allocator>
|
Chris@16
|
1518 struct has_trivial_destructor_after_move<boost::container::multimap<K, T, C, Allocator> >
|
Chris@16
|
1519 {
|
Chris@16
|
1520 static const bool value = has_trivial_destructor_after_move<Allocator>::value && has_trivial_destructor_after_move<C>::value;
|
Chris@16
|
1521 };
|
Chris@16
|
1522
|
Chris@16
|
1523 namespace container {
|
Chris@16
|
1524
|
Chris@16
|
1525 /// @endcond
|
Chris@16
|
1526
|
Chris@16
|
1527 }}
|
Chris@16
|
1528
|
Chris@16
|
1529 #include <boost/container/detail/config_end.hpp>
|
Chris@16
|
1530
|
Chris@16
|
1531 #endif /* BOOST_CONTAINER_MAP_HPP */
|
Chris@16
|
1532
|