10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 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_UNORDERED_SET 110b57cec5SDimitry Andric#define _LIBCPP_UNORDERED_SET 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric unordered_set synopsis 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric#include <initializer_list> 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricnamespace std 200b57cec5SDimitry Andric{ 210b57cec5SDimitry Andric 220b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 230b57cec5SDimitry Andric class Alloc = allocator<Value>> 240b57cec5SDimitry Andricclass unordered_set 250b57cec5SDimitry Andric{ 260b57cec5SDimitry Andricpublic: 270b57cec5SDimitry Andric // types 280b57cec5SDimitry Andric typedef Value key_type; 290b57cec5SDimitry Andric typedef key_type value_type; 300b57cec5SDimitry Andric typedef Hash hasher; 310b57cec5SDimitry Andric typedef Pred key_equal; 320b57cec5SDimitry Andric typedef Alloc allocator_type; 330b57cec5SDimitry Andric typedef value_type& reference; 340b57cec5SDimitry Andric typedef const value_type& const_reference; 350b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::pointer pointer; 360b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 370b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::size_type size_type; 380b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::difference_type difference_type; 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric typedef /unspecified/ iterator; 410b57cec5SDimitry Andric typedef /unspecified/ const_iterator; 420b57cec5SDimitry Andric typedef /unspecified/ local_iterator; 430b57cec5SDimitry Andric typedef /unspecified/ const_local_iterator; 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric typedef unspecified node_type unspecified; // C++17 460b57cec5SDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric unordered_set() 490b57cec5SDimitry Andric noexcept( 500b57cec5SDimitry Andric is_nothrow_default_constructible<hasher>::value && 510b57cec5SDimitry Andric is_nothrow_default_constructible<key_equal>::value && 520b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value); 530b57cec5SDimitry Andric explicit unordered_set(size_type n, const hasher& hf = hasher(), 540b57cec5SDimitry Andric const key_equal& eql = key_equal(), 550b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 560b57cec5SDimitry Andric template <class InputIterator> 570b57cec5SDimitry Andric unordered_set(InputIterator f, InputIterator l, 580b57cec5SDimitry Andric size_type n = 0, const hasher& hf = hasher(), 590b57cec5SDimitry Andric const key_equal& eql = key_equal(), 600b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 61*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 62*06c3fb27SDimitry Andric unordered_set(from_range_t, R&& rg, size_type n = see below, 63*06c3fb27SDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 64*06c3fb27SDimitry Andric const allocator_type& a = allocator_type()); // C++23 650b57cec5SDimitry Andric explicit unordered_set(const allocator_type&); 660b57cec5SDimitry Andric unordered_set(const unordered_set&); 670b57cec5SDimitry Andric unordered_set(const unordered_set&, const Allocator&); 680b57cec5SDimitry Andric unordered_set(unordered_set&&) 690b57cec5SDimitry Andric noexcept( 700b57cec5SDimitry Andric is_nothrow_move_constructible<hasher>::value && 710b57cec5SDimitry Andric is_nothrow_move_constructible<key_equal>::value && 720b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value); 730b57cec5SDimitry Andric unordered_set(unordered_set&&, const Allocator&); 740b57cec5SDimitry Andric unordered_set(initializer_list<value_type>, size_type n = 0, 750b57cec5SDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 760b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 770b57cec5SDimitry Andric unordered_set(size_type n, const allocator_type& a); // C++14 780b57cec5SDimitry Andric unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14 790b57cec5SDimitry Andric template <class InputIterator> 800b57cec5SDimitry Andric unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 810b57cec5SDimitry Andric template <class InputIterator> 820b57cec5SDimitry Andric unordered_set(InputIterator f, InputIterator l, size_type n, 830b57cec5SDimitry Andric const hasher& hf, const allocator_type& a); // C++14 84*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 85*06c3fb27SDimitry Andric unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a) 86*06c3fb27SDimitry Andric : unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23 87*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 88*06c3fb27SDimitry Andric unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a) 89*06c3fb27SDimitry Andric : unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23 900b57cec5SDimitry Andric unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 910b57cec5SDimitry Andric unordered_set(initializer_list<value_type> il, size_type n, 920b57cec5SDimitry Andric const hasher& hf, const allocator_type& a); // C++14 930b57cec5SDimitry Andric ~unordered_set(); 940b57cec5SDimitry Andric unordered_set& operator=(const unordered_set&); 950b57cec5SDimitry Andric unordered_set& operator=(unordered_set&&) 960b57cec5SDimitry Andric noexcept( 970b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 980b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 990b57cec5SDimitry Andric is_nothrow_move_assignable<hasher>::value && 1000b57cec5SDimitry Andric is_nothrow_move_assignable<key_equal>::value); 1010b57cec5SDimitry Andric unordered_set& operator=(initializer_list<value_type>); 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric bool empty() const noexcept; 1060b57cec5SDimitry Andric size_type size() const noexcept; 1070b57cec5SDimitry Andric size_type max_size() const noexcept; 1080b57cec5SDimitry Andric 1090b57cec5SDimitry Andric iterator begin() noexcept; 1100b57cec5SDimitry Andric iterator end() noexcept; 1110b57cec5SDimitry Andric const_iterator begin() const noexcept; 1120b57cec5SDimitry Andric const_iterator end() const noexcept; 1130b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 1140b57cec5SDimitry Andric const_iterator cend() const noexcept; 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric template <class... Args> 1170b57cec5SDimitry Andric pair<iterator, bool> emplace(Args&&... args); 1180b57cec5SDimitry Andric template <class... Args> 1190b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 1200b57cec5SDimitry Andric pair<iterator, bool> insert(const value_type& obj); 1210b57cec5SDimitry Andric pair<iterator, bool> insert(value_type&& obj); 1220b57cec5SDimitry Andric iterator insert(const_iterator hint, const value_type& obj); 1230b57cec5SDimitry Andric iterator insert(const_iterator hint, value_type&& obj); 1240b57cec5SDimitry Andric template <class InputIterator> 1250b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 126*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 127*06c3fb27SDimitry Andric void insert_range(R&& rg); // C++23 1280b57cec5SDimitry Andric void insert(initializer_list<value_type>); 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 1310b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 1320b57cec5SDimitry Andric insert_return_type insert(node_type&& nh); // C++17 1330b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric iterator erase(const_iterator position); 1360b57cec5SDimitry Andric iterator erase(iterator position); // C++14 1370b57cec5SDimitry Andric size_type erase(const key_type& k); 1380b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 1390b57cec5SDimitry Andric void clear() noexcept; 1400b57cec5SDimitry Andric 1410b57cec5SDimitry Andric template<class H2, class P2> 1420b57cec5SDimitry Andric void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17 1430b57cec5SDimitry Andric template<class H2, class P2> 1440b57cec5SDimitry Andric void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17 1450b57cec5SDimitry Andric template<class H2, class P2> 1460b57cec5SDimitry Andric void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17 1470b57cec5SDimitry Andric template<class H2, class P2> 1480b57cec5SDimitry Andric void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17 1490b57cec5SDimitry Andric 1500b57cec5SDimitry Andric void swap(unordered_set&) 1510b57cec5SDimitry Andric noexcept(allocator_traits<Allocator>::is_always_equal::value && 1520b57cec5SDimitry Andric noexcept(swap(declval<hasher&>(), declval<hasher&>())) && 1530b57cec5SDimitry Andric noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andric hasher hash_function() const; 1560b57cec5SDimitry Andric key_equal key_eq() const; 1570b57cec5SDimitry Andric 1580b57cec5SDimitry Andric iterator find(const key_type& k); 1590b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 160e8d8bef9SDimitry Andric template<typename K> 161e8d8bef9SDimitry Andric iterator find(const K& x); // C++20 162e8d8bef9SDimitry Andric template<typename K> 163e8d8bef9SDimitry Andric const_iterator find(const K& x) const; // C++20 1640b57cec5SDimitry Andric size_type count(const key_type& k) const; 165e8d8bef9SDimitry Andric template<typename K> 166e8d8bef9SDimitry Andric size_type count(const K& k) const; // C++20 1670b57cec5SDimitry Andric bool contains(const key_type& k) const; // C++20 168e8d8bef9SDimitry Andric template<typename K> 169e8d8bef9SDimitry Andric bool contains(const K& k) const; // C++20 1700b57cec5SDimitry Andric pair<iterator, iterator> equal_range(const key_type& k); 1710b57cec5SDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 172e8d8bef9SDimitry Andric template<typename K> 173e8d8bef9SDimitry Andric pair<iterator, iterator> equal_range(const K& k); // C++20 174e8d8bef9SDimitry Andric template<typename K> 175e8d8bef9SDimitry Andric pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric size_type bucket_count() const noexcept; 1780b57cec5SDimitry Andric size_type max_bucket_count() const noexcept; 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric size_type bucket_size(size_type n) const; 1810b57cec5SDimitry Andric size_type bucket(const key_type& k) const; 1820b57cec5SDimitry Andric 1830b57cec5SDimitry Andric local_iterator begin(size_type n); 1840b57cec5SDimitry Andric local_iterator end(size_type n); 1850b57cec5SDimitry Andric const_local_iterator begin(size_type n) const; 1860b57cec5SDimitry Andric const_local_iterator end(size_type n) const; 1870b57cec5SDimitry Andric const_local_iterator cbegin(size_type n) const; 1880b57cec5SDimitry Andric const_local_iterator cend(size_type n) const; 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric float load_factor() const noexcept; 1910b57cec5SDimitry Andric float max_load_factor() const noexcept; 1920b57cec5SDimitry Andric void max_load_factor(float z); 1930b57cec5SDimitry Andric void rehash(size_type n); 1940b57cec5SDimitry Andric void reserve(size_type n); 1950b57cec5SDimitry Andric}; 1960b57cec5SDimitry Andric 197349cc55cSDimitry Andrictemplate<class InputIterator, 198349cc55cSDimitry Andric class Hash = hash<typename iterator_traits<InputIterator>::value_type>, 199349cc55cSDimitry Andric class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, 200349cc55cSDimitry Andric class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 201349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type = see below, 202349cc55cSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 203349cc55cSDimitry Andric -> unordered_set<typename iterator_traits<InputIterator>::value_type, 204349cc55cSDimitry Andric Hash, Pred, Allocator>; // C++17 205349cc55cSDimitry Andric 206*06c3fb27SDimitry Andrictemplate<ranges::input_range R, 207*06c3fb27SDimitry Andric class Hash = hash<ranges::range_value_t<R>>, 208*06c3fb27SDimitry Andric class Pred = equal_to<ranges::range_value_t<R>>, 209*06c3fb27SDimitry Andric class Allocator = allocator<ranges::range_value_t<R>>> 210*06c3fb27SDimitry Andric unordered_set(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 211*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23 212*06c3fb27SDimitry Andric 213349cc55cSDimitry Andrictemplate<class T, class Hash = hash<T>, 214349cc55cSDimitry Andric class Pred = equal_to<T>, class Allocator = allocator<T>> 215349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type = see below, 216349cc55cSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 217349cc55cSDimitry Andric -> unordered_set<T, Hash, Pred, Allocator>; // C++17 218349cc55cSDimitry Andric 219349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 220349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator) 221349cc55cSDimitry Andric -> unordered_set<typename iterator_traits<InputIterator>::value_type, 222349cc55cSDimitry Andric hash<typename iterator_traits<InputIterator>::value_type>, 223349cc55cSDimitry Andric equal_to<typename iterator_traits<InputIterator>::value_type>, 224349cc55cSDimitry Andric Allocator>; // C++17 225349cc55cSDimitry Andric 226349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator> 227349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type, 228349cc55cSDimitry Andric Hash, Allocator) 229349cc55cSDimitry Andric -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash, 230349cc55cSDimitry Andric equal_to<typename iterator_traits<InputIterator>::value_type>, 231349cc55cSDimitry Andric Allocator>; // C++17 232349cc55cSDimitry Andric 233*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 234*06c3fb27SDimitry Andric unordered_set(from_range_t, R&&, typename see below::size_type, Allocator) 235*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>, 236*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 237*06c3fb27SDimitry Andric 238*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 239*06c3fb27SDimitry Andric unordered_set(from_range_t, R&&, Allocator) 240*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>, 241*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 242*06c3fb27SDimitry Andric 243*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator> 244*06c3fb27SDimitry Andric unordered_set(from_range_t, R&&, typename see below::size_type, Hash, Allocator) 245*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<R>, Hash, 246*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 247*06c3fb27SDimitry Andric 248349cc55cSDimitry Andrictemplate<class T, class Allocator> 249349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type, Allocator) 250349cc55cSDimitry Andric -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17 251349cc55cSDimitry Andric 252349cc55cSDimitry Andrictemplate<class T, class Hash, class Allocator> 253349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator) 254349cc55cSDimitry Andric -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17 255349cc55cSDimitry Andric 2560b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 2570b57cec5SDimitry Andric void swap(unordered_set<Value, Hash, Pred, Alloc>& x, 2580b57cec5SDimitry Andric unordered_set<Value, Hash, Pred, Alloc>& y) 2590b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 2620b57cec5SDimitry Andric bool 2630b57cec5SDimitry Andric operator==(const unordered_set<Value, Hash, Pred, Alloc>& x, 2640b57cec5SDimitry Andric const unordered_set<Value, Hash, Pred, Alloc>& y); 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 2670b57cec5SDimitry Andric bool 2680b57cec5SDimitry Andric operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x, 269*06c3fb27SDimitry Andric const unordered_set<Value, Hash, Pred, Alloc>& y); // removed in C++20 2700b57cec5SDimitry Andric 2710b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 2720b57cec5SDimitry Andric class Alloc = allocator<Value>> 2730b57cec5SDimitry Andricclass unordered_multiset 2740b57cec5SDimitry Andric{ 2750b57cec5SDimitry Andricpublic: 2760b57cec5SDimitry Andric // types 2770b57cec5SDimitry Andric typedef Value key_type; 2780b57cec5SDimitry Andric typedef key_type value_type; 2790b57cec5SDimitry Andric typedef Hash hasher; 2800b57cec5SDimitry Andric typedef Pred key_equal; 2810b57cec5SDimitry Andric typedef Alloc allocator_type; 2820b57cec5SDimitry Andric typedef value_type& reference; 2830b57cec5SDimitry Andric typedef const value_type& const_reference; 2840b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::pointer pointer; 2850b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 2860b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::size_type size_type; 2870b57cec5SDimitry Andric typedef typename allocator_traits<allocator_type>::difference_type difference_type; 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric typedef /unspecified/ iterator; 2900b57cec5SDimitry Andric typedef /unspecified/ const_iterator; 2910b57cec5SDimitry Andric typedef /unspecified/ local_iterator; 2920b57cec5SDimitry Andric typedef /unspecified/ const_local_iterator; 2930b57cec5SDimitry Andric 2940b57cec5SDimitry Andric typedef unspecified node_type unspecified; // C++17 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric unordered_multiset() 2970b57cec5SDimitry Andric noexcept( 2980b57cec5SDimitry Andric is_nothrow_default_constructible<hasher>::value && 2990b57cec5SDimitry Andric is_nothrow_default_constructible<key_equal>::value && 3000b57cec5SDimitry Andric is_nothrow_default_constructible<allocator_type>::value); 3010b57cec5SDimitry Andric explicit unordered_multiset(size_type n, const hasher& hf = hasher(), 3020b57cec5SDimitry Andric const key_equal& eql = key_equal(), 3030b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 3040b57cec5SDimitry Andric template <class InputIterator> 3050b57cec5SDimitry Andric unordered_multiset(InputIterator f, InputIterator l, 3060b57cec5SDimitry Andric size_type n = 0, const hasher& hf = hasher(), 3070b57cec5SDimitry Andric const key_equal& eql = key_equal(), 3080b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 309*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 310*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&& rg, size_type n = see below, 311*06c3fb27SDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 312*06c3fb27SDimitry Andric const allocator_type& a = allocator_type()); // C++23 3130b57cec5SDimitry Andric explicit unordered_multiset(const allocator_type&); 3140b57cec5SDimitry Andric unordered_multiset(const unordered_multiset&); 3150b57cec5SDimitry Andric unordered_multiset(const unordered_multiset&, const Allocator&); 3160b57cec5SDimitry Andric unordered_multiset(unordered_multiset&&) 3170b57cec5SDimitry Andric noexcept( 3180b57cec5SDimitry Andric is_nothrow_move_constructible<hasher>::value && 3190b57cec5SDimitry Andric is_nothrow_move_constructible<key_equal>::value && 3200b57cec5SDimitry Andric is_nothrow_move_constructible<allocator_type>::value); 3210b57cec5SDimitry Andric unordered_multiset(unordered_multiset&&, const Allocator&); 3220b57cec5SDimitry Andric unordered_multiset(initializer_list<value_type>, size_type n = /see below/, 3230b57cec5SDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 3240b57cec5SDimitry Andric const allocator_type& a = allocator_type()); 3250b57cec5SDimitry Andric unordered_multiset(size_type n, const allocator_type& a); // C++14 3260b57cec5SDimitry Andric unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14 3270b57cec5SDimitry Andric template <class InputIterator> 3280b57cec5SDimitry Andric unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 3290b57cec5SDimitry Andric template <class InputIterator> 3300b57cec5SDimitry Andric unordered_multiset(InputIterator f, InputIterator l, size_type n, 3310b57cec5SDimitry Andric const hasher& hf, const allocator_type& a); // C++14 332*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 333*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a) 334*06c3fb27SDimitry Andric : unordered_multiset(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23 335*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 336*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a) 337*06c3fb27SDimitry Andric : unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23 3380b57cec5SDimitry Andric unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 3390b57cec5SDimitry Andric unordered_multiset(initializer_list<value_type> il, size_type n, 3400b57cec5SDimitry Andric const hasher& hf, const allocator_type& a); // C++14 3410b57cec5SDimitry Andric ~unordered_multiset(); 3420b57cec5SDimitry Andric unordered_multiset& operator=(const unordered_multiset&); 3430b57cec5SDimitry Andric unordered_multiset& operator=(unordered_multiset&&) 3440b57cec5SDimitry Andric noexcept( 3450b57cec5SDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 3460b57cec5SDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 3470b57cec5SDimitry Andric is_nothrow_move_assignable<hasher>::value && 3480b57cec5SDimitry Andric is_nothrow_move_assignable<key_equal>::value); 3490b57cec5SDimitry Andric unordered_multiset& operator=(initializer_list<value_type>); 3500b57cec5SDimitry Andric 3510b57cec5SDimitry Andric allocator_type get_allocator() const noexcept; 3520b57cec5SDimitry Andric 3530b57cec5SDimitry Andric bool empty() const noexcept; 3540b57cec5SDimitry Andric size_type size() const noexcept; 3550b57cec5SDimitry Andric size_type max_size() const noexcept; 3560b57cec5SDimitry Andric 3570b57cec5SDimitry Andric iterator begin() noexcept; 3580b57cec5SDimitry Andric iterator end() noexcept; 3590b57cec5SDimitry Andric const_iterator begin() const noexcept; 3600b57cec5SDimitry Andric const_iterator end() const noexcept; 3610b57cec5SDimitry Andric const_iterator cbegin() const noexcept; 3620b57cec5SDimitry Andric const_iterator cend() const noexcept; 3630b57cec5SDimitry Andric 3640b57cec5SDimitry Andric template <class... Args> 3650b57cec5SDimitry Andric iterator emplace(Args&&... args); 3660b57cec5SDimitry Andric template <class... Args> 3670b57cec5SDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 3680b57cec5SDimitry Andric iterator insert(const value_type& obj); 3690b57cec5SDimitry Andric iterator insert(value_type&& obj); 3700b57cec5SDimitry Andric iterator insert(const_iterator hint, const value_type& obj); 3710b57cec5SDimitry Andric iterator insert(const_iterator hint, value_type&& obj); 3720b57cec5SDimitry Andric template <class InputIterator> 3730b57cec5SDimitry Andric void insert(InputIterator first, InputIterator last); 374*06c3fb27SDimitry Andric template<container-compatible-range<value_type> R> 375*06c3fb27SDimitry Andric void insert_range(R&& rg); // C++23 3760b57cec5SDimitry Andric void insert(initializer_list<value_type>); 3770b57cec5SDimitry Andric 3780b57cec5SDimitry Andric node_type extract(const_iterator position); // C++17 3790b57cec5SDimitry Andric node_type extract(const key_type& x); // C++17 3800b57cec5SDimitry Andric iterator insert(node_type&& nh); // C++17 3810b57cec5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 3820b57cec5SDimitry Andric 3830b57cec5SDimitry Andric iterator erase(const_iterator position); 3840b57cec5SDimitry Andric iterator erase(iterator position); // C++14 3850b57cec5SDimitry Andric size_type erase(const key_type& k); 3860b57cec5SDimitry Andric iterator erase(const_iterator first, const_iterator last); 3870b57cec5SDimitry Andric void clear() noexcept; 3880b57cec5SDimitry Andric 3890b57cec5SDimitry Andric template<class H2, class P2> 3900b57cec5SDimitry Andric void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17 3910b57cec5SDimitry Andric template<class H2, class P2> 3920b57cec5SDimitry Andric void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17 3930b57cec5SDimitry Andric template<class H2, class P2> 3940b57cec5SDimitry Andric void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17 3950b57cec5SDimitry Andric template<class H2, class P2> 3960b57cec5SDimitry Andric void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andric void swap(unordered_multiset&) 3990b57cec5SDimitry Andric noexcept(allocator_traits<Allocator>::is_always_equal::value && 4000b57cec5SDimitry Andric noexcept(swap(declval<hasher&>(), declval<hasher&>())) && 4010b57cec5SDimitry Andric noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17 4020b57cec5SDimitry Andric 4030b57cec5SDimitry Andric hasher hash_function() const; 4040b57cec5SDimitry Andric key_equal key_eq() const; 4050b57cec5SDimitry Andric 4060b57cec5SDimitry Andric iterator find(const key_type& k); 4070b57cec5SDimitry Andric const_iterator find(const key_type& k) const; 408e8d8bef9SDimitry Andric template<typename K> 409e8d8bef9SDimitry Andric iterator find(const K& x); // C++20 410e8d8bef9SDimitry Andric template<typename K> 411e8d8bef9SDimitry Andric const_iterator find(const K& x) const; // C++20 4120b57cec5SDimitry Andric size_type count(const key_type& k) const; 413e8d8bef9SDimitry Andric template<typename K> 414e8d8bef9SDimitry Andric size_type count(const K& k) const; // C++20 4150b57cec5SDimitry Andric bool contains(const key_type& k) const; // C++20 416e8d8bef9SDimitry Andric template<typename K> 417e8d8bef9SDimitry Andric bool contains(const K& k) const; // C++20 4180b57cec5SDimitry Andric pair<iterator, iterator> equal_range(const key_type& k); 4190b57cec5SDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 420e8d8bef9SDimitry Andric template<typename K> 421e8d8bef9SDimitry Andric pair<iterator, iterator> equal_range(const K& k); // C++20 422e8d8bef9SDimitry Andric template<typename K> 423e8d8bef9SDimitry Andric pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 4240b57cec5SDimitry Andric 4250b57cec5SDimitry Andric size_type bucket_count() const noexcept; 4260b57cec5SDimitry Andric size_type max_bucket_count() const noexcept; 4270b57cec5SDimitry Andric 4280b57cec5SDimitry Andric size_type bucket_size(size_type n) const; 4290b57cec5SDimitry Andric size_type bucket(const key_type& k) const; 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andric local_iterator begin(size_type n); 4320b57cec5SDimitry Andric local_iterator end(size_type n); 4330b57cec5SDimitry Andric const_local_iterator begin(size_type n) const; 4340b57cec5SDimitry Andric const_local_iterator end(size_type n) const; 4350b57cec5SDimitry Andric const_local_iterator cbegin(size_type n) const; 4360b57cec5SDimitry Andric const_local_iterator cend(size_type n) const; 4370b57cec5SDimitry Andric 4380b57cec5SDimitry Andric float load_factor() const noexcept; 4390b57cec5SDimitry Andric float max_load_factor() const noexcept; 4400b57cec5SDimitry Andric void max_load_factor(float z); 4410b57cec5SDimitry Andric void rehash(size_type n); 4420b57cec5SDimitry Andric void reserve(size_type n); 4430b57cec5SDimitry Andric}; 4440b57cec5SDimitry Andric 445349cc55cSDimitry Andrictemplate<class InputIterator, 446349cc55cSDimitry Andric class Hash = hash<typename iterator_traits<InputIterator>::value_type>, 447349cc55cSDimitry Andric class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, 448349cc55cSDimitry Andric class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 449349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, see below::size_type = see below, 450349cc55cSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 451349cc55cSDimitry Andric -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, 452349cc55cSDimitry Andric Hash, Pred, Allocator>; // C++17 453349cc55cSDimitry Andric 454*06c3fb27SDimitry Andrictemplate<ranges::input_range R, 455*06c3fb27SDimitry Andric class Hash = hash<ranges::range_value_t<R>>, 456*06c3fb27SDimitry Andric class Pred = equal_to<ranges::range_value_t<R>>, 457*06c3fb27SDimitry Andric class Allocator = allocator<ranges::range_value_t<R>>> 458*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 459*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23 460*06c3fb27SDimitry Andric 461349cc55cSDimitry Andrictemplate<class T, class Hash = hash<T>, 462349cc55cSDimitry Andric class Pred = equal_to<T>, class Allocator = allocator<T>> 463349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type = see below, 464349cc55cSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 465349cc55cSDimitry Andric -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17 466349cc55cSDimitry Andric 467349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 468349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator) 469349cc55cSDimitry Andric -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, 470349cc55cSDimitry Andric hash<typename iterator_traits<InputIterator>::value_type>, 471349cc55cSDimitry Andric equal_to<typename iterator_traits<InputIterator>::value_type>, 472349cc55cSDimitry Andric Allocator>; // C++17 473349cc55cSDimitry Andric 474349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator> 475349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, typename see below::size_type, 476349cc55cSDimitry Andric Hash, Allocator) 477349cc55cSDimitry Andric -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash, 478349cc55cSDimitry Andric equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 479349cc55cSDimitry Andric 480*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 481*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&&, typename see below::size_type, Allocator) 482*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>, 483*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 484*06c3fb27SDimitry Andric 485*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 486*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&&, Allocator) 487*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>, 488*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 489*06c3fb27SDimitry Andric 490*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator> 491*06c3fb27SDimitry Andric unordered_multiset(from_range_t, R&&, typename see below::size_type, Hash, Allocator) 492*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<R>, Hash, 493*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<R>>, Allocator>; // C++23 494*06c3fb27SDimitry Andric 495349cc55cSDimitry Andrictemplate<class T, class Allocator> 496349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type, Allocator) 497349cc55cSDimitry Andric -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17 498349cc55cSDimitry Andric 499349cc55cSDimitry Andrictemplate<class T, class Hash, class Allocator> 500349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator) 501349cc55cSDimitry Andric -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17 502349cc55cSDimitry Andric 5030b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 5040b57cec5SDimitry Andric void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x, 5050b57cec5SDimitry Andric unordered_multiset<Value, Hash, Pred, Alloc>& y) 5060b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 5070b57cec5SDimitry Andric 5080b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 5095ffd83dbSDimitry Andric typename unordered_set<K, T, H, P, A>::size_type 5105ffd83dbSDimitry Andric erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 5110b57cec5SDimitry Andric 5120b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 5135ffd83dbSDimitry Andric typename unordered_multiset<K, T, H, P, A>::size_type 5145ffd83dbSDimitry Andric erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 5150b57cec5SDimitry Andric 5160b57cec5SDimitry Andric 5170b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 5180b57cec5SDimitry Andric bool 5190b57cec5SDimitry Andric operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x, 5200b57cec5SDimitry Andric const unordered_multiset<Value, Hash, Pred, Alloc>& y); 5210b57cec5SDimitry Andric 5220b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc> 5230b57cec5SDimitry Andric bool 5240b57cec5SDimitry Andric operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x, 525*06c3fb27SDimitry Andric const unordered_multiset<Value, Hash, Pred, Alloc>& y); // removed in C++20 5260b57cec5SDimitry Andric} // std 5270b57cec5SDimitry Andric 5280b57cec5SDimitry Andric*/ 5290b57cec5SDimitry Andric 53081ad6265SDimitry Andric#include <__algorithm/is_permutation.h> 53181ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 532*06c3fb27SDimitry Andric#include <__availability> 5330b57cec5SDimitry Andric#include <__config> 534fe6060f1SDimitry Andric#include <__functional/is_transparent.h> 53581ad6265SDimitry Andric#include <__functional/operations.h> 5360b57cec5SDimitry Andric#include <__hash_table> 53781ad6265SDimitry Andric#include <__iterator/distance.h> 53881ad6265SDimitry Andric#include <__iterator/erase_if_container.h> 53981ad6265SDimitry Andric#include <__iterator/iterator_traits.h> 540*06c3fb27SDimitry Andric#include <__iterator/ranges_iterator_traits.h> 54104eeddc0SDimitry Andric#include <__memory/addressof.h> 542bdd1243dSDimitry Andric#include <__memory/allocator.h> 543bdd1243dSDimitry Andric#include <__memory_resource/polymorphic_allocator.h> 5440b57cec5SDimitry Andric#include <__node_handle> 545*06c3fb27SDimitry Andric#include <__ranges/concepts.h> 546*06c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h> 547*06c3fb27SDimitry Andric#include <__ranges/from_range.h> 548bdd1243dSDimitry Andric#include <__type_traits/is_allocator.h> 549fe6060f1SDimitry Andric#include <__utility/forward.h> 5500b57cec5SDimitry Andric#include <version> 5510b57cec5SDimitry Andric 55281ad6265SDimitry Andric// standard-mandated includes 55381ad6265SDimitry Andric 55481ad6265SDimitry Andric// [iterator.range] 55581ad6265SDimitry Andric#include <__iterator/access.h> 55681ad6265SDimitry Andric#include <__iterator/data.h> 55781ad6265SDimitry Andric#include <__iterator/empty.h> 55881ad6265SDimitry Andric#include <__iterator/reverse_access.h> 55981ad6265SDimitry Andric#include <__iterator/size.h> 56081ad6265SDimitry Andric 56181ad6265SDimitry Andric// [unord.set.syn] 56281ad6265SDimitry Andric#include <compare> 56381ad6265SDimitry Andric#include <initializer_list> 56481ad6265SDimitry Andric 5650b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5660b57cec5SDimitry Andric# pragma GCC system_header 5670b57cec5SDimitry Andric#endif 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 5700b57cec5SDimitry Andric 5710b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 5720b57cec5SDimitry Andricclass unordered_multiset; 5730b57cec5SDimitry Andric 5740b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, 5750b57cec5SDimitry Andric class _Alloc = allocator<_Value> > 5760b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_set 5770b57cec5SDimitry Andric{ 5780b57cec5SDimitry Andricpublic: 5790b57cec5SDimitry Andric // types 5800b57cec5SDimitry Andric typedef _Value key_type; 5810b57cec5SDimitry Andric typedef key_type value_type; 58281ad6265SDimitry Andric typedef __type_identity_t<_Hash> hasher; 58381ad6265SDimitry Andric typedef __type_identity_t<_Pred> key_equal; 58481ad6265SDimitry Andric typedef __type_identity_t<_Alloc> allocator_type; 5850b57cec5SDimitry Andric typedef value_type& reference; 5860b57cec5SDimitry Andric typedef const value_type& const_reference; 5870b57cec5SDimitry Andric static_assert((is_same<value_type, typename allocator_type::value_type>::value), 588*06c3fb27SDimitry Andric "Allocator::value_type must be same type as value_type"); 5890b57cec5SDimitry Andric 590bdd1243dSDimitry Andric static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value, 591bdd1243dSDimitry Andric "[allocator.requirements] states that rebinding an allocator to the same type should result in the " 592bdd1243dSDimitry Andric "original allocator"); 593bdd1243dSDimitry Andric 5940b57cec5SDimitry Andric private: 5950b57cec5SDimitry Andric typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; 5960b57cec5SDimitry Andric 5970b57cec5SDimitry Andric __table __table_; 5980b57cec5SDimitry Andric 5990b57cec5SDimitry Andricpublic: 6000b57cec5SDimitry Andric typedef typename __table::pointer pointer; 6010b57cec5SDimitry Andric typedef typename __table::const_pointer const_pointer; 6020b57cec5SDimitry Andric typedef typename __table::size_type size_type; 6030b57cec5SDimitry Andric typedef typename __table::difference_type difference_type; 6040b57cec5SDimitry Andric 6050b57cec5SDimitry Andric typedef typename __table::const_iterator iterator; 6060b57cec5SDimitry Andric typedef typename __table::const_iterator const_iterator; 6070b57cec5SDimitry Andric typedef typename __table::const_local_iterator local_iterator; 6080b57cec5SDimitry Andric typedef typename __table::const_local_iterator const_local_iterator; 6090b57cec5SDimitry Andric 610*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 6110b57cec5SDimitry Andric typedef __set_node_handle<typename __table::__node, allocator_type> node_type; 6120b57cec5SDimitry Andric typedef __insert_return_type<iterator, node_type> insert_return_type; 6130b57cec5SDimitry Andric#endif 6140b57cec5SDimitry Andric 6150b57cec5SDimitry Andric template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 6160b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_set; 6170b57cec5SDimitry Andric template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 6180b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; 6190b57cec5SDimitry Andric 6200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6210b57cec5SDimitry Andric unordered_set() 6220b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 6230b57cec5SDimitry Andric { 6240b57cec5SDimitry Andric } 625*06c3fb27SDimitry Andric explicit _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf = hasher(), 6260b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 627*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 6280b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6290b57cec5SDimitry Andric unordered_set(size_type __n, const allocator_type& __a) 6300b57cec5SDimitry Andric : unordered_set(__n, hasher(), key_equal(), __a) {} 6310b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6320b57cec5SDimitry Andric unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) 6330b57cec5SDimitry Andric : unordered_set(__n, __hf, key_equal(), __a) {} 6340b57cec5SDimitry Andric#endif 635*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, 6360b57cec5SDimitry Andric const allocator_type& __a); 6370b57cec5SDimitry Andric template <class _InputIterator> 638*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last); 6390b57cec5SDimitry Andric template <class _InputIterator> 640*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last, 6410b57cec5SDimitry Andric size_type __n, const hasher& __hf = hasher(), 6420b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 6430b57cec5SDimitry Andric template <class _InputIterator> 644*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last, 6450b57cec5SDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql, 6460b57cec5SDimitry Andric const allocator_type& __a); 647*06c3fb27SDimitry Andric 648*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 649*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 650*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 651*06c3fb27SDimitry Andric unordered_set(from_range_t, _Range&& __range, size_type __n = /*implementation-defined*/0, 652*06c3fb27SDimitry Andric const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), 653*06c3fb27SDimitry Andric const allocator_type& __a = allocator_type()) 654*06c3fb27SDimitry Andric : __table_(__hf, __eql, __a) { 655*06c3fb27SDimitry Andric if (__n > 0) { 656*06c3fb27SDimitry Andric __table_.__rehash_unique(__n); 657*06c3fb27SDimitry Andric } 658*06c3fb27SDimitry Andric insert_range(std::forward<_Range>(__range)); 659*06c3fb27SDimitry Andric } 660*06c3fb27SDimitry Andric#endif 661*06c3fb27SDimitry Andric 662*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 6630b57cec5SDimitry Andric template <class _InputIterator> 6640b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6650b57cec5SDimitry Andric unordered_set(_InputIterator __first, _InputIterator __last, 6660b57cec5SDimitry Andric size_type __n, const allocator_type& __a) 6670b57cec5SDimitry Andric : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} 6680b57cec5SDimitry Andric template <class _InputIterator> 669*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last, 6700b57cec5SDimitry Andric size_type __n, const hasher& __hf, const allocator_type& __a) 6710b57cec5SDimitry Andric : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} 6720b57cec5SDimitry Andric#endif 673*06c3fb27SDimitry Andric 674*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 675*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 676*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 677*06c3fb27SDimitry Andric unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) 678*06c3fb27SDimitry Andric : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} 679*06c3fb27SDimitry Andric 680*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 681*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 682*06c3fb27SDimitry Andric unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) 683*06c3fb27SDimitry Andric : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} 684*06c3fb27SDimitry Andric#endif 685*06c3fb27SDimitry Andric 6860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6870b57cec5SDimitry Andric explicit unordered_set(const allocator_type& __a); 688*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u); 689*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a); 6900b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6920b57cec5SDimitry Andric unordered_set(unordered_set&& __u) 6930b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 694*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a); 695*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il); 696*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il, size_type __n, 6970b57cec5SDimitry Andric const hasher& __hf = hasher(), 6980b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 699*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il, size_type __n, 7000b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql, 7010b57cec5SDimitry Andric const allocator_type& __a); 702*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 7030b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7040b57cec5SDimitry Andric unordered_set(initializer_list<value_type> __il, size_type __n, 7050b57cec5SDimitry Andric const allocator_type& __a) 7060b57cec5SDimitry Andric : unordered_set(__il, __n, hasher(), key_equal(), __a) {} 7070b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7080b57cec5SDimitry Andric unordered_set(initializer_list<value_type> __il, size_type __n, 7090b57cec5SDimitry Andric const hasher& __hf, const allocator_type& __a) 7100b57cec5SDimitry Andric : unordered_set(__il, __n, __hf, key_equal(), __a) {} 7110b57cec5SDimitry Andric#endif 7120b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7140b57cec5SDimitry Andric ~unordered_set() { 715bdd1243dSDimitry Andric static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); 7160b57cec5SDimitry Andric } 7170b57cec5SDimitry Andric 7180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7190b57cec5SDimitry Andric unordered_set& operator=(const unordered_set& __u) 7200b57cec5SDimitry Andric { 7210b57cec5SDimitry Andric __table_ = __u.__table_; 7220b57cec5SDimitry Andric return *this; 7230b57cec5SDimitry Andric } 7240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7260b57cec5SDimitry Andric unordered_set& operator=(unordered_set&& __u) 7270b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 7280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7290b57cec5SDimitry Andric unordered_set& operator=(initializer_list<value_type> __il); 7300b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7310b57cec5SDimitry Andric 7320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7330b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT 7340b57cec5SDimitry Andric {return allocator_type(__table_.__node_alloc());} 7350b57cec5SDimitry Andric 7360b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 7370b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __table_.size() == 0;} 7380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7390b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __table_.size();} 7400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7410b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __table_.max_size();} 7420b57cec5SDimitry Andric 7430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7440b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __table_.begin();} 7450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7460b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __table_.end();} 7470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7480b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __table_.begin();} 7490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7500b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __table_.end();} 7510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7520b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 7530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7540b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return __table_.end();} 7550b57cec5SDimitry Andric 7560b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7570b57cec5SDimitry Andric template <class... _Args> 7580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7590b57cec5SDimitry Andric pair<iterator, bool> emplace(_Args&&... __args) 7600b57cec5SDimitry Andric {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} 7610b57cec5SDimitry Andric template <class... _Args> 7620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 763*06c3fb27SDimitry Andric iterator emplace_hint(const_iterator, _Args&&... __args) { 76481ad6265SDimitry Andric return __table_.__emplace_unique(std::forward<_Args>(__args)...).first; 7650b57cec5SDimitry Andric } 7660b57cec5SDimitry Andric 7670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7680b57cec5SDimitry Andric pair<iterator, bool> insert(value_type&& __x) 7690b57cec5SDimitry Andric {return __table_.__insert_unique(_VSTD::move(__x));} 7700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 771*06c3fb27SDimitry Andric iterator insert(const_iterator, value_type&& __x) { 77281ad6265SDimitry Andric return insert(std::move(__x)).first; 7730b57cec5SDimitry Andric } 77481ad6265SDimitry Andric 7750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7760b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 7770b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 7780b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7790b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7800b57cec5SDimitry Andric pair<iterator, bool> insert(const value_type& __x) 7810b57cec5SDimitry Andric {return __table_.__insert_unique(__x);} 7820b57cec5SDimitry Andric 7830b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 784*06c3fb27SDimitry Andric iterator insert(const_iterator, const value_type& __x) { 7850b57cec5SDimitry Andric return insert(__x).first; 7860b57cec5SDimitry Andric } 7870b57cec5SDimitry Andric template <class _InputIterator> 7880b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7890b57cec5SDimitry Andric void insert(_InputIterator __first, _InputIterator __last); 7900b57cec5SDimitry Andric 791*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 792*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 793*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 794*06c3fb27SDimitry Andric void insert_range(_Range&& __range) { 795*06c3fb27SDimitry Andric for (auto&& __element : __range) { 796*06c3fb27SDimitry Andric __table_.__insert_unique(std::forward<decltype(__element)>(__element)); 797*06c3fb27SDimitry Andric } 798*06c3fb27SDimitry Andric } 799*06c3fb27SDimitry Andric#endif 800*06c3fb27SDimitry Andric 8010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8020b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __table_.erase(__p);} 8030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8040b57cec5SDimitry Andric size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 8050b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8060b57cec5SDimitry Andric iterator erase(const_iterator __first, const_iterator __last) 8070b57cec5SDimitry Andric {return __table_.erase(__first, __last);} 8080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8090b57cec5SDimitry Andric void clear() _NOEXCEPT {__table_.clear();} 8100b57cec5SDimitry Andric 811*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 8120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8130b57cec5SDimitry Andric insert_return_type insert(node_type&& __nh) 8140b57cec5SDimitry Andric { 815*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), 8160b57cec5SDimitry Andric "node_type with incompatible allocator passed to unordered_set::insert()"); 8170b57cec5SDimitry Andric return __table_.template __node_handle_insert_unique< 8180b57cec5SDimitry Andric node_type, insert_return_type>(_VSTD::move(__nh)); 8190b57cec5SDimitry Andric } 8200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8210b57cec5SDimitry Andric iterator insert(const_iterator __h, node_type&& __nh) 8220b57cec5SDimitry Andric { 823*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), 8240b57cec5SDimitry Andric "node_type with incompatible allocator passed to unordered_set::insert()"); 8250b57cec5SDimitry Andric return __table_.template __node_handle_insert_unique<node_type>( 8260b57cec5SDimitry Andric __h, _VSTD::move(__nh)); 8270b57cec5SDimitry Andric } 8280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8290b57cec5SDimitry Andric node_type extract(key_type const& __key) 8300b57cec5SDimitry Andric { 8310b57cec5SDimitry Andric return __table_.template __node_handle_extract<node_type>(__key); 8320b57cec5SDimitry Andric } 8330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8340b57cec5SDimitry Andric node_type extract(const_iterator __it) 8350b57cec5SDimitry Andric { 8360b57cec5SDimitry Andric return __table_.template __node_handle_extract<node_type>(__it); 8370b57cec5SDimitry Andric } 8380b57cec5SDimitry Andric 8390b57cec5SDimitry Andric template<class _H2, class _P2> 8400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8410b57cec5SDimitry Andric void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) 8420b57cec5SDimitry Andric { 843*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 8440b57cec5SDimitry Andric "merging container with incompatible allocator"); 8450b57cec5SDimitry Andric __table_.__node_handle_merge_unique(__source.__table_); 8460b57cec5SDimitry Andric } 8470b57cec5SDimitry Andric template<class _H2, class _P2> 8480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8490b57cec5SDimitry Andric void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) 8500b57cec5SDimitry Andric { 851*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 8520b57cec5SDimitry Andric "merging container with incompatible allocator"); 8530b57cec5SDimitry Andric __table_.__node_handle_merge_unique(__source.__table_); 8540b57cec5SDimitry Andric } 8550b57cec5SDimitry Andric template<class _H2, class _P2> 8560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8570b57cec5SDimitry Andric void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) 8580b57cec5SDimitry Andric { 859*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 8600b57cec5SDimitry Andric "merging container with incompatible allocator"); 8610b57cec5SDimitry Andric __table_.__node_handle_merge_unique(__source.__table_); 8620b57cec5SDimitry Andric } 8630b57cec5SDimitry Andric template<class _H2, class _P2> 8640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8650b57cec5SDimitry Andric void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) 8660b57cec5SDimitry Andric { 867*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 8680b57cec5SDimitry Andric "merging container with incompatible allocator"); 8690b57cec5SDimitry Andric __table_.__node_handle_merge_unique(__source.__table_); 8700b57cec5SDimitry Andric } 8710b57cec5SDimitry Andric#endif 8720b57cec5SDimitry Andric 8730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8740b57cec5SDimitry Andric void swap(unordered_set& __u) 8750b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 8760b57cec5SDimitry Andric {__table_.swap(__u.__table_);} 8770b57cec5SDimitry Andric 8780b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8790b57cec5SDimitry Andric hasher hash_function() const {return __table_.hash_function();} 8800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8810b57cec5SDimitry Andric key_equal key_eq() const {return __table_.key_eq();} 8820b57cec5SDimitry Andric 8830b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8840b57cec5SDimitry Andric iterator find(const key_type& __k) {return __table_.find(__k);} 8850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8860b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __table_.find(__k);} 887*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 888349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 889e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 890349cc55cSDimitry Andric iterator find(const _K2& __k) {return __table_.find(__k);} 891349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 892e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 893349cc55cSDimitry Andric const_iterator find(const _K2& __k) const {return __table_.find(__k);} 894*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 895349cc55cSDimitry Andric 8960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8970b57cec5SDimitry Andric size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 898*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 899349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 900e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 901349cc55cSDimitry Andric size_type count(const _K2& __k) const {return __table_.__count_unique(__k);} 902*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 903349cc55cSDimitry Andric 904*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 9050b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9060b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 907e8d8bef9SDimitry Andric 908349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 909e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 910349cc55cSDimitry Andric bool contains(const _K2& __k) const {return find(__k) != end();} 911*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 912349cc55cSDimitry Andric 9130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9140b57cec5SDimitry Andric pair<iterator, iterator> equal_range(const key_type& __k) 9150b57cec5SDimitry Andric {return __table_.__equal_range_unique(__k);} 9160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9170b57cec5SDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 9180b57cec5SDimitry Andric {return __table_.__equal_range_unique(__k);} 919*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 920349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 921e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 922349cc55cSDimitry Andric pair<iterator, iterator> equal_range(const _K2& __k) 923349cc55cSDimitry Andric {return __table_.__equal_range_unique(__k);} 924349cc55cSDimitry Andric template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 925e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 926349cc55cSDimitry Andric pair<const_iterator, const_iterator> equal_range(const _K2& __k) const 927349cc55cSDimitry Andric {return __table_.__equal_range_unique(__k);} 928*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 9290b57cec5SDimitry Andric 9300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9310b57cec5SDimitry Andric size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 9320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9330b57cec5SDimitry Andric size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} 9340b57cec5SDimitry Andric 9350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9360b57cec5SDimitry Andric size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} 9370b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9380b57cec5SDimitry Andric size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 9390b57cec5SDimitry Andric 9400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9410b57cec5SDimitry Andric local_iterator begin(size_type __n) {return __table_.begin(__n);} 9420b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9430b57cec5SDimitry Andric local_iterator end(size_type __n) {return __table_.end(__n);} 9440b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9450b57cec5SDimitry Andric const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 9460b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9470b57cec5SDimitry Andric const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 9480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9490b57cec5SDimitry Andric const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 9500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9510b57cec5SDimitry Andric const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 9520b57cec5SDimitry Andric 9530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9540b57cec5SDimitry Andric float load_factor() const _NOEXCEPT {return __table_.load_factor();} 9550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9560b57cec5SDimitry Andric float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 9570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9580b57cec5SDimitry Andric void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 9590b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 960753f127fSDimitry Andric void rehash(size_type __n) {__table_.__rehash_unique(__n);} 9610b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 962753f127fSDimitry Andric void reserve(size_type __n) {__table_.__reserve_unique(__n);} 9630b57cec5SDimitry Andric}; 9640b57cec5SDimitry Andric 965349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 9660b57cec5SDimitry Andrictemplate<class _InputIterator, 9670b57cec5SDimitry Andric class _Hash = hash<__iter_value_type<_InputIterator>>, 9680b57cec5SDimitry Andric class _Pred = equal_to<__iter_value_type<_InputIterator>>, 9690b57cec5SDimitry Andric class _Allocator = allocator<__iter_value_type<_InputIterator>>, 970*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 971349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 972349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 973349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 974349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 9750b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, 9760b57cec5SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 9770b57cec5SDimitry Andric -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; 9780b57cec5SDimitry Andric 979*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 980*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 981*06c3fb27SDimitry Andric class _Hash = hash<ranges::range_value_t<_Range>>, 982*06c3fb27SDimitry Andric class _Pred = equal_to<ranges::range_value_t<_Range>>, 983*06c3fb27SDimitry Andric class _Allocator = allocator<ranges::range_value_t<_Range>>, 984*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 985*06c3fb27SDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 986*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 987*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 988*06c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type = 0, 989*06c3fb27SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 990*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 991*06c3fb27SDimitry Andric#endif 992*06c3fb27SDimitry Andric 9930b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>, 9940b57cec5SDimitry Andric class _Pred = equal_to<_Tp>, 9950b57cec5SDimitry Andric class _Allocator = allocator<_Tp>, 996349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 997349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 998349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 999349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 10000b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, 10010b57cec5SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 10020b57cec5SDimitry Andric -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; 10030b57cec5SDimitry Andric 10040b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 1005*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 1006349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 10070b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator, 10080b57cec5SDimitry Andric typename allocator_traits<_Allocator>::size_type, _Allocator) 10090b57cec5SDimitry Andric -> unordered_set<__iter_value_type<_InputIterator>, 10100b57cec5SDimitry Andric hash<__iter_value_type<_InputIterator>>, 10110b57cec5SDimitry Andric equal_to<__iter_value_type<_InputIterator>>, 10120b57cec5SDimitry Andric _Allocator>; 10130b57cec5SDimitry Andric 10140b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator, 1015*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 1016349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1017349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1018349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 10190b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator, 10200b57cec5SDimitry Andric typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 10210b57cec5SDimitry Andric -> unordered_set<__iter_value_type<_InputIterator>, _Hash, 10220b57cec5SDimitry Andric equal_to<__iter_value_type<_InputIterator>>, 10230b57cec5SDimitry Andric _Allocator>; 10240b57cec5SDimitry Andric 1025*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1026*06c3fb27SDimitry Andric 1027*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 1028*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1029*06c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) 1030*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<_Range>, hash<ranges::range_value_t<_Range>>, 1031*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1032*06c3fb27SDimitry Andric 1033*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 1034*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1035*06c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, _Allocator) 1036*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<_Range>, hash<ranges::range_value_t<_Range>>, 1037*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1038*06c3fb27SDimitry Andric 1039*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Hash, class _Allocator, 1040*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1041*06c3fb27SDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1042*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1043*06c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 1044*06c3fb27SDimitry Andric -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1045*06c3fb27SDimitry Andric 1046*06c3fb27SDimitry Andric#endif 1047*06c3fb27SDimitry Andric 10480b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator, 1049349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 10500b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) 10510b57cec5SDimitry Andric -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; 10520b57cec5SDimitry Andric 10530b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator, 1054349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1055349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1056349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 10570b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 10580b57cec5SDimitry Andric -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; 10590b57cec5SDimitry Andric#endif 10600b57cec5SDimitry Andric 10610b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10620b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, 10630b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql) 10640b57cec5SDimitry Andric : __table_(__hf, __eql) 10650b57cec5SDimitry Andric{ 1066753f127fSDimitry Andric __table_.__rehash_unique(__n); 10670b57cec5SDimitry Andric} 10680b57cec5SDimitry Andric 10690b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10700b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, 10710b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 10720b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 10730b57cec5SDimitry Andric{ 1074753f127fSDimitry Andric __table_.__rehash_unique(__n); 10750b57cec5SDimitry Andric} 10760b57cec5SDimitry Andric 10770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10780b57cec5SDimitry Andrictemplate <class _InputIterator> 10790b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 10800b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last) 10810b57cec5SDimitry Andric{ 10820b57cec5SDimitry Andric insert(__first, __last); 10830b57cec5SDimitry Andric} 10840b57cec5SDimitry Andric 10850b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10860b57cec5SDimitry Andrictemplate <class _InputIterator> 10870b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 10880b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, 10890b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql) 10900b57cec5SDimitry Andric : __table_(__hf, __eql) 10910b57cec5SDimitry Andric{ 1092753f127fSDimitry Andric __table_.__rehash_unique(__n); 10930b57cec5SDimitry Andric insert(__first, __last); 10940b57cec5SDimitry Andric} 10950b57cec5SDimitry Andric 10960b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10970b57cec5SDimitry Andrictemplate <class _InputIterator> 10980b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 10990b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, 11000b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 11010b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 11020b57cec5SDimitry Andric{ 1103753f127fSDimitry Andric __table_.__rehash_unique(__n); 11040b57cec5SDimitry Andric insert(__first, __last); 11050b57cec5SDimitry Andric} 11060b57cec5SDimitry Andric 11070b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11080b57cec5SDimitry Andricinline 11090b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11100b57cec5SDimitry Andric const allocator_type& __a) 11110b57cec5SDimitry Andric : __table_(__a) 11120b57cec5SDimitry Andric{ 11130b57cec5SDimitry Andric} 11140b57cec5SDimitry Andric 11150b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11160b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11170b57cec5SDimitry Andric const unordered_set& __u) 11180b57cec5SDimitry Andric : __table_(__u.__table_) 11190b57cec5SDimitry Andric{ 1120753f127fSDimitry Andric __table_.__rehash_unique(__u.bucket_count()); 11210b57cec5SDimitry Andric insert(__u.begin(), __u.end()); 11220b57cec5SDimitry Andric} 11230b57cec5SDimitry Andric 11240b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11250b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11260b57cec5SDimitry Andric const unordered_set& __u, const allocator_type& __a) 11270b57cec5SDimitry Andric : __table_(__u.__table_, __a) 11280b57cec5SDimitry Andric{ 1129753f127fSDimitry Andric __table_.__rehash_unique(__u.bucket_count()); 11300b57cec5SDimitry Andric insert(__u.begin(), __u.end()); 11310b57cec5SDimitry Andric} 11320b57cec5SDimitry Andric 11330b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11340b57cec5SDimitry Andric 11350b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11360b57cec5SDimitry Andricinline 11370b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11380b57cec5SDimitry Andric unordered_set&& __u) 11390b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 11400b57cec5SDimitry Andric : __table_(_VSTD::move(__u.__table_)) 11410b57cec5SDimitry Andric{ 11420b57cec5SDimitry Andric} 11430b57cec5SDimitry Andric 11440b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11450b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11460b57cec5SDimitry Andric unordered_set&& __u, const allocator_type& __a) 11470b57cec5SDimitry Andric : __table_(_VSTD::move(__u.__table_), __a) 11480b57cec5SDimitry Andric{ 11490b57cec5SDimitry Andric if (__a != __u.get_allocator()) 11500b57cec5SDimitry Andric { 11510b57cec5SDimitry Andric iterator __i = __u.begin(); 11520b57cec5SDimitry Andric while (__u.size() != 0) 11530b57cec5SDimitry Andric __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); 11540b57cec5SDimitry Andric } 11550b57cec5SDimitry Andric} 11560b57cec5SDimitry Andric 11570b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11580b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11590b57cec5SDimitry Andric initializer_list<value_type> __il) 11600b57cec5SDimitry Andric{ 11610b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 11620b57cec5SDimitry Andric} 11630b57cec5SDimitry Andric 11640b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11650b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11660b57cec5SDimitry Andric initializer_list<value_type> __il, size_type __n, const hasher& __hf, 11670b57cec5SDimitry Andric const key_equal& __eql) 11680b57cec5SDimitry Andric : __table_(__hf, __eql) 11690b57cec5SDimitry Andric{ 1170753f127fSDimitry Andric __table_.__rehash_unique(__n); 11710b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 11720b57cec5SDimitry Andric} 11730b57cec5SDimitry Andric 11740b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11750b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 11760b57cec5SDimitry Andric initializer_list<value_type> __il, size_type __n, const hasher& __hf, 11770b57cec5SDimitry Andric const key_equal& __eql, const allocator_type& __a) 11780b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 11790b57cec5SDimitry Andric{ 1180753f127fSDimitry Andric __table_.__rehash_unique(__n); 11810b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 11820b57cec5SDimitry Andric} 11830b57cec5SDimitry Andric 11840b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11850b57cec5SDimitry Andricinline 11860b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>& 11870b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u) 11880b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 11890b57cec5SDimitry Andric{ 11900b57cec5SDimitry Andric __table_ = _VSTD::move(__u.__table_); 11910b57cec5SDimitry Andric return *this; 11920b57cec5SDimitry Andric} 11930b57cec5SDimitry Andric 11940b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 11950b57cec5SDimitry Andricinline 11960b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>& 11970b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=( 11980b57cec5SDimitry Andric initializer_list<value_type> __il) 11990b57cec5SDimitry Andric{ 12000b57cec5SDimitry Andric __table_.__assign_unique(__il.begin(), __il.end()); 12010b57cec5SDimitry Andric return *this; 12020b57cec5SDimitry Andric} 12030b57cec5SDimitry Andric 12040b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 12050b57cec5SDimitry Andric 12060b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 12070b57cec5SDimitry Andrictemplate <class _InputIterator> 12080b57cec5SDimitry Andricinline 12090b57cec5SDimitry Andricvoid 12100b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 12110b57cec5SDimitry Andric _InputIterator __last) 12120b57cec5SDimitry Andric{ 12130b57cec5SDimitry Andric for (; __first != __last; ++__first) 12140b57cec5SDimitry Andric __table_.__insert_unique(*__first); 12150b57cec5SDimitry Andric} 12160b57cec5SDimitry Andric 12170b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 12180b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 12190b57cec5SDimitry Andricvoid 12200b57cec5SDimitry Andricswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 12210b57cec5SDimitry Andric unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 12220b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 12230b57cec5SDimitry Andric{ 12240b57cec5SDimitry Andric __x.swap(__y); 12250b57cec5SDimitry Andric} 12260b57cec5SDimitry Andric 1227*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 12285ffd83dbSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, 12295ffd83dbSDimitry Andric class _Predicate> 12300b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 12315ffd83dbSDimitry Andric typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type 12325ffd83dbSDimitry Andric erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, 12335ffd83dbSDimitry Andric _Predicate __pred) { 1234fe6060f1SDimitry Andric return _VSTD::__libcpp_erase_if_container(__c, __pred); 12355ffd83dbSDimitry Andric} 12360b57cec5SDimitry Andric#endif 12370b57cec5SDimitry Andric 12380b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1239bdd1243dSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool 12400b57cec5SDimitry Andricoperator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 12410b57cec5SDimitry Andric const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 12420b57cec5SDimitry Andric{ 12430b57cec5SDimitry Andric if (__x.size() != __y.size()) 12440b57cec5SDimitry Andric return false; 12450b57cec5SDimitry Andric typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator 12460b57cec5SDimitry Andric const_iterator; 12470b57cec5SDimitry Andric for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 12480b57cec5SDimitry Andric __i != __ex; ++__i) 12490b57cec5SDimitry Andric { 12500b57cec5SDimitry Andric const_iterator __j = __y.find(*__i); 12510b57cec5SDimitry Andric if (__j == __ey || !(*__i == *__j)) 12520b57cec5SDimitry Andric return false; 12530b57cec5SDimitry Andric } 12540b57cec5SDimitry Andric return true; 12550b57cec5SDimitry Andric} 12560b57cec5SDimitry Andric 1257*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 1258*06c3fb27SDimitry Andric 12590b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 12600b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 12610b57cec5SDimitry Andricbool 12620b57cec5SDimitry Andricoperator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 12630b57cec5SDimitry Andric const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 12640b57cec5SDimitry Andric{ 12650b57cec5SDimitry Andric return !(__x == __y); 12660b57cec5SDimitry Andric} 12670b57cec5SDimitry Andric 1268*06c3fb27SDimitry Andric#endif 1269*06c3fb27SDimitry Andric 12700b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, 12710b57cec5SDimitry Andric class _Alloc = allocator<_Value> > 12720b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multiset 12730b57cec5SDimitry Andric{ 12740b57cec5SDimitry Andricpublic: 12750b57cec5SDimitry Andric // types 12760b57cec5SDimitry Andric typedef _Value key_type; 12770b57cec5SDimitry Andric typedef key_type value_type; 127881ad6265SDimitry Andric typedef __type_identity_t<_Hash> hasher; 127981ad6265SDimitry Andric typedef __type_identity_t<_Pred> key_equal; 128081ad6265SDimitry Andric typedef __type_identity_t<_Alloc> allocator_type; 12810b57cec5SDimitry Andric typedef value_type& reference; 12820b57cec5SDimitry Andric typedef const value_type& const_reference; 12830b57cec5SDimitry Andric static_assert((is_same<value_type, typename allocator_type::value_type>::value), 1284*06c3fb27SDimitry Andric "Allocator::value_type must be same type as value_type"); 12850b57cec5SDimitry Andric 12860b57cec5SDimitry Andricprivate: 12870b57cec5SDimitry Andric typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; 12880b57cec5SDimitry Andric 12890b57cec5SDimitry Andric __table __table_; 12900b57cec5SDimitry Andric 12910b57cec5SDimitry Andricpublic: 12920b57cec5SDimitry Andric typedef typename __table::pointer pointer; 12930b57cec5SDimitry Andric typedef typename __table::const_pointer const_pointer; 12940b57cec5SDimitry Andric typedef typename __table::size_type size_type; 12950b57cec5SDimitry Andric typedef typename __table::difference_type difference_type; 12960b57cec5SDimitry Andric 12970b57cec5SDimitry Andric typedef typename __table::const_iterator iterator; 12980b57cec5SDimitry Andric typedef typename __table::const_iterator const_iterator; 12990b57cec5SDimitry Andric typedef typename __table::const_local_iterator local_iterator; 13000b57cec5SDimitry Andric typedef typename __table::const_local_iterator const_local_iterator; 13010b57cec5SDimitry Andric 1302*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 13030b57cec5SDimitry Andric typedef __set_node_handle<typename __table::__node, allocator_type> node_type; 13040b57cec5SDimitry Andric#endif 13050b57cec5SDimitry Andric 13060b57cec5SDimitry Andric template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 13070b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_set; 13080b57cec5SDimitry Andric template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 13090b57cec5SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; 13100b57cec5SDimitry Andric 13110b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13120b57cec5SDimitry Andric unordered_multiset() 13130b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 13140b57cec5SDimitry Andric { 13150b57cec5SDimitry Andric } 1316*06c3fb27SDimitry Andric explicit _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf = hasher(), 13170b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 1318*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, 13190b57cec5SDimitry Andric const key_equal& __eql, const allocator_type& __a); 1320*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 13210b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13220b57cec5SDimitry Andric unordered_multiset(size_type __n, const allocator_type& __a) 13230b57cec5SDimitry Andric : unordered_multiset(__n, hasher(), key_equal(), __a) {} 13240b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13250b57cec5SDimitry Andric unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) 13260b57cec5SDimitry Andric : unordered_multiset(__n, __hf, key_equal(), __a) {} 13270b57cec5SDimitry Andric#endif 13280b57cec5SDimitry Andric template <class _InputIterator> 1329*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last); 13300b57cec5SDimitry Andric template <class _InputIterator> 1331*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last, 13320b57cec5SDimitry Andric size_type __n, const hasher& __hf = hasher(), 13330b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 13340b57cec5SDimitry Andric template <class _InputIterator> 1335*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last, 13360b57cec5SDimitry Andric size_type __n , const hasher& __hf, 13370b57cec5SDimitry Andric const key_equal& __eql, const allocator_type& __a); 1338*06c3fb27SDimitry Andric 1339*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1340*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 1341*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 1342*06c3fb27SDimitry Andric unordered_multiset(from_range_t, _Range&& __range, size_type __n = /*implementation-defined*/0, 1343*06c3fb27SDimitry Andric const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), 1344*06c3fb27SDimitry Andric const allocator_type& __a = allocator_type()) 1345*06c3fb27SDimitry Andric : __table_(__hf, __eql, __a) { 1346*06c3fb27SDimitry Andric if (__n > 0) { 1347*06c3fb27SDimitry Andric __table_.__rehash_multi(__n); 1348*06c3fb27SDimitry Andric } 1349*06c3fb27SDimitry Andric insert_range(std::forward<_Range>(__range)); 1350*06c3fb27SDimitry Andric } 1351*06c3fb27SDimitry Andric#endif 1352*06c3fb27SDimitry Andric 1353*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 13540b57cec5SDimitry Andric template <class _InputIterator> 13550b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13560b57cec5SDimitry Andric unordered_multiset(_InputIterator __first, _InputIterator __last, 13570b57cec5SDimitry Andric size_type __n, const allocator_type& __a) 13580b57cec5SDimitry Andric : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} 13590b57cec5SDimitry Andric template <class _InputIterator> 13600b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13610b57cec5SDimitry Andric unordered_multiset(_InputIterator __first, _InputIterator __last, 13620b57cec5SDimitry Andric size_type __n, const hasher& __hf, const allocator_type& __a) 13630b57cec5SDimitry Andric : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} 13640b57cec5SDimitry Andric#endif 1365*06c3fb27SDimitry Andric 1366*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1367*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 1368*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 1369*06c3fb27SDimitry Andric unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) 1370*06c3fb27SDimitry Andric : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} 1371*06c3fb27SDimitry Andric 1372*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 1373*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 1374*06c3fb27SDimitry Andric unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) 1375*06c3fb27SDimitry Andric : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} 1376*06c3fb27SDimitry Andric#endif 1377*06c3fb27SDimitry Andric 13780b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13790b57cec5SDimitry Andric explicit unordered_multiset(const allocator_type& __a); 1380*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u); 1381*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); 13820b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 13830b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13840b57cec5SDimitry Andric unordered_multiset(unordered_multiset&& __u) 13850b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 1386*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); 1387*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il); 1388*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il, size_type __n, 13890b57cec5SDimitry Andric const hasher& __hf = hasher(), 13900b57cec5SDimitry Andric const key_equal& __eql = key_equal()); 1391*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il, size_type __n, 13920b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql, 13930b57cec5SDimitry Andric const allocator_type& __a); 1394*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14 13950b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13960b57cec5SDimitry Andric unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) 13970b57cec5SDimitry Andric : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} 13980b57cec5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 13990b57cec5SDimitry Andric unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) 14000b57cec5SDimitry Andric : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} 14010b57cec5SDimitry Andric#endif 14020b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 14030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14040b57cec5SDimitry Andric ~unordered_multiset() { 1405bdd1243dSDimitry Andric static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); 14060b57cec5SDimitry Andric } 14070b57cec5SDimitry Andric 14080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14090b57cec5SDimitry Andric unordered_multiset& operator=(const unordered_multiset& __u) 14100b57cec5SDimitry Andric { 14110b57cec5SDimitry Andric __table_ = __u.__table_; 14120b57cec5SDimitry Andric return *this; 14130b57cec5SDimitry Andric } 14140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14160b57cec5SDimitry Andric unordered_multiset& operator=(unordered_multiset&& __u) 14170b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 1418*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il); 14190b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 14200b57cec5SDimitry Andric 14210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14220b57cec5SDimitry Andric allocator_type get_allocator() const _NOEXCEPT 14230b57cec5SDimitry Andric {return allocator_type(__table_.__node_alloc());} 14240b57cec5SDimitry Andric 14250b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 14260b57cec5SDimitry Andric bool empty() const _NOEXCEPT {return __table_.size() == 0;} 14270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14280b57cec5SDimitry Andric size_type size() const _NOEXCEPT {return __table_.size();} 14290b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14300b57cec5SDimitry Andric size_type max_size() const _NOEXCEPT {return __table_.max_size();} 14310b57cec5SDimitry Andric 14320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14330b57cec5SDimitry Andric iterator begin() _NOEXCEPT {return __table_.begin();} 14340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14350b57cec5SDimitry Andric iterator end() _NOEXCEPT {return __table_.end();} 14360b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14370b57cec5SDimitry Andric const_iterator begin() const _NOEXCEPT {return __table_.begin();} 14380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14390b57cec5SDimitry Andric const_iterator end() const _NOEXCEPT {return __table_.end();} 14400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14410b57cec5SDimitry Andric const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 14420b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14430b57cec5SDimitry Andric const_iterator cend() const _NOEXCEPT {return __table_.end();} 14440b57cec5SDimitry Andric 14450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14460b57cec5SDimitry Andric template <class... _Args> 14470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14480b57cec5SDimitry Andric iterator emplace(_Args&&... __args) 14490b57cec5SDimitry Andric {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} 14500b57cec5SDimitry Andric template <class... _Args> 14510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14520b57cec5SDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) 14530b57cec5SDimitry Andric {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} 14540b57cec5SDimitry Andric 14550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14560b57cec5SDimitry Andric iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));} 14570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14580b57cec5SDimitry Andric iterator insert(const_iterator __p, value_type&& __x) 14590b57cec5SDimitry Andric {return __table_.__insert_multi(__p, _VSTD::move(__x));} 14600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14610b57cec5SDimitry Andric void insert(initializer_list<value_type> __il) 14620b57cec5SDimitry Andric {insert(__il.begin(), __il.end());} 14630b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 14640b57cec5SDimitry Andric 14650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14660b57cec5SDimitry Andric iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 14670b57cec5SDimitry Andric 14680b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14690b57cec5SDimitry Andric iterator insert(const_iterator __p, const value_type& __x) 14700b57cec5SDimitry Andric {return __table_.__insert_multi(__p, __x);} 14710b57cec5SDimitry Andric 14720b57cec5SDimitry Andric template <class _InputIterator> 14730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14740b57cec5SDimitry Andric void insert(_InputIterator __first, _InputIterator __last); 14750b57cec5SDimitry Andric 1476*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1477*06c3fb27SDimitry Andric template <_ContainerCompatibleRange<value_type> _Range> 1478*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 1479*06c3fb27SDimitry Andric void insert_range(_Range&& __range) { 1480*06c3fb27SDimitry Andric for (auto&& __element : __range) { 1481*06c3fb27SDimitry Andric __table_.__insert_multi(std::forward<decltype(__element)>(__element)); 1482*06c3fb27SDimitry Andric } 1483*06c3fb27SDimitry Andric } 1484*06c3fb27SDimitry Andric#endif 1485*06c3fb27SDimitry Andric 1486*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 14870b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14880b57cec5SDimitry Andric iterator insert(node_type&& __nh) 14890b57cec5SDimitry Andric { 1490*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), 14910b57cec5SDimitry Andric "node_type with incompatible allocator passed to unordered_multiset::insert()"); 14920b57cec5SDimitry Andric return __table_.template __node_handle_insert_multi<node_type>( 14930b57cec5SDimitry Andric _VSTD::move(__nh)); 14940b57cec5SDimitry Andric } 14950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14960b57cec5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 14970b57cec5SDimitry Andric { 1498*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), 14990b57cec5SDimitry Andric "node_type with incompatible allocator passed to unordered_multiset::insert()"); 15000b57cec5SDimitry Andric return __table_.template __node_handle_insert_multi<node_type>( 15010b57cec5SDimitry Andric __hint, _VSTD::move(__nh)); 15020b57cec5SDimitry Andric } 15030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15040b57cec5SDimitry Andric node_type extract(const_iterator __position) 15050b57cec5SDimitry Andric { 15060b57cec5SDimitry Andric return __table_.template __node_handle_extract<node_type>( 15070b57cec5SDimitry Andric __position); 15080b57cec5SDimitry Andric } 15090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15100b57cec5SDimitry Andric node_type extract(key_type const& __key) 15110b57cec5SDimitry Andric { 15120b57cec5SDimitry Andric return __table_.template __node_handle_extract<node_type>(__key); 15130b57cec5SDimitry Andric } 15140b57cec5SDimitry Andric 15150b57cec5SDimitry Andric template <class _H2, class _P2> 15160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15170b57cec5SDimitry Andric void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) 15180b57cec5SDimitry Andric { 1519*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 15200b57cec5SDimitry Andric "merging container with incompatible allocator"); 15210b57cec5SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 15220b57cec5SDimitry Andric } 15230b57cec5SDimitry Andric template <class _H2, class _P2> 15240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15250b57cec5SDimitry Andric void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) 15260b57cec5SDimitry Andric { 1527*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 15280b57cec5SDimitry Andric "merging container with incompatible allocator"); 15290b57cec5SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 15300b57cec5SDimitry Andric } 15310b57cec5SDimitry Andric template <class _H2, class _P2> 15320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15330b57cec5SDimitry Andric void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) 15340b57cec5SDimitry Andric { 1535*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 15360b57cec5SDimitry Andric "merging container with incompatible allocator"); 15370b57cec5SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 15380b57cec5SDimitry Andric } 15390b57cec5SDimitry Andric template <class _H2, class _P2> 15400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15410b57cec5SDimitry Andric void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) 15420b57cec5SDimitry Andric { 1543*06c3fb27SDimitry Andric _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(), 15440b57cec5SDimitry Andric "merging container with incompatible allocator"); 15450b57cec5SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 15460b57cec5SDimitry Andric } 15470b57cec5SDimitry Andric#endif 15480b57cec5SDimitry Andric 15490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15500b57cec5SDimitry Andric iterator erase(const_iterator __p) {return __table_.erase(__p);} 15510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15520b57cec5SDimitry Andric size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 15530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15540b57cec5SDimitry Andric iterator erase(const_iterator __first, const_iterator __last) 15550b57cec5SDimitry Andric {return __table_.erase(__first, __last);} 15560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15570b57cec5SDimitry Andric void clear() _NOEXCEPT {__table_.clear();} 15580b57cec5SDimitry Andric 15590b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15600b57cec5SDimitry Andric void swap(unordered_multiset& __u) 15610b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 15620b57cec5SDimitry Andric {__table_.swap(__u.__table_);} 15630b57cec5SDimitry Andric 15640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15650b57cec5SDimitry Andric hasher hash_function() const {return __table_.hash_function();} 15660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15670b57cec5SDimitry Andric key_equal key_eq() const {return __table_.key_eq();} 15680b57cec5SDimitry Andric 15690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15700b57cec5SDimitry Andric iterator find(const key_type& __k) {return __table_.find(__k);} 15710b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15720b57cec5SDimitry Andric const_iterator find(const key_type& __k) const {return __table_.find(__k);} 1573*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 1574349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1575e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1576349cc55cSDimitry Andric iterator find(const _K2& __k) {return __table_.find(__k);} 1577349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1578e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1579349cc55cSDimitry Andric const_iterator find(const _K2& __k) const {return __table_.find(__k);} 1580*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 1581349cc55cSDimitry Andric 15820b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15830b57cec5SDimitry Andric size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 1584*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 1585349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1586e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1587349cc55cSDimitry Andric size_type count(const _K2& __k) const {return __table_.__count_multi(__k);} 1588*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 1589349cc55cSDimitry Andric 1590*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 15910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15920b57cec5SDimitry Andric bool contains(const key_type& __k) const {return find(__k) != end();} 1593e8d8bef9SDimitry Andric 1594349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1595e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1596349cc55cSDimitry Andric bool contains(const _K2& __k) const {return find(__k) != end();} 1597*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 1598349cc55cSDimitry Andric 15990b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16000b57cec5SDimitry Andric pair<iterator, iterator> equal_range(const key_type& __k) 16010b57cec5SDimitry Andric {return __table_.__equal_range_multi(__k);} 16020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16030b57cec5SDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 16040b57cec5SDimitry Andric {return __table_.__equal_range_multi(__k);} 1605*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 1606349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1607e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1608349cc55cSDimitry Andric pair<iterator, iterator> equal_range(const _K2& __k) 1609349cc55cSDimitry Andric {return __table_.__equal_range_multi(__k);} 1610349cc55cSDimitry Andric template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> 1611e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1612349cc55cSDimitry Andric pair<const_iterator, const_iterator> equal_range(const _K2& __k) const 1613349cc55cSDimitry Andric {return __table_.__equal_range_multi(__k);} 1614*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20 16150b57cec5SDimitry Andric 16160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16170b57cec5SDimitry Andric size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 16180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16190b57cec5SDimitry Andric size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} 16200b57cec5SDimitry Andric 16210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16220b57cec5SDimitry Andric size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} 16230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16240b57cec5SDimitry Andric size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 16250b57cec5SDimitry Andric 16260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16270b57cec5SDimitry Andric local_iterator begin(size_type __n) {return __table_.begin(__n);} 16280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16290b57cec5SDimitry Andric local_iterator end(size_type __n) {return __table_.end(__n);} 16300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16310b57cec5SDimitry Andric const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 16320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16330b57cec5SDimitry Andric const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 16340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16350b57cec5SDimitry Andric const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 16360b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16370b57cec5SDimitry Andric const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 16380b57cec5SDimitry Andric 16390b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16400b57cec5SDimitry Andric float load_factor() const _NOEXCEPT {return __table_.load_factor();} 16410b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16420b57cec5SDimitry Andric float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 16430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16440b57cec5SDimitry Andric void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 16450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1646753f127fSDimitry Andric void rehash(size_type __n) {__table_.__rehash_multi(__n);} 16470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1648753f127fSDimitry Andric void reserve(size_type __n) {__table_.__reserve_multi(__n);} 16490b57cec5SDimitry Andric}; 16500b57cec5SDimitry Andric 1651349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 16520b57cec5SDimitry Andrictemplate<class _InputIterator, 16530b57cec5SDimitry Andric class _Hash = hash<__iter_value_type<_InputIterator>>, 16540b57cec5SDimitry Andric class _Pred = equal_to<__iter_value_type<_InputIterator>>, 16550b57cec5SDimitry Andric class _Allocator = allocator<__iter_value_type<_InputIterator>>, 1656*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 1657349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1658349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1659349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 1660349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 16610b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, 16620b57cec5SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 16630b57cec5SDimitry Andric -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; 16640b57cec5SDimitry Andric 1665*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1666*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 1667*06c3fb27SDimitry Andric class _Hash = hash<ranges::range_value_t<_Range>>, 1668*06c3fb27SDimitry Andric class _Pred = equal_to<ranges::range_value_t<_Range>>, 1669*06c3fb27SDimitry Andric class _Allocator = allocator<ranges::range_value_t<_Range>>, 1670*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1671*06c3fb27SDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1672*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 1673*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1674*06c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type = 0, 1675*06c3fb27SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 1676*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 1677*06c3fb27SDimitry Andric#endif 1678*06c3fb27SDimitry Andric 16790b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>, 16800b57cec5SDimitry Andric class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>, 1681349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1682349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1683349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Pred>::value>, 1684349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 16850b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, 16860b57cec5SDimitry Andric _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 16870b57cec5SDimitry Andric -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; 16880b57cec5SDimitry Andric 16890b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator, 1690*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 1691349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 16920b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) 16930b57cec5SDimitry Andric -> unordered_multiset<__iter_value_type<_InputIterator>, 16940b57cec5SDimitry Andric hash<__iter_value_type<_InputIterator>>, 16950b57cec5SDimitry Andric equal_to<__iter_value_type<_InputIterator>>, 16960b57cec5SDimitry Andric _Allocator>; 16970b57cec5SDimitry Andric 16980b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator, 1699*06c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 1700349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1701349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1702349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 17030b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, 17040b57cec5SDimitry Andric _Hash, _Allocator) 17050b57cec5SDimitry Andric -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, 17060b57cec5SDimitry Andric equal_to<__iter_value_type<_InputIterator>>, 17070b57cec5SDimitry Andric _Allocator>; 17080b57cec5SDimitry Andric 1709*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 1710*06c3fb27SDimitry Andric 1711*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 1712*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1713*06c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) 1714*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<_Range>, hash<ranges::range_value_t<_Range>>, 1715*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1716*06c3fb27SDimitry Andric 1717*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, 1718*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1719*06c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, _Allocator) 1720*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<_Range>, hash<ranges::range_value_t<_Range>>, 1721*06c3fb27SDimitry Andric equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1722*06c3fb27SDimitry Andric 1723*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Hash, class _Allocator, 1724*06c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1725*06c3fb27SDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1726*06c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 1727*06c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 1728*06c3fb27SDimitry Andric -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; 1729*06c3fb27SDimitry Andric 1730*06c3fb27SDimitry Andric#endif 1731*06c3fb27SDimitry Andric 17320b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator, 1733349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 17340b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) 17350b57cec5SDimitry Andric -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; 17360b57cec5SDimitry Andric 17370b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator, 1738349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Hash>::value>, 1739349cc55cSDimitry Andric class = enable_if_t<!is_integral<_Hash>::value>, 1740349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value>> 17410b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 17420b57cec5SDimitry Andric -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; 17430b57cec5SDimitry Andric#endif 17440b57cec5SDimitry Andric 17450b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17460b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17470b57cec5SDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql) 17480b57cec5SDimitry Andric : __table_(__hf, __eql) 17490b57cec5SDimitry Andric{ 1750753f127fSDimitry Andric __table_.__rehash_multi(__n); 17510b57cec5SDimitry Andric} 17520b57cec5SDimitry Andric 17530b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17540b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17550b57cec5SDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql, 17560b57cec5SDimitry Andric const allocator_type& __a) 17570b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 17580b57cec5SDimitry Andric{ 1759753f127fSDimitry Andric __table_.__rehash_multi(__n); 17600b57cec5SDimitry Andric} 17610b57cec5SDimitry Andric 17620b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17630b57cec5SDimitry Andrictemplate <class _InputIterator> 17640b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17650b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last) 17660b57cec5SDimitry Andric{ 17670b57cec5SDimitry Andric insert(__first, __last); 17680b57cec5SDimitry Andric} 17690b57cec5SDimitry Andric 17700b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17710b57cec5SDimitry Andrictemplate <class _InputIterator> 17720b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17730b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, 17740b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql) 17750b57cec5SDimitry Andric : __table_(__hf, __eql) 17760b57cec5SDimitry Andric{ 1777753f127fSDimitry Andric __table_.__rehash_multi(__n); 17780b57cec5SDimitry Andric insert(__first, __last); 17790b57cec5SDimitry Andric} 17800b57cec5SDimitry Andric 17810b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17820b57cec5SDimitry Andrictemplate <class _InputIterator> 17830b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17840b57cec5SDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, 17850b57cec5SDimitry Andric const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 17860b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 17870b57cec5SDimitry Andric{ 1788753f127fSDimitry Andric __table_.__rehash_multi(__n); 17890b57cec5SDimitry Andric insert(__first, __last); 17900b57cec5SDimitry Andric} 17910b57cec5SDimitry Andric 17920b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17930b57cec5SDimitry Andricinline 17940b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 17950b57cec5SDimitry Andric const allocator_type& __a) 17960b57cec5SDimitry Andric : __table_(__a) 17970b57cec5SDimitry Andric{ 17980b57cec5SDimitry Andric} 17990b57cec5SDimitry Andric 18000b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18010b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18020b57cec5SDimitry Andric const unordered_multiset& __u) 18030b57cec5SDimitry Andric : __table_(__u.__table_) 18040b57cec5SDimitry Andric{ 1805753f127fSDimitry Andric __table_.__rehash_multi(__u.bucket_count()); 18060b57cec5SDimitry Andric insert(__u.begin(), __u.end()); 18070b57cec5SDimitry Andric} 18080b57cec5SDimitry Andric 18090b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18100b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18110b57cec5SDimitry Andric const unordered_multiset& __u, const allocator_type& __a) 18120b57cec5SDimitry Andric : __table_(__u.__table_, __a) 18130b57cec5SDimitry Andric{ 1814753f127fSDimitry Andric __table_.__rehash_multi(__u.bucket_count()); 18150b57cec5SDimitry Andric insert(__u.begin(), __u.end()); 18160b57cec5SDimitry Andric} 18170b57cec5SDimitry Andric 18180b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18190b57cec5SDimitry Andric 18200b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18210b57cec5SDimitry Andricinline 18220b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18230b57cec5SDimitry Andric unordered_multiset&& __u) 18240b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 18250b57cec5SDimitry Andric : __table_(_VSTD::move(__u.__table_)) 18260b57cec5SDimitry Andric{ 18270b57cec5SDimitry Andric} 18280b57cec5SDimitry Andric 18290b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18300b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18310b57cec5SDimitry Andric unordered_multiset&& __u, const allocator_type& __a) 18320b57cec5SDimitry Andric : __table_(_VSTD::move(__u.__table_), __a) 18330b57cec5SDimitry Andric{ 18340b57cec5SDimitry Andric if (__a != __u.get_allocator()) 18350b57cec5SDimitry Andric { 18360b57cec5SDimitry Andric iterator __i = __u.begin(); 18370b57cec5SDimitry Andric while (__u.size() != 0) 18380b57cec5SDimitry Andric __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); 18390b57cec5SDimitry Andric } 18400b57cec5SDimitry Andric} 18410b57cec5SDimitry Andric 18420b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18430b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18440b57cec5SDimitry Andric initializer_list<value_type> __il) 18450b57cec5SDimitry Andric{ 18460b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 18470b57cec5SDimitry Andric} 18480b57cec5SDimitry Andric 18490b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18500b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18510b57cec5SDimitry Andric initializer_list<value_type> __il, size_type __n, const hasher& __hf, 18520b57cec5SDimitry Andric const key_equal& __eql) 18530b57cec5SDimitry Andric : __table_(__hf, __eql) 18540b57cec5SDimitry Andric{ 1855753f127fSDimitry Andric __table_.__rehash_multi(__n); 18560b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 18570b57cec5SDimitry Andric} 18580b57cec5SDimitry Andric 18590b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18600b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 18610b57cec5SDimitry Andric initializer_list<value_type> __il, size_type __n, const hasher& __hf, 18620b57cec5SDimitry Andric const key_equal& __eql, const allocator_type& __a) 18630b57cec5SDimitry Andric : __table_(__hf, __eql, __a) 18640b57cec5SDimitry Andric{ 1865753f127fSDimitry Andric __table_.__rehash_multi(__n); 18660b57cec5SDimitry Andric insert(__il.begin(), __il.end()); 18670b57cec5SDimitry Andric} 18680b57cec5SDimitry Andric 18690b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18700b57cec5SDimitry Andricinline 18710b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>& 18720b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=( 18730b57cec5SDimitry Andric unordered_multiset&& __u) 18740b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 18750b57cec5SDimitry Andric{ 18760b57cec5SDimitry Andric __table_ = _VSTD::move(__u.__table_); 18770b57cec5SDimitry Andric return *this; 18780b57cec5SDimitry Andric} 18790b57cec5SDimitry Andric 18800b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18810b57cec5SDimitry Andricinline 18820b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>& 18830b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=( 18840b57cec5SDimitry Andric initializer_list<value_type> __il) 18850b57cec5SDimitry Andric{ 18860b57cec5SDimitry Andric __table_.__assign_multi(__il.begin(), __il.end()); 18870b57cec5SDimitry Andric return *this; 18880b57cec5SDimitry Andric} 18890b57cec5SDimitry Andric 18900b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 18910b57cec5SDimitry Andric 18920b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 18930b57cec5SDimitry Andrictemplate <class _InputIterator> 18940b57cec5SDimitry Andricinline 18950b57cec5SDimitry Andricvoid 18960b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 18970b57cec5SDimitry Andric _InputIterator __last) 18980b57cec5SDimitry Andric{ 18990b57cec5SDimitry Andric for (; __first != __last; ++__first) 19000b57cec5SDimitry Andric __table_.__insert_multi(*__first); 19010b57cec5SDimitry Andric} 19020b57cec5SDimitry Andric 19030b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 19040b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 19050b57cec5SDimitry Andricvoid 19060b57cec5SDimitry Andricswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 19070b57cec5SDimitry Andric unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 19080b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 19090b57cec5SDimitry Andric{ 19100b57cec5SDimitry Andric __x.swap(__y); 19110b57cec5SDimitry Andric} 19120b57cec5SDimitry Andric 1913*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 19145ffd83dbSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, 19155ffd83dbSDimitry Andric class _Predicate> 19160b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 19175ffd83dbSDimitry Andric typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type 19185ffd83dbSDimitry Andric erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, 19195ffd83dbSDimitry Andric _Predicate __pred) { 1920fe6060f1SDimitry Andric return _VSTD::__libcpp_erase_if_container(__c, __pred); 19215ffd83dbSDimitry Andric} 19220b57cec5SDimitry Andric#endif 19230b57cec5SDimitry Andric 19240b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1925bdd1243dSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool 19260b57cec5SDimitry Andricoperator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 19270b57cec5SDimitry Andric const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 19280b57cec5SDimitry Andric{ 19290b57cec5SDimitry Andric if (__x.size() != __y.size()) 19300b57cec5SDimitry Andric return false; 19310b57cec5SDimitry Andric typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator 19320b57cec5SDimitry Andric const_iterator; 19330b57cec5SDimitry Andric typedef pair<const_iterator, const_iterator> _EqRng; 19340b57cec5SDimitry Andric for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 19350b57cec5SDimitry Andric { 19360b57cec5SDimitry Andric _EqRng __xeq = __x.equal_range(*__i); 19370b57cec5SDimitry Andric _EqRng __yeq = __y.equal_range(*__i); 19380b57cec5SDimitry Andric if (_VSTD::distance(__xeq.first, __xeq.second) != 19390b57cec5SDimitry Andric _VSTD::distance(__yeq.first, __yeq.second) || 19400b57cec5SDimitry Andric !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 19410b57cec5SDimitry Andric return false; 19420b57cec5SDimitry Andric __i = __xeq.second; 19430b57cec5SDimitry Andric } 19440b57cec5SDimitry Andric return true; 19450b57cec5SDimitry Andric} 19460b57cec5SDimitry Andric 1947*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 1948*06c3fb27SDimitry Andric 19490b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc> 19500b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 19510b57cec5SDimitry Andricbool 19520b57cec5SDimitry Andricoperator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 19530b57cec5SDimitry Andric const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 19540b57cec5SDimitry Andric{ 19550b57cec5SDimitry Andric return !(__x == __y); 19560b57cec5SDimitry Andric} 19570b57cec5SDimitry Andric 1958*06c3fb27SDimitry Andric#endif 1959*06c3fb27SDimitry Andric 19600b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 19610b57cec5SDimitry Andric 1962*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 1963bdd1243dSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1964bdd1243dSDimitry Andricnamespace pmr { 1965bdd1243dSDimitry Andrictemplate <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>> 1966*06c3fb27SDimitry Andricusing unordered_set _LIBCPP_AVAILABILITY_PMR = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; 1967bdd1243dSDimitry Andric 1968bdd1243dSDimitry Andrictemplate <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>> 1969*06c3fb27SDimitry Andricusing unordered_multiset _LIBCPP_AVAILABILITY_PMR = std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; 1970bdd1243dSDimitry Andric} // namespace pmr 1971bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD 1972bdd1243dSDimitry Andric#endif 1973bdd1243dSDimitry Andric 1974bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1975bdd1243dSDimitry Andric# include <concepts> 1976*06c3fb27SDimitry Andric# include <cstdlib> 1977bdd1243dSDimitry Andric# include <functional> 1978bdd1243dSDimitry Andric# include <iterator> 1979*06c3fb27SDimitry Andric# include <type_traits> 1980bdd1243dSDimitry Andric#endif 1981bdd1243dSDimitry Andric 19820b57cec5SDimitry Andric#endif // _LIBCPP_UNORDERED_SET 1983