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