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