Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- set -------------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 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 | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 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 | 24a7e33 | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 74 | ~set(); |
| 75 | |
| 76 | set& operator=(const set& s); |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 82 | set& operator=(initializer_list<value_type> il); |
| 83 | |
| 84 | // iterators: |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 94 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 99 | |
| 100 | // capacity: |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 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 | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 119 | iterator erase(iterator position); // C++14 |
Howard Hinnant | bc8d3f9 | 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 | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 122 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 129 | |
| 130 | // observers: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 131 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 202 | |
Howard Hinnant | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 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 | 24a7e33 | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | ~multiset(); |
| 257 | |
| 258 | multiset& operator=(const multiset& s); |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 264 | multiset& operator=(initializer_list<value_type> il); |
| 265 | |
| 266 | // iterators: |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 271 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 276 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 281 | |
| 282 | // capacity: |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 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 | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 301 | iterator erase(iterator position); // C++14 |
Howard Hinnant | bc8d3f9 | 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 | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 304 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 305 | |
Howard Hinnant | b2e2a8f | 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 | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 311 | |
| 312 | // observers: |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 313 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | 4a0a981 | 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 | bc8d3f9 | 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 | b2e2a8f | 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 | bc8d3f9 | 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 | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 392 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 393 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 394 | #endif |
Howard Hinnant | bc8d3f9 | 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> > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 400 | class _LIBCPP_TYPE_VIS_ONLY set |
Howard Hinnant | bc8d3f9 | 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 | |
| 412 | private: |
| 413 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 414 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 415 | typedef typename __base::__node_holder __node_holder; |
| 416 | |
| 417 | __base __tree_; |
| 418 | |
| 419 | public: |
| 420 | typedef typename __base::pointer pointer; |
| 421 | typedef typename __base::const_pointer const_pointer; |
| 422 | typedef typename __base::size_type size_type; |
| 423 | typedef typename __base::difference_type difference_type; |
| 424 | typedef typename __base::const_iterator iterator; |
| 425 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 426 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 427 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 429 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 430 | set() |
| 431 | _NOEXCEPT_( |
| 432 | is_nothrow_default_constructible<allocator_type>::value && |
| 433 | is_nothrow_default_constructible<key_compare>::value && |
| 434 | is_nothrow_copy_constructible<key_compare>::value) |
| 435 | : __tree_(value_compare()) {} |
| 436 | |
| 437 | _LIBCPP_INLINE_VISIBILITY |
| 438 | explicit set(const value_compare& __comp) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 439 | _NOEXCEPT_( |
| 440 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 441 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 442 | : __tree_(__comp) {} |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 443 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 444 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 445 | explicit set(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 446 | : __tree_(__comp, __a) {} |
| 447 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 448 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 449 | set(_InputIterator __f, _InputIterator __l, |
| 450 | const value_compare& __comp = value_compare()) |
| 451 | : __tree_(__comp) |
| 452 | { |
| 453 | insert(__f, __l); |
| 454 | } |
| 455 | |
| 456 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 457 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 458 | set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, |
| 459 | const allocator_type& __a) |
| 460 | : __tree_(__comp, __a) |
| 461 | { |
| 462 | insert(__f, __l); |
| 463 | } |
| 464 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 465 | #if _LIBCPP_STD_VER > 11 |
| 466 | template <class _InputIterator> |
| 467 | _LIBCPP_INLINE_VISIBILITY |
| 468 | set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 469 | : set(__f, __l, key_compare(), __a) {} |
| 470 | #endif |
| 471 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 472 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 473 | set(const set& __s) |
| 474 | : __tree_(__s.__tree_) |
| 475 | { |
| 476 | insert(__s.begin(), __s.end()); |
| 477 | } |
| 478 | |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 479 | _LIBCPP_INLINE_VISIBILITY |
| 480 | set& operator=(const set& __s) |
| 481 | { |
| 482 | __tree_ = __s.__tree_; |
| 483 | return *this; |
| 484 | } |
| 485 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 486 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 487 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 488 | set(set&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 489 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 490 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 491 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 492 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 493 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 494 | explicit set(const allocator_type& __a) |
| 495 | : __tree_(__a) {} |
| 496 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 497 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 498 | set(const set& __s, const allocator_type& __a) |
| 499 | : __tree_(__s.__tree_.value_comp(), __a) |
| 500 | { |
| 501 | insert(__s.begin(), __s.end()); |
| 502 | } |
| 503 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 504 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 505 | set(set&& __s, const allocator_type& __a); |
| 506 | #endif |
| 507 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 508 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 509 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 510 | set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 511 | : __tree_(__comp) |
| 512 | { |
| 513 | insert(__il.begin(), __il.end()); |
| 514 | } |
| 515 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 516 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 517 | set(initializer_list<value_type> __il, const value_compare& __comp, |
| 518 | const allocator_type& __a) |
| 519 | : __tree_(__comp, __a) |
| 520 | { |
| 521 | insert(__il.begin(), __il.end()); |
| 522 | } |
| 523 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 524 | #if _LIBCPP_STD_VER > 11 |
| 525 | _LIBCPP_INLINE_VISIBILITY |
| 526 | set(initializer_list<value_type> __il, const allocator_type& __a) |
| 527 | : set(__il, key_compare(), __a) {} |
| 528 | #endif |
| 529 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 530 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 531 | set& operator=(initializer_list<value_type> __il) |
| 532 | { |
| 533 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 534 | return *this; |
| 535 | } |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 536 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 537 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 538 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 539 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 540 | set& operator=(set&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 541 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 542 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 543 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 544 | return *this; |
| 545 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 546 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 547 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 548 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 549 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 550 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 551 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 552 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 553 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 554 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 555 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 556 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 557 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 558 | reverse_iterator rbegin() _NOEXCEPT |
| 559 | {return reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 560 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 561 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 562 | {return const_reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 563 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 564 | reverse_iterator rend() _NOEXCEPT |
| 565 | {return reverse_iterator(begin());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 566 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 567 | const_reverse_iterator rend() const _NOEXCEPT |
| 568 | {return const_reverse_iterator(begin());} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 569 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 570 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 571 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 572 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 573 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 574 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 575 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 576 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 577 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 578 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 579 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 580 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 581 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 582 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 583 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 584 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 585 | |
| 586 | // modifiers: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 587 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 588 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 589 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 590 | pair<iterator, bool> emplace(_Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 591 | {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 592 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 593 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 594 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 595 | {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 596 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 597 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 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 | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 600 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 601 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | pair<iterator,bool> insert(value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 603 | {return __tree_.__insert_unique(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 604 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 605 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 606 | iterator insert(const_iterator __p, const value_type& __v) |
| 607 | {return __tree_.__insert_unique(__p, __v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 608 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 609 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 610 | iterator insert(const_iterator __p, value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 611 | {return __tree_.__insert_unique(__p, _VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 612 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 613 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 614 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 615 | void insert(_InputIterator __f, _InputIterator __l) |
| 616 | { |
| 617 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 618 | __tree_.__insert_unique(__e, *__f); |
| 619 | } |
| 620 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 621 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 622 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 623 | void insert(initializer_list<value_type> __il) |
| 624 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 625 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 626 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 627 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 628 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 629 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 630 | size_type erase(const key_type& __k) |
| 631 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 632 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 633 | iterator erase(const_iterator __f, const_iterator __l) |
| 634 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 635 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 636 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 637 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 638 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 639 | void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 640 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 641 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 642 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 643 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 644 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 645 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 646 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 647 | value_compare value_comp() const {return __tree_.value_comp();} |
| 648 | |
| 649 | // set operations: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 650 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 651 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 652 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 654 | #if _LIBCPP_STD_VER > 11 |
| 655 | template <typename _K2> |
| 656 | _LIBCPP_INLINE_VISIBILITY |
| 657 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 658 | find(const _K2& __k) {return __tree_.find(__k);} |
| 659 | template <typename _K2> |
| 660 | _LIBCPP_INLINE_VISIBILITY |
| 661 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 662 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 663 | #endif |
| 664 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 665 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 666 | size_type count(const key_type& __k) const |
| 667 | {return __tree_.__count_unique(__k);} |
Marshall Clow | 4de3204 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 668 | #if _LIBCPP_STD_VER > 11 |
| 669 | template <typename _K2> |
| 670 | _LIBCPP_INLINE_VISIBILITY |
| 671 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
| 672 | count(const _K2& __k) {return __tree_.__count_unique(__k);} |
| 673 | #endif |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 674 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 675 | iterator lower_bound(const key_type& __k) |
| 676 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 677 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 678 | const_iterator lower_bound(const key_type& __k) const |
| 679 | {return __tree_.lower_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 680 | #if _LIBCPP_STD_VER > 11 |
| 681 | template <typename _K2> |
| 682 | _LIBCPP_INLINE_VISIBILITY |
| 683 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 684 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 685 | |
| 686 | template <typename _K2> |
| 687 | _LIBCPP_INLINE_VISIBILITY |
| 688 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 689 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 690 | #endif |
| 691 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 692 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 693 | iterator upper_bound(const key_type& __k) |
| 694 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 695 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 696 | const_iterator upper_bound(const key_type& __k) const |
| 697 | {return __tree_.upper_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 698 | #if _LIBCPP_STD_VER > 11 |
| 699 | template <typename _K2> |
| 700 | _LIBCPP_INLINE_VISIBILITY |
| 701 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 702 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 703 | template <typename _K2> |
| 704 | _LIBCPP_INLINE_VISIBILITY |
| 705 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 706 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 707 | #endif |
| 708 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 709 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 710 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 711 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 712 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 713 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 714 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 715 | #if _LIBCPP_STD_VER > 11 |
| 716 | template <typename _K2> |
| 717 | _LIBCPP_INLINE_VISIBILITY |
| 718 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 719 | equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} |
| 720 | template <typename _K2> |
| 721 | _LIBCPP_INLINE_VISIBILITY |
| 722 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 723 | equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} |
| 724 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 725 | }; |
| 726 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 727 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 728 | |
| 729 | template <class _Key, class _Compare, class _Allocator> |
| 730 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 731 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 732 | { |
| 733 | if (__a != __s.get_allocator()) |
| 734 | { |
| 735 | const_iterator __e = cend(); |
| 736 | while (!__s.empty()) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 737 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 741 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 742 | |
| 743 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 744 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 745 | bool |
| 746 | operator==(const set<_Key, _Compare, _Allocator>& __x, |
| 747 | const set<_Key, _Compare, _Allocator>& __y) |
| 748 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 749 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 753 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 754 | bool |
| 755 | operator< (const set<_Key, _Compare, _Allocator>& __x, |
| 756 | const set<_Key, _Compare, _Allocator>& __y) |
| 757 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 758 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 762 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 763 | bool |
| 764 | operator!=(const set<_Key, _Compare, _Allocator>& __x, |
| 765 | const set<_Key, _Compare, _Allocator>& __y) |
| 766 | { |
| 767 | return !(__x == __y); |
| 768 | } |
| 769 | |
| 770 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 771 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 772 | bool |
| 773 | operator> (const set<_Key, _Compare, _Allocator>& __x, |
| 774 | const set<_Key, _Compare, _Allocator>& __y) |
| 775 | { |
| 776 | return __y < __x; |
| 777 | } |
| 778 | |
| 779 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 780 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 781 | bool |
| 782 | operator>=(const set<_Key, _Compare, _Allocator>& __x, |
| 783 | const set<_Key, _Compare, _Allocator>& __y) |
| 784 | { |
| 785 | return !(__x < __y); |
| 786 | } |
| 787 | |
| 788 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 789 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 790 | bool |
| 791 | operator<=(const set<_Key, _Compare, _Allocator>& __x, |
| 792 | const set<_Key, _Compare, _Allocator>& __y) |
| 793 | { |
| 794 | return !(__y < __x); |
| 795 | } |
| 796 | |
| 797 | // specialized algorithms: |
| 798 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 799 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 800 | void |
| 801 | swap(set<_Key, _Compare, _Allocator>& __x, |
| 802 | set<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 803 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 804 | { |
| 805 | __x.swap(__y); |
| 806 | } |
| 807 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 808 | template <class _Key, class _Compare = less<_Key>, |
| 809 | class _Allocator = allocator<_Key> > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 810 | class _LIBCPP_TYPE_VIS_ONLY multiset |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 811 | { |
| 812 | public: |
| 813 | // types: |
| 814 | typedef _Key key_type; |
| 815 | typedef key_type value_type; |
| 816 | typedef _Compare key_compare; |
| 817 | typedef key_compare value_compare; |
| 818 | typedef _Allocator allocator_type; |
| 819 | typedef value_type& reference; |
| 820 | typedef const value_type& const_reference; |
| 821 | |
| 822 | private: |
| 823 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 824 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 825 | typedef typename __base::__node_holder __node_holder; |
| 826 | |
| 827 | __base __tree_; |
| 828 | |
| 829 | public: |
| 830 | typedef typename __base::pointer pointer; |
| 831 | typedef typename __base::const_pointer const_pointer; |
| 832 | typedef typename __base::size_type size_type; |
| 833 | typedef typename __base::difference_type difference_type; |
| 834 | typedef typename __base::const_iterator iterator; |
| 835 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 836 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 837 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 838 | |
| 839 | // construct/copy/destroy: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 840 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 841 | multiset() |
| 842 | _NOEXCEPT_( |
| 843 | is_nothrow_default_constructible<allocator_type>::value && |
| 844 | is_nothrow_default_constructible<key_compare>::value && |
| 845 | is_nothrow_copy_constructible<key_compare>::value) |
| 846 | : __tree_(value_compare()) {} |
| 847 | |
| 848 | _LIBCPP_INLINE_VISIBILITY |
| 849 | explicit multiset(const value_compare& __comp) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 850 | _NOEXCEPT_( |
| 851 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 852 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 853 | : __tree_(__comp) {} |
Marshall Clow | caaa141 | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 854 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 855 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 856 | explicit multiset(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | : __tree_(__comp, __a) {} |
| 858 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 859 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 860 | multiset(_InputIterator __f, _InputIterator __l, |
| 861 | const value_compare& __comp = value_compare()) |
| 862 | : __tree_(__comp) |
| 863 | { |
| 864 | insert(__f, __l); |
| 865 | } |
| 866 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 867 | #if _LIBCPP_STD_VER > 11 |
| 868 | template <class _InputIterator> |
| 869 | _LIBCPP_INLINE_VISIBILITY |
| 870 | multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 871 | : multiset(__f, __l, key_compare(), __a) {} |
| 872 | #endif |
| 873 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 874 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 875 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 876 | multiset(_InputIterator __f, _InputIterator __l, |
| 877 | const value_compare& __comp, const allocator_type& __a) |
| 878 | : __tree_(__comp, __a) |
| 879 | { |
| 880 | insert(__f, __l); |
| 881 | } |
| 882 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 883 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 884 | multiset(const multiset& __s) |
| 885 | : __tree_(__s.__tree_.value_comp(), |
| 886 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) |
| 887 | { |
| 888 | insert(__s.begin(), __s.end()); |
| 889 | } |
| 890 | |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 891 | _LIBCPP_INLINE_VISIBILITY |
| 892 | multiset& operator=(const multiset& __s) |
| 893 | { |
| 894 | __tree_ = __s.__tree_; |
| 895 | return *this; |
| 896 | } |
| 897 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 898 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 899 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 900 | multiset(multiset&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 901 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 902 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 903 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 904 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | explicit multiset(const allocator_type& __a) |
| 906 | : __tree_(__a) {} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 907 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 908 | multiset(const multiset& __s, const allocator_type& __a) |
| 909 | : __tree_(__s.__tree_.value_comp(), __a) |
| 910 | { |
| 911 | insert(__s.begin(), __s.end()); |
| 912 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 913 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 914 | multiset(multiset&& __s, const allocator_type& __a); |
| 915 | #endif |
| 916 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 917 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 918 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 919 | multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 920 | : __tree_(__comp) |
| 921 | { |
| 922 | insert(__il.begin(), __il.end()); |
| 923 | } |
| 924 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 925 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 926 | multiset(initializer_list<value_type> __il, const value_compare& __comp, |
| 927 | const allocator_type& __a) |
| 928 | : __tree_(__comp, __a) |
| 929 | { |
| 930 | insert(__il.begin(), __il.end()); |
| 931 | } |
| 932 | |
Marshall Clow | 24a7e33 | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 933 | #if _LIBCPP_STD_VER > 11 |
| 934 | _LIBCPP_INLINE_VISIBILITY |
| 935 | multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 936 | : multiset(__il, key_compare(), __a) {} |
| 937 | #endif |
| 938 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 939 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | multiset& operator=(initializer_list<value_type> __il) |
| 941 | { |
| 942 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 943 | return *this; |
| 944 | } |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 945 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 946 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 947 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 948 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 949 | multiset& operator=(multiset&& __s) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 950 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 951 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 952 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 953 | return *this; |
| 954 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 955 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 956 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 957 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 958 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 959 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 960 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 961 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 962 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 963 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 964 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 965 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 966 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 967 | reverse_iterator rbegin() _NOEXCEPT |
| 968 | {return reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 969 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 970 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 971 | {return const_reverse_iterator(end());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 972 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 973 | reverse_iterator rend() _NOEXCEPT |
| 974 | {return reverse_iterator(begin());} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 975 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 976 | const_reverse_iterator rend() const _NOEXCEPT |
| 977 | {return const_reverse_iterator(begin());} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 978 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 979 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 980 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 981 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 982 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 983 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 984 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 985 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 986 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 987 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 988 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 989 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 990 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 991 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 992 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 993 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 994 | |
| 995 | // modifiers: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 996 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 997 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 998 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 999 | iterator emplace(_Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1000 | {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1001 | template <class... _Args> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1002 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1003 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1004 | {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1005 | #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1006 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1007 | iterator insert(const value_type& __v) |
| 1008 | {return __tree_.__insert_multi(__v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1009 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1010 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1011 | iterator insert(value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1012 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1013 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1014 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1015 | iterator insert(const_iterator __p, const value_type& __v) |
| 1016 | {return __tree_.__insert_multi(__p, __v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1017 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1018 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1019 | iterator insert(const_iterator __p, value_type&& __v) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1020 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1021 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1022 | template <class _InputIterator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1023 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1024 | void insert(_InputIterator __f, _InputIterator __l) |
| 1025 | { |
| 1026 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1027 | __tree_.__insert_multi(__e, *__f); |
| 1028 | } |
| 1029 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1030 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1031 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1032 | void insert(initializer_list<value_type> __il) |
| 1033 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1034 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1035 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1036 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1037 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1038 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1039 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1040 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1041 | iterator erase(const_iterator __f, const_iterator __l) |
| 1042 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1043 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1044 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1045 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1046 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1047 | void swap(multiset& __s) |
| 1048 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1049 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1051 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1052 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1053 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1054 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1055 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1056 | value_compare value_comp() const {return __tree_.value_comp();} |
| 1057 | |
| 1058 | // set operations: |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1059 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1060 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1061 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1062 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1063 | #if _LIBCPP_STD_VER > 11 |
| 1064 | template <typename _K2> |
| 1065 | _LIBCPP_INLINE_VISIBILITY |
| 1066 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1067 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1068 | template <typename _K2> |
| 1069 | _LIBCPP_INLINE_VISIBILITY |
| 1070 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1071 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1072 | #endif |
| 1073 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1074 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1075 | size_type count(const key_type& __k) const |
| 1076 | {return __tree_.__count_multi(__k);} |
Marshall Clow | 4de3204 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1077 | #if _LIBCPP_STD_VER > 11 |
| 1078 | template <typename _K2> |
| 1079 | _LIBCPP_INLINE_VISIBILITY |
| 1080 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
| 1081 | count(const _K2& __k) {return __tree_.__count_multi(__k);} |
| 1082 | #endif |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1083 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1084 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1085 | iterator lower_bound(const key_type& __k) |
| 1086 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1087 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1088 | const_iterator lower_bound(const key_type& __k) const |
| 1089 | {return __tree_.lower_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1090 | #if _LIBCPP_STD_VER > 11 |
| 1091 | template <typename _K2> |
| 1092 | _LIBCPP_INLINE_VISIBILITY |
| 1093 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1094 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1095 | |
| 1096 | template <typename _K2> |
| 1097 | _LIBCPP_INLINE_VISIBILITY |
| 1098 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1099 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1100 | #endif |
| 1101 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1102 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1103 | iterator upper_bound(const key_type& __k) |
| 1104 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1105 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1106 | const_iterator upper_bound(const key_type& __k) const |
| 1107 | {return __tree_.upper_bound(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1108 | #if _LIBCPP_STD_VER > 11 |
| 1109 | template <typename _K2> |
| 1110 | _LIBCPP_INLINE_VISIBILITY |
| 1111 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1112 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1113 | template <typename _K2> |
| 1114 | _LIBCPP_INLINE_VISIBILITY |
| 1115 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1116 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1117 | #endif |
| 1118 | |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1119 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1120 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1121 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1122 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1123 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1124 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | 4a0a981 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1125 | #if _LIBCPP_STD_VER > 11 |
| 1126 | template <typename _K2> |
| 1127 | _LIBCPP_INLINE_VISIBILITY |
| 1128 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 1129 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1130 | template <typename _K2> |
| 1131 | _LIBCPP_INLINE_VISIBILITY |
| 1132 | typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 1133 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1134 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1135 | }; |
| 1136 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1137 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1138 | |
| 1139 | template <class _Key, class _Compare, class _Allocator> |
| 1140 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1141 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1142 | { |
| 1143 | if (__a != __s.get_allocator()) |
| 1144 | { |
| 1145 | const_iterator __e = cend(); |
| 1146 | while (!__s.empty()) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1147 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1148 | } |
| 1149 | } |
| 1150 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1151 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1152 | |
| 1153 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1154 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1155 | bool |
| 1156 | operator==(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1157 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1158 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1159 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1163 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1164 | bool |
| 1165 | operator< (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1166 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1167 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1168 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1172 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1173 | bool |
| 1174 | operator!=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1175 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1176 | { |
| 1177 | return !(__x == __y); |
| 1178 | } |
| 1179 | |
| 1180 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1181 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1182 | bool |
| 1183 | operator> (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1184 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1185 | { |
| 1186 | return __y < __x; |
| 1187 | } |
| 1188 | |
| 1189 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1190 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1191 | bool |
| 1192 | operator>=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1193 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1194 | { |
| 1195 | return !(__x < __y); |
| 1196 | } |
| 1197 | |
| 1198 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1199 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1200 | bool |
| 1201 | operator<=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1202 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1203 | { |
| 1204 | return !(__y < __x); |
| 1205 | } |
| 1206 | |
| 1207 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 28c97e6 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1208 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1209 | void |
| 1210 | swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1211 | multiset<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | b2e2a8f | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1212 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1213 | { |
| 1214 | __x.swap(__y); |
| 1215 | } |
| 1216 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1217 | _LIBCPP_END_NAMESPACE_STD |
| 1218 | |
| 1219 | #endif // _LIBCPP_SET |