10b57cec5SDimitry Andric// -*- C++ -*- 20b57cec5SDimitry Andric//===---------------------------- set -------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_SET 110b57cec5SDimitry Andric#define _LIBCPP_SET 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric set synopsis 160b57cec5SDimitry Andric 170b57cec5SDimitry Andricnamespace std 180b57cec5SDimitry Andric{ 190b57cec5SDimitry Andric 200b57cec5SDimitry Andrictemplate <class Key, class Compare = less<Key>, 210b57cec5SDimitry Andric class Allocator = allocator<Key>> 220b57cec5SDimitry Andricclass set 230b57cec5SDimitry Andric{ 240b57cec5SDimitry Andricpublic: 250b57cec5SDimitry Andric // types: 260b57cec5SDimitry Andric typedef Key key_type; 270b57cec5SDimitry Andric typedef key_type value_type; 280b57cec5SDimitry Andric typedef Compare key_compare; 290b57cec5SDimitry Andric typedef key_compare value_compare; 300b57cec5SDimitry Andric typedef Allocator allocator_type; 310b57cec5SDimitry Andric typedef typename allocator_type::reference reference; 320b57cec5SDimitry Andric typedef typename allocator_type::const_reference const_reference; 330b57cec5SDimitry Andric typedef typename allocator_type::size_type size_type; 340b57cec5SDimitry Andric typedef typename allocator_type::difference_type difference_type; 350b57cec5SDimitry Andric typedef typename allocator_type::pointer pointer; 360b57cec5SDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric typedef implementation-defined iterator; 390b57cec5SDimitry Andric typedef implementation-defined const_iterator; 400b57cec5SDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 410b57cec5SDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 420b57cec5SDimitry Andric typedef unspecified node_type; // C++17 430b57cec5SDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric // construct/copy/destroy: 460b57cec5SDimitry Andric set() 470b57cec5SDimitry Andric noexcept( 480b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 490b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 500b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 510b57cec5SDimitry Andric explicit set(const value_compare& comp); 520b57cec5SDimitry Andric set(const value_compare& comp, const allocator_type& a); 530b57cec5SDimitry Andric template <class InputIterator> 540b57cec5SDimitry Andric set(InputIterator first, InputIterator last, 550b57cec5SDimitry Andric const value_compare& comp = value_compare()); 560b57cec5SDimitry Andric template <class InputIterator> 570b57cec5SDimitry Andric set(InputIterator first, InputIterator last, const value_compare& comp, 580b57cec5SDimitry Andric const allocator_type& a); 590b57cec5SDimitry Andric set(const set& s); 600b57cec5SDimitry Andric set(set&& s) 610b57cec5SDimitry Andric noexcept( 620b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 630b57cec5SDimitry Andric is_nothrow_move_constructible<key_compare>::value); 640b57cec5SDimitry Andric explicit set(const allocator_type& a); 650b57cec5SDimitry Andric set(const set& s, const allocator_type& a); 660b57cec5SDimitry Andric set(set&& s, const allocator_type& a); 670b57cec5SDimitry Andric set(initializer_list<value_type> il, const value_compare& comp = value_compare()); 680b57cec5SDimitry Andric set(initializer_list<value_type> il, const value_compare& comp, 690b57cec5SDimitry Andric const allocator_type& a); 700b57cec5SDimitry Andric template <class InputIterator> 710b57cec5SDimitry Andric set(InputIterator first, InputIterator last, const allocator_type& a) 720b57cec5SDimitry Andric : set(first, last, Compare(), a) {} // C++14 730b57cec5SDimitry Andric set(initializer_list<value_type> il, const allocator_type& a) 740b57cec5SDimitry Andric : set(il, Compare(), a) {} // C++14 750b57cec5SDimitry Andric ~set(); 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric set& operator=(const set& s); 780b57cec5SDimitry Andric set& operator=(set&& s) 790b57cec5SDimitry Andric noexcept( 800b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 810b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 820b57cec5SDimitry Andric is_nothrow_move_assignable<key_compare>::value); 830b57cec5SDimitry Andric set& operator=(initializer_list<value_type> il); 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric // iterators: 860b57cec5SDimitry Andric iterator begin() noexcept; 870b57cec5SDimitry Andric const_iterator begin() const noexcept; 880b57cec5SDimitry Andric iterator end() noexcept; 890b57cec5SDimitry Andric const_iterator end() const noexcept; 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric reverse_iterator rbegin() noexcept; 920b57cec5SDimitry Andric const_reverse_iterator rbegin() const noexcept; 930b57cec5SDimitry Andric reverse_iterator rend() noexcept; 940b57cec5SDimitry Andric const_reverse_iterator rend() const noexcept; 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 970b57cec5SDimitry Andric const_iterator cend() const noexcept; 980b57cec5SDimitry Andric const_reverse_iterator crbegin() const noexcept; 990b57cec5SDimitry Andric const_reverse_iterator crend() const noexcept; 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric // capacity: 1020b57cec5SDimitry Andric bool empty() const noexcept; 1030b57cec5SDimitry Andric size_type size() const noexcept; 1040b57cec5SDimitry Andric size_type max_size() const noexcept; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric // modifiers: 1070b57cec5SDimitry Andric template <class... Args> 1080b57cec5SDimitry Andric pair<iterator, bool> emplace(Args&&... args); 1090b57cec5SDimitry Andric template <class... Args> 1100b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 1110b57cec5SDimitry Andric pair<iterator,bool> insert(const value_type& v); 1120b57cec5SDimitry Andric pair<iterator,bool> insert(value_type&& v); 1130b57cec5SDimitry Andric iterator insert(const_iterator position, const value_type& v); 1140b57cec5SDimitry Andric iterator insert(const_iterator position, value_type&& v); 1150b57cec5SDimitry Andric template <class InputIterator> 1160b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 1170b57cec5SDimitry Andric void insert(initializer_list<value_type> il); 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 1200b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 1210b57cec5SDimitry Andric insert_return_type insert(node_type&& nh); // C++17 1220b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andric iterator erase(const_iterator position); 1250b57cec5SDimitry Andric iterator erase(iterator position); // C++14 1260b57cec5SDimitry Andric size_type erase(const key_type& k); 1270b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 1280b57cec5SDimitry Andric void clear() noexcept; 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric template<class C2> 1310b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>& source); // C++17 1320b57cec5SDimitry Andric template<class C2> 1330b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>&& source); // C++17 1340b57cec5SDimitry Andric template<class C2> 1350b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>& source); // C++17 1360b57cec5SDimitry Andric template<class C2> 1370b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>&& source); // C++17 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric void swap(set& s) 1400b57cec5SDimitry Andric noexcept( 1410b57cec5SDimitry Andric __is_nothrow_swappable<key_compare>::value && 1420b57cec5SDimitry Andric (!allocator_type::propagate_on_container_swap::value || 1430b57cec5SDimitry Andric __is_nothrow_swappable<allocator_type>::value)); 1440b57cec5SDimitry Andric 1450b57cec5SDimitry Andric // observers: 1460b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 1470b57cec5SDimitry Andric key_compare key_comp() const; 1480b57cec5SDimitry Andric value_compare value_comp() const; 1490b57cec5SDimitry Andric 1500b57cec5SDimitry Andric // set operations: 1510b57cec5SDimitry Andric iterator find(const key_type& k); 1520b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 1530b57cec5SDimitry Andric template<typename K> 1540b57cec5SDimitry Andric iterator find(const K& x); 1550b57cec5SDimitry Andric template<typename K> 1560b57cec5SDimitry Andric const_iterator find(const K& x) const; // C++14 1570b57cec5SDimitry Andric template<typename K> 1580b57cec5SDimitry Andric size_type count(const K& x) const; // C++14 1590b57cec5SDimitry Andric size_type count(const key_type& k) const; 1600b57cec5SDimitry Andric bool contains(const key_type& x) const; // C++20 1610b57cec5SDimitry Andric iterator lower_bound(const key_type& k); 1620b57cec5SDimitry Andric const_iterator lower_bound(const key_type& k) const; 1630b57cec5SDimitry Andric template<typename K> 1640b57cec5SDimitry Andric iterator lower_bound(const K& x); // C++14 1650b57cec5SDimitry Andric template<typename K> 1660b57cec5SDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andric iterator upper_bound(const key_type& k); 1690b57cec5SDimitry Andric const_iterator upper_bound(const key_type& k) const; 1700b57cec5SDimitry Andric template<typename K> 1710b57cec5SDimitry Andric iterator upper_bound(const K& x); // C++14 1720b57cec5SDimitry Andric template<typename K> 1730b57cec5SDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 1740b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 1750b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 1760b57cec5SDimitry Andric template<typename K> 1770b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 1780b57cec5SDimitry Andric template<typename K> 1790b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 1800b57cec5SDimitry Andric}; 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 1830b57cec5SDimitry Andricbool 1840b57cec5SDimitry Andricoperator==(const set<Key, Compare, Allocator>& x, 1850b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 1880b57cec5SDimitry Andricbool 1890b57cec5SDimitry Andricoperator< (const set<Key, Compare, Allocator>& x, 1900b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 1930b57cec5SDimitry Andricbool 1940b57cec5SDimitry Andricoperator!=(const set<Key, Compare, Allocator>& x, 1950b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 1960b57cec5SDimitry Andric 1970b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 1980b57cec5SDimitry Andricbool 1990b57cec5SDimitry Andricoperator> (const set<Key, Compare, Allocator>& x, 2000b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2030b57cec5SDimitry Andricbool 2040b57cec5SDimitry Andricoperator>=(const set<Key, Compare, Allocator>& x, 2050b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2080b57cec5SDimitry Andricbool 2090b57cec5SDimitry Andricoperator<=(const set<Key, Compare, Allocator>& x, 2100b57cec5SDimitry Andric const set<Key, Compare, Allocator>& y); 2110b57cec5SDimitry Andric 2120b57cec5SDimitry Andric// specialized algorithms: 2130b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 2140b57cec5SDimitry Andricvoid 2150b57cec5SDimitry Andricswap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) 2160b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2170b57cec5SDimitry Andric 2180b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate> 219*5ffd83dbSDimitry Andrictypename set<Key, Compare, Allocator>::size_type 220*5ffd83dbSDimitry Andricerase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andrictemplate <class Key, class Compare = less<Key>, 2230b57cec5SDimitry Andric class Allocator = allocator<Key>> 2240b57cec5SDimitry Andricclass multiset 2250b57cec5SDimitry Andric{ 2260b57cec5SDimitry Andricpublic: 2270b57cec5SDimitry Andric // types: 2280b57cec5SDimitry Andric typedef Key key_type; 2290b57cec5SDimitry Andric typedef key_type value_type; 2300b57cec5SDimitry Andric typedef Compare key_compare; 2310b57cec5SDimitry Andric typedef key_compare value_compare; 2320b57cec5SDimitry Andric typedef Allocator allocator_type; 2330b57cec5SDimitry Andric typedef typename allocator_type::reference reference; 2340b57cec5SDimitry Andric typedef typename allocator_type::const_reference const_reference; 2350b57cec5SDimitry Andric typedef typename allocator_type::size_type size_type; 2360b57cec5SDimitry Andric typedef typename allocator_type::difference_type difference_type; 2370b57cec5SDimitry Andric typedef typename allocator_type::pointer pointer; 2380b57cec5SDimitry Andric typedef typename allocator_type::const_pointer const_pointer; 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andric typedef implementation-defined iterator; 2410b57cec5SDimitry Andric typedef implementation-defined const_iterator; 2420b57cec5SDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 2430b57cec5SDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 2440b57cec5SDimitry Andric typedef unspecified node_type; // C++17 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andric // construct/copy/destroy: 2470b57cec5SDimitry Andric multiset() 2480b57cec5SDimitry Andric noexcept( 2490b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 2500b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 2510b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value); 2520b57cec5SDimitry Andric explicit multiset(const value_compare& comp); 2530b57cec5SDimitry Andric multiset(const value_compare& comp, const allocator_type& a); 2540b57cec5SDimitry Andric template <class InputIterator> 2550b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, 2560b57cec5SDimitry Andric const value_compare& comp = value_compare()); 2570b57cec5SDimitry Andric template <class InputIterator> 2580b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, 2590b57cec5SDimitry Andric const value_compare& comp, const allocator_type& a); 2600b57cec5SDimitry Andric multiset(const multiset& s); 2610b57cec5SDimitry Andric multiset(multiset&& s) 2620b57cec5SDimitry Andric noexcept( 2630b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value && 2640b57cec5SDimitry Andric is_nothrow_move_constructible<key_compare>::value); 2650b57cec5SDimitry Andric explicit multiset(const allocator_type& a); 2660b57cec5SDimitry Andric multiset(const multiset& s, const allocator_type& a); 2670b57cec5SDimitry Andric multiset(multiset&& s, const allocator_type& a); 2680b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); 2690b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const value_compare& comp, 2700b57cec5SDimitry Andric const allocator_type& a); 2710b57cec5SDimitry Andric template <class InputIterator> 2720b57cec5SDimitry Andric multiset(InputIterator first, InputIterator last, const allocator_type& a) 2730b57cec5SDimitry Andric : set(first, last, Compare(), a) {} // C++14 2740b57cec5SDimitry Andric multiset(initializer_list<value_type> il, const allocator_type& a) 2750b57cec5SDimitry Andric : set(il, Compare(), a) {} // C++14 2760b57cec5SDimitry Andric ~multiset(); 2770b57cec5SDimitry Andric 2780b57cec5SDimitry Andric multiset& operator=(const multiset& s); 2790b57cec5SDimitry Andric multiset& operator=(multiset&& s) 2800b57cec5SDimitry Andric noexcept( 2810b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 2820b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 2830b57cec5SDimitry Andric is_nothrow_move_assignable<key_compare>::value); 2840b57cec5SDimitry Andric multiset& operator=(initializer_list<value_type> il); 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric // iterators: 2870b57cec5SDimitry Andric iterator begin() noexcept; 2880b57cec5SDimitry Andric const_iterator begin() const noexcept; 2890b57cec5SDimitry Andric iterator end() noexcept; 2900b57cec5SDimitry Andric const_iterator end() const noexcept; 2910b57cec5SDimitry Andric 2920b57cec5SDimitry Andric reverse_iterator rbegin() noexcept; 2930b57cec5SDimitry Andric const_reverse_iterator rbegin() const noexcept; 2940b57cec5SDimitry Andric reverse_iterator rend() noexcept; 2950b57cec5SDimitry Andric const_reverse_iterator rend() const noexcept; 2960b57cec5SDimitry Andric 2970b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 2980b57cec5SDimitry Andric const_iterator cend() const noexcept; 2990b57cec5SDimitry Andric const_reverse_iterator crbegin() const noexcept; 3000b57cec5SDimitry Andric const_reverse_iterator crend() const noexcept; 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric // capacity: 3030b57cec5SDimitry Andric bool empty() const noexcept; 3040b57cec5SDimitry Andric size_type size() const noexcept; 3050b57cec5SDimitry Andric size_type max_size() const noexcept; 3060b57cec5SDimitry Andric 3070b57cec5SDimitry Andric // modifiers: 3080b57cec5SDimitry Andric template <class... Args> 3090b57cec5SDimitry Andric iterator emplace(Args&&... args); 3100b57cec5SDimitry Andric template <class... Args> 3110b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 3120b57cec5SDimitry Andric iterator insert(const value_type& v); 3130b57cec5SDimitry Andric iterator insert(value_type&& v); 3140b57cec5SDimitry Andric iterator insert(const_iterator position, const value_type& v); 3150b57cec5SDimitry Andric iterator insert(const_iterator position, value_type&& v); 3160b57cec5SDimitry Andric template <class InputIterator> 3170b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 3180b57cec5SDimitry Andric void insert(initializer_list<value_type> il); 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 3210b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 3220b57cec5SDimitry Andric iterator insert(node_type&& nh); // C++17 3230b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andric iterator erase(const_iterator position); 3260b57cec5SDimitry Andric iterator erase(iterator position); // C++14 3270b57cec5SDimitry Andric size_type erase(const key_type& k); 3280b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 3290b57cec5SDimitry Andric void clear() noexcept; 3300b57cec5SDimitry Andric 3310b57cec5SDimitry Andric template<class C2> 3320b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>& source); // C++17 3330b57cec5SDimitry Andric template<class C2> 3340b57cec5SDimitry Andric void merge(multiset<Key, C2, Allocator>&& source); // C++17 3350b57cec5SDimitry Andric template<class C2> 3360b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>& source); // C++17 3370b57cec5SDimitry Andric template<class C2> 3380b57cec5SDimitry Andric void merge(set<Key, C2, Allocator>&& source); // C++17 3390b57cec5SDimitry Andric 3400b57cec5SDimitry Andric void swap(multiset& s) 3410b57cec5SDimitry Andric noexcept( 3420b57cec5SDimitry Andric __is_nothrow_swappable<key_compare>::value && 3430b57cec5SDimitry Andric (!allocator_type::propagate_on_container_swap::value || 3440b57cec5SDimitry Andric __is_nothrow_swappable<allocator_type>::value)); 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andric // observers: 3470b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 3480b57cec5SDimitry Andric key_compare key_comp() const; 3490b57cec5SDimitry Andric value_compare value_comp() const; 3500b57cec5SDimitry Andric 3510b57cec5SDimitry Andric // set operations: 3520b57cec5SDimitry Andric iterator find(const key_type& k); 3530b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 3540b57cec5SDimitry Andric template<typename K> 3550b57cec5SDimitry Andric iterator find(const K& x); 3560b57cec5SDimitry Andric template<typename K> 3570b57cec5SDimitry Andric const_iterator find(const K& x) const; // C++14 3580b57cec5SDimitry Andric template<typename K> 3590b57cec5SDimitry Andric size_type count(const K& x) const; // C++14 3600b57cec5SDimitry Andric size_type count(const key_type& k) const; 3610b57cec5SDimitry Andric bool contains(const key_type& x) const; // C++20 3620b57cec5SDimitry Andric iterator lower_bound(const key_type& k); 3630b57cec5SDimitry Andric const_iterator lower_bound(const key_type& k) const; 3640b57cec5SDimitry Andric template<typename K> 3650b57cec5SDimitry Andric iterator lower_bound(const K& x); // C++14 3660b57cec5SDimitry Andric template<typename K> 3670b57cec5SDimitry Andric const_iterator lower_bound(const K& x) const; // C++14 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric iterator upper_bound(const key_type& k); 3700b57cec5SDimitry Andric const_iterator upper_bound(const key_type& k) const; 3710b57cec5SDimitry Andric template<typename K> 3720b57cec5SDimitry Andric iterator upper_bound(const K& x); // C++14 3730b57cec5SDimitry Andric template<typename K> 3740b57cec5SDimitry Andric const_iterator upper_bound(const K& x) const; // C++14 3750b57cec5SDimitry Andric 3760b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& k); 3770b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& k) const; 3780b57cec5SDimitry Andric template<typename K> 3790b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const K& x); // C++14 3800b57cec5SDimitry Andric template<typename K> 3810b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 3820b57cec5SDimitry Andric}; 3830b57cec5SDimitry Andric 3840b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 3850b57cec5SDimitry Andricbool 3860b57cec5SDimitry Andricoperator==(const multiset<Key, Compare, Allocator>& x, 3870b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 3880b57cec5SDimitry Andric 3890b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 3900b57cec5SDimitry Andricbool 3910b57cec5SDimitry Andricoperator< (const multiset<Key, Compare, Allocator>& x, 3920b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 3930b57cec5SDimitry Andric 3940b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 3950b57cec5SDimitry Andricbool 3960b57cec5SDimitry Andricoperator!=(const multiset<Key, Compare, Allocator>& x, 3970b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 3980b57cec5SDimitry Andric 3990b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4000b57cec5SDimitry Andricbool 4010b57cec5SDimitry Andricoperator> (const multiset<Key, Compare, Allocator>& x, 4020b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 4030b57cec5SDimitry Andric 4040b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4050b57cec5SDimitry Andricbool 4060b57cec5SDimitry Andricoperator>=(const multiset<Key, Compare, Allocator>& x, 4070b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 4080b57cec5SDimitry Andric 4090b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4100b57cec5SDimitry Andricbool 4110b57cec5SDimitry Andricoperator<=(const multiset<Key, Compare, Allocator>& x, 4120b57cec5SDimitry Andric const multiset<Key, Compare, Allocator>& y); 4130b57cec5SDimitry Andric 4140b57cec5SDimitry Andric// specialized algorithms: 4150b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator> 4160b57cec5SDimitry Andricvoid 4170b57cec5SDimitry Andricswap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) 4180b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 4190b57cec5SDimitry Andric 4200b57cec5SDimitry Andrictemplate <class Key, class Compare, class Allocator, class Predicate> 421*5ffd83dbSDimitry Andrictypename multiset<Key, Compare, Allocator>::size_type 422*5ffd83dbSDimitry Andricerase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 4230b57cec5SDimitry Andric 4240b57cec5SDimitry Andric} // std 4250b57cec5SDimitry Andric 4260b57cec5SDimitry Andric*/ 4270b57cec5SDimitry Andric 4280b57cec5SDimitry Andric#include <__config> 4290b57cec5SDimitry Andric#include <__tree> 4300b57cec5SDimitry Andric#include <__node_handle> 4310b57cec5SDimitry Andric#include <functional> 4320b57cec5SDimitry Andric#include <version> 4330b57cec5SDimitry Andric 4340b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4350b57cec5SDimitry Andric#pragma GCC system_header 4360b57cec5SDimitry Andric#endif 4370b57cec5SDimitry Andric 4380b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 4390b57cec5SDimitry Andric 4400b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 4410b57cec5SDimitry Andricclass multiset; 4420b57cec5SDimitry Andric 4430b57cec5SDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, 4440b57cec5SDimitry Andric class _Allocator = allocator<_Key> > 4450b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS set 4460b57cec5SDimitry Andric{ 4470b57cec5SDimitry Andricpublic: 4480b57cec5SDimitry Andric // types: 4490b57cec5SDimitry Andric typedef _Key key_type; 4500b57cec5SDimitry Andric typedef key_type value_type; 4510b57cec5SDimitry Andric typedef _Compare key_compare; 4520b57cec5SDimitry Andric typedef key_compare value_compare; 4530b57cec5SDimitry Andric typedef typename __identity<_Allocator>::type allocator_type; 4540b57cec5SDimitry Andric typedef value_type& reference; 4550b57cec5SDimitry Andric typedef const value_type& const_reference; 4560b57cec5SDimitry Andric 4570b57cec5SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 4580b57cec5SDimitry Andric "Allocator::value_type must be same type as value_type"); 4590b57cec5SDimitry Andric 4600b57cec5SDimitry Andricprivate: 4610b57cec5SDimitry Andric typedef __tree<value_type, value_compare, allocator_type> __base; 4620b57cec5SDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 4630b57cec5SDimitry Andric typedef typename __base::__node_holder __node_holder; 4640b57cec5SDimitry Andric 4650b57cec5SDimitry Andric __base __tree_; 4660b57cec5SDimitry Andric 4670b57cec5SDimitry Andricpublic: 4680b57cec5SDimitry Andric typedef typename __base::pointer pointer; 4690b57cec5SDimitry Andric typedef typename __base::const_pointer const_pointer; 4700b57cec5SDimitry Andric typedef typename __base::size_type size_type; 4710b57cec5SDimitry Andric typedef typename __base::difference_type difference_type; 4720b57cec5SDimitry Andric typedef typename __base::const_iterator iterator; 4730b57cec5SDimitry Andric typedef typename __base::const_iterator const_iterator; 4740b57cec5SDimitry Andric typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 4750b57cec5SDimitry Andric typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 4760b57cec5SDimitry Andric 4770b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 4780b57cec5SDimitry Andric typedef __set_node_handle<typename __base::__node, allocator_type> node_type; 4790b57cec5SDimitry Andric typedef __insert_return_type<iterator, node_type> insert_return_type; 4800b57cec5SDimitry Andric#endif 4810b57cec5SDimitry Andric 4820b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 4830b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS set; 4840b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 4850b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multiset; 4860b57cec5SDimitry Andric 4870b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4880b57cec5SDimitry Andric set() 4890b57cec5SDimitry Andric _NOEXCEPT_( 4900b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 4910b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 4920b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 4930b57cec5SDimitry Andric : __tree_(value_compare()) {} 4940b57cec5SDimitry Andric 4950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4960b57cec5SDimitry Andric explicit set(const value_compare& __comp) 4970b57cec5SDimitry Andric _NOEXCEPT_( 4980b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 4990b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 5000b57cec5SDimitry Andric : __tree_(__comp) {} 5010b57cec5SDimitry Andric 5020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5030b57cec5SDimitry Andric explicit set(const value_compare& __comp, const allocator_type& __a) 5040b57cec5SDimitry Andric : __tree_(__comp, __a) {} 5050b57cec5SDimitry Andric template <class _InputIterator> 5060b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5070b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, 5080b57cec5SDimitry Andric const value_compare& __comp = value_compare()) 5090b57cec5SDimitry Andric : __tree_(__comp) 5100b57cec5SDimitry Andric { 5110b57cec5SDimitry Andric insert(__f, __l); 5120b57cec5SDimitry Andric } 5130b57cec5SDimitry Andric 5140b57cec5SDimitry Andric template <class _InputIterator> 5150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5160b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, 5170b57cec5SDimitry Andric const allocator_type& __a) 5180b57cec5SDimitry Andric : __tree_(__comp, __a) 5190b57cec5SDimitry Andric { 5200b57cec5SDimitry Andric insert(__f, __l); 5210b57cec5SDimitry Andric } 5220b57cec5SDimitry Andric 5230b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 5240b57cec5SDimitry Andric template <class _InputIterator> 5250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5260b57cec5SDimitry Andric set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 5270b57cec5SDimitry Andric : set(__f, __l, key_compare(), __a) {} 5280b57cec5SDimitry Andric#endif 5290b57cec5SDimitry Andric 5300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5310b57cec5SDimitry Andric set(const set& __s) 5320b57cec5SDimitry Andric : __tree_(__s.__tree_) 5330b57cec5SDimitry Andric { 5340b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 5350b57cec5SDimitry Andric } 5360b57cec5SDimitry Andric 5370b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5380b57cec5SDimitry Andric set& operator=(const set& __s) 5390b57cec5SDimitry Andric { 5400b57cec5SDimitry Andric __tree_ = __s.__tree_; 5410b57cec5SDimitry Andric return *this; 5420b57cec5SDimitry Andric } 5430b57cec5SDimitry Andric 5440b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5460b57cec5SDimitry Andric set(set&& __s) 5470b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 5480b57cec5SDimitry Andric : __tree_(_VSTD::move(__s.__tree_)) {} 5490b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5500b57cec5SDimitry Andric 5510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5520b57cec5SDimitry Andric explicit set(const allocator_type& __a) 5530b57cec5SDimitry Andric : __tree_(__a) {} 5540b57cec5SDimitry Andric 5550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5560b57cec5SDimitry Andric set(const set& __s, const allocator_type& __a) 5570b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), __a) 5580b57cec5SDimitry Andric { 5590b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 5600b57cec5SDimitry Andric } 5610b57cec5SDimitry Andric 5620b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5630b57cec5SDimitry Andric set(set&& __s, const allocator_type& __a); 5640b57cec5SDimitry Andric 5650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5660b57cec5SDimitry Andric set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) 5670b57cec5SDimitry Andric : __tree_(__comp) 5680b57cec5SDimitry Andric { 5690b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 5700b57cec5SDimitry Andric } 5710b57cec5SDimitry Andric 5720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5730b57cec5SDimitry Andric set(initializer_list<value_type> __il, const value_compare& __comp, 5740b57cec5SDimitry Andric const allocator_type& __a) 5750b57cec5SDimitry Andric : __tree_(__comp, __a) 5760b57cec5SDimitry Andric { 5770b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 5780b57cec5SDimitry Andric } 5790b57cec5SDimitry Andric 5800b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 5810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5820b57cec5SDimitry Andric set(initializer_list<value_type> __il, const allocator_type& __a) 5830b57cec5SDimitry Andric : set(__il, key_compare(), __a) {} 5840b57cec5SDimitry Andric#endif 5850b57cec5SDimitry Andric 5860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5870b57cec5SDimitry Andric set& operator=(initializer_list<value_type> __il) 5880b57cec5SDimitry Andric { 5890b57cec5SDimitry Andric __tree_.__assign_unique(__il.begin(), __il.end()); 5900b57cec5SDimitry Andric return *this; 5910b57cec5SDimitry Andric } 5920b57cec5SDimitry Andric 5930b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5940b57cec5SDimitry Andric set& operator=(set&& __s) 5950b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 5960b57cec5SDimitry Andric { 5970b57cec5SDimitry Andric __tree_ = _VSTD::move(__s.__tree_); 5980b57cec5SDimitry Andric return *this; 5990b57cec5SDimitry Andric } 6000b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6010b57cec5SDimitry Andric 6020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6030b57cec5SDimitry Andric ~set() { 6040b57cec5SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 6050b57cec5SDimitry Andric } 6060b57cec5SDimitry Andric 6070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6080b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __tree_.begin();} 6090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6100b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 6110b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6120b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __tree_.end();} 6130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6140b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __tree_.end();} 6150b57cec5SDimitry Andric 6160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6170b57cec5SDimitry Andric reverse_iterator rbegin() _NOEXCEPT 6180b57cec5SDimitry Andric {return reverse_iterator(end());} 6190b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6200b57cec5SDimitry Andric const_reverse_iterator rbegin() const _NOEXCEPT 6210b57cec5SDimitry Andric {return const_reverse_iterator(end());} 6220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6230b57cec5SDimitry Andric reverse_iterator rend() _NOEXCEPT 6240b57cec5SDimitry Andric {return reverse_iterator(begin());} 6250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6260b57cec5SDimitry Andric const_reverse_iterator rend() const _NOEXCEPT 6270b57cec5SDimitry Andric {return const_reverse_iterator(begin());} 6280b57cec5SDimitry Andric 6290b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6300b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return begin();} 6310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6320b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return end();} 6330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6340b57cec5SDimitry Andric const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 6350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6360b57cec5SDimitry Andric const_reverse_iterator crend() const _NOEXCEPT {return rend();} 6370b57cec5SDimitry Andric 6380b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6390b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 6400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6410b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __tree_.size();} 6420b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6430b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 6440b57cec5SDimitry Andric 6450b57cec5SDimitry Andric // modifiers: 6460b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6470b57cec5SDimitry Andric template <class... _Args> 6480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6490b57cec5SDimitry Andric pair<iterator, bool> emplace(_Args&&... __args) 6500b57cec5SDimitry Andric {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} 6510b57cec5SDimitry Andric template <class... _Args> 6520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6530b57cec5SDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) 6540b57cec5SDimitry Andric {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} 6550b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6560b57cec5SDimitry Andric 6570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6580b57cec5SDimitry Andric pair<iterator,bool> insert(const value_type& __v) 6590b57cec5SDimitry Andric {return __tree_.__insert_unique(__v);} 6600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6610b57cec5SDimitry Andric iterator insert(const_iterator __p, const value_type& __v) 6620b57cec5SDimitry Andric {return __tree_.__insert_unique(__p, __v);} 6630b57cec5SDimitry Andric 6640b57cec5SDimitry Andric template <class _InputIterator> 6650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6660b57cec5SDimitry Andric void insert(_InputIterator __f, _InputIterator __l) 6670b57cec5SDimitry Andric { 6680b57cec5SDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 6690b57cec5SDimitry Andric __tree_.__insert_unique(__e, *__f); 6700b57cec5SDimitry Andric } 6710b57cec5SDimitry Andric 6720b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6740b57cec5SDimitry Andric pair<iterator,bool> insert(value_type&& __v) 6750b57cec5SDimitry Andric {return __tree_.__insert_unique(_VSTD::move(__v));} 6760b57cec5SDimitry Andric 6770b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6780b57cec5SDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 6790b57cec5SDimitry Andric {return __tree_.__insert_unique(__p, _VSTD::move(__v));} 6800b57cec5SDimitry Andric 6810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6820b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 6830b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 6840b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6850b57cec5SDimitry Andric 6860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6870b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __tree_.erase(__p);} 6880b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6890b57cec5SDimitry Andric size_type erase(const key_type& __k) 6900b57cec5SDimitry Andric {return __tree_.__erase_unique(__k);} 6910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6920b57cec5SDimitry Andric iterator erase(const_iterator __f, const_iterator __l) 6930b57cec5SDimitry Andric {return __tree_.erase(__f, __l);} 6940b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6950b57cec5SDimitry Andric void clear() _NOEXCEPT {__tree_.clear();} 6960b57cec5SDimitry Andric 6970b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 6980b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6990b57cec5SDimitry Andric insert_return_type insert(node_type&& __nh) 7000b57cec5SDimitry Andric { 7010b57cec5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 7020b57cec5SDimitry Andric "node_type with incompatible allocator passed to set::insert()"); 7030b57cec5SDimitry Andric return __tree_.template __node_handle_insert_unique< 7040b57cec5SDimitry Andric node_type, insert_return_type>(_VSTD::move(__nh)); 7050b57cec5SDimitry Andric } 7060b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7070b57cec5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 7080b57cec5SDimitry Andric { 7090b57cec5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 7100b57cec5SDimitry Andric "node_type with incompatible allocator passed to set::insert()"); 7110b57cec5SDimitry Andric return __tree_.template __node_handle_insert_unique<node_type>( 7120b57cec5SDimitry Andric __hint, _VSTD::move(__nh)); 7130b57cec5SDimitry Andric } 7140b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7150b57cec5SDimitry Andric node_type extract(key_type const& __key) 7160b57cec5SDimitry Andric { 7170b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 7180b57cec5SDimitry Andric } 7190b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7200b57cec5SDimitry Andric node_type extract(const_iterator __it) 7210b57cec5SDimitry Andric { 7220b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__it); 7230b57cec5SDimitry Andric } 7240b57cec5SDimitry Andric template <class _Compare2> 7250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7260b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>& __source) 7270b57cec5SDimitry Andric { 7280b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 7290b57cec5SDimitry Andric "merging container with incompatible allocator"); 7300b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 7310b57cec5SDimitry Andric } 7320b57cec5SDimitry Andric template <class _Compare2> 7330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7340b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>&& __source) 7350b57cec5SDimitry Andric { 7360b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 7370b57cec5SDimitry Andric "merging container with incompatible allocator"); 7380b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 7390b57cec5SDimitry Andric } 7400b57cec5SDimitry Andric template <class _Compare2> 7410b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7420b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>& __source) 7430b57cec5SDimitry Andric { 7440b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 7450b57cec5SDimitry Andric "merging container with incompatible allocator"); 7460b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 7470b57cec5SDimitry Andric } 7480b57cec5SDimitry Andric template <class _Compare2> 7490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7500b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>&& __source) 7510b57cec5SDimitry Andric { 7520b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 7530b57cec5SDimitry Andric "merging container with incompatible allocator"); 7540b57cec5SDimitry Andric __tree_.__node_handle_merge_unique(__source.__tree_); 7550b57cec5SDimitry Andric } 7560b57cec5SDimitry Andric#endif 7570b57cec5SDimitry Andric 7580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7590b57cec5SDimitry Andric void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 7600b57cec5SDimitry Andric {__tree_.swap(__s.__tree_);} 7610b57cec5SDimitry Andric 7620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7630b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 7640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7650b57cec5SDimitry Andric key_compare key_comp() const {return __tree_.value_comp();} 7660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7670b57cec5SDimitry Andric value_compare value_comp() const {return __tree_.value_comp();} 7680b57cec5SDimitry Andric 7690b57cec5SDimitry Andric // set operations: 7700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7710b57cec5SDimitry Andric iterator find(const key_type& __k) {return __tree_.find(__k);} 7720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7730b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 7740b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 7750b57cec5SDimitry Andric template <typename _K2> 7760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7770b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 7780b57cec5SDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 7790b57cec5SDimitry Andric template <typename _K2> 7800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7810b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 7820b57cec5SDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 7830b57cec5SDimitry Andric#endif 7840b57cec5SDimitry Andric 7850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7860b57cec5SDimitry Andric size_type count(const key_type& __k) const 7870b57cec5SDimitry Andric {return __tree_.__count_unique(__k);} 7880b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 7890b57cec5SDimitry Andric template <typename _K2> 7900b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7910b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 7920b57cec5SDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 7930b57cec5SDimitry Andric#endif 7940b57cec5SDimitry Andric 7950b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 7960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7970b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 7980b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17 7990b57cec5SDimitry Andric 8000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8010b57cec5SDimitry Andric iterator lower_bound(const key_type& __k) 8020b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 8030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8040b57cec5SDimitry Andric const_iterator lower_bound(const key_type& __k) const 8050b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 8060b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 8070b57cec5SDimitry Andric template <typename _K2> 8080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8090b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 8100b57cec5SDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 8110b57cec5SDimitry Andric 8120b57cec5SDimitry Andric template <typename _K2> 8130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8140b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 8150b57cec5SDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 8160b57cec5SDimitry Andric#endif 8170b57cec5SDimitry Andric 8180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8190b57cec5SDimitry Andric iterator upper_bound(const key_type& __k) 8200b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 8210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8220b57cec5SDimitry Andric const_iterator upper_bound(const key_type& __k) const 8230b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 8240b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 8250b57cec5SDimitry Andric template <typename _K2> 8260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8270b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type 8280b57cec5SDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 8290b57cec5SDimitry Andric template <typename _K2> 8300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8310b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type 8320b57cec5SDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 8330b57cec5SDimitry Andric#endif 8340b57cec5SDimitry Andric 8350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8360b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& __k) 8370b57cec5SDimitry Andric {return __tree_.__equal_range_unique(__k);} 8380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8390b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 8400b57cec5SDimitry Andric {return __tree_.__equal_range_unique(__k);} 8410b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 8420b57cec5SDimitry Andric template <typename _K2> 8430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8440b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 8450b57cec5SDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 8460b57cec5SDimitry Andric template <typename _K2> 8470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8480b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 8490b57cec5SDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 8500b57cec5SDimitry Andric#endif 8510b57cec5SDimitry Andric}; 8520b57cec5SDimitry Andric 8530b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 8540b57cec5SDimitry Andrictemplate<class _InputIterator, 8550b57cec5SDimitry Andric class _Compare = less<typename iterator_traits<_InputIterator>::value_type>, 8560b57cec5SDimitry Andric class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>, 857e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>, 858e40139ffSDimitry Andric class = _EnableIf<!__is_allocator<_Compare>::value, void>> 8590b57cec5SDimitry Andricset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) 8600b57cec5SDimitry Andric -> set<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>; 8610b57cec5SDimitry Andric 8620b57cec5SDimitry Andrictemplate<class _Key, class _Compare = less<_Key>, 8630b57cec5SDimitry Andric class _Allocator = allocator<_Key>, 864e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>, 865e40139ffSDimitry Andric class = _EnableIf<!__is_allocator<_Compare>::value, void>> 8660b57cec5SDimitry Andricset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) 8670b57cec5SDimitry Andric -> set<_Key, _Compare, _Allocator>; 8680b57cec5SDimitry Andric 8690b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 870e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>> 8710b57cec5SDimitry Andricset(_InputIterator, _InputIterator, _Allocator) 8720b57cec5SDimitry Andric -> set<typename iterator_traits<_InputIterator>::value_type, 8730b57cec5SDimitry Andric less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>; 8740b57cec5SDimitry Andric 8750b57cec5SDimitry Andrictemplate<class _Key, class _Allocator, 876e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>> 8770b57cec5SDimitry Andricset(initializer_list<_Key>, _Allocator) 8780b57cec5SDimitry Andric -> set<_Key, less<_Key>, _Allocator>; 8790b57cec5SDimitry Andric#endif 8800b57cec5SDimitry Andric 8810b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8820b57cec5SDimitry Andric 8830b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 8840b57cec5SDimitry Andricset<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) 8850b57cec5SDimitry Andric : __tree_(_VSTD::move(__s.__tree_), __a) 8860b57cec5SDimitry Andric{ 8870b57cec5SDimitry Andric if (__a != __s.get_allocator()) 8880b57cec5SDimitry Andric { 8890b57cec5SDimitry Andric const_iterator __e = cend(); 8900b57cec5SDimitry Andric while (!__s.empty()) 8910b57cec5SDimitry Andric insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); 8920b57cec5SDimitry Andric } 8930b57cec5SDimitry Andric} 8940b57cec5SDimitry Andric 8950b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8960b57cec5SDimitry Andric 8970b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 8980b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8990b57cec5SDimitry Andricbool 9000b57cec5SDimitry Andricoperator==(const set<_Key, _Compare, _Allocator>& __x, 9010b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9020b57cec5SDimitry Andric{ 9030b57cec5SDimitry Andric return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 9040b57cec5SDimitry Andric} 9050b57cec5SDimitry Andric 9060b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9070b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9080b57cec5SDimitry Andricbool 9090b57cec5SDimitry Andricoperator< (const set<_Key, _Compare, _Allocator>& __x, 9100b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9110b57cec5SDimitry Andric{ 9120b57cec5SDimitry Andric return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 9130b57cec5SDimitry Andric} 9140b57cec5SDimitry Andric 9150b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9160b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9170b57cec5SDimitry Andricbool 9180b57cec5SDimitry Andricoperator!=(const set<_Key, _Compare, _Allocator>& __x, 9190b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9200b57cec5SDimitry Andric{ 9210b57cec5SDimitry Andric return !(__x == __y); 9220b57cec5SDimitry Andric} 9230b57cec5SDimitry Andric 9240b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9250b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9260b57cec5SDimitry Andricbool 9270b57cec5SDimitry Andricoperator> (const set<_Key, _Compare, _Allocator>& __x, 9280b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9290b57cec5SDimitry Andric{ 9300b57cec5SDimitry Andric return __y < __x; 9310b57cec5SDimitry Andric} 9320b57cec5SDimitry Andric 9330b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9340b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9350b57cec5SDimitry Andricbool 9360b57cec5SDimitry Andricoperator>=(const set<_Key, _Compare, _Allocator>& __x, 9370b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9380b57cec5SDimitry Andric{ 9390b57cec5SDimitry Andric return !(__x < __y); 9400b57cec5SDimitry Andric} 9410b57cec5SDimitry Andric 9420b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9430b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9440b57cec5SDimitry Andricbool 9450b57cec5SDimitry Andricoperator<=(const set<_Key, _Compare, _Allocator>& __x, 9460b57cec5SDimitry Andric const set<_Key, _Compare, _Allocator>& __y) 9470b57cec5SDimitry Andric{ 9480b57cec5SDimitry Andric return !(__y < __x); 9490b57cec5SDimitry Andric} 9500b57cec5SDimitry Andric 9510b57cec5SDimitry Andric// specialized algorithms: 9520b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 9530b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 9540b57cec5SDimitry Andricvoid 9550b57cec5SDimitry Andricswap(set<_Key, _Compare, _Allocator>& __x, 9560b57cec5SDimitry Andric set<_Key, _Compare, _Allocator>& __y) 9570b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9580b57cec5SDimitry Andric{ 9590b57cec5SDimitry Andric __x.swap(__y); 9600b57cec5SDimitry Andric} 9610b57cec5SDimitry Andric 9620b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 9630b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator, class _Predicate> 9640b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 965*5ffd83dbSDimitry Andric typename set<_Key, _Compare, _Allocator>::size_type 966*5ffd83dbSDimitry Andric erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { 967*5ffd83dbSDimitry Andric return __libcpp_erase_if_container(__c, __pred); 968*5ffd83dbSDimitry Andric} 9690b57cec5SDimitry Andric#endif 9700b57cec5SDimitry Andric 9710b57cec5SDimitry Andrictemplate <class _Key, class _Compare = less<_Key>, 9720b57cec5SDimitry Andric class _Allocator = allocator<_Key> > 9730b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS multiset 9740b57cec5SDimitry Andric{ 9750b57cec5SDimitry Andricpublic: 9760b57cec5SDimitry Andric // types: 9770b57cec5SDimitry Andric typedef _Key key_type; 9780b57cec5SDimitry Andric typedef key_type value_type; 9790b57cec5SDimitry Andric typedef _Compare key_compare; 9800b57cec5SDimitry Andric typedef key_compare value_compare; 9810b57cec5SDimitry Andric typedef typename __identity<_Allocator>::type allocator_type; 9820b57cec5SDimitry Andric typedef value_type& reference; 9830b57cec5SDimitry Andric typedef const value_type& const_reference; 9840b57cec5SDimitry Andric 9850b57cec5SDimitry Andric static_assert((is_same<typename allocator_type::value_type, value_type>::value), 9860b57cec5SDimitry Andric "Allocator::value_type must be same type as value_type"); 9870b57cec5SDimitry Andric 9880b57cec5SDimitry Andricprivate: 9890b57cec5SDimitry Andric typedef __tree<value_type, value_compare, allocator_type> __base; 9900b57cec5SDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 9910b57cec5SDimitry Andric typedef typename __base::__node_holder __node_holder; 9920b57cec5SDimitry Andric 9930b57cec5SDimitry Andric __base __tree_; 9940b57cec5SDimitry Andric 9950b57cec5SDimitry Andricpublic: 9960b57cec5SDimitry Andric typedef typename __base::pointer pointer; 9970b57cec5SDimitry Andric typedef typename __base::const_pointer const_pointer; 9980b57cec5SDimitry Andric typedef typename __base::size_type size_type; 9990b57cec5SDimitry Andric typedef typename __base::difference_type difference_type; 10000b57cec5SDimitry Andric typedef typename __base::const_iterator iterator; 10010b57cec5SDimitry Andric typedef typename __base::const_iterator const_iterator; 10020b57cec5SDimitry Andric typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 10030b57cec5SDimitry Andric typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 10040b57cec5SDimitry Andric 10050b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 10060b57cec5SDimitry Andric typedef __set_node_handle<typename __base::__node, allocator_type> node_type; 10070b57cec5SDimitry Andric#endif 10080b57cec5SDimitry Andric 10090b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 10100b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS set; 10110b57cec5SDimitry Andric template <class _Key2, class _Compare2, class _Alloc2> 10120b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS multiset; 10130b57cec5SDimitry Andric 10140b57cec5SDimitry Andric // construct/copy/destroy: 10150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10160b57cec5SDimitry Andric multiset() 10170b57cec5SDimitry Andric _NOEXCEPT_( 10180b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 10190b57cec5SDimitry Andric is_nothrow_default_constructible<key_compare>::value && 10200b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 10210b57cec5SDimitry Andric : __tree_(value_compare()) {} 10220b57cec5SDimitry Andric 10230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10240b57cec5SDimitry Andric explicit multiset(const value_compare& __comp) 10250b57cec5SDimitry Andric _NOEXCEPT_( 10260b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value && 10270b57cec5SDimitry Andric is_nothrow_copy_constructible<key_compare>::value) 10280b57cec5SDimitry Andric : __tree_(__comp) {} 10290b57cec5SDimitry Andric 10300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10310b57cec5SDimitry Andric explicit multiset(const value_compare& __comp, const allocator_type& __a) 10320b57cec5SDimitry Andric : __tree_(__comp, __a) {} 10330b57cec5SDimitry Andric template <class _InputIterator> 10340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10350b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, 10360b57cec5SDimitry Andric const value_compare& __comp = value_compare()) 10370b57cec5SDimitry Andric : __tree_(__comp) 10380b57cec5SDimitry Andric { 10390b57cec5SDimitry Andric insert(__f, __l); 10400b57cec5SDimitry Andric } 10410b57cec5SDimitry Andric 10420b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 10430b57cec5SDimitry Andric template <class _InputIterator> 10440b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10450b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) 10460b57cec5SDimitry Andric : multiset(__f, __l, key_compare(), __a) {} 10470b57cec5SDimitry Andric#endif 10480b57cec5SDimitry Andric 10490b57cec5SDimitry Andric template <class _InputIterator> 10500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10510b57cec5SDimitry Andric multiset(_InputIterator __f, _InputIterator __l, 10520b57cec5SDimitry Andric const value_compare& __comp, const allocator_type& __a) 10530b57cec5SDimitry Andric : __tree_(__comp, __a) 10540b57cec5SDimitry Andric { 10550b57cec5SDimitry Andric insert(__f, __l); 10560b57cec5SDimitry Andric } 10570b57cec5SDimitry Andric 10580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10590b57cec5SDimitry Andric multiset(const multiset& __s) 10600b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), 10610b57cec5SDimitry Andric __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) 10620b57cec5SDimitry Andric { 10630b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 10640b57cec5SDimitry Andric } 10650b57cec5SDimitry Andric 10660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10670b57cec5SDimitry Andric multiset& operator=(const multiset& __s) 10680b57cec5SDimitry Andric { 10690b57cec5SDimitry Andric __tree_ = __s.__tree_; 10700b57cec5SDimitry Andric return *this; 10710b57cec5SDimitry Andric } 10720b57cec5SDimitry Andric 10730b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10750b57cec5SDimitry Andric multiset(multiset&& __s) 10760b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) 10770b57cec5SDimitry Andric : __tree_(_VSTD::move(__s.__tree_)) {} 10780b57cec5SDimitry Andric 10790b57cec5SDimitry Andric multiset(multiset&& __s, const allocator_type& __a); 10800b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 10810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10820b57cec5SDimitry Andric explicit multiset(const allocator_type& __a) 10830b57cec5SDimitry Andric : __tree_(__a) {} 10840b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10850b57cec5SDimitry Andric multiset(const multiset& __s, const allocator_type& __a) 10860b57cec5SDimitry Andric : __tree_(__s.__tree_.value_comp(), __a) 10870b57cec5SDimitry Andric { 10880b57cec5SDimitry Andric insert(__s.begin(), __s.end()); 10890b57cec5SDimitry Andric } 10900b57cec5SDimitry Andric 10910b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10920b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10930b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) 10940b57cec5SDimitry Andric : __tree_(__comp) 10950b57cec5SDimitry Andric { 10960b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 10970b57cec5SDimitry Andric } 10980b57cec5SDimitry Andric 10990b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11000b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const value_compare& __comp, 11010b57cec5SDimitry Andric const allocator_type& __a) 11020b57cec5SDimitry Andric : __tree_(__comp, __a) 11030b57cec5SDimitry Andric { 11040b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 11050b57cec5SDimitry Andric } 11060b57cec5SDimitry Andric 11070b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 11080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11090b57cec5SDimitry Andric multiset(initializer_list<value_type> __il, const allocator_type& __a) 11100b57cec5SDimitry Andric : multiset(__il, key_compare(), __a) {} 11110b57cec5SDimitry Andric#endif 11120b57cec5SDimitry Andric 11130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11140b57cec5SDimitry Andric multiset& operator=(initializer_list<value_type> __il) 11150b57cec5SDimitry Andric { 11160b57cec5SDimitry Andric __tree_.__assign_multi(__il.begin(), __il.end()); 11170b57cec5SDimitry Andric return *this; 11180b57cec5SDimitry Andric } 11190b57cec5SDimitry Andric 11200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11210b57cec5SDimitry Andric multiset& operator=(multiset&& __s) 11220b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) 11230b57cec5SDimitry Andric { 11240b57cec5SDimitry Andric __tree_ = _VSTD::move(__s.__tree_); 11250b57cec5SDimitry Andric return *this; 11260b57cec5SDimitry Andric } 11270b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 11280b57cec5SDimitry Andric 11290b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11300b57cec5SDimitry Andric ~multiset() { 11310b57cec5SDimitry Andric static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); 11320b57cec5SDimitry Andric } 11330b57cec5SDimitry Andric 11340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11350b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __tree_.begin();} 11360b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11370b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __tree_.begin();} 11380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11390b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __tree_.end();} 11400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11410b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __tree_.end();} 11420b57cec5SDimitry Andric 11430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11440b57cec5SDimitry Andric reverse_iterator rbegin() _NOEXCEPT 11450b57cec5SDimitry Andric {return reverse_iterator(end());} 11460b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11470b57cec5SDimitry Andric const_reverse_iterator rbegin() const _NOEXCEPT 11480b57cec5SDimitry Andric {return const_reverse_iterator(end());} 11490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11500b57cec5SDimitry Andric reverse_iterator rend() _NOEXCEPT 11510b57cec5SDimitry Andric {return reverse_iterator(begin());} 11520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11530b57cec5SDimitry Andric const_reverse_iterator rend() const _NOEXCEPT 11540b57cec5SDimitry Andric {return const_reverse_iterator(begin());} 11550b57cec5SDimitry Andric 11560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11570b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return begin();} 11580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11590b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return end();} 11600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11610b57cec5SDimitry Andric const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 11620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11630b57cec5SDimitry Andric const_reverse_iterator crend() const _NOEXCEPT {return rend();} 11640b57cec5SDimitry Andric 11650b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 11660b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __tree_.size() == 0;} 11670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11680b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __tree_.size();} 11690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11700b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __tree_.max_size();} 11710b57cec5SDimitry Andric 11720b57cec5SDimitry Andric // modifiers: 11730b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11740b57cec5SDimitry Andric template <class... _Args> 11750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11760b57cec5SDimitry Andric iterator emplace(_Args&&... __args) 11770b57cec5SDimitry Andric {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} 11780b57cec5SDimitry Andric template <class... _Args> 11790b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11800b57cec5SDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) 11810b57cec5SDimitry Andric {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} 11820b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 11830b57cec5SDimitry Andric 11840b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11850b57cec5SDimitry Andric iterator insert(const value_type& __v) 11860b57cec5SDimitry Andric {return __tree_.__insert_multi(__v);} 11870b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11880b57cec5SDimitry Andric iterator insert(const_iterator __p, const value_type& __v) 11890b57cec5SDimitry Andric {return __tree_.__insert_multi(__p, __v);} 11900b57cec5SDimitry Andric 11910b57cec5SDimitry Andric template <class _InputIterator> 11920b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11930b57cec5SDimitry Andric void insert(_InputIterator __f, _InputIterator __l) 11940b57cec5SDimitry Andric { 11950b57cec5SDimitry Andric for (const_iterator __e = cend(); __f != __l; ++__f) 11960b57cec5SDimitry Andric __tree_.__insert_multi(__e, *__f); 11970b57cec5SDimitry Andric } 11980b57cec5SDimitry Andric 11990b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 12000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12010b57cec5SDimitry Andric iterator insert(value_type&& __v) 12020b57cec5SDimitry Andric {return __tree_.__insert_multi(_VSTD::move(__v));} 12030b57cec5SDimitry Andric 12040b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12050b57cec5SDimitry Andric iterator insert(const_iterator __p, value_type&& __v) 12060b57cec5SDimitry Andric {return __tree_.__insert_multi(__p, _VSTD::move(__v));} 12070b57cec5SDimitry Andric 12080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12090b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 12100b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 12110b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 12120b57cec5SDimitry Andric 12130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12140b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __tree_.erase(__p);} 12150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12160b57cec5SDimitry Andric size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} 12170b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12180b57cec5SDimitry Andric iterator erase(const_iterator __f, const_iterator __l) 12190b57cec5SDimitry Andric {return __tree_.erase(__f, __l);} 12200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12210b57cec5SDimitry Andric void clear() _NOEXCEPT {__tree_.clear();} 12220b57cec5SDimitry Andric 12230b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 12240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12250b57cec5SDimitry Andric iterator insert(node_type&& __nh) 12260b57cec5SDimitry Andric { 12270b57cec5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 12280b57cec5SDimitry Andric "node_type with incompatible allocator passed to multiset::insert()"); 12290b57cec5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 12300b57cec5SDimitry Andric _VSTD::move(__nh)); 12310b57cec5SDimitry Andric } 12320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12330b57cec5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 12340b57cec5SDimitry Andric { 12350b57cec5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 12360b57cec5SDimitry Andric "node_type with incompatible allocator passed to multiset::insert()"); 12370b57cec5SDimitry Andric return __tree_.template __node_handle_insert_multi<node_type>( 12380b57cec5SDimitry Andric __hint, _VSTD::move(__nh)); 12390b57cec5SDimitry Andric } 12400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12410b57cec5SDimitry Andric node_type extract(key_type const& __key) 12420b57cec5SDimitry Andric { 12430b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__key); 12440b57cec5SDimitry Andric } 12450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12460b57cec5SDimitry Andric node_type extract(const_iterator __it) 12470b57cec5SDimitry Andric { 12480b57cec5SDimitry Andric return __tree_.template __node_handle_extract<node_type>(__it); 12490b57cec5SDimitry Andric } 12500b57cec5SDimitry Andric template <class _Compare2> 12510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12520b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>& __source) 12530b57cec5SDimitry Andric { 12540b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 12550b57cec5SDimitry Andric "merging container with incompatible allocator"); 12560b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 12570b57cec5SDimitry Andric } 12580b57cec5SDimitry Andric template <class _Compare2> 12590b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12600b57cec5SDimitry Andric void merge(multiset<key_type, _Compare2, allocator_type>&& __source) 12610b57cec5SDimitry Andric { 12620b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 12630b57cec5SDimitry Andric "merging container with incompatible allocator"); 12640b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 12650b57cec5SDimitry Andric } 12660b57cec5SDimitry Andric template <class _Compare2> 12670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12680b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>& __source) 12690b57cec5SDimitry Andric { 12700b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 12710b57cec5SDimitry Andric "merging container with incompatible allocator"); 12720b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 12730b57cec5SDimitry Andric } 12740b57cec5SDimitry Andric template <class _Compare2> 12750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12760b57cec5SDimitry Andric void merge(set<key_type, _Compare2, allocator_type>&& __source) 12770b57cec5SDimitry Andric { 12780b57cec5SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 12790b57cec5SDimitry Andric "merging container with incompatible allocator"); 12800b57cec5SDimitry Andric __tree_.__node_handle_merge_multi(__source.__tree_); 12810b57cec5SDimitry Andric } 12820b57cec5SDimitry Andric#endif 12830b57cec5SDimitry Andric 12840b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12850b57cec5SDimitry Andric void swap(multiset& __s) 12860b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<__base>::value) 12870b57cec5SDimitry Andric {__tree_.swap(__s.__tree_);} 12880b57cec5SDimitry Andric 12890b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12900b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} 12910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12920b57cec5SDimitry Andric key_compare key_comp() const {return __tree_.value_comp();} 12930b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12940b57cec5SDimitry Andric value_compare value_comp() const {return __tree_.value_comp();} 12950b57cec5SDimitry Andric 12960b57cec5SDimitry Andric // set operations: 12970b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12980b57cec5SDimitry Andric iterator find(const key_type& __k) {return __tree_.find(__k);} 12990b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13000b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __tree_.find(__k);} 13010b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 13020b57cec5SDimitry Andric template <typename _K2> 13030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13040b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type 13050b57cec5SDimitry Andric find(const _K2& __k) {return __tree_.find(__k);} 13060b57cec5SDimitry Andric template <typename _K2> 13070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13080b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type 13090b57cec5SDimitry Andric find(const _K2& __k) const {return __tree_.find(__k);} 13100b57cec5SDimitry Andric#endif 13110b57cec5SDimitry Andric 13120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13130b57cec5SDimitry Andric size_type count(const key_type& __k) const 13140b57cec5SDimitry Andric {return __tree_.__count_multi(__k);} 13150b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 13160b57cec5SDimitry Andric template <typename _K2> 13170b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13180b57cec5SDimitry Andric typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type 13190b57cec5SDimitry Andric count(const _K2& __k) const {return __tree_.__count_multi(__k);} 13200b57cec5SDimitry Andric#endif 13210b57cec5SDimitry Andric 13220b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 13230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13240b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 13250b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17 13260b57cec5SDimitry Andric 13270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13280b57cec5SDimitry Andric iterator lower_bound(const key_type& __k) 13290b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 13300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13310b57cec5SDimitry Andric const_iterator lower_bound(const key_type& __k) const 13320b57cec5SDimitry Andric {return __tree_.lower_bound(__k);} 13330b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 13340b57cec5SDimitry Andric template <typename _K2> 13350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13360b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type 13370b57cec5SDimitry Andric lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} 13380b57cec5SDimitry Andric 13390b57cec5SDimitry Andric template <typename _K2> 13400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13410b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type 13420b57cec5SDimitry Andric lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} 13430b57cec5SDimitry Andric#endif 13440b57cec5SDimitry Andric 13450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13460b57cec5SDimitry Andric iterator upper_bound(const key_type& __k) 13470b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 13480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13490b57cec5SDimitry Andric const_iterator upper_bound(const key_type& __k) const 13500b57cec5SDimitry Andric {return __tree_.upper_bound(__k);} 13510b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 13520b57cec5SDimitry Andric template <typename _K2> 13530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13540b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type 13550b57cec5SDimitry Andric upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} 13560b57cec5SDimitry Andric template <typename _K2> 13570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13580b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type 13590b57cec5SDimitry Andric upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} 13600b57cec5SDimitry Andric#endif 13610b57cec5SDimitry Andric 13620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13630b57cec5SDimitry Andric pair<iterator,iterator> equal_range(const key_type& __k) 13640b57cec5SDimitry Andric {return __tree_.__equal_range_multi(__k);} 13650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13660b57cec5SDimitry Andric pair<const_iterator,const_iterator> equal_range(const key_type& __k) const 13670b57cec5SDimitry Andric {return __tree_.__equal_range_multi(__k);} 13680b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 13690b57cec5SDimitry Andric template <typename _K2> 13700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13710b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type 13720b57cec5SDimitry Andric equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} 13730b57cec5SDimitry Andric template <typename _K2> 13740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13750b57cec5SDimitry Andric typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type 13760b57cec5SDimitry Andric equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} 13770b57cec5SDimitry Andric#endif 13780b57cec5SDimitry Andric}; 13790b57cec5SDimitry Andric 13800b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 13810b57cec5SDimitry Andrictemplate<class _InputIterator, 13820b57cec5SDimitry Andric class _Compare = less<typename iterator_traits<_InputIterator>::value_type>, 13830b57cec5SDimitry Andric class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>, 1384e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>, 1385e40139ffSDimitry Andric class = _EnableIf<!__is_allocator<_Compare>::value, void>> 13860b57cec5SDimitry Andricmultiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) 13870b57cec5SDimitry Andric -> multiset<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>; 13880b57cec5SDimitry Andric 13890b57cec5SDimitry Andrictemplate<class _Key, class _Compare = less<_Key>, 13900b57cec5SDimitry Andric class _Allocator = allocator<_Key>, 1391e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>, 1392e40139ffSDimitry Andric class = _EnableIf<!__is_allocator<_Compare>::value, void>> 13930b57cec5SDimitry Andricmultiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) 13940b57cec5SDimitry Andric -> multiset<_Key, _Compare, _Allocator>; 13950b57cec5SDimitry Andric 13960b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 1397e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>> 13980b57cec5SDimitry Andricmultiset(_InputIterator, _InputIterator, _Allocator) 13990b57cec5SDimitry Andric -> multiset<typename iterator_traits<_InputIterator>::value_type, 14000b57cec5SDimitry Andric less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>; 14010b57cec5SDimitry Andric 14020b57cec5SDimitry Andrictemplate<class _Key, class _Allocator, 1403e40139ffSDimitry Andric class = _EnableIf<__is_allocator<_Allocator>::value, void>> 14040b57cec5SDimitry Andricmultiset(initializer_list<_Key>, _Allocator) 14050b57cec5SDimitry Andric -> multiset<_Key, less<_Key>, _Allocator>; 14060b57cec5SDimitry Andric#endif 14070b57cec5SDimitry Andric 14080b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14090b57cec5SDimitry Andric 14100b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14110b57cec5SDimitry Andricmultiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) 14120b57cec5SDimitry Andric : __tree_(_VSTD::move(__s.__tree_), __a) 14130b57cec5SDimitry Andric{ 14140b57cec5SDimitry Andric if (__a != __s.get_allocator()) 14150b57cec5SDimitry Andric { 14160b57cec5SDimitry Andric const_iterator __e = cend(); 14170b57cec5SDimitry Andric while (!__s.empty()) 14180b57cec5SDimitry Andric insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); 14190b57cec5SDimitry Andric } 14200b57cec5SDimitry Andric} 14210b57cec5SDimitry Andric 14220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 14230b57cec5SDimitry Andric 14240b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14250b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14260b57cec5SDimitry Andricbool 14270b57cec5SDimitry Andricoperator==(const multiset<_Key, _Compare, _Allocator>& __x, 14280b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14290b57cec5SDimitry Andric{ 14300b57cec5SDimitry Andric return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 14310b57cec5SDimitry Andric} 14320b57cec5SDimitry Andric 14330b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14340b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14350b57cec5SDimitry Andricbool 14360b57cec5SDimitry Andricoperator< (const multiset<_Key, _Compare, _Allocator>& __x, 14370b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14380b57cec5SDimitry Andric{ 14390b57cec5SDimitry Andric return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 14400b57cec5SDimitry Andric} 14410b57cec5SDimitry Andric 14420b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14430b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14440b57cec5SDimitry Andricbool 14450b57cec5SDimitry Andricoperator!=(const multiset<_Key, _Compare, _Allocator>& __x, 14460b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14470b57cec5SDimitry Andric{ 14480b57cec5SDimitry Andric return !(__x == __y); 14490b57cec5SDimitry Andric} 14500b57cec5SDimitry Andric 14510b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14520b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14530b57cec5SDimitry Andricbool 14540b57cec5SDimitry Andricoperator> (const multiset<_Key, _Compare, _Allocator>& __x, 14550b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14560b57cec5SDimitry Andric{ 14570b57cec5SDimitry Andric return __y < __x; 14580b57cec5SDimitry Andric} 14590b57cec5SDimitry Andric 14600b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14610b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14620b57cec5SDimitry Andricbool 14630b57cec5SDimitry Andricoperator>=(const multiset<_Key, _Compare, _Allocator>& __x, 14640b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14650b57cec5SDimitry Andric{ 14660b57cec5SDimitry Andric return !(__x < __y); 14670b57cec5SDimitry Andric} 14680b57cec5SDimitry Andric 14690b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14700b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14710b57cec5SDimitry Andricbool 14720b57cec5SDimitry Andricoperator<=(const multiset<_Key, _Compare, _Allocator>& __x, 14730b57cec5SDimitry Andric const multiset<_Key, _Compare, _Allocator>& __y) 14740b57cec5SDimitry Andric{ 14750b57cec5SDimitry Andric return !(__y < __x); 14760b57cec5SDimitry Andric} 14770b57cec5SDimitry Andric 14780b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator> 14790b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 14800b57cec5SDimitry Andricvoid 14810b57cec5SDimitry Andricswap(multiset<_Key, _Compare, _Allocator>& __x, 14820b57cec5SDimitry Andric multiset<_Key, _Compare, _Allocator>& __y) 14830b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 14840b57cec5SDimitry Andric{ 14850b57cec5SDimitry Andric __x.swap(__y); 14860b57cec5SDimitry Andric} 14870b57cec5SDimitry Andric 14880b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 14890b57cec5SDimitry Andrictemplate <class _Key, class _Compare, class _Allocator, class _Predicate> 14900b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1491*5ffd83dbSDimitry Andric typename multiset<_Key, _Compare, _Allocator>::size_type 1492*5ffd83dbSDimitry Andric erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { 1493*5ffd83dbSDimitry Andric return __libcpp_erase_if_container(__c, __pred); 1494*5ffd83dbSDimitry Andric} 14950b57cec5SDimitry Andric#endif 14960b57cec5SDimitry Andric 14970b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 14980b57cec5SDimitry Andric 14990b57cec5SDimitry Andric#endif // _LIBCPP_SET 1500