Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- set -------------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_SET |
| 12 | #define _LIBCPP_SET |
| 13 | |
| 14 | /* |
| 15 | |
| 16 | set synopsis |
| 17 | |
| 18 | namespace std |
| 19 | { |
| 20 | |
| 21 | template <class Key, class Compare = less<Key>, |
| 22 | class Allocator = allocator<Key>> |
| 23 | class set |
| 24 | { |
| 25 | public: |
| 26 | // types: |
| 27 | typedef Key key_type; |
| 28 | typedef key_type value_type; |
| 29 | typedef Compare key_compare; |
| 30 | typedef key_compare value_compare; |
| 31 | typedef Allocator allocator_type; |
| 32 | typedef typename allocator_type::reference reference; |
| 33 | typedef typename allocator_type::const_reference const_reference; |
| 34 | typedef typename allocator_type::size_type size_type; |
| 35 | typedef typename allocator_type::difference_type difference_type; |
| 36 | typedef typename allocator_type::pointer pointer; |
| 37 | typedef typename allocator_type::const_pointer const_pointer; |
| 38 | |
| 39 | typedef implementation-defined iterator; |
| 40 | typedef implementation-defined const_iterator; |
| 41 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 42 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 43 | |
| 44 | // construct/copy/destroy: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 45 | set() |
| 46 | noexcept( |
| 47 | is_nothrow_default_constructible<allocator_type>::value && |
| 48 | is_nothrow_default_constructible<key_compare>::value && |
| 49 | is_nothrow_copy_constructible<key_compare>::value); |
| 50 | explicit set(const value_compare& comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | set(const value_compare& comp, const allocator_type& a); |
| 52 | template <class InputIterator> |
| 53 | set(InputIterator first, InputIterator last, |
| 54 | const value_compare& comp = value_compare()); |
| 55 | template <class InputIterator> |
| 56 | set(InputIterator first, InputIterator last, const value_compare& comp, |
| 57 | const allocator_type& a); |
| 58 | set(const set& s); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 59 | set(set&& s) |
| 60 | noexcept( |
| 61 | is_nothrow_move_constructible<allocator_type>::value && |
| 62 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | explicit set(const allocator_type& a); |
| 64 | set(const set& s, const allocator_type& a); |
| 65 | set(set&& s, const allocator_type& a); |
| 66 | set(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 67 | set(initializer_list<value_type> il, const value_compare& comp, |
| 68 | const allocator_type& a); |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 69 | template <class InputIterator> |
| 70 | set(InputIterator first, InputIterator last, const allocator_type& a) |
| 71 | : set(first, last, Compare(), a) {} // C++14 |
| 72 | set(initializer_list<value_type> il, const allocator_type& a) |
| 73 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 74 | ~set(); |
| 75 | |
| 76 | set& operator=(const set& s); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 77 | set& operator=(set&& s) |
| 78 | noexcept( |
| 79 | allocator_type::propagate_on_container_move_assignment::value && |
| 80 | is_nothrow_move_assignable<allocator_type>::value && |
| 81 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 82 | set& operator=(initializer_list<value_type> il); |
| 83 | |
| 84 | // iterators: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 85 | iterator begin() noexcept; |
| 86 | const_iterator begin() const noexcept; |
| 87 | iterator end() noexcept; |
| 88 | const_iterator end() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 90 | reverse_iterator rbegin() noexcept; |
| 91 | const_reverse_iterator rbegin() const noexcept; |
| 92 | reverse_iterator rend() noexcept; |
| 93 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 94 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 95 | const_iterator cbegin() const noexcept; |
| 96 | const_iterator cend() const noexcept; |
| 97 | const_reverse_iterator crbegin() const noexcept; |
| 98 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 99 | |
| 100 | // capacity: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 101 | bool empty() const noexcept; |
| 102 | size_type size() const noexcept; |
| 103 | size_type max_size() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | |
| 105 | // modifiers: |
| 106 | template <class... Args> |
| 107 | pair<iterator, bool> emplace(Args&&... args); |
| 108 | template <class... Args> |
| 109 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 110 | pair<iterator,bool> insert(const value_type& v); |
| 111 | pair<iterator,bool> insert(value_type&& v); |
| 112 | iterator insert(const_iterator position, const value_type& v); |
| 113 | iterator insert(const_iterator position, value_type&& v); |
| 114 | template <class InputIterator> |
| 115 | void insert(InputIterator first, InputIterator last); |
| 116 | void insert(initializer_list<value_type> il); |
| 117 | |
| 118 | iterator erase(const_iterator position); |
| 119 | size_type erase(const key_type& k); |
| 120 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 121 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 122 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 123 | void swap(set& s) |
| 124 | noexcept( |
| 125 | __is_nothrow_swappable<key_compare>::value && |
| 126 | (!allocator_type::propagate_on_container_swap::value || |
| 127 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 128 | |
| 129 | // observers: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 130 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 131 | key_compare key_comp() const; |
| 132 | value_compare value_comp() const; |
| 133 | |
| 134 | // set operations: |
| 135 | iterator find(const key_type& k); |
| 136 | const_iterator find(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 137 | template<typename K> |
| 138 | iterator find(const K& x); |
| 139 | template<typename K> |
| 140 | const_iterator find(const K& x) const; // C++14 |
| 141 | template<typename K> |
| 142 | size_type count(const K& x) const; // C++14 |
| 143 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | size_type count(const key_type& k) const; |
| 145 | iterator lower_bound(const key_type& k); |
| 146 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 147 | template<typename K> |
| 148 | iterator lower_bound(const K& x); // C++14 |
| 149 | template<typename K> |
| 150 | const_iterator lower_bound(const K& x) const; // C++14 |
| 151 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 152 | iterator upper_bound(const key_type& k); |
| 153 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 154 | template<typename K> |
| 155 | iterator upper_bound(const K& x); // C++14 |
| 156 | template<typename K> |
| 157 | const_iterator upper_bound(const K& x) const; // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 158 | pair<iterator,iterator> equal_range(const key_type& k); |
| 159 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 160 | template<typename K> |
| 161 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 162 | template<typename K> |
| 163 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | template <class Key, class Compare, class Allocator> |
| 167 | bool |
| 168 | operator==(const set<Key, Compare, Allocator>& x, |
| 169 | const set<Key, Compare, Allocator>& y); |
| 170 | |
| 171 | template <class Key, class Compare, class Allocator> |
| 172 | bool |
| 173 | operator< (const set<Key, Compare, Allocator>& x, |
| 174 | const set<Key, Compare, Allocator>& y); |
| 175 | |
| 176 | template <class Key, class Compare, class Allocator> |
| 177 | bool |
| 178 | operator!=(const set<Key, Compare, Allocator>& x, |
| 179 | const set<Key, Compare, Allocator>& y); |
| 180 | |
| 181 | template <class Key, class Compare, class Allocator> |
| 182 | bool |
| 183 | operator> (const set<Key, Compare, Allocator>& x, |
| 184 | const set<Key, Compare, Allocator>& y); |
| 185 | |
| 186 | template <class Key, class Compare, class Allocator> |
| 187 | bool |
| 188 | operator>=(const set<Key, Compare, Allocator>& x, |
| 189 | const set<Key, Compare, Allocator>& y); |
| 190 | |
| 191 | template <class Key, class Compare, class Allocator> |
| 192 | bool |
| 193 | operator<=(const set<Key, Compare, Allocator>& x, |
| 194 | const set<Key, Compare, Allocator>& y); |
| 195 | |
| 196 | // specialized algorithms: |
| 197 | template <class Key, class Compare, class Allocator> |
| 198 | void |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 199 | swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) |
| 200 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 201 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 202 | template <class Key, class Compare = less<Key>, |
| 203 | class Allocator = allocator<Key>> |
| 204 | class multiset |
| 205 | { |
| 206 | public: |
| 207 | // types: |
| 208 | typedef Key key_type; |
| 209 | typedef key_type value_type; |
| 210 | typedef Compare key_compare; |
| 211 | typedef key_compare value_compare; |
| 212 | typedef Allocator allocator_type; |
| 213 | typedef typename allocator_type::reference reference; |
| 214 | typedef typename allocator_type::const_reference const_reference; |
| 215 | typedef typename allocator_type::size_type size_type; |
| 216 | typedef typename allocator_type::difference_type difference_type; |
| 217 | typedef typename allocator_type::pointer pointer; |
| 218 | typedef typename allocator_type::const_pointer const_pointer; |
| 219 | |
| 220 | typedef implementation-defined iterator; |
| 221 | typedef implementation-defined const_iterator; |
| 222 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 223 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 224 | |
| 225 | // construct/copy/destroy: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 226 | multiset() |
| 227 | noexcept( |
| 228 | is_nothrow_default_constructible<allocator_type>::value && |
| 229 | is_nothrow_default_constructible<key_compare>::value && |
| 230 | is_nothrow_copy_constructible<key_compare>::value); |
| 231 | explicit multiset(const value_compare& comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 232 | multiset(const value_compare& comp, const allocator_type& a); |
| 233 | template <class InputIterator> |
| 234 | multiset(InputIterator first, InputIterator last, |
| 235 | const value_compare& comp = value_compare()); |
| 236 | template <class InputIterator> |
| 237 | multiset(InputIterator first, InputIterator last, |
| 238 | const value_compare& comp, const allocator_type& a); |
| 239 | multiset(const multiset& s); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 240 | multiset(multiset&& s) |
| 241 | noexcept( |
| 242 | is_nothrow_move_constructible<allocator_type>::value && |
| 243 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 244 | explicit multiset(const allocator_type& a); |
| 245 | multiset(const multiset& s, const allocator_type& a); |
| 246 | multiset(multiset&& s, const allocator_type& a); |
| 247 | multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 248 | multiset(initializer_list<value_type> il, const value_compare& comp, |
| 249 | const allocator_type& a); |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 250 | template <class InputIterator> |
| 251 | multiset(InputIterator first, InputIterator last, const allocator_type& a) |
| 252 | : set(first, last, Compare(), a) {} // C++14 |
| 253 | multiset(initializer_list<value_type> il, const allocator_type& a) |
| 254 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 255 | ~multiset(); |
| 256 | |
| 257 | multiset& operator=(const multiset& s); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 258 | multiset& operator=(multiset&& s) |
| 259 | noexcept( |
| 260 | allocator_type::propagate_on_container_move_assignment::value && |
| 261 | is_nothrow_move_assignable<allocator_type>::value && |
| 262 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 263 | multiset& operator=(initializer_list<value_type> il); |
| 264 | |
| 265 | // iterators: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 266 | iterator begin() noexcept; |
| 267 | const_iterator begin() const noexcept; |
| 268 | iterator end() noexcept; |
| 269 | const_iterator end() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 270 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 271 | reverse_iterator rbegin() noexcept; |
| 272 | const_reverse_iterator rbegin() const noexcept; |
| 273 | reverse_iterator rend() noexcept; |
| 274 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 275 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 276 | const_iterator cbegin() const noexcept; |
| 277 | const_iterator cend() const noexcept; |
| 278 | const_reverse_iterator crbegin() const noexcept; |
| 279 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 280 | |
| 281 | // capacity: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 282 | bool empty() const noexcept; |
| 283 | size_type size() const noexcept; |
| 284 | size_type max_size() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 285 | |
| 286 | // modifiers: |
| 287 | template <class... Args> |
| 288 | iterator emplace(Args&&... args); |
| 289 | template <class... Args> |
| 290 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 291 | iterator insert(const value_type& v); |
| 292 | iterator insert(value_type&& v); |
| 293 | iterator insert(const_iterator position, const value_type& v); |
| 294 | iterator insert(const_iterator position, value_type&& v); |
| 295 | template <class InputIterator> |
| 296 | void insert(InputIterator first, InputIterator last); |
| 297 | void insert(initializer_list<value_type> il); |
| 298 | |
| 299 | iterator erase(const_iterator position); |
| 300 | size_type erase(const key_type& k); |
| 301 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 302 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 303 | |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 304 | void swap(multiset& s) |
| 305 | noexcept( |
| 306 | __is_nothrow_swappable<key_compare>::value && |
| 307 | (!allocator_type::propagate_on_container_swap::value || |
| 308 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 309 | |
| 310 | // observers: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 311 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 312 | key_compare key_comp() const; |
| 313 | value_compare value_comp() const; |
| 314 | |
| 315 | // set operations: |
| 316 | iterator find(const key_type& k); |
| 317 | const_iterator find(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 318 | template<typename K> |
| 319 | iterator find(const K& x); |
| 320 | template<typename K> |
| 321 | const_iterator find(const K& x) const; // C++14 |
| 322 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 323 | size_type count(const key_type& k) const; |
| 324 | iterator lower_bound(const key_type& k); |
| 325 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 326 | template<typename K> |
| 327 | iterator lower_bound(const K& x); // C++14 |
| 328 | template<typename K> |
| 329 | const_iterator lower_bound(const K& x) const; // C++14 |
| 330 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 331 | iterator upper_bound(const key_type& k); |
| 332 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 333 | template<typename K> |
| 334 | iterator upper_bound(const K& x); // C++14 |
| 335 | template<typename K> |
| 336 | const_iterator upper_bound(const K& x) const; // C++14 |
| 337 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 338 | pair<iterator,iterator> equal_range(const key_type& k); |
| 339 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 340 | template<typename K> |
| 341 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 342 | template<typename K> |
| 343 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | template <class Key, class Compare, class Allocator> |
| 347 | bool |
| 348 | operator==(const multiset<Key, Compare, Allocator>& x, |
| 349 | const multiset<Key, Compare, Allocator>& y); |
| 350 | |
| 351 | template <class Key, class Compare, class Allocator> |
| 352 | bool |
| 353 | operator< (const multiset<Key, Compare, Allocator>& x, |
| 354 | const multiset<Key, Compare, Allocator>& y); |
| 355 | |
| 356 | template <class Key, class Compare, class Allocator> |
| 357 | bool |
| 358 | operator!=(const multiset<Key, Compare, Allocator>& x, |
| 359 | const multiset<Key, Compare, Allocator>& y); |
| 360 | |
| 361 | template <class Key, class Compare, class Allocator> |
| 362 | bool |
| 363 | operator> (const multiset<Key, Compare, Allocator>& x, |
| 364 | const multiset<Key, Compare, Allocator>& y); |
| 365 | |
| 366 | template <class Key, class Compare, class Allocator> |
| 367 | bool |
| 368 | operator>=(const multiset<Key, Compare, Allocator>& x, |
| 369 | const multiset<Key, Compare, Allocator>& y); |
| 370 | |
| 371 | template <class Key, class Compare, class Allocator> |
| 372 | bool |
| 373 | operator<=(const multiset<Key, Compare, Allocator>& x, |
| 374 | const multiset<Key, Compare, Allocator>& y); |
| 375 | |
| 376 | // specialized algorithms: |
| 377 | template <class Key, class Compare, class Allocator> |
| 378 | void |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 379 | swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) |
| 380 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 381 | |
| 382 | } // std |
| 383 | |
| 384 | */ |
| 385 | |
| 386 | #include <__config> |
| 387 | #include <__tree> |
| 388 | #include <functional> |
| 389 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 390 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 391 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 392 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 393 | |
| 394 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 395 | |
| 396 | template <class _Key, class _Compare = less<_Key>, |
| 397 | class _Allocator = allocator<_Key> > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 398 | class _LIBCPP_TYPE_VIS_ONLY set |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 399 | { |
| 400 | public: |
| 401 | // types: |
| 402 | typedef _Key key_type; |
| 403 | typedef key_type value_type; |
| 404 | typedef _Compare key_compare; |
| 405 | typedef key_compare value_compare; |
| 406 | typedef _Allocator allocator_type; |
| 407 | typedef value_type& reference; |
| 408 | typedef const value_type& const_reference; |
| 409 | |
| 410 | private: |
| 411 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 412 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 413 | typedef typename __base::__node_holder __node_holder; |
| 414 | |
| 415 | __base __tree_; |
| 416 | |
| 417 | public: |
| 418 | typedef typename __base::pointer pointer; |
| 419 | typedef typename __base::const_pointer const_pointer; |
| 420 | typedef typename __base::size_type size_type; |
| 421 | typedef typename __base::difference_type difference_type; |
| 422 | typedef typename __base::const_iterator iterator; |
| 423 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 424 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 425 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 426 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 427 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 428 | set() |
| 429 | _NOEXCEPT_( |
| 430 | is_nothrow_default_constructible<allocator_type>::value && |
| 431 | is_nothrow_default_constructible<key_compare>::value && |
| 432 | is_nothrow_copy_constructible<key_compare>::value) |
| 433 | : __tree_(value_compare()) {} |
| 434 | |
| 435 | _LIBCPP_INLINE_VISIBILITY |
| 436 | explicit set(const value_compare& __comp) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 437 | _NOEXCEPT_( |
| 438 | is_nothrow_default_constructible<allocator_type>::value && |
| 439 | is_nothrow_default_constructible<key_compare>::value && |
| 440 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 441 | : __tree_(__comp) {} |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 442 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 443 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 444 | explicit set(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | : __tree_(__comp, __a) {} |
| 446 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 447 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 448 | set(_InputIterator __f, _InputIterator __l, |
| 449 | const value_compare& __comp = value_compare()) |
| 450 | : __tree_(__comp) |
| 451 | { |
| 452 | insert(__f, __l); |
| 453 | } |
| 454 | |
| 455 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 456 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, |
| 458 | const allocator_type& __a) |
| 459 | : __tree_(__comp, __a) |
| 460 | { |
| 461 | insert(__f, __l); |
| 462 | } |
| 463 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 464 | #if _LIBCPP_STD_VER > 11 |
| 465 | template <class _InputIterator> |
| 466 | _LIBCPP_INLINE_VISIBILITY |
| 467 | set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 468 | : set(__f, __l, key_compare(), __a) {} |
| 469 | #endif |
| 470 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 471 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 472 | set(const set& __s) |
| 473 | : __tree_(__s.__tree_) |
| 474 | { |
| 475 | insert(__s.begin(), __s.end()); |
| 476 | } |
| 477 | |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 478 | _LIBCPP_INLINE_VISIBILITY |
| 479 | set& operator=(const set& __s) |
| 480 | { |
| 481 | __tree_ = __s.__tree_; |
| 482 | return *this; |
| 483 | } |
| 484 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 485 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 486 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | set(set&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 488 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 489 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 490 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 491 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 492 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 493 | explicit set(const allocator_type& __a) |
| 494 | : __tree_(__a) {} |
| 495 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 496 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 497 | set(const set& __s, const allocator_type& __a) |
| 498 | : __tree_(__s.__tree_.value_comp(), __a) |
| 499 | { |
| 500 | insert(__s.begin(), __s.end()); |
| 501 | } |
| 502 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 503 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 504 | set(set&& __s, const allocator_type& __a); |
| 505 | #endif |
| 506 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 507 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 508 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 509 | set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 510 | : __tree_(__comp) |
| 511 | { |
| 512 | insert(__il.begin(), __il.end()); |
| 513 | } |
| 514 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 515 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 516 | set(initializer_list<value_type> __il, const value_compare& __comp, |
| 517 | const allocator_type& __a) |
| 518 | : __tree_(__comp, __a) |
| 519 | { |
| 520 | insert(__il.begin(), __il.end()); |
| 521 | } |
| 522 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 523 | #if _LIBCPP_STD_VER > 11 |
| 524 | _LIBCPP_INLINE_VISIBILITY |
| 525 | set(initializer_list<value_type> __il, const allocator_type& __a) |
| 526 | : set(__il, key_compare(), __a) {} |
| 527 | #endif |
| 528 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 529 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 530 | set& operator=(initializer_list<value_type> __il) |
| 531 | { |
| 532 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 533 | return *this; |
| 534 | } |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 535 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 536 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 537 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 538 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 539 | set& operator=(set&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 540 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 541 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 542 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 543 | return *this; |
| 544 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 545 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 546 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 547 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 548 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 549 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 550 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 551 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 552 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 553 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 554 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 555 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 556 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 557 | reverse_iterator rbegin() _NOEXCEPT |
| 558 | {return reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 559 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 560 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 561 | {return const_reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 562 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 563 | reverse_iterator rend() _NOEXCEPT |
| 564 | {return reverse_iterator(begin());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 565 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 566 | const_reverse_iterator rend() const _NOEXCEPT |
| 567 | {return const_reverse_iterator(begin());} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 568 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 569 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 570 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 571 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 572 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 573 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 574 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 575 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 576 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 577 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 578 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 579 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 580 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 581 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 582 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 583 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 584 | |
| 585 | // modifiers: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 586 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 587 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 588 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | pair<iterator, bool> emplace(_Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 590 | {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 591 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 592 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 593 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 594 | {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 595 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 596 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 597 | pair<iterator,bool> insert(const value_type& __v) |
| 598 | {return __tree_.__insert_unique(__v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 599 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 600 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 601 | pair<iterator,bool> insert(value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 602 | {return __tree_.__insert_unique(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 603 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 604 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | iterator insert(const_iterator __p, const value_type& __v) |
| 606 | {return __tree_.__insert_unique(__p, __v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 607 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 608 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 609 | iterator insert(const_iterator __p, value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 610 | {return __tree_.__insert_unique(__p, _VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 611 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 613 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 614 | void insert(_InputIterator __f, _InputIterator __l) |
| 615 | { |
| 616 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 617 | __tree_.__insert_unique(__e, *__f); |
| 618 | } |
| 619 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 620 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 621 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 622 | void insert(initializer_list<value_type> __il) |
| 623 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 624 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 625 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 626 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 627 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 628 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | size_type erase(const key_type& __k) |
| 630 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 631 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 632 | iterator erase(const_iterator __f, const_iterator __l) |
| 633 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 634 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 635 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 636 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 637 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 638 | void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 639 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 640 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 641 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 642 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 643 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 644 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 645 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 646 | value_compare value_comp() const {return __tree_.value_comp();} |
| 647 | |
| 648 | // set operations: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 649 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 650 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 651 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 652 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 653 | #if _LIBCPP_STD_VER > 11 |
| 654 | template <typename _K2> |
| 655 | _LIBCPP_INLINE_VISIBILITY |
| 656 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 657 | find(const _K2& __k) {return __tree_.find(__k);} |
| 658 | template <typename _K2> |
| 659 | _LIBCPP_INLINE_VISIBILITY |
| 660 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 661 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 662 | #endif |
| 663 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 664 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 665 | size_type count(const key_type& __k) const |
| 666 | {return __tree_.__count_unique(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 667 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 668 | iterator lower_bound(const key_type& __k) |
| 669 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 670 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 671 | const_iterator lower_bound(const key_type& __k) const |
| 672 | {return __tree_.lower_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 673 | #if _LIBCPP_STD_VER > 11 |
| 674 | template <typename _K2> |
| 675 | _LIBCPP_INLINE_VISIBILITY |
| 676 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 677 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 678 | |
| 679 | template <typename _K2> |
| 680 | _LIBCPP_INLINE_VISIBILITY |
| 681 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 682 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 683 | #endif |
| 684 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 685 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 686 | iterator upper_bound(const key_type& __k) |
| 687 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 688 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | const_iterator upper_bound(const key_type& __k) const |
| 690 | {return __tree_.upper_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 691 | #if _LIBCPP_STD_VER > 11 |
| 692 | template <typename _K2> |
| 693 | _LIBCPP_INLINE_VISIBILITY |
| 694 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 695 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 696 | template <typename _K2> |
| 697 | _LIBCPP_INLINE_VISIBILITY |
| 698 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 699 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 700 | #endif |
| 701 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 702 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 703 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 704 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 705 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 706 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 707 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 708 | #if _LIBCPP_STD_VER > 11 |
| 709 | template <typename _K2> |
| 710 | _LIBCPP_INLINE_VISIBILITY |
| 711 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 712 | equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} |
| 713 | template <typename _K2> |
| 714 | _LIBCPP_INLINE_VISIBILITY |
| 715 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 716 | equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} |
| 717 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 718 | }; |
| 719 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 720 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 721 | |
| 722 | template <class _Key, class _Compare, class _Allocator> |
| 723 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 724 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 725 | { |
| 726 | if (__a != __s.get_allocator()) |
| 727 | { |
| 728 | const_iterator __e = cend(); |
| 729 | while (!__s.empty()) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 730 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 731 | } |
| 732 | } |
| 733 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 734 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 735 | |
| 736 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 737 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 738 | bool |
| 739 | operator==(const set<_Key, _Compare, _Allocator>& __x, |
| 740 | const set<_Key, _Compare, _Allocator>& __y) |
| 741 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 742 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 746 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 747 | bool |
| 748 | operator< (const set<_Key, _Compare, _Allocator>& __x, |
| 749 | const set<_Key, _Compare, _Allocator>& __y) |
| 750 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 751 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 755 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 756 | bool |
| 757 | operator!=(const set<_Key, _Compare, _Allocator>& __x, |
| 758 | const set<_Key, _Compare, _Allocator>& __y) |
| 759 | { |
| 760 | return !(__x == __y); |
| 761 | } |
| 762 | |
| 763 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 764 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 765 | bool |
| 766 | operator> (const set<_Key, _Compare, _Allocator>& __x, |
| 767 | const set<_Key, _Compare, _Allocator>& __y) |
| 768 | { |
| 769 | return __y < __x; |
| 770 | } |
| 771 | |
| 772 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 773 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 774 | bool |
| 775 | operator>=(const set<_Key, _Compare, _Allocator>& __x, |
| 776 | const set<_Key, _Compare, _Allocator>& __y) |
| 777 | { |
| 778 | return !(__x < __y); |
| 779 | } |
| 780 | |
| 781 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 782 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 783 | bool |
| 784 | operator<=(const set<_Key, _Compare, _Allocator>& __x, |
| 785 | const set<_Key, _Compare, _Allocator>& __y) |
| 786 | { |
| 787 | return !(__y < __x); |
| 788 | } |
| 789 | |
| 790 | // specialized algorithms: |
| 791 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 792 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 793 | void |
| 794 | swap(set<_Key, _Compare, _Allocator>& __x, |
| 795 | set<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 796 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 797 | { |
| 798 | __x.swap(__y); |
| 799 | } |
| 800 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 801 | template <class _Key, class _Compare = less<_Key>, |
| 802 | class _Allocator = allocator<_Key> > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 803 | class _LIBCPP_TYPE_VIS_ONLY multiset |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 804 | { |
| 805 | public: |
| 806 | // types: |
| 807 | typedef _Key key_type; |
| 808 | typedef key_type value_type; |
| 809 | typedef _Compare key_compare; |
| 810 | typedef key_compare value_compare; |
| 811 | typedef _Allocator allocator_type; |
| 812 | typedef value_type& reference; |
| 813 | typedef const value_type& const_reference; |
| 814 | |
| 815 | private: |
| 816 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 817 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 818 | typedef typename __base::__node_holder __node_holder; |
| 819 | |
| 820 | __base __tree_; |
| 821 | |
| 822 | public: |
| 823 | typedef typename __base::pointer pointer; |
| 824 | typedef typename __base::const_pointer const_pointer; |
| 825 | typedef typename __base::size_type size_type; |
| 826 | typedef typename __base::difference_type difference_type; |
| 827 | typedef typename __base::const_iterator iterator; |
| 828 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 829 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 830 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 831 | |
| 832 | // construct/copy/destroy: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 833 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 834 | multiset() |
| 835 | _NOEXCEPT_( |
| 836 | is_nothrow_default_constructible<allocator_type>::value && |
| 837 | is_nothrow_default_constructible<key_compare>::value && |
| 838 | is_nothrow_copy_constructible<key_compare>::value) |
| 839 | : __tree_(value_compare()) {} |
| 840 | |
| 841 | _LIBCPP_INLINE_VISIBILITY |
| 842 | explicit multiset(const value_compare& __comp) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 843 | _NOEXCEPT_( |
| 844 | is_nothrow_default_constructible<allocator_type>::value && |
| 845 | is_nothrow_default_constructible<key_compare>::value && |
| 846 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 847 | : __tree_(__comp) {} |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 848 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 849 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 850 | explicit multiset(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 851 | : __tree_(__comp, __a) {} |
| 852 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 853 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 854 | multiset(_InputIterator __f, _InputIterator __l, |
| 855 | const value_compare& __comp = value_compare()) |
| 856 | : __tree_(__comp) |
| 857 | { |
| 858 | insert(__f, __l); |
| 859 | } |
| 860 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 861 | #if _LIBCPP_STD_VER > 11 |
| 862 | template <class _InputIterator> |
| 863 | _LIBCPP_INLINE_VISIBILITY |
| 864 | multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 865 | : multiset(__f, __l, key_compare(), __a) {} |
| 866 | #endif |
| 867 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 868 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 869 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 870 | multiset(_InputIterator __f, _InputIterator __l, |
| 871 | const value_compare& __comp, const allocator_type& __a) |
| 872 | : __tree_(__comp, __a) |
| 873 | { |
| 874 | insert(__f, __l); |
| 875 | } |
| 876 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 877 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 878 | multiset(const multiset& __s) |
| 879 | : __tree_(__s.__tree_.value_comp(), |
| 880 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) |
| 881 | { |
| 882 | insert(__s.begin(), __s.end()); |
| 883 | } |
| 884 | |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 885 | _LIBCPP_INLINE_VISIBILITY |
| 886 | multiset& operator=(const multiset& __s) |
| 887 | { |
| 888 | __tree_ = __s.__tree_; |
| 889 | return *this; |
| 890 | } |
| 891 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 892 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 893 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 894 | multiset(multiset&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 895 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 896 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 897 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 898 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 899 | explicit multiset(const allocator_type& __a) |
| 900 | : __tree_(__a) {} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 901 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | multiset(const multiset& __s, const allocator_type& __a) |
| 903 | : __tree_(__s.__tree_.value_comp(), __a) |
| 904 | { |
| 905 | insert(__s.begin(), __s.end()); |
| 906 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 907 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 908 | multiset(multiset&& __s, const allocator_type& __a); |
| 909 | #endif |
| 910 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 911 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 912 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 913 | multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 914 | : __tree_(__comp) |
| 915 | { |
| 916 | insert(__il.begin(), __il.end()); |
| 917 | } |
| 918 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 919 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 920 | multiset(initializer_list<value_type> __il, const value_compare& __comp, |
| 921 | const allocator_type& __a) |
| 922 | : __tree_(__comp, __a) |
| 923 | { |
| 924 | insert(__il.begin(), __il.end()); |
| 925 | } |
| 926 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 927 | #if _LIBCPP_STD_VER > 11 |
| 928 | _LIBCPP_INLINE_VISIBILITY |
| 929 | multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 930 | : multiset(__il, key_compare(), __a) {} |
| 931 | #endif |
| 932 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 933 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 934 | multiset& operator=(initializer_list<value_type> __il) |
| 935 | { |
| 936 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 937 | return *this; |
| 938 | } |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 939 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 941 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 942 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 943 | multiset& operator=(multiset&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 944 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 945 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 946 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 947 | return *this; |
| 948 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 949 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 950 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 951 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 952 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 953 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 954 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 955 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 956 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 957 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 958 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 959 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 960 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 961 | reverse_iterator rbegin() _NOEXCEPT |
| 962 | {return reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 963 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 964 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 965 | {return const_reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 966 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 967 | reverse_iterator rend() _NOEXCEPT |
| 968 | {return reverse_iterator(begin());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 969 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 970 | const_reverse_iterator rend() const _NOEXCEPT |
| 971 | {return const_reverse_iterator(begin());} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 972 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 973 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 974 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 975 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 976 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 977 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 978 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 979 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 980 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 981 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 982 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 983 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 984 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 985 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 986 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 987 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 988 | |
| 989 | // modifiers: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 990 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 991 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 992 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 993 | iterator emplace(_Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 994 | {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 995 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 996 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 997 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 998 | {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 999 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1000 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1001 | iterator insert(const value_type& __v) |
| 1002 | {return __tree_.__insert_multi(__v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1003 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1004 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1005 | iterator insert(value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1006 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1007 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1008 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1009 | iterator insert(const_iterator __p, const value_type& __v) |
| 1010 | {return __tree_.__insert_multi(__p, __v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1011 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1012 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1013 | iterator insert(const_iterator __p, value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1014 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1015 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1016 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1017 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1018 | void insert(_InputIterator __f, _InputIterator __l) |
| 1019 | { |
| 1020 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1021 | __tree_.__insert_multi(__e, *__f); |
| 1022 | } |
| 1023 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1024 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1025 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1026 | void insert(initializer_list<value_type> __il) |
| 1027 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1028 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1029 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1030 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1031 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1032 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1033 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1034 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1035 | iterator erase(const_iterator __f, const_iterator __l) |
| 1036 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1037 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1038 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1039 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1040 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1041 | void swap(multiset& __s) |
| 1042 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1043 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1044 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1045 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1046 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1047 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1048 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1049 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | value_compare value_comp() const {return __tree_.value_comp();} |
| 1051 | |
| 1052 | // set operations: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1053 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1054 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1055 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1056 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1057 | #if _LIBCPP_STD_VER > 11 |
| 1058 | template <typename _K2> |
| 1059 | _LIBCPP_INLINE_VISIBILITY |
| 1060 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1061 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1062 | template <typename _K2> |
| 1063 | _LIBCPP_INLINE_VISIBILITY |
| 1064 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1065 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1066 | #endif |
| 1067 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1068 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1069 | size_type count(const key_type& __k) const |
| 1070 | {return __tree_.__count_multi(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1071 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1072 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1073 | iterator lower_bound(const key_type& __k) |
| 1074 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1075 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1076 | const_iterator lower_bound(const key_type& __k) const |
| 1077 | {return __tree_.lower_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1078 | #if _LIBCPP_STD_VER > 11 |
| 1079 | template <typename _K2> |
| 1080 | _LIBCPP_INLINE_VISIBILITY |
| 1081 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1082 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1083 | |
| 1084 | template <typename _K2> |
| 1085 | _LIBCPP_INLINE_VISIBILITY |
| 1086 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1087 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1088 | #endif |
| 1089 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1090 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1091 | iterator upper_bound(const key_type& __k) |
| 1092 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1093 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1094 | const_iterator upper_bound(const key_type& __k) const |
| 1095 | {return __tree_.upper_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1096 | #if _LIBCPP_STD_VER > 11 |
| 1097 | template <typename _K2> |
| 1098 | _LIBCPP_INLINE_VISIBILITY |
| 1099 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1100 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1101 | template <typename _K2> |
| 1102 | _LIBCPP_INLINE_VISIBILITY |
| 1103 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1104 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1105 | #endif |
| 1106 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1107 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1108 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1109 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1110 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1111 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1112 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1113 | #if _LIBCPP_STD_VER > 11 |
| 1114 | template <typename _K2> |
| 1115 | _LIBCPP_INLINE_VISIBILITY |
| 1116 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 1117 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1118 | template <typename _K2> |
| 1119 | _LIBCPP_INLINE_VISIBILITY |
| 1120 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 1121 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1122 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1123 | }; |
| 1124 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1125 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1126 | |
| 1127 | template <class _Key, class _Compare, class _Allocator> |
| 1128 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1129 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1130 | { |
| 1131 | if (__a != __s.get_allocator()) |
| 1132 | { |
| 1133 | const_iterator __e = cend(); |
| 1134 | while (!__s.empty()) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1135 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1136 | } |
| 1137 | } |
| 1138 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1139 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1140 | |
| 1141 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1142 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1143 | bool |
| 1144 | operator==(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1145 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1146 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1147 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1151 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1152 | bool |
| 1153 | operator< (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1154 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1155 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1156 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1160 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1161 | bool |
| 1162 | operator!=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1163 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1164 | { |
| 1165 | return !(__x == __y); |
| 1166 | } |
| 1167 | |
| 1168 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1169 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1170 | bool |
| 1171 | operator> (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1172 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1173 | { |
| 1174 | return __y < __x; |
| 1175 | } |
| 1176 | |
| 1177 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1178 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1179 | bool |
| 1180 | operator>=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1181 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1182 | { |
| 1183 | return !(__x < __y); |
| 1184 | } |
| 1185 | |
| 1186 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1187 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1188 | bool |
| 1189 | operator<=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1190 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1191 | { |
| 1192 | return !(__y < __x); |
| 1193 | } |
| 1194 | |
| 1195 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1196 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1197 | void |
| 1198 | swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1199 | multiset<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1200 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1201 | { |
| 1202 | __x.swap(__y); |
| 1203 | } |
| 1204 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1205 | _LIBCPP_END_NAMESPACE_STD |
| 1206 | |
| 1207 | #endif // _LIBCPP_SET |