Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- set -------------------------------------===// |
| 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_SET |
| 11 | #define _LIBCPP_SET |
| 12 | |
| 13 | /* |
| 14 | |
| 15 | set synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | template <class Key, class Compare = less<Key>, |
| 21 | class Allocator = allocator<Key>> |
| 22 | class set |
| 23 | { |
| 24 | public: |
| 25 | // types: |
| 26 | typedef Key key_type; |
| 27 | typedef key_type value_type; |
| 28 | typedef Compare key_compare; |
| 29 | typedef key_compare value_compare; |
| 30 | typedef Allocator allocator_type; |
| 31 | typedef typename allocator_type::reference reference; |
| 32 | typedef typename allocator_type::const_reference const_reference; |
| 33 | typedef typename allocator_type::size_type size_type; |
| 34 | typedef typename allocator_type::difference_type difference_type; |
| 35 | typedef typename allocator_type::pointer pointer; |
| 36 | typedef typename allocator_type::const_pointer const_pointer; |
| 37 | |
| 38 | typedef implementation-defined iterator; |
| 39 | typedef implementation-defined const_iterator; |
| 40 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 41 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 42 | typedef unspecified node_type; // C++17 |
| 43 | typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | |
| 45 | // construct/copy/destroy: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 46 | set() |
| 47 | noexcept( |
| 48 | is_nothrow_default_constructible<allocator_type>::value && |
| 49 | is_nothrow_default_constructible<key_compare>::value && |
| 50 | is_nothrow_copy_constructible<key_compare>::value); |
| 51 | explicit set(const value_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | set(const value_compare& comp, const allocator_type& a); |
| 53 | template <class InputIterator> |
| 54 | set(InputIterator first, InputIterator last, |
| 55 | const value_compare& comp = value_compare()); |
| 56 | template <class InputIterator> |
| 57 | set(InputIterator first, InputIterator last, const value_compare& comp, |
| 58 | const allocator_type& a); |
| 59 | set(const set& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 60 | set(set&& s) |
| 61 | noexcept( |
| 62 | is_nothrow_move_constructible<allocator_type>::value && |
| 63 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | explicit set(const allocator_type& a); |
| 65 | set(const set& s, const allocator_type& a); |
| 66 | set(set&& s, const allocator_type& a); |
| 67 | set(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 68 | set(initializer_list<value_type> il, const value_compare& comp, |
| 69 | const allocator_type& a); |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 70 | template <class InputIterator> |
| 71 | set(InputIterator first, InputIterator last, const allocator_type& a) |
| 72 | : set(first, last, Compare(), a) {} // C++14 |
| 73 | set(initializer_list<value_type> il, const allocator_type& a) |
| 74 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 75 | ~set(); |
| 76 | |
| 77 | set& operator=(const set& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 78 | set& operator=(set&& s) |
| 79 | noexcept( |
| 80 | allocator_type::propagate_on_container_move_assignment::value && |
| 81 | is_nothrow_move_assignable<allocator_type>::value && |
| 82 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 83 | set& operator=(initializer_list<value_type> il); |
| 84 | |
| 85 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 86 | iterator begin() noexcept; |
| 87 | const_iterator begin() const noexcept; |
| 88 | iterator end() noexcept; |
| 89 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 90 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 91 | reverse_iterator rbegin() noexcept; |
| 92 | const_reverse_iterator rbegin() const noexcept; |
| 93 | reverse_iterator rend() noexcept; |
| 94 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 96 | const_iterator cbegin() const noexcept; |
| 97 | const_iterator cend() const noexcept; |
| 98 | const_reverse_iterator crbegin() const noexcept; |
| 99 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 100 | |
| 101 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 102 | bool empty() const noexcept; |
| 103 | size_type size() const noexcept; |
| 104 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 105 | |
| 106 | // modifiers: |
| 107 | template <class... Args> |
| 108 | pair<iterator, bool> emplace(Args&&... args); |
| 109 | template <class... Args> |
| 110 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 111 | pair<iterator,bool> insert(const value_type& v); |
| 112 | pair<iterator,bool> insert(value_type&& v); |
| 113 | iterator insert(const_iterator position, const value_type& v); |
| 114 | iterator insert(const_iterator position, value_type&& v); |
| 115 | template <class InputIterator> |
| 116 | void insert(InputIterator first, InputIterator last); |
| 117 | void insert(initializer_list<value_type> il); |
| 118 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 119 | node_type extract(const_iterator position); // C++17 |
| 120 | node_type extract(const key_type& x); // C++17 |
| 121 | insert_return_type insert(node_type&& nh); // C++17 |
| 122 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 123 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 124 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 125 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 126 | size_type erase(const key_type& k); |
| 127 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 128 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 129 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 130 | template<class C2> |
| 131 | void merge(set<Key, C2, Allocator>& source); // C++17 |
| 132 | template<class C2> |
| 133 | void merge(set<Key, C2, Allocator>&& source); // C++17 |
| 134 | template<class C2> |
| 135 | void merge(multiset<Key, C2, Allocator>& source); // C++17 |
| 136 | template<class C2> |
| 137 | void merge(multiset<Key, C2, Allocator>&& source); // C++17 |
| 138 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 139 | void swap(set& s) |
| 140 | noexcept( |
| 141 | __is_nothrow_swappable<key_compare>::value && |
| 142 | (!allocator_type::propagate_on_container_swap::value || |
| 143 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | |
| 145 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 146 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | key_compare key_comp() const; |
| 148 | value_compare value_comp() const; |
| 149 | |
| 150 | // set operations: |
| 151 | iterator find(const key_type& k); |
| 152 | const_iterator find(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 153 | template<typename K> |
| 154 | iterator find(const K& x); |
| 155 | template<typename K> |
| 156 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 157 | |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 158 | template<typename K> |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 159 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 160 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 161 | |
| 162 | bool contains(const key_type& x) const; // C++20 |
| 163 | template<class K> bool contains(const K& x) const; // C++20 |
| 164 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 165 | iterator lower_bound(const key_type& k); |
| 166 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 167 | template<typename K> |
| 168 | iterator lower_bound(const K& x); // C++14 |
| 169 | template<typename K> |
| 170 | const_iterator lower_bound(const K& x) const; // C++14 |
| 171 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 172 | iterator upper_bound(const key_type& k); |
| 173 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 174 | template<typename K> |
| 175 | iterator upper_bound(const K& x); // C++14 |
| 176 | template<typename K> |
| 177 | const_iterator upper_bound(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 178 | pair<iterator,iterator> equal_range(const key_type& k); |
| 179 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 180 | template<typename K> |
| 181 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 182 | template<typename K> |
| 183 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | }; |
| 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 | template <class Key, class Compare, class Allocator> |
| 197 | bool |
| 198 | operator!=(const set<Key, Compare, Allocator>& x, |
| 199 | const set<Key, Compare, Allocator>& y); |
| 200 | |
| 201 | template <class Key, class Compare, class Allocator> |
| 202 | bool |
| 203 | operator> (const set<Key, Compare, Allocator>& x, |
| 204 | const set<Key, Compare, Allocator>& y); |
| 205 | |
| 206 | template <class Key, class Compare, class Allocator> |
| 207 | bool |
| 208 | operator>=(const set<Key, Compare, Allocator>& x, |
| 209 | const set<Key, Compare, Allocator>& y); |
| 210 | |
| 211 | template <class Key, class Compare, class Allocator> |
| 212 | bool |
| 213 | operator<=(const set<Key, Compare, Allocator>& x, |
| 214 | const set<Key, Compare, Allocator>& y); |
| 215 | |
| 216 | // specialized algorithms: |
| 217 | template <class Key, class Compare, class Allocator> |
| 218 | void |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 219 | swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) |
| 220 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 221 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 222 | template <class Key, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 223 | typename set<Key, Compare, Allocator>::size_type |
| 224 | erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 225 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 226 | template <class Key, class Compare = less<Key>, |
| 227 | class Allocator = allocator<Key>> |
| 228 | class multiset |
| 229 | { |
| 230 | public: |
| 231 | // types: |
| 232 | typedef Key key_type; |
| 233 | typedef key_type value_type; |
| 234 | typedef Compare key_compare; |
| 235 | typedef key_compare value_compare; |
| 236 | typedef Allocator allocator_type; |
| 237 | typedef typename allocator_type::reference reference; |
| 238 | typedef typename allocator_type::const_reference const_reference; |
| 239 | typedef typename allocator_type::size_type size_type; |
| 240 | typedef typename allocator_type::difference_type difference_type; |
| 241 | typedef typename allocator_type::pointer pointer; |
| 242 | typedef typename allocator_type::const_pointer const_pointer; |
| 243 | |
| 244 | typedef implementation-defined iterator; |
| 245 | typedef implementation-defined const_iterator; |
| 246 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 247 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 248 | typedef unspecified node_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 249 | |
| 250 | // construct/copy/destroy: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 251 | multiset() |
| 252 | noexcept( |
| 253 | is_nothrow_default_constructible<allocator_type>::value && |
| 254 | is_nothrow_default_constructible<key_compare>::value && |
| 255 | is_nothrow_copy_constructible<key_compare>::value); |
| 256 | explicit multiset(const value_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 257 | multiset(const value_compare& comp, const allocator_type& a); |
| 258 | template <class InputIterator> |
| 259 | multiset(InputIterator first, InputIterator last, |
| 260 | const value_compare& comp = value_compare()); |
| 261 | template <class InputIterator> |
| 262 | multiset(InputIterator first, InputIterator last, |
| 263 | const value_compare& comp, const allocator_type& a); |
| 264 | multiset(const multiset& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 265 | multiset(multiset&& s) |
| 266 | noexcept( |
| 267 | is_nothrow_move_constructible<allocator_type>::value && |
| 268 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 269 | explicit multiset(const allocator_type& a); |
| 270 | multiset(const multiset& s, const allocator_type& a); |
| 271 | multiset(multiset&& s, const allocator_type& a); |
| 272 | multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 273 | multiset(initializer_list<value_type> il, const value_compare& comp, |
| 274 | const allocator_type& a); |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 275 | template <class InputIterator> |
| 276 | multiset(InputIterator first, InputIterator last, const allocator_type& a) |
| 277 | : set(first, last, Compare(), a) {} // C++14 |
| 278 | multiset(initializer_list<value_type> il, const allocator_type& a) |
| 279 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 280 | ~multiset(); |
| 281 | |
| 282 | multiset& operator=(const multiset& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 283 | multiset& operator=(multiset&& s) |
| 284 | noexcept( |
| 285 | allocator_type::propagate_on_container_move_assignment::value && |
| 286 | is_nothrow_move_assignable<allocator_type>::value && |
| 287 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 288 | multiset& operator=(initializer_list<value_type> il); |
| 289 | |
| 290 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 291 | iterator begin() noexcept; |
| 292 | const_iterator begin() const noexcept; |
| 293 | iterator end() noexcept; |
| 294 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 295 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 296 | reverse_iterator rbegin() noexcept; |
| 297 | const_reverse_iterator rbegin() const noexcept; |
| 298 | reverse_iterator rend() noexcept; |
| 299 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 300 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 301 | const_iterator cbegin() const noexcept; |
| 302 | const_iterator cend() const noexcept; |
| 303 | const_reverse_iterator crbegin() const noexcept; |
| 304 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 305 | |
| 306 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 307 | bool empty() const noexcept; |
| 308 | size_type size() const noexcept; |
| 309 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 310 | |
| 311 | // modifiers: |
| 312 | template <class... Args> |
| 313 | iterator emplace(Args&&... args); |
| 314 | template <class... Args> |
| 315 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 316 | iterator insert(const value_type& v); |
| 317 | iterator insert(value_type&& v); |
| 318 | iterator insert(const_iterator position, const value_type& v); |
| 319 | iterator insert(const_iterator position, value_type&& v); |
| 320 | template <class InputIterator> |
| 321 | void insert(InputIterator first, InputIterator last); |
| 322 | void insert(initializer_list<value_type> il); |
| 323 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 324 | node_type extract(const_iterator position); // C++17 |
| 325 | node_type extract(const key_type& x); // C++17 |
| 326 | iterator insert(node_type&& nh); // C++17 |
| 327 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 328 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 329 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 330 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 331 | size_type erase(const key_type& k); |
| 332 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 333 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 334 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 335 | template<class C2> |
| 336 | void merge(multiset<Key, C2, Allocator>& source); // C++17 |
| 337 | template<class C2> |
| 338 | void merge(multiset<Key, C2, Allocator>&& source); // C++17 |
| 339 | template<class C2> |
| 340 | void merge(set<Key, C2, Allocator>& source); // C++17 |
| 341 | template<class C2> |
| 342 | void merge(set<Key, C2, Allocator>&& source); // C++17 |
| 343 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 344 | void swap(multiset& s) |
| 345 | noexcept( |
| 346 | __is_nothrow_swappable<key_compare>::value && |
| 347 | (!allocator_type::propagate_on_container_swap::value || |
| 348 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 349 | |
| 350 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 351 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 352 | key_compare key_comp() const; |
| 353 | value_compare value_comp() const; |
| 354 | |
| 355 | // set operations: |
| 356 | iterator find(const key_type& k); |
| 357 | const_iterator find(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 358 | template<typename K> |
| 359 | iterator find(const K& x); |
| 360 | template<typename K> |
| 361 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 362 | |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 363 | template<typename K> |
| 364 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 365 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 366 | |
| 367 | bool contains(const key_type& x) const; // C++20 |
| 368 | template<class K> bool contains(const K& x) const; // C++20 |
| 369 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 370 | iterator lower_bound(const key_type& k); |
| 371 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 372 | template<typename K> |
| 373 | iterator lower_bound(const K& x); // C++14 |
| 374 | template<typename K> |
| 375 | const_iterator lower_bound(const K& x) const; // C++14 |
| 376 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 377 | iterator upper_bound(const key_type& k); |
| 378 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 379 | template<typename K> |
| 380 | iterator upper_bound(const K& x); // C++14 |
| 381 | template<typename K> |
| 382 | const_iterator upper_bound(const K& x) const; // C++14 |
| 383 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | pair<iterator,iterator> equal_range(const key_type& k); |
| 385 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 386 | template<typename K> |
| 387 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 388 | template<typename K> |
| 389 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | template <class Key, class Compare, class Allocator> |
| 393 | bool |
| 394 | operator==(const multiset<Key, Compare, Allocator>& x, |
| 395 | const multiset<Key, Compare, Allocator>& y); |
| 396 | |
| 397 | template <class Key, class Compare, class Allocator> |
| 398 | bool |
| 399 | operator< (const multiset<Key, Compare, Allocator>& x, |
| 400 | const multiset<Key, Compare, Allocator>& y); |
| 401 | |
| 402 | template <class Key, class Compare, class Allocator> |
| 403 | bool |
| 404 | operator!=(const multiset<Key, Compare, Allocator>& x, |
| 405 | const multiset<Key, Compare, Allocator>& y); |
| 406 | |
| 407 | template <class Key, class Compare, class Allocator> |
| 408 | bool |
| 409 | operator> (const multiset<Key, Compare, Allocator>& x, |
| 410 | const multiset<Key, Compare, Allocator>& y); |
| 411 | |
| 412 | template <class Key, class Compare, class Allocator> |
| 413 | bool |
| 414 | operator>=(const multiset<Key, Compare, Allocator>& x, |
| 415 | const multiset<Key, Compare, Allocator>& y); |
| 416 | |
| 417 | template <class Key, class Compare, class Allocator> |
| 418 | bool |
| 419 | operator<=(const multiset<Key, Compare, Allocator>& x, |
| 420 | const multiset<Key, Compare, Allocator>& y); |
| 421 | |
| 422 | // specialized algorithms: |
| 423 | template <class Key, class Compare, class Allocator> |
| 424 | void |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 425 | swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) |
| 426 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 427 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 428 | template <class Key, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 429 | typename multiset<Key, Compare, Allocator>::size_type |
| 430 | erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 431 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 432 | } // std |
| 433 | |
| 434 | */ |
| 435 | |
| 436 | #include <__config> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 437 | #include <__debug> |
Christopher Di Bella | 55d7a82 | 2021-07-01 09:25:35 -0400 | [diff] [blame] | 438 | #include <__functional/is_transparent.h> |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 439 | #include <__node_handle> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 440 | #include <__tree> |
Christopher Di Bella | 41f26e8 | 2021-06-05 02:47:47 +0000 | [diff] [blame] | 441 | #include <__utility/forward.h> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 442 | #include <compare> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 443 | #include <functional> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 444 | #include <initializer_list> |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 445 | #include <iterator> // __libcpp_erase_if_container |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 446 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 447 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 448 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 449 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 450 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 451 | |
| 452 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 453 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 454 | template <class _Key, class _Compare, class _Allocator> |
| 455 | class multiset; |
| 456 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | template <class _Key, class _Compare = less<_Key>, |
| 458 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 459 | class _LIBCPP_TEMPLATE_VIS set |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 460 | { |
| 461 | public: |
| 462 | // types: |
| 463 | typedef _Key key_type; |
| 464 | typedef key_type value_type; |
| 465 | typedef _Compare key_compare; |
| 466 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 467 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 468 | typedef value_type& reference; |
| 469 | typedef const value_type& const_reference; |
| 470 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 471 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 472 | "Allocator::value_type must be same type as value_type"); |
| 473 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 474 | private: |
| 475 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 476 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 477 | typedef typename __base::__node_holder __node_holder; |
| 478 | |
| 479 | __base __tree_; |
| 480 | |
| 481 | public: |
| 482 | typedef typename __base::pointer pointer; |
| 483 | typedef typename __base::const_pointer const_pointer; |
| 484 | typedef typename __base::size_type size_type; |
| 485 | typedef typename __base::difference_type difference_type; |
| 486 | typedef typename __base::const_iterator iterator; |
| 487 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 488 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 489 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 490 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 491 | #if _LIBCPP_STD_VER > 14 |
| 492 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 493 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 494 | #endif |
| 495 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 496 | template <class _Key2, class _Compare2, class _Alloc2> |
| 497 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 498 | template <class _Key2, class _Compare2, class _Alloc2> |
| 499 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 500 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 501 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 502 | set() |
| 503 | _NOEXCEPT_( |
| 504 | is_nothrow_default_constructible<allocator_type>::value && |
| 505 | is_nothrow_default_constructible<key_compare>::value && |
| 506 | is_nothrow_copy_constructible<key_compare>::value) |
| 507 | : __tree_(value_compare()) {} |
| 508 | |
| 509 | _LIBCPP_INLINE_VISIBILITY |
| 510 | explicit set(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 511 | _NOEXCEPT_( |
| 512 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 513 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 514 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 515 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 516 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 517 | explicit set(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 518 | : __tree_(__comp, __a) {} |
| 519 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 520 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 521 | set(_InputIterator __f, _InputIterator __l, |
| 522 | const value_compare& __comp = value_compare()) |
| 523 | : __tree_(__comp) |
| 524 | { |
| 525 | insert(__f, __l); |
| 526 | } |
| 527 | |
| 528 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 529 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 530 | set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, |
| 531 | const allocator_type& __a) |
| 532 | : __tree_(__comp, __a) |
| 533 | { |
| 534 | insert(__f, __l); |
| 535 | } |
| 536 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 537 | #if _LIBCPP_STD_VER > 11 |
| 538 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 539 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 540 | set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 541 | : set(__f, __l, key_compare(), __a) {} |
| 542 | #endif |
| 543 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 544 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 545 | set(const set& __s) |
| 546 | : __tree_(__s.__tree_) |
| 547 | { |
| 548 | insert(__s.begin(), __s.end()); |
| 549 | } |
| 550 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 551 | _LIBCPP_INLINE_VISIBILITY |
| 552 | set& operator=(const set& __s) |
| 553 | { |
| 554 | __tree_ = __s.__tree_; |
| 555 | return *this; |
| 556 | } |
| 557 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 558 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 559 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 560 | set(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 561 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 562 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 563 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 564 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 565 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 566 | explicit set(const allocator_type& __a) |
| 567 | : __tree_(__a) {} |
| 568 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 569 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 570 | set(const set& __s, const allocator_type& __a) |
| 571 | : __tree_(__s.__tree_.value_comp(), __a) |
| 572 | { |
| 573 | insert(__s.begin(), __s.end()); |
| 574 | } |
| 575 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 576 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 577 | set(set&& __s, const allocator_type& __a); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 578 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 579 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 580 | set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 581 | : __tree_(__comp) |
| 582 | { |
| 583 | insert(__il.begin(), __il.end()); |
| 584 | } |
| 585 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 586 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 587 | set(initializer_list<value_type> __il, const value_compare& __comp, |
| 588 | const allocator_type& __a) |
| 589 | : __tree_(__comp, __a) |
| 590 | { |
| 591 | insert(__il.begin(), __il.end()); |
| 592 | } |
| 593 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 594 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 595 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 596 | set(initializer_list<value_type> __il, const allocator_type& __a) |
| 597 | : set(__il, key_compare(), __a) {} |
| 598 | #endif |
| 599 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 600 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 601 | set& operator=(initializer_list<value_type> __il) |
| 602 | { |
| 603 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 604 | return *this; |
| 605 | } |
| 606 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 607 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 608 | set& operator=(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 609 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 610 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 611 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | return *this; |
| 613 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 614 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 615 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 616 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 617 | ~set() { |
| 618 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 619 | } |
| 620 | |
| 621 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 622 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 623 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 624 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 625 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 626 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 627 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 628 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 630 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 631 | reverse_iterator rbegin() _NOEXCEPT |
| 632 | {return reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 633 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 634 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 635 | {return const_reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 636 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 637 | reverse_iterator rend() _NOEXCEPT |
| 638 | {return reverse_iterator(begin());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 639 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 640 | const_reverse_iterator rend() const _NOEXCEPT |
| 641 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 642 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 643 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 644 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 645 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 646 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 647 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 648 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 649 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 650 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 651 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 652 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 653 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 654 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 655 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 656 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 657 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 658 | |
| 659 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 660 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 662 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 663 | pair<iterator, bool> emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 664 | {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 665 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 666 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 667 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 668 | {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 669 | #endif // _LIBCPP_CXX03_LANG |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 670 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 671 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 672 | pair<iterator,bool> insert(const value_type& __v) |
| 673 | {return __tree_.__insert_unique(__v);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 674 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 675 | iterator insert(const_iterator __p, const value_type& __v) |
| 676 | {return __tree_.__insert_unique(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 677 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 678 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 679 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | void insert(_InputIterator __f, _InputIterator __l) |
| 681 | { |
| 682 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 683 | __tree_.__insert_unique(__e, *__f); |
| 684 | } |
| 685 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 686 | #ifndef _LIBCPP_CXX03_LANG |
| 687 | _LIBCPP_INLINE_VISIBILITY |
| 688 | pair<iterator,bool> insert(value_type&& __v) |
| 689 | {return __tree_.__insert_unique(_VSTD::move(__v));} |
| 690 | |
| 691 | _LIBCPP_INLINE_VISIBILITY |
| 692 | iterator insert(const_iterator __p, value_type&& __v) |
| 693 | {return __tree_.__insert_unique(__p, _VSTD::move(__v));} |
| 694 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 695 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 696 | void insert(initializer_list<value_type> __il) |
| 697 | {insert(__il.begin(), __il.end());} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 698 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 699 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 700 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 701 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 702 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 703 | size_type erase(const key_type& __k) |
| 704 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 705 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 706 | iterator erase(const_iterator __f, const_iterator __l) |
| 707 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 708 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 709 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 710 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 711 | #if _LIBCPP_STD_VER > 14 |
| 712 | _LIBCPP_INLINE_VISIBILITY |
| 713 | insert_return_type insert(node_type&& __nh) |
| 714 | { |
| 715 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 716 | "node_type with incompatible allocator passed to set::insert()"); |
| 717 | return __tree_.template __node_handle_insert_unique< |
| 718 | node_type, insert_return_type>(_VSTD::move(__nh)); |
| 719 | } |
| 720 | _LIBCPP_INLINE_VISIBILITY |
| 721 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 722 | { |
| 723 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 724 | "node_type with incompatible allocator passed to set::insert()"); |
| 725 | return __tree_.template __node_handle_insert_unique<node_type>( |
| 726 | __hint, _VSTD::move(__nh)); |
| 727 | } |
| 728 | _LIBCPP_INLINE_VISIBILITY |
| 729 | node_type extract(key_type const& __key) |
| 730 | { |
| 731 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 732 | } |
| 733 | _LIBCPP_INLINE_VISIBILITY |
| 734 | node_type extract(const_iterator __it) |
| 735 | { |
| 736 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 737 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 738 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 739 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 740 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 741 | { |
| 742 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 743 | "merging container with incompatible allocator"); |
| 744 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 745 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 746 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 747 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 748 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 749 | { |
| 750 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 751 | "merging container with incompatible allocator"); |
| 752 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 753 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 754 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 755 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 756 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 757 | { |
| 758 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 759 | "merging container with incompatible allocator"); |
| 760 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 761 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 762 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 763 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 764 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 765 | { |
| 766 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 767 | "merging container with incompatible allocator"); |
| 768 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 769 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 770 | #endif |
| 771 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 772 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 773 | void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 774 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 775 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 776 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 777 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 778 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 779 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 780 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 781 | value_compare value_comp() const {return __tree_.value_comp();} |
| 782 | |
| 783 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 784 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 785 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 786 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 787 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 788 | #if _LIBCPP_STD_VER > 11 |
| 789 | template <typename _K2> |
| 790 | _LIBCPP_INLINE_VISIBILITY |
| 791 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 792 | find(const _K2& __k) {return __tree_.find(__k);} |
| 793 | template <typename _K2> |
| 794 | _LIBCPP_INLINE_VISIBILITY |
| 795 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 796 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 797 | #endif |
| 798 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 799 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 800 | size_type count(const key_type& __k) const |
| 801 | {return __tree_.__count_unique(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 802 | #if _LIBCPP_STD_VER > 11 |
| 803 | template <typename _K2> |
| 804 | _LIBCPP_INLINE_VISIBILITY |
| 805 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 806 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 807 | #endif |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 808 | |
| 809 | #if _LIBCPP_STD_VER > 17 |
| 810 | _LIBCPP_INLINE_VISIBILITY |
| 811 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 812 | template <typename _K2> |
| 813 | _LIBCPP_INLINE_VISIBILITY |
| 814 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 815 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 816 | #endif // _LIBCPP_STD_VER > 17 |
| 817 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 818 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 819 | iterator lower_bound(const key_type& __k) |
| 820 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 821 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 822 | const_iterator lower_bound(const key_type& __k) const |
| 823 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 824 | #if _LIBCPP_STD_VER > 11 |
| 825 | template <typename _K2> |
| 826 | _LIBCPP_INLINE_VISIBILITY |
| 827 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 828 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 829 | |
| 830 | template <typename _K2> |
| 831 | _LIBCPP_INLINE_VISIBILITY |
| 832 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 833 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 834 | #endif |
| 835 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 836 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 837 | iterator upper_bound(const key_type& __k) |
| 838 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 839 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 840 | const_iterator upper_bound(const key_type& __k) const |
| 841 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 842 | #if _LIBCPP_STD_VER > 11 |
| 843 | template <typename _K2> |
| 844 | _LIBCPP_INLINE_VISIBILITY |
| 845 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 846 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 847 | template <typename _K2> |
| 848 | _LIBCPP_INLINE_VISIBILITY |
| 849 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 850 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 851 | #endif |
| 852 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 853 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 854 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 855 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 856 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 858 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 859 | #if _LIBCPP_STD_VER > 11 |
| 860 | template <typename _K2> |
| 861 | _LIBCPP_INLINE_VISIBILITY |
| 862 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 863 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 864 | template <typename _K2> |
| 865 | _LIBCPP_INLINE_VISIBILITY |
| 866 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 867 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 868 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 869 | }; |
| 870 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame^] | 871 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 872 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 873 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 874 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 875 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 876 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 877 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 878 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 879 | |
| 880 | template<class _Key, class _Compare = less<_Key>, |
| 881 | class _Allocator = allocator<_Key>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 882 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 883 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 884 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 885 | -> set<_Key, _Compare, _Allocator>; |
| 886 | |
| 887 | template<class _InputIterator, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 888 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 889 | set(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 890 | -> set<__iter_value_type<_InputIterator>, |
| 891 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 892 | |
| 893 | template<class _Key, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 894 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 895 | set(initializer_list<_Key>, _Allocator) |
| 896 | -> set<_Key, less<_Key>, _Allocator>; |
| 897 | #endif |
| 898 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 899 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 900 | |
| 901 | template <class _Key, class _Compare, class _Allocator> |
| 902 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 903 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 904 | { |
| 905 | if (__a != __s.get_allocator()) |
| 906 | { |
| 907 | const_iterator __e = cend(); |
| 908 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 909 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 913 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 914 | |
| 915 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 916 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 917 | bool |
| 918 | operator==(const set<_Key, _Compare, _Allocator>& __x, |
| 919 | const set<_Key, _Compare, _Allocator>& __y) |
| 920 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 921 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 925 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 926 | bool |
| 927 | operator< (const set<_Key, _Compare, _Allocator>& __x, |
| 928 | const set<_Key, _Compare, _Allocator>& __y) |
| 929 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 930 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 934 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 935 | bool |
| 936 | operator!=(const set<_Key, _Compare, _Allocator>& __x, |
| 937 | const set<_Key, _Compare, _Allocator>& __y) |
| 938 | { |
| 939 | return !(__x == __y); |
| 940 | } |
| 941 | |
| 942 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 943 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 944 | bool |
| 945 | operator> (const set<_Key, _Compare, _Allocator>& __x, |
| 946 | const set<_Key, _Compare, _Allocator>& __y) |
| 947 | { |
| 948 | return __y < __x; |
| 949 | } |
| 950 | |
| 951 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 952 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 953 | bool |
| 954 | operator>=(const set<_Key, _Compare, _Allocator>& __x, |
| 955 | const set<_Key, _Compare, _Allocator>& __y) |
| 956 | { |
| 957 | return !(__x < __y); |
| 958 | } |
| 959 | |
| 960 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 961 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 962 | bool |
| 963 | operator<=(const set<_Key, _Compare, _Allocator>& __x, |
| 964 | const set<_Key, _Compare, _Allocator>& __y) |
| 965 | { |
| 966 | return !(__y < __x); |
| 967 | } |
| 968 | |
| 969 | // specialized algorithms: |
| 970 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 971 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 972 | void |
| 973 | swap(set<_Key, _Compare, _Allocator>& __x, |
| 974 | set<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 975 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 976 | { |
| 977 | __x.swap(__y); |
| 978 | } |
| 979 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 980 | #if _LIBCPP_STD_VER > 17 |
| 981 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 982 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 983 | typename set<_Key, _Compare, _Allocator>::size_type |
| 984 | erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 985 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 986 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 987 | #endif |
| 988 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 989 | template <class _Key, class _Compare = less<_Key>, |
| 990 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 991 | class _LIBCPP_TEMPLATE_VIS multiset |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 992 | { |
| 993 | public: |
| 994 | // types: |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 995 | typedef _Key key_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 996 | typedef key_type value_type; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 997 | typedef _Compare key_compare; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 998 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 999 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1000 | typedef value_type& reference; |
| 1001 | typedef const value_type& const_reference; |
| 1002 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 1003 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1004 | "Allocator::value_type must be same type as value_type"); |
| 1005 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1006 | private: |
| 1007 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 1008 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1009 | typedef typename __base::__node_holder __node_holder; |
| 1010 | |
| 1011 | __base __tree_; |
| 1012 | |
| 1013 | public: |
| 1014 | typedef typename __base::pointer pointer; |
| 1015 | typedef typename __base::const_pointer const_pointer; |
| 1016 | typedef typename __base::size_type size_type; |
| 1017 | typedef typename __base::difference_type difference_type; |
| 1018 | typedef typename __base::const_iterator iterator; |
| 1019 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1020 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1021 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1022 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1023 | #if _LIBCPP_STD_VER > 14 |
| 1024 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 1025 | #endif |
| 1026 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1027 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1028 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 1029 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1030 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 1031 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1032 | // construct/copy/destroy: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1033 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1034 | multiset() |
| 1035 | _NOEXCEPT_( |
| 1036 | is_nothrow_default_constructible<allocator_type>::value && |
| 1037 | is_nothrow_default_constructible<key_compare>::value && |
| 1038 | is_nothrow_copy_constructible<key_compare>::value) |
| 1039 | : __tree_(value_compare()) {} |
| 1040 | |
| 1041 | _LIBCPP_INLINE_VISIBILITY |
| 1042 | explicit multiset(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1043 | _NOEXCEPT_( |
| 1044 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1045 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1046 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1047 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1048 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 1049 | explicit multiset(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | : __tree_(__comp, __a) {} |
| 1051 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1052 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1053 | multiset(_InputIterator __f, _InputIterator __l, |
| 1054 | const value_compare& __comp = value_compare()) |
| 1055 | : __tree_(__comp) |
| 1056 | { |
| 1057 | insert(__f, __l); |
| 1058 | } |
| 1059 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1060 | #if _LIBCPP_STD_VER > 11 |
| 1061 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1062 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1063 | multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1064 | : multiset(__f, __l, key_compare(), __a) {} |
| 1065 | #endif |
| 1066 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1067 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1068 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1069 | multiset(_InputIterator __f, _InputIterator __l, |
| 1070 | const value_compare& __comp, const allocator_type& __a) |
| 1071 | : __tree_(__comp, __a) |
| 1072 | { |
| 1073 | insert(__f, __l); |
| 1074 | } |
| 1075 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1076 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1077 | multiset(const multiset& __s) |
| 1078 | : __tree_(__s.__tree_.value_comp(), |
| 1079 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) |
| 1080 | { |
| 1081 | insert(__s.begin(), __s.end()); |
| 1082 | } |
| 1083 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1084 | _LIBCPP_INLINE_VISIBILITY |
| 1085 | multiset& operator=(const multiset& __s) |
| 1086 | { |
| 1087 | __tree_ = __s.__tree_; |
| 1088 | return *this; |
| 1089 | } |
| 1090 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1091 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1092 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1093 | multiset(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1094 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1095 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1096 | |
| 1097 | multiset(multiset&& __s, const allocator_type& __a); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1098 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1099 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1100 | explicit multiset(const allocator_type& __a) |
| 1101 | : __tree_(__a) {} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1102 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1103 | multiset(const multiset& __s, const allocator_type& __a) |
| 1104 | : __tree_(__s.__tree_.value_comp(), __a) |
| 1105 | { |
| 1106 | insert(__s.begin(), __s.end()); |
| 1107 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1108 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1109 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1110 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1111 | multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 1112 | : __tree_(__comp) |
| 1113 | { |
| 1114 | insert(__il.begin(), __il.end()); |
| 1115 | } |
| 1116 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1117 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1118 | multiset(initializer_list<value_type> __il, const value_compare& __comp, |
| 1119 | const allocator_type& __a) |
| 1120 | : __tree_(__comp, __a) |
| 1121 | { |
| 1122 | insert(__il.begin(), __il.end()); |
| 1123 | } |
| 1124 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1125 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1126 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1127 | multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 1128 | : multiset(__il, key_compare(), __a) {} |
| 1129 | #endif |
| 1130 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1131 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1132 | multiset& operator=(initializer_list<value_type> __il) |
| 1133 | { |
| 1134 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1135 | return *this; |
| 1136 | } |
| 1137 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1138 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1139 | multiset& operator=(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1140 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1141 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1142 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1143 | return *this; |
| 1144 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1145 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1146 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1147 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 1148 | ~multiset() { |
| 1149 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1150 | } |
| 1151 | |
| 1152 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1153 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1154 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1155 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1156 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1157 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1158 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1159 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1160 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1161 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1162 | reverse_iterator rbegin() _NOEXCEPT |
| 1163 | {return reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1164 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1165 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1166 | {return const_reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1167 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1168 | reverse_iterator rend() _NOEXCEPT |
| 1169 | {return reverse_iterator(begin());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1170 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1171 | const_reverse_iterator rend() const _NOEXCEPT |
| 1172 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1173 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1174 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1175 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1176 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1177 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1178 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1179 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1180 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1181 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1182 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1183 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1184 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1185 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1186 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1187 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1188 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1189 | |
| 1190 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1191 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1192 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1193 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1194 | iterator emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1195 | {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1196 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1197 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1198 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1199 | {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1200 | #endif // _LIBCPP_CXX03_LANG |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1201 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1202 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1203 | iterator insert(const value_type& __v) |
| 1204 | {return __tree_.__insert_multi(__v);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1205 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1206 | iterator insert(const_iterator __p, const value_type& __v) |
| 1207 | {return __tree_.__insert_multi(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1208 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1209 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1210 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1211 | void insert(_InputIterator __f, _InputIterator __l) |
| 1212 | { |
| 1213 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1214 | __tree_.__insert_multi(__e, *__f); |
| 1215 | } |
| 1216 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1217 | #ifndef _LIBCPP_CXX03_LANG |
| 1218 | _LIBCPP_INLINE_VISIBILITY |
| 1219 | iterator insert(value_type&& __v) |
| 1220 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
| 1221 | |
| 1222 | _LIBCPP_INLINE_VISIBILITY |
| 1223 | iterator insert(const_iterator __p, value_type&& __v) |
| 1224 | {return __tree_.__insert_multi(__p, _VSTD::move(__v));} |
| 1225 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1226 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1227 | void insert(initializer_list<value_type> __il) |
| 1228 | {insert(__il.begin(), __il.end());} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1229 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1230 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1231 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1232 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1233 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1234 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1235 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1236 | iterator erase(const_iterator __f, const_iterator __l) |
| 1237 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1238 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1239 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1240 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1241 | #if _LIBCPP_STD_VER > 14 |
| 1242 | _LIBCPP_INLINE_VISIBILITY |
| 1243 | iterator insert(node_type&& __nh) |
| 1244 | { |
| 1245 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1246 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1247 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1248 | _VSTD::move(__nh)); |
| 1249 | } |
| 1250 | _LIBCPP_INLINE_VISIBILITY |
| 1251 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1252 | { |
| 1253 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1254 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1255 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1256 | __hint, _VSTD::move(__nh)); |
| 1257 | } |
| 1258 | _LIBCPP_INLINE_VISIBILITY |
| 1259 | node_type extract(key_type const& __key) |
| 1260 | { |
| 1261 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1262 | } |
| 1263 | _LIBCPP_INLINE_VISIBILITY |
| 1264 | node_type extract(const_iterator __it) |
| 1265 | { |
| 1266 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 1267 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1268 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1269 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1270 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1271 | { |
| 1272 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1273 | "merging container with incompatible allocator"); |
| 1274 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1275 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1276 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1277 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1278 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1279 | { |
| 1280 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1281 | "merging container with incompatible allocator"); |
| 1282 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1283 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1284 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1285 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1286 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1287 | { |
| 1288 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1289 | "merging container with incompatible allocator"); |
| 1290 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1291 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1292 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1293 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1294 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1295 | { |
| 1296 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1297 | "merging container with incompatible allocator"); |
| 1298 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1299 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1300 | #endif |
| 1301 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1302 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1303 | void swap(multiset& __s) |
| 1304 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1305 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1306 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1307 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1308 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1309 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1310 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1311 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1312 | value_compare value_comp() const {return __tree_.value_comp();} |
| 1313 | |
| 1314 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1315 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1316 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1317 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1318 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1319 | #if _LIBCPP_STD_VER > 11 |
| 1320 | template <typename _K2> |
| 1321 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1322 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1323 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1324 | template <typename _K2> |
| 1325 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1326 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1327 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1328 | #endif |
| 1329 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1330 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1331 | size_type count(const key_type& __k) const |
| 1332 | {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1333 | #if _LIBCPP_STD_VER > 11 |
| 1334 | template <typename _K2> |
| 1335 | _LIBCPP_INLINE_VISIBILITY |
| 1336 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Marshall Clow | 5571bcd | 2018-01-07 17:39:57 +0000 | [diff] [blame] | 1337 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1338 | #endif |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1339 | |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1340 | #if _LIBCPP_STD_VER > 17 |
| 1341 | _LIBCPP_INLINE_VISIBILITY |
| 1342 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 1343 | template <typename _K2> |
| 1344 | _LIBCPP_INLINE_VISIBILITY |
| 1345 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 1346 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1347 | #endif // _LIBCPP_STD_VER > 17 |
| 1348 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1349 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1350 | iterator lower_bound(const key_type& __k) |
| 1351 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1352 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1353 | const_iterator lower_bound(const key_type& __k) const |
| 1354 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1355 | #if _LIBCPP_STD_VER > 11 |
| 1356 | template <typename _K2> |
| 1357 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1358 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1359 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1360 | |
| 1361 | template <typename _K2> |
| 1362 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1363 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1364 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1365 | #endif |
| 1366 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1367 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1368 | iterator upper_bound(const key_type& __k) |
| 1369 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1370 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1371 | const_iterator upper_bound(const key_type& __k) const |
| 1372 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1373 | #if _LIBCPP_STD_VER > 11 |
| 1374 | template <typename _K2> |
| 1375 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1376 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1377 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1378 | template <typename _K2> |
| 1379 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1380 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1381 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1382 | #endif |
| 1383 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1384 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1385 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1386 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1387 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1388 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1389 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1390 | #if _LIBCPP_STD_VER > 11 |
| 1391 | template <typename _K2> |
| 1392 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1393 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1394 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1395 | template <typename _K2> |
| 1396 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1397 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1398 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1399 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1400 | }; |
| 1401 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame^] | 1402 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1403 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1404 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 1405 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1406 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 1407 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1408 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1409 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1410 | |
| 1411 | template<class _Key, class _Compare = less<_Key>, |
| 1412 | class _Allocator = allocator<_Key>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1413 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 1414 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1415 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1416 | -> multiset<_Key, _Compare, _Allocator>; |
| 1417 | |
| 1418 | template<class _InputIterator, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1419 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1420 | multiset(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1421 | -> multiset<__iter_value_type<_InputIterator>, |
| 1422 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1423 | |
| 1424 | template<class _Key, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1425 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1426 | multiset(initializer_list<_Key>, _Allocator) |
| 1427 | -> multiset<_Key, less<_Key>, _Allocator>; |
| 1428 | #endif |
| 1429 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1430 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1431 | |
| 1432 | template <class _Key, class _Compare, class _Allocator> |
| 1433 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1434 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1435 | { |
| 1436 | if (__a != __s.get_allocator()) |
| 1437 | { |
| 1438 | const_iterator __e = cend(); |
| 1439 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1440 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1441 | } |
| 1442 | } |
| 1443 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1444 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1445 | |
| 1446 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1447 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1448 | bool |
| 1449 | operator==(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1450 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1451 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1452 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
| 1455 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1456 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1457 | bool |
| 1458 | operator< (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1459 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1460 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1461 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1465 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1466 | bool |
| 1467 | operator!=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1468 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1469 | { |
| 1470 | return !(__x == __y); |
| 1471 | } |
| 1472 | |
| 1473 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1474 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1475 | bool |
| 1476 | operator> (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1477 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1478 | { |
| 1479 | return __y < __x; |
| 1480 | } |
| 1481 | |
| 1482 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1483 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1484 | bool |
| 1485 | operator>=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1486 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1487 | { |
| 1488 | return !(__x < __y); |
| 1489 | } |
| 1490 | |
| 1491 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1492 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1493 | bool |
| 1494 | operator<=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1495 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1496 | { |
| 1497 | return !(__y < __x); |
| 1498 | } |
| 1499 | |
| 1500 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1501 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1502 | void |
| 1503 | swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1504 | multiset<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1505 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1506 | { |
| 1507 | __x.swap(__y); |
| 1508 | } |
| 1509 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1510 | #if _LIBCPP_STD_VER > 17 |
| 1511 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1512 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1513 | typename multiset<_Key, _Compare, _Allocator>::size_type |
| 1514 | erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 1515 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1516 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1517 | #endif |
| 1518 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1519 | _LIBCPP_END_NAMESPACE_STD |
| 1520 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1521 | #endif // _LIBCPP_SET |