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