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