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