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> |
| 437 | #include <__tree> |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 438 | #include <__node_handle> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 439 | #include <compare> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 440 | #include <functional> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 441 | #include <initializer_list> |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 442 | #include <iterator> // __libcpp_erase_if_container |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 443 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 445 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 446 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 447 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 448 | |
| 449 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 450 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 451 | template <class _Key, class _Compare, class _Allocator> |
| 452 | class multiset; |
| 453 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 454 | template <class _Key, class _Compare = less<_Key>, |
| 455 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 456 | class _LIBCPP_TEMPLATE_VIS set |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | { |
| 458 | public: |
| 459 | // types: |
| 460 | typedef _Key key_type; |
| 461 | typedef key_type value_type; |
| 462 | typedef _Compare key_compare; |
| 463 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 464 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 465 | typedef value_type& reference; |
| 466 | typedef const value_type& const_reference; |
| 467 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 468 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 469 | "Allocator::value_type must be same type as value_type"); |
| 470 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 471 | private: |
| 472 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 473 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 474 | typedef typename __base::__node_holder __node_holder; |
| 475 | |
| 476 | __base __tree_; |
| 477 | |
| 478 | public: |
| 479 | typedef typename __base::pointer pointer; |
| 480 | typedef typename __base::const_pointer const_pointer; |
| 481 | typedef typename __base::size_type size_type; |
| 482 | typedef typename __base::difference_type difference_type; |
| 483 | typedef typename __base::const_iterator iterator; |
| 484 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 485 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 486 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 488 | #if _LIBCPP_STD_VER > 14 |
| 489 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 490 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 491 | #endif |
| 492 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 493 | template <class _Key2, class _Compare2, class _Alloc2> |
| 494 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 495 | template <class _Key2, class _Compare2, class _Alloc2> |
| 496 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 497 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 498 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 499 | set() |
| 500 | _NOEXCEPT_( |
| 501 | is_nothrow_default_constructible<allocator_type>::value && |
| 502 | is_nothrow_default_constructible<key_compare>::value && |
| 503 | is_nothrow_copy_constructible<key_compare>::value) |
| 504 | : __tree_(value_compare()) {} |
| 505 | |
| 506 | _LIBCPP_INLINE_VISIBILITY |
| 507 | explicit set(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 508 | _NOEXCEPT_( |
| 509 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 510 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 511 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 512 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 513 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 514 | explicit set(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 515 | : __tree_(__comp, __a) {} |
| 516 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 517 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 518 | set(_InputIterator __f, _InputIterator __l, |
| 519 | const value_compare& __comp = value_compare()) |
| 520 | : __tree_(__comp) |
| 521 | { |
| 522 | insert(__f, __l); |
| 523 | } |
| 524 | |
| 525 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 526 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 527 | set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, |
| 528 | const allocator_type& __a) |
| 529 | : __tree_(__comp, __a) |
| 530 | { |
| 531 | insert(__f, __l); |
| 532 | } |
| 533 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 534 | #if _LIBCPP_STD_VER > 11 |
| 535 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 536 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 537 | set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 538 | : set(__f, __l, key_compare(), __a) {} |
| 539 | #endif |
| 540 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 541 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 542 | set(const set& __s) |
| 543 | : __tree_(__s.__tree_) |
| 544 | { |
| 545 | insert(__s.begin(), __s.end()); |
| 546 | } |
| 547 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 548 | _LIBCPP_INLINE_VISIBILITY |
| 549 | set& operator=(const set& __s) |
| 550 | { |
| 551 | __tree_ = __s.__tree_; |
| 552 | return *this; |
| 553 | } |
| 554 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 555 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 556 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | set(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 558 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 559 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 560 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 561 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 562 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 563 | explicit set(const allocator_type& __a) |
| 564 | : __tree_(__a) {} |
| 565 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 566 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 567 | set(const set& __s, const allocator_type& __a) |
| 568 | : __tree_(__s.__tree_.value_comp(), __a) |
| 569 | { |
| 570 | insert(__s.begin(), __s.end()); |
| 571 | } |
| 572 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 573 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 574 | set(set&& __s, const allocator_type& __a); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 575 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 576 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 577 | set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 578 | : __tree_(__comp) |
| 579 | { |
| 580 | insert(__il.begin(), __il.end()); |
| 581 | } |
| 582 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 583 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 584 | set(initializer_list<value_type> __il, const value_compare& __comp, |
| 585 | const allocator_type& __a) |
| 586 | : __tree_(__comp, __a) |
| 587 | { |
| 588 | insert(__il.begin(), __il.end()); |
| 589 | } |
| 590 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 591 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 592 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 593 | set(initializer_list<value_type> __il, const allocator_type& __a) |
| 594 | : set(__il, key_compare(), __a) {} |
| 595 | #endif |
| 596 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 597 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | set& operator=(initializer_list<value_type> __il) |
| 599 | { |
| 600 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 601 | return *this; |
| 602 | } |
| 603 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 604 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | set& operator=(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 606 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 607 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 608 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 609 | return *this; |
| 610 | } |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 611 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 613 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 614 | ~set() { |
| 615 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 616 | } |
| 617 | |
| 618 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 619 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 620 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 621 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 622 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 623 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 624 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 625 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 626 | |
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 | reverse_iterator rbegin() _NOEXCEPT |
| 629 | {return reverse_iterator(end());} |
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 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 632 | {return const_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 | reverse_iterator rend() _NOEXCEPT |
| 635 | {return reverse_iterator(begin());} |
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 | const_reverse_iterator rend() const _NOEXCEPT |
| 638 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 639 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 640 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 641 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 642 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 643 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 644 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 645 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 646 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 647 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 648 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 649 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 650 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 651 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 652 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 653 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 654 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 655 | |
| 656 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 657 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 658 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 659 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 660 | pair<iterator, bool> emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 661 | {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 663 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 664 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 665 | {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 666 | #endif // _LIBCPP_CXX03_LANG |
| 667 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 668 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 669 | pair<iterator,bool> insert(const value_type& __v) |
| 670 | {return __tree_.__insert_unique(__v);} |
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 | iterator insert(const_iterator __p, const value_type& __v) |
| 673 | {return __tree_.__insert_unique(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 674 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 675 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 676 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 677 | void insert(_InputIterator __f, _InputIterator __l) |
| 678 | { |
| 679 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 680 | __tree_.__insert_unique(__e, *__f); |
| 681 | } |
| 682 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 683 | #ifndef _LIBCPP_CXX03_LANG |
| 684 | _LIBCPP_INLINE_VISIBILITY |
| 685 | pair<iterator,bool> insert(value_type&& __v) |
| 686 | {return __tree_.__insert_unique(_VSTD::move(__v));} |
| 687 | |
| 688 | _LIBCPP_INLINE_VISIBILITY |
| 689 | iterator insert(const_iterator __p, value_type&& __v) |
| 690 | {return __tree_.__insert_unique(__p, _VSTD::move(__v));} |
| 691 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 692 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 693 | void insert(initializer_list<value_type> __il) |
| 694 | {insert(__il.begin(), __il.end());} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 695 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 696 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 697 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 698 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 699 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 700 | size_type erase(const key_type& __k) |
| 701 | {return __tree_.__erase_unique(__k);} |
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 | iterator erase(const_iterator __f, const_iterator __l) |
| 704 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 705 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 706 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 707 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 708 | #if _LIBCPP_STD_VER > 14 |
| 709 | _LIBCPP_INLINE_VISIBILITY |
| 710 | insert_return_type insert(node_type&& __nh) |
| 711 | { |
| 712 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 713 | "node_type with incompatible allocator passed to set::insert()"); |
| 714 | return __tree_.template __node_handle_insert_unique< |
| 715 | node_type, insert_return_type>(_VSTD::move(__nh)); |
| 716 | } |
| 717 | _LIBCPP_INLINE_VISIBILITY |
| 718 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 719 | { |
| 720 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 721 | "node_type with incompatible allocator passed to set::insert()"); |
| 722 | return __tree_.template __node_handle_insert_unique<node_type>( |
| 723 | __hint, _VSTD::move(__nh)); |
| 724 | } |
| 725 | _LIBCPP_INLINE_VISIBILITY |
| 726 | node_type extract(key_type const& __key) |
| 727 | { |
| 728 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 729 | } |
| 730 | _LIBCPP_INLINE_VISIBILITY |
| 731 | node_type extract(const_iterator __it) |
| 732 | { |
| 733 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 734 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 735 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 736 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 737 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 738 | { |
| 739 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 740 | "merging container with incompatible allocator"); |
| 741 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 742 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 743 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 744 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 745 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 746 | { |
| 747 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 748 | "merging container with incompatible allocator"); |
| 749 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 750 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 751 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 752 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 753 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 754 | { |
| 755 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 756 | "merging container with incompatible allocator"); |
| 757 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 758 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 759 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 760 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 761 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 762 | { |
| 763 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 764 | "merging container with incompatible allocator"); |
| 765 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 766 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 767 | #endif |
| 768 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 769 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 770 | void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 771 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 772 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 773 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 774 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 775 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 776 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 777 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 778 | value_compare value_comp() const {return __tree_.value_comp();} |
| 779 | |
| 780 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 781 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 782 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 783 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 784 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 785 | #if _LIBCPP_STD_VER > 11 |
| 786 | template <typename _K2> |
| 787 | _LIBCPP_INLINE_VISIBILITY |
| 788 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 789 | find(const _K2& __k) {return __tree_.find(__k);} |
| 790 | template <typename _K2> |
| 791 | _LIBCPP_INLINE_VISIBILITY |
| 792 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 793 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 794 | #endif |
| 795 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 796 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 797 | size_type count(const key_type& __k) const |
| 798 | {return __tree_.__count_unique(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 799 | #if _LIBCPP_STD_VER > 11 |
| 800 | template <typename _K2> |
| 801 | _LIBCPP_INLINE_VISIBILITY |
| 802 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 803 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 804 | #endif |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 805 | |
| 806 | #if _LIBCPP_STD_VER > 17 |
| 807 | _LIBCPP_INLINE_VISIBILITY |
| 808 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame^] | 809 | template <typename _K2> |
| 810 | _LIBCPP_INLINE_VISIBILITY |
| 811 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 812 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 813 | #endif // _LIBCPP_STD_VER > 17 |
| 814 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 815 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 816 | iterator lower_bound(const key_type& __k) |
| 817 | {return __tree_.lower_bound(__k);} |
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 | const_iterator lower_bound(const key_type& __k) const |
| 820 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 821 | #if _LIBCPP_STD_VER > 11 |
| 822 | template <typename _K2> |
| 823 | _LIBCPP_INLINE_VISIBILITY |
| 824 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 825 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 826 | |
| 827 | template <typename _K2> |
| 828 | _LIBCPP_INLINE_VISIBILITY |
| 829 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 830 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 831 | #endif |
| 832 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 833 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 834 | iterator upper_bound(const key_type& __k) |
| 835 | {return __tree_.upper_bound(__k);} |
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 | const_iterator upper_bound(const key_type& __k) const |
| 838 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 839 | #if _LIBCPP_STD_VER > 11 |
| 840 | template <typename _K2> |
| 841 | _LIBCPP_INLINE_VISIBILITY |
| 842 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 843 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 844 | template <typename _K2> |
| 845 | _LIBCPP_INLINE_VISIBILITY |
| 846 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 847 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 848 | #endif |
| 849 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 850 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 851 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 852 | {return __tree_.__equal_range_unique(__k);} |
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<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 855 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 856 | #if _LIBCPP_STD_VER > 11 |
| 857 | template <typename _K2> |
| 858 | _LIBCPP_INLINE_VISIBILITY |
| 859 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 860 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 861 | template <typename _K2> |
| 862 | _LIBCPP_INLINE_VISIBILITY |
| 863 | 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] | 864 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 865 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 866 | }; |
| 867 | |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 868 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 869 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 870 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 871 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 872 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 873 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 874 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 875 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 876 | |
| 877 | template<class _Key, class _Compare = less<_Key>, |
| 878 | class _Allocator = allocator<_Key>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 879 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 880 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 881 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 882 | -> set<_Key, _Compare, _Allocator>; |
| 883 | |
| 884 | template<class _InputIterator, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 885 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 886 | set(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 887 | -> set<__iter_value_type<_InputIterator>, |
| 888 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 889 | |
| 890 | template<class _Key, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 891 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 892 | set(initializer_list<_Key>, _Allocator) |
| 893 | -> set<_Key, less<_Key>, _Allocator>; |
| 894 | #endif |
| 895 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 896 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 897 | |
| 898 | template <class _Key, class _Compare, class _Allocator> |
| 899 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 900 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 901 | { |
| 902 | if (__a != __s.get_allocator()) |
| 903 | { |
| 904 | const_iterator __e = cend(); |
| 905 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 906 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 907 | } |
| 908 | } |
| 909 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 910 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 911 | |
| 912 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 913 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 914 | bool |
| 915 | operator==(const set<_Key, _Compare, _Allocator>& __x, |
| 916 | const set<_Key, _Compare, _Allocator>& __y) |
| 917 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 918 | 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] | 919 | } |
| 920 | |
| 921 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 922 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 923 | bool |
| 924 | operator< (const set<_Key, _Compare, _Allocator>& __x, |
| 925 | const set<_Key, _Compare, _Allocator>& __y) |
| 926 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 927 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 931 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 932 | bool |
| 933 | operator!=(const set<_Key, _Compare, _Allocator>& __x, |
| 934 | const set<_Key, _Compare, _Allocator>& __y) |
| 935 | { |
| 936 | return !(__x == __y); |
| 937 | } |
| 938 | |
| 939 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 940 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 941 | bool |
| 942 | operator> (const set<_Key, _Compare, _Allocator>& __x, |
| 943 | const set<_Key, _Compare, _Allocator>& __y) |
| 944 | { |
| 945 | return __y < __x; |
| 946 | } |
| 947 | |
| 948 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 949 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 950 | bool |
| 951 | operator>=(const set<_Key, _Compare, _Allocator>& __x, |
| 952 | const set<_Key, _Compare, _Allocator>& __y) |
| 953 | { |
| 954 | return !(__x < __y); |
| 955 | } |
| 956 | |
| 957 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 958 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 959 | bool |
| 960 | operator<=(const set<_Key, _Compare, _Allocator>& __x, |
| 961 | const set<_Key, _Compare, _Allocator>& __y) |
| 962 | { |
| 963 | return !(__y < __x); |
| 964 | } |
| 965 | |
| 966 | // specialized algorithms: |
| 967 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 968 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 969 | void |
| 970 | swap(set<_Key, _Compare, _Allocator>& __x, |
| 971 | set<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 972 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 973 | { |
| 974 | __x.swap(__y); |
| 975 | } |
| 976 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 977 | #if _LIBCPP_STD_VER > 17 |
| 978 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 979 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 980 | typename set<_Key, _Compare, _Allocator>::size_type |
| 981 | erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 982 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 983 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 984 | #endif |
| 985 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 986 | template <class _Key, class _Compare = less<_Key>, |
| 987 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 988 | class _LIBCPP_TEMPLATE_VIS multiset |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 989 | { |
| 990 | public: |
| 991 | // types: |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 992 | typedef _Key key_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 993 | typedef key_type value_type; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 994 | typedef _Compare key_compare; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 995 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 996 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 997 | typedef value_type& reference; |
| 998 | typedef const value_type& const_reference; |
| 999 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 1000 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1001 | "Allocator::value_type must be same type as value_type"); |
| 1002 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1003 | private: |
| 1004 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 1005 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1006 | typedef typename __base::__node_holder __node_holder; |
| 1007 | |
| 1008 | __base __tree_; |
| 1009 | |
| 1010 | public: |
| 1011 | typedef typename __base::pointer pointer; |
| 1012 | typedef typename __base::const_pointer const_pointer; |
| 1013 | typedef typename __base::size_type size_type; |
| 1014 | typedef typename __base::difference_type difference_type; |
| 1015 | typedef typename __base::const_iterator iterator; |
| 1016 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1017 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1018 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1019 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1020 | #if _LIBCPP_STD_VER > 14 |
| 1021 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 1022 | #endif |
| 1023 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1024 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1025 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 1026 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1027 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 1028 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1029 | // construct/copy/destroy: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1030 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1031 | multiset() |
| 1032 | _NOEXCEPT_( |
| 1033 | is_nothrow_default_constructible<allocator_type>::value && |
| 1034 | is_nothrow_default_constructible<key_compare>::value && |
| 1035 | is_nothrow_copy_constructible<key_compare>::value) |
| 1036 | : __tree_(value_compare()) {} |
| 1037 | |
| 1038 | _LIBCPP_INLINE_VISIBILITY |
| 1039 | explicit multiset(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1040 | _NOEXCEPT_( |
| 1041 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1042 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1043 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1044 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1045 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 1046 | explicit multiset(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1047 | : __tree_(__comp, __a) {} |
| 1048 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1049 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | multiset(_InputIterator __f, _InputIterator __l, |
| 1051 | const value_compare& __comp = value_compare()) |
| 1052 | : __tree_(__comp) |
| 1053 | { |
| 1054 | insert(__f, __l); |
| 1055 | } |
| 1056 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1057 | #if _LIBCPP_STD_VER > 11 |
| 1058 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1059 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1060 | multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1061 | : multiset(__f, __l, key_compare(), __a) {} |
| 1062 | #endif |
| 1063 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1064 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1065 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1066 | multiset(_InputIterator __f, _InputIterator __l, |
| 1067 | const value_compare& __comp, const allocator_type& __a) |
| 1068 | : __tree_(__comp, __a) |
| 1069 | { |
| 1070 | insert(__f, __l); |
| 1071 | } |
| 1072 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1073 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1074 | multiset(const multiset& __s) |
| 1075 | : __tree_(__s.__tree_.value_comp(), |
| 1076 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) |
| 1077 | { |
| 1078 | insert(__s.begin(), __s.end()); |
| 1079 | } |
| 1080 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1081 | _LIBCPP_INLINE_VISIBILITY |
| 1082 | multiset& operator=(const multiset& __s) |
| 1083 | { |
| 1084 | __tree_ = __s.__tree_; |
| 1085 | return *this; |
| 1086 | } |
| 1087 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1088 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1089 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1090 | multiset(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1091 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1092 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1093 | |
| 1094 | multiset(multiset&& __s, const allocator_type& __a); |
| 1095 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1096 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1097 | explicit multiset(const allocator_type& __a) |
| 1098 | : __tree_(__a) {} |
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 | multiset(const multiset& __s, const allocator_type& __a) |
| 1101 | : __tree_(__s.__tree_.value_comp(), __a) |
| 1102 | { |
| 1103 | insert(__s.begin(), __s.end()); |
| 1104 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1105 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1106 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1107 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1108 | multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 1109 | : __tree_(__comp) |
| 1110 | { |
| 1111 | insert(__il.begin(), __il.end()); |
| 1112 | } |
| 1113 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1114 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1115 | multiset(initializer_list<value_type> __il, const value_compare& __comp, |
| 1116 | const allocator_type& __a) |
| 1117 | : __tree_(__comp, __a) |
| 1118 | { |
| 1119 | insert(__il.begin(), __il.end()); |
| 1120 | } |
| 1121 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1122 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1123 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1124 | multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 1125 | : multiset(__il, key_compare(), __a) {} |
| 1126 | #endif |
| 1127 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1128 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1129 | multiset& operator=(initializer_list<value_type> __il) |
| 1130 | { |
| 1131 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1132 | return *this; |
| 1133 | } |
| 1134 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1135 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1136 | multiset& operator=(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1137 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1138 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1139 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1140 | return *this; |
| 1141 | } |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1142 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1143 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1144 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 1145 | ~multiset() { |
| 1146 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1147 | } |
| 1148 | |
| 1149 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1150 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1151 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1152 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1153 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1154 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1155 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1156 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1157 | |
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 | reverse_iterator rbegin() _NOEXCEPT |
| 1160 | {return reverse_iterator(end());} |
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 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1163 | {return const_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 | reverse_iterator rend() _NOEXCEPT |
| 1166 | {return reverse_iterator(begin());} |
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 | const_reverse_iterator rend() const _NOEXCEPT |
| 1169 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1170 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1171 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1172 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1173 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1174 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1175 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1176 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1177 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1178 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1179 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1180 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1181 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1182 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1183 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1184 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1185 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 | |
| 1187 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1188 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1189 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1190 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1191 | iterator emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1192 | {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1193 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1194 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1195 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1196 | {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1197 | #endif // _LIBCPP_CXX03_LANG |
| 1198 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1199 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1200 | iterator insert(const value_type& __v) |
| 1201 | {return __tree_.__insert_multi(__v);} |
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_iterator __p, const value_type& __v) |
| 1204 | {return __tree_.__insert_multi(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1205 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1206 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1207 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1208 | void insert(_InputIterator __f, _InputIterator __l) |
| 1209 | { |
| 1210 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1211 | __tree_.__insert_multi(__e, *__f); |
| 1212 | } |
| 1213 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1214 | #ifndef _LIBCPP_CXX03_LANG |
| 1215 | _LIBCPP_INLINE_VISIBILITY |
| 1216 | iterator insert(value_type&& __v) |
| 1217 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
| 1218 | |
| 1219 | _LIBCPP_INLINE_VISIBILITY |
| 1220 | iterator insert(const_iterator __p, value_type&& __v) |
| 1221 | {return __tree_.__insert_multi(__p, _VSTD::move(__v));} |
| 1222 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1223 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1224 | void insert(initializer_list<value_type> __il) |
| 1225 | {insert(__il.begin(), __il.end());} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1226 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1227 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1228 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1229 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1230 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1231 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1232 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1233 | iterator erase(const_iterator __f, const_iterator __l) |
| 1234 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1235 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1236 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1237 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1238 | #if _LIBCPP_STD_VER > 14 |
| 1239 | _LIBCPP_INLINE_VISIBILITY |
| 1240 | iterator insert(node_type&& __nh) |
| 1241 | { |
| 1242 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1243 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1244 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1245 | _VSTD::move(__nh)); |
| 1246 | } |
| 1247 | _LIBCPP_INLINE_VISIBILITY |
| 1248 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1249 | { |
| 1250 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1251 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1252 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1253 | __hint, _VSTD::move(__nh)); |
| 1254 | } |
| 1255 | _LIBCPP_INLINE_VISIBILITY |
| 1256 | node_type extract(key_type const& __key) |
| 1257 | { |
| 1258 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1259 | } |
| 1260 | _LIBCPP_INLINE_VISIBILITY |
| 1261 | node_type extract(const_iterator __it) |
| 1262 | { |
| 1263 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 1264 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1265 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1266 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1267 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1268 | { |
| 1269 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1270 | "merging container with incompatible allocator"); |
| 1271 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1272 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1273 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1274 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1275 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1276 | { |
| 1277 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1278 | "merging container with incompatible allocator"); |
| 1279 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1280 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1281 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1282 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1283 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1284 | { |
| 1285 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1286 | "merging container with incompatible allocator"); |
| 1287 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1288 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1289 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1290 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1291 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1292 | { |
| 1293 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1294 | "merging container with incompatible allocator"); |
| 1295 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1296 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1297 | #endif |
| 1298 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1299 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1300 | void swap(multiset& __s) |
| 1301 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1302 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1303 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1304 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1305 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1306 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1307 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1308 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1309 | value_compare value_comp() const {return __tree_.value_comp();} |
| 1310 | |
| 1311 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1312 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1313 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1314 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1315 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1316 | #if _LIBCPP_STD_VER > 11 |
| 1317 | template <typename _K2> |
| 1318 | _LIBCPP_INLINE_VISIBILITY |
| 1319 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1320 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1321 | template <typename _K2> |
| 1322 | _LIBCPP_INLINE_VISIBILITY |
| 1323 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1324 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1325 | #endif |
| 1326 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1327 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1328 | size_type count(const key_type& __k) const |
| 1329 | {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1330 | #if _LIBCPP_STD_VER > 11 |
| 1331 | template <typename _K2> |
| 1332 | _LIBCPP_INLINE_VISIBILITY |
| 1333 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Marshall Clow | 5571bcd | 2018-01-07 17:39:57 +0000 | [diff] [blame] | 1334 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1335 | #endif |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1336 | |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1337 | #if _LIBCPP_STD_VER > 17 |
| 1338 | _LIBCPP_INLINE_VISIBILITY |
| 1339 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame^] | 1340 | template <typename _K2> |
| 1341 | _LIBCPP_INLINE_VISIBILITY |
| 1342 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 1343 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1344 | #endif // _LIBCPP_STD_VER > 17 |
| 1345 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1346 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1347 | iterator lower_bound(const key_type& __k) |
| 1348 | {return __tree_.lower_bound(__k);} |
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 | const_iterator lower_bound(const key_type& __k) const |
| 1351 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1352 | #if _LIBCPP_STD_VER > 11 |
| 1353 | template <typename _K2> |
| 1354 | _LIBCPP_INLINE_VISIBILITY |
| 1355 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1356 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1357 | |
| 1358 | template <typename _K2> |
| 1359 | _LIBCPP_INLINE_VISIBILITY |
| 1360 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1361 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1362 | #endif |
| 1363 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1364 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1365 | iterator upper_bound(const key_type& __k) |
| 1366 | {return __tree_.upper_bound(__k);} |
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 | const_iterator upper_bound(const key_type& __k) const |
| 1369 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1370 | #if _LIBCPP_STD_VER > 11 |
| 1371 | template <typename _K2> |
| 1372 | _LIBCPP_INLINE_VISIBILITY |
| 1373 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1374 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1375 | template <typename _K2> |
| 1376 | _LIBCPP_INLINE_VISIBILITY |
| 1377 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1378 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1379 | #endif |
| 1380 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1381 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1382 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1383 | {return __tree_.__equal_range_multi(__k);} |
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<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1386 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1387 | #if _LIBCPP_STD_VER > 11 |
| 1388 | template <typename _K2> |
| 1389 | _LIBCPP_INLINE_VISIBILITY |
| 1390 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 1391 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1392 | template <typename _K2> |
| 1393 | _LIBCPP_INLINE_VISIBILITY |
| 1394 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 1395 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1396 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1397 | }; |
| 1398 | |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1399 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 1400 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1401 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 1402 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1403 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 1404 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1405 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1406 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1407 | |
| 1408 | template<class _Key, class _Compare = less<_Key>, |
| 1409 | class _Allocator = allocator<_Key>, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1410 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, |
| 1411 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1412 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1413 | -> multiset<_Key, _Compare, _Allocator>; |
| 1414 | |
| 1415 | template<class _InputIterator, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1416 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1417 | multiset(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1418 | -> multiset<__iter_value_type<_InputIterator>, |
| 1419 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1420 | |
| 1421 | template<class _Key, class _Allocator, |
Louis Dionne | 6c7da9a | 2019-07-19 17:13:39 +0000 | [diff] [blame] | 1422 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1423 | multiset(initializer_list<_Key>, _Allocator) |
| 1424 | -> multiset<_Key, less<_Key>, _Allocator>; |
| 1425 | #endif |
| 1426 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1427 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1428 | |
| 1429 | template <class _Key, class _Compare, class _Allocator> |
| 1430 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1431 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1432 | { |
| 1433 | if (__a != __s.get_allocator()) |
| 1434 | { |
| 1435 | const_iterator __e = cend(); |
| 1436 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1437 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1438 | } |
| 1439 | } |
| 1440 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1441 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1442 | |
| 1443 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1444 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1445 | bool |
| 1446 | operator==(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1447 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1448 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1449 | 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] | 1450 | } |
| 1451 | |
| 1452 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1453 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1454 | bool |
| 1455 | operator< (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1456 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1457 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1458 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1462 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1463 | bool |
| 1464 | operator!=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1465 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1466 | { |
| 1467 | return !(__x == __y); |
| 1468 | } |
| 1469 | |
| 1470 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1471 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1472 | bool |
| 1473 | operator> (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1474 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1475 | { |
| 1476 | return __y < __x; |
| 1477 | } |
| 1478 | |
| 1479 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1480 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1481 | bool |
| 1482 | operator>=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1483 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1484 | { |
| 1485 | return !(__x < __y); |
| 1486 | } |
| 1487 | |
| 1488 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1489 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1490 | bool |
| 1491 | operator<=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1492 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1493 | { |
| 1494 | return !(__y < __x); |
| 1495 | } |
| 1496 | |
| 1497 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1498 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1499 | void |
| 1500 | swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1501 | multiset<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1502 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1503 | { |
| 1504 | __x.swap(__y); |
| 1505 | } |
| 1506 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1507 | #if _LIBCPP_STD_VER > 17 |
| 1508 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1509 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1510 | typename multiset<_Key, _Compare, _Allocator>::size_type |
| 1511 | erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 1512 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1513 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1514 | #endif |
| 1515 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1516 | _LIBCPP_END_NAMESPACE_STD |
| 1517 | |
| 1518 | #endif // _LIBCPP_SET |