13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===-------------------------- unordered_set -----------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 103e519524SHoward Hinnant#ifndef _LIBCPP_UNORDERED_SET 113e519524SHoward Hinnant#define _LIBCPP_UNORDERED_SET 123e519524SHoward Hinnant 133e519524SHoward Hinnant/* 143e519524SHoward Hinnant 153e519524SHoward Hinnant unordered_set synopsis 163e519524SHoward Hinnant 173e519524SHoward Hinnant#include <initializer_list> 183e519524SHoward Hinnant 193e519524SHoward Hinnantnamespace std 203e519524SHoward Hinnant{ 213e519524SHoward Hinnant 223e519524SHoward Hinnanttemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 233e519524SHoward Hinnant class Alloc = allocator<Value>> 243e519524SHoward Hinnantclass unordered_set 253e519524SHoward Hinnant{ 263e519524SHoward Hinnantpublic: 273e519524SHoward Hinnant // types 283e519524SHoward Hinnant typedef Value key_type; 293e519524SHoward Hinnant typedef key_type value_type; 303e519524SHoward Hinnant typedef Hash hasher; 313e519524SHoward Hinnant typedef Pred key_equal; 323e519524SHoward Hinnant typedef Alloc allocator_type; 333e519524SHoward Hinnant typedef value_type& reference; 343e519524SHoward Hinnant typedef const value_type& const_reference; 353e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::pointer pointer; 363e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 373e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::size_type size_type; 383e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::difference_type difference_type; 393e519524SHoward Hinnant 403e519524SHoward Hinnant typedef /unspecified/ iterator; 413e519524SHoward Hinnant typedef /unspecified/ const_iterator; 423e519524SHoward Hinnant typedef /unspecified/ local_iterator; 433e519524SHoward Hinnant typedef /unspecified/ const_local_iterator; 443e519524SHoward Hinnant 45b0386a51SErik Pilkington typedef unspecified node_type unspecified; // C++17 46b0386a51SErik Pilkington typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 47b0386a51SErik Pilkington 48557da866SHoward Hinnant unordered_set() 49557da866SHoward Hinnant noexcept( 50557da866SHoward Hinnant is_nothrow_default_constructible<hasher>::value && 51557da866SHoward Hinnant is_nothrow_default_constructible<key_equal>::value && 52557da866SHoward Hinnant is_nothrow_default_constructible<allocator_type>::value); 53557da866SHoward Hinnant explicit unordered_set(size_type n, const hasher& hf = hasher(), 543e519524SHoward Hinnant const key_equal& eql = key_equal(), 553e519524SHoward Hinnant const allocator_type& a = allocator_type()); 563e519524SHoward Hinnant template <class InputIterator> 573e519524SHoward Hinnant unordered_set(InputIterator f, InputIterator l, 583e519524SHoward Hinnant size_type n = 0, const hasher& hf = hasher(), 593e519524SHoward Hinnant const key_equal& eql = key_equal(), 603e519524SHoward Hinnant const allocator_type& a = allocator_type()); 613e519524SHoward Hinnant explicit unordered_set(const allocator_type&); 623e519524SHoward Hinnant unordered_set(const unordered_set&); 633e519524SHoward Hinnant unordered_set(const unordered_set&, const Allocator&); 64557da866SHoward Hinnant unordered_set(unordered_set&&) 65557da866SHoward Hinnant noexcept( 66557da866SHoward Hinnant is_nothrow_move_constructible<hasher>::value && 67557da866SHoward Hinnant is_nothrow_move_constructible<key_equal>::value && 68557da866SHoward Hinnant is_nothrow_move_constructible<allocator_type>::value); 693e519524SHoward Hinnant unordered_set(unordered_set&&, const Allocator&); 703e519524SHoward Hinnant unordered_set(initializer_list<value_type>, size_type n = 0, 713e519524SHoward Hinnant const hasher& hf = hasher(), const key_equal& eql = key_equal(), 723e519524SHoward Hinnant const allocator_type& a = allocator_type()); 7345b983c4SMarshall Clow unordered_set(size_type n, const allocator_type& a); // C++14 7445b983c4SMarshall Clow unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14 7545b983c4SMarshall Clow template <class InputIterator> 7645b983c4SMarshall Clow unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 7745b983c4SMarshall Clow template <class InputIterator> 7845b983c4SMarshall Clow unordered_set(InputIterator f, InputIterator l, size_type n, 7945b983c4SMarshall Clow const hasher& hf, const allocator_type& a); // C++14 8045b983c4SMarshall Clow unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 8145b983c4SMarshall Clow unordered_set(initializer_list<value_type> il, size_type n, 8245b983c4SMarshall Clow const hasher& hf, const allocator_type& a); // C++14 833e519524SHoward Hinnant ~unordered_set(); 843e519524SHoward Hinnant unordered_set& operator=(const unordered_set&); 85557da866SHoward Hinnant unordered_set& operator=(unordered_set&&) 86557da866SHoward Hinnant noexcept( 87557da866SHoward Hinnant allocator_type::propagate_on_container_move_assignment::value && 88557da866SHoward Hinnant is_nothrow_move_assignable<allocator_type>::value && 89557da866SHoward Hinnant is_nothrow_move_assignable<hasher>::value && 90557da866SHoward Hinnant is_nothrow_move_assignable<key_equal>::value); 913e519524SHoward Hinnant unordered_set& operator=(initializer_list<value_type>); 923e519524SHoward Hinnant 93557da866SHoward Hinnant allocator_type get_allocator() const noexcept; 943e519524SHoward Hinnant 95557da866SHoward Hinnant bool empty() const noexcept; 96557da866SHoward Hinnant size_type size() const noexcept; 97557da866SHoward Hinnant size_type max_size() const noexcept; 983e519524SHoward Hinnant 99557da866SHoward Hinnant iterator begin() noexcept; 100557da866SHoward Hinnant iterator end() noexcept; 101557da866SHoward Hinnant const_iterator begin() const noexcept; 102557da866SHoward Hinnant const_iterator end() const noexcept; 103557da866SHoward Hinnant const_iterator cbegin() const noexcept; 104557da866SHoward Hinnant const_iterator cend() const noexcept; 1053e519524SHoward Hinnant 1063e519524SHoward Hinnant template <class... Args> 1073e519524SHoward Hinnant pair<iterator, bool> emplace(Args&&... args); 1083e519524SHoward Hinnant template <class... Args> 1093e519524SHoward Hinnant iterator emplace_hint(const_iterator position, Args&&... args); 1103e519524SHoward Hinnant pair<iterator, bool> insert(const value_type& obj); 1113e519524SHoward Hinnant pair<iterator, bool> insert(value_type&& obj); 1123e519524SHoward Hinnant iterator insert(const_iterator hint, const value_type& obj); 1133e519524SHoward Hinnant iterator insert(const_iterator hint, value_type&& obj); 1143e519524SHoward Hinnant template <class InputIterator> 1153e519524SHoward Hinnant void insert(InputIterator first, InputIterator last); 1163e519524SHoward Hinnant void insert(initializer_list<value_type>); 1173e519524SHoward Hinnant 118b0386a51SErik Pilkington node_type extract(const_iterator position); // C++17 119b0386a51SErik Pilkington node_type extract(const key_type& x); // C++17 120b0386a51SErik Pilkington insert_return_type insert(node_type&& nh); // C++17 121b0386a51SErik Pilkington iterator insert(const_iterator hint, node_type&& nh); // C++17 122b0386a51SErik Pilkington 1233e519524SHoward Hinnant iterator erase(const_iterator position); 124ec392968SMarshall Clow iterator erase(iterator position); // C++14 1253e519524SHoward Hinnant size_type erase(const key_type& k); 1263e519524SHoward Hinnant iterator erase(const_iterator first, const_iterator last); 127557da866SHoward Hinnant void clear() noexcept; 1283e519524SHoward Hinnant 1295c4e07aeSErik Pilkington template<class H2, class P2> 1305c4e07aeSErik Pilkington void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17 1315c4e07aeSErik Pilkington template<class H2, class P2> 1325c4e07aeSErik Pilkington void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17 1335c4e07aeSErik Pilkington template<class H2, class P2> 1345c4e07aeSErik Pilkington void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17 1355c4e07aeSErik Pilkington template<class H2, class P2> 1365c4e07aeSErik Pilkington void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17 1375c4e07aeSErik Pilkington 138557da866SHoward Hinnant void swap(unordered_set&) 139e3fbe143SMarshall Clow noexcept(allocator_traits<Allocator>::is_always_equal::value && 140e3fbe143SMarshall Clow noexcept(swap(declval<hasher&>(), declval<hasher&>())) && 141e3fbe143SMarshall Clow noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17 1423e519524SHoward Hinnant 1433e519524SHoward Hinnant hasher hash_function() const; 1443e519524SHoward Hinnant key_equal key_eq() const; 1453e519524SHoward Hinnant 1463e519524SHoward Hinnant iterator find(const key_type& k); 1473e519524SHoward Hinnant const_iterator find(const key_type& k) const; 148e5ec94a1SRuslan Arutyunyan template<typename K> 149e5ec94a1SRuslan Arutyunyan iterator find(const K& x); // C++20 150e5ec94a1SRuslan Arutyunyan template<typename K> 151e5ec94a1SRuslan Arutyunyan const_iterator find(const K& x) const; // C++20 1523e519524SHoward Hinnant size_type count(const key_type& k) const; 153e5ec94a1SRuslan Arutyunyan template<typename K> 154e5ec94a1SRuslan Arutyunyan size_type count(const K& k) const; // C++20 155a17b1aedSZoe Carver bool contains(const key_type& k) const; // C++20 156e5ec94a1SRuslan Arutyunyan template<typename K> 157e5ec94a1SRuslan Arutyunyan bool contains(const K& k) const; // C++20 1583e519524SHoward Hinnant pair<iterator, iterator> equal_range(const key_type& k); 1593e519524SHoward Hinnant pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 160e5ec94a1SRuslan Arutyunyan template<typename K> 161e5ec94a1SRuslan Arutyunyan pair<iterator, iterator> equal_range(const K& k); // C++20 162e5ec94a1SRuslan Arutyunyan template<typename K> 163e5ec94a1SRuslan Arutyunyan pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 1643e519524SHoward Hinnant 165557da866SHoward Hinnant size_type bucket_count() const noexcept; 166557da866SHoward Hinnant size_type max_bucket_count() const noexcept; 1673e519524SHoward Hinnant 1683e519524SHoward Hinnant size_type bucket_size(size_type n) const; 1693e519524SHoward Hinnant size_type bucket(const key_type& k) const; 1703e519524SHoward Hinnant 1713e519524SHoward Hinnant local_iterator begin(size_type n); 1723e519524SHoward Hinnant local_iterator end(size_type n); 1733e519524SHoward Hinnant const_local_iterator begin(size_type n) const; 1743e519524SHoward Hinnant const_local_iterator end(size_type n) const; 1753e519524SHoward Hinnant const_local_iterator cbegin(size_type n) const; 1763e519524SHoward Hinnant const_local_iterator cend(size_type n) const; 1773e519524SHoward Hinnant 178557da866SHoward Hinnant float load_factor() const noexcept; 179557da866SHoward Hinnant float max_load_factor() const noexcept; 1803e519524SHoward Hinnant void max_load_factor(float z); 1813e519524SHoward Hinnant void rehash(size_type n); 1823e519524SHoward Hinnant void reserve(size_type n); 1833e519524SHoward Hinnant}; 1843e519524SHoward Hinnant 1853e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 1863e519524SHoward Hinnant void swap(unordered_set<Value, Hash, Pred, Alloc>& x, 187557da866SHoward Hinnant unordered_set<Value, Hash, Pred, Alloc>& y) 188557da866SHoward Hinnant noexcept(noexcept(x.swap(y))); 1893e519524SHoward Hinnant 1903e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 1913e519524SHoward Hinnant bool 1923e519524SHoward Hinnant operator==(const unordered_set<Value, Hash, Pred, Alloc>& x, 1933e519524SHoward Hinnant const unordered_set<Value, Hash, Pred, Alloc>& y); 1943e519524SHoward Hinnant 1953e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 1963e519524SHoward Hinnant bool 1973e519524SHoward Hinnant operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x, 1983e519524SHoward Hinnant const unordered_set<Value, Hash, Pred, Alloc>& y); 1993e519524SHoward Hinnant 2003e519524SHoward Hinnanttemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 2013e519524SHoward Hinnant class Alloc = allocator<Value>> 2023e519524SHoward Hinnantclass unordered_multiset 2033e519524SHoward Hinnant{ 2043e519524SHoward Hinnantpublic: 2053e519524SHoward Hinnant // types 2063e519524SHoward Hinnant typedef Value key_type; 2073e519524SHoward Hinnant typedef key_type value_type; 2083e519524SHoward Hinnant typedef Hash hasher; 2093e519524SHoward Hinnant typedef Pred key_equal; 2103e519524SHoward Hinnant typedef Alloc allocator_type; 2113e519524SHoward Hinnant typedef value_type& reference; 2123e519524SHoward Hinnant typedef const value_type& const_reference; 2133e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::pointer pointer; 2143e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 2153e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::size_type size_type; 2163e519524SHoward Hinnant typedef typename allocator_traits<allocator_type>::difference_type difference_type; 2173e519524SHoward Hinnant 2183e519524SHoward Hinnant typedef /unspecified/ iterator; 2193e519524SHoward Hinnant typedef /unspecified/ const_iterator; 2203e519524SHoward Hinnant typedef /unspecified/ local_iterator; 2213e519524SHoward Hinnant typedef /unspecified/ const_local_iterator; 2223e519524SHoward Hinnant 223b0386a51SErik Pilkington typedef unspecified node_type unspecified; // C++17 224b0386a51SErik Pilkington 225557da866SHoward Hinnant unordered_multiset() 226557da866SHoward Hinnant noexcept( 227557da866SHoward Hinnant is_nothrow_default_constructible<hasher>::value && 228557da866SHoward Hinnant is_nothrow_default_constructible<key_equal>::value && 229557da866SHoward Hinnant is_nothrow_default_constructible<allocator_type>::value); 230557da866SHoward Hinnant explicit unordered_multiset(size_type n, const hasher& hf = hasher(), 2313e519524SHoward Hinnant const key_equal& eql = key_equal(), 2323e519524SHoward Hinnant const allocator_type& a = allocator_type()); 2333e519524SHoward Hinnant template <class InputIterator> 2343e519524SHoward Hinnant unordered_multiset(InputIterator f, InputIterator l, 2353e519524SHoward Hinnant size_type n = 0, const hasher& hf = hasher(), 2363e519524SHoward Hinnant const key_equal& eql = key_equal(), 2373e519524SHoward Hinnant const allocator_type& a = allocator_type()); 2383e519524SHoward Hinnant explicit unordered_multiset(const allocator_type&); 2393e519524SHoward Hinnant unordered_multiset(const unordered_multiset&); 2403e519524SHoward Hinnant unordered_multiset(const unordered_multiset&, const Allocator&); 241557da866SHoward Hinnant unordered_multiset(unordered_multiset&&) 242557da866SHoward Hinnant noexcept( 243557da866SHoward Hinnant is_nothrow_move_constructible<hasher>::value && 244557da866SHoward Hinnant is_nothrow_move_constructible<key_equal>::value && 245557da866SHoward Hinnant is_nothrow_move_constructible<allocator_type>::value); 2463e519524SHoward Hinnant unordered_multiset(unordered_multiset&&, const Allocator&); 2473e519524SHoward Hinnant unordered_multiset(initializer_list<value_type>, size_type n = /see below/, 2483e519524SHoward Hinnant const hasher& hf = hasher(), const key_equal& eql = key_equal(), 2493e519524SHoward Hinnant const allocator_type& a = allocator_type()); 25045b983c4SMarshall Clow unordered_multiset(size_type n, const allocator_type& a); // C++14 25145b983c4SMarshall Clow unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14 25245b983c4SMarshall Clow template <class InputIterator> 25345b983c4SMarshall Clow unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 25445b983c4SMarshall Clow template <class InputIterator> 25545b983c4SMarshall Clow unordered_multiset(InputIterator f, InputIterator l, size_type n, 25645b983c4SMarshall Clow const hasher& hf, const allocator_type& a); // C++14 25745b983c4SMarshall Clow unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 25845b983c4SMarshall Clow unordered_multiset(initializer_list<value_type> il, size_type n, 25945b983c4SMarshall Clow const hasher& hf, const allocator_type& a); // C++14 2603e519524SHoward Hinnant ~unordered_multiset(); 2613e519524SHoward Hinnant unordered_multiset& operator=(const unordered_multiset&); 262557da866SHoward Hinnant unordered_multiset& operator=(unordered_multiset&&) 263557da866SHoward Hinnant noexcept( 264557da866SHoward Hinnant allocator_type::propagate_on_container_move_assignment::value && 265557da866SHoward Hinnant is_nothrow_move_assignable<allocator_type>::value && 266557da866SHoward Hinnant is_nothrow_move_assignable<hasher>::value && 267557da866SHoward Hinnant is_nothrow_move_assignable<key_equal>::value); 2683e519524SHoward Hinnant unordered_multiset& operator=(initializer_list<value_type>); 2693e519524SHoward Hinnant 270557da866SHoward Hinnant allocator_type get_allocator() const noexcept; 2713e519524SHoward Hinnant 272557da866SHoward Hinnant bool empty() const noexcept; 273557da866SHoward Hinnant size_type size() const noexcept; 274557da866SHoward Hinnant size_type max_size() const noexcept; 2753e519524SHoward Hinnant 276557da866SHoward Hinnant iterator begin() noexcept; 277557da866SHoward Hinnant iterator end() noexcept; 278557da866SHoward Hinnant const_iterator begin() const noexcept; 279557da866SHoward Hinnant const_iterator end() const noexcept; 280557da866SHoward Hinnant const_iterator cbegin() const noexcept; 281557da866SHoward Hinnant const_iterator cend() const noexcept; 2823e519524SHoward Hinnant 2833e519524SHoward Hinnant template <class... Args> 2843e519524SHoward Hinnant iterator emplace(Args&&... args); 2853e519524SHoward Hinnant template <class... Args> 2863e519524SHoward Hinnant iterator emplace_hint(const_iterator position, Args&&... args); 2873e519524SHoward Hinnant iterator insert(const value_type& obj); 2883e519524SHoward Hinnant iterator insert(value_type&& obj); 2893e519524SHoward Hinnant iterator insert(const_iterator hint, const value_type& obj); 2903e519524SHoward Hinnant iterator insert(const_iterator hint, value_type&& obj); 2913e519524SHoward Hinnant template <class InputIterator> 2923e519524SHoward Hinnant void insert(InputIterator first, InputIterator last); 2933e519524SHoward Hinnant void insert(initializer_list<value_type>); 2943e519524SHoward Hinnant 295b0386a51SErik Pilkington node_type extract(const_iterator position); // C++17 296b0386a51SErik Pilkington node_type extract(const key_type& x); // C++17 297b0386a51SErik Pilkington iterator insert(node_type&& nh); // C++17 298b0386a51SErik Pilkington iterator insert(const_iterator hint, node_type&& nh); // C++17 299b0386a51SErik Pilkington 3003e519524SHoward Hinnant iterator erase(const_iterator position); 301ec392968SMarshall Clow iterator erase(iterator position); // C++14 3023e519524SHoward Hinnant size_type erase(const key_type& k); 3033e519524SHoward Hinnant iterator erase(const_iterator first, const_iterator last); 304557da866SHoward Hinnant void clear() noexcept; 3053e519524SHoward Hinnant 3065c4e07aeSErik Pilkington template<class H2, class P2> 3075c4e07aeSErik Pilkington void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17 3085c4e07aeSErik Pilkington template<class H2, class P2> 3095c4e07aeSErik Pilkington void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17 3105c4e07aeSErik Pilkington template<class H2, class P2> 3115c4e07aeSErik Pilkington void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17 3125c4e07aeSErik Pilkington template<class H2, class P2> 3135c4e07aeSErik Pilkington void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17 3145c4e07aeSErik Pilkington 315557da866SHoward Hinnant void swap(unordered_multiset&) 316e3fbe143SMarshall Clow noexcept(allocator_traits<Allocator>::is_always_equal::value && 317e3fbe143SMarshall Clow noexcept(swap(declval<hasher&>(), declval<hasher&>())) && 318e3fbe143SMarshall Clow noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17 3193e519524SHoward Hinnant 3203e519524SHoward Hinnant hasher hash_function() const; 3213e519524SHoward Hinnant key_equal key_eq() const; 3223e519524SHoward Hinnant 3233e519524SHoward Hinnant iterator find(const key_type& k); 3243e519524SHoward Hinnant const_iterator find(const key_type& k) const; 325e5ec94a1SRuslan Arutyunyan template<typename K> 326e5ec94a1SRuslan Arutyunyan iterator find(const K& x); // C++20 327e5ec94a1SRuslan Arutyunyan template<typename K> 328e5ec94a1SRuslan Arutyunyan const_iterator find(const K& x) const; // C++20 3293e519524SHoward Hinnant size_type count(const key_type& k) const; 330e5ec94a1SRuslan Arutyunyan template<typename K> 331e5ec94a1SRuslan Arutyunyan size_type count(const K& k) const; // C++20 332a17b1aedSZoe Carver bool contains(const key_type& k) const; // C++20 333e5ec94a1SRuslan Arutyunyan template<typename K> 334e5ec94a1SRuslan Arutyunyan bool contains(const K& k) const; // C++20 3353e519524SHoward Hinnant pair<iterator, iterator> equal_range(const key_type& k); 3363e519524SHoward Hinnant pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 337e5ec94a1SRuslan Arutyunyan template<typename K> 338e5ec94a1SRuslan Arutyunyan pair<iterator, iterator> equal_range(const K& k); // C++20 339e5ec94a1SRuslan Arutyunyan template<typename K> 340e5ec94a1SRuslan Arutyunyan pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 3413e519524SHoward Hinnant 342557da866SHoward Hinnant size_type bucket_count() const noexcept; 343557da866SHoward Hinnant size_type max_bucket_count() const noexcept; 3443e519524SHoward Hinnant 3453e519524SHoward Hinnant size_type bucket_size(size_type n) const; 3463e519524SHoward Hinnant size_type bucket(const key_type& k) const; 3473e519524SHoward Hinnant 3483e519524SHoward Hinnant local_iterator begin(size_type n); 3493e519524SHoward Hinnant local_iterator end(size_type n); 3503e519524SHoward Hinnant const_local_iterator begin(size_type n) const; 3513e519524SHoward Hinnant const_local_iterator end(size_type n) const; 3523e519524SHoward Hinnant const_local_iterator cbegin(size_type n) const; 3533e519524SHoward Hinnant const_local_iterator cend(size_type n) const; 3543e519524SHoward Hinnant 355557da866SHoward Hinnant float load_factor() const noexcept; 356557da866SHoward Hinnant float max_load_factor() const noexcept; 3573e519524SHoward Hinnant void max_load_factor(float z); 3583e519524SHoward Hinnant void rehash(size_type n); 3593e519524SHoward Hinnant void reserve(size_type n); 3603e519524SHoward Hinnant}; 3613e519524SHoward Hinnant 3623e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 3633e519524SHoward Hinnant void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x, 364557da866SHoward Hinnant unordered_multiset<Value, Hash, Pred, Alloc>& y) 365557da866SHoward Hinnant noexcept(noexcept(x.swap(y))); 3663e519524SHoward Hinnant 367f60c63c0SMarshall Clowtemplate <class K, class T, class H, class P, class A, class Predicate> 3683e895085SMarek Kurdej typename unordered_set<K, T, H, P, A>::size_type 3693e895085SMarek Kurdej erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 370f60c63c0SMarshall Clow 371f60c63c0SMarshall Clowtemplate <class K, class T, class H, class P, class A, class Predicate> 3723e895085SMarek Kurdej typename unordered_multiset<K, T, H, P, A>::size_type 3733e895085SMarek Kurdej erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 374f60c63c0SMarshall Clow 375f60c63c0SMarshall Clow 3763e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 3773e519524SHoward Hinnant bool 3783e519524SHoward Hinnant operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x, 3793e519524SHoward Hinnant const unordered_multiset<Value, Hash, Pred, Alloc>& y); 3803e519524SHoward Hinnant 3813e519524SHoward Hinnanttemplate <class Value, class Hash, class Pred, class Alloc> 3823e519524SHoward Hinnant bool 3833e519524SHoward Hinnant operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x, 3843e519524SHoward Hinnant const unordered_multiset<Value, Hash, Pred, Alloc>& y); 3853e519524SHoward Hinnant} // std 3863e519524SHoward Hinnant 3873e519524SHoward Hinnant*/ 3883e519524SHoward Hinnant 3893e519524SHoward Hinnant#include <__config> 390bfbd73f8SArthur O'Dwyer#include <__debug> 391050b064fSChristopher Di Bella#include <__functional/is_transparent.h> 3923e519524SHoward Hinnant#include <__hash_table> 393b0386a51SErik Pilkington#include <__node_handle> 3946adbc83eSChristopher Di Bella#include <__utility/forward.h> 3952d0f1fa4SArthur O'Dwyer#include <compare> 3963e519524SHoward Hinnant#include <functional> 3972ac6babcSArthur O'Dwyer#include <iterator> // __libcpp_erase_if_container 398f56972e2SMarshall Clow#include <version> 3993e519524SHoward Hinnant 400073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4013e519524SHoward Hinnant#pragma GCC system_header 402073458b1SHoward Hinnant#endif 4033e519524SHoward Hinnant 4043e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 4053e519524SHoward Hinnant 4065c4e07aeSErik Pilkingtontemplate <class _Value, class _Hash, class _Pred, class _Alloc> 4075c4e07aeSErik Pilkingtonclass unordered_multiset; 4085c4e07aeSErik Pilkington 4093e519524SHoward Hinnanttemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, 4103e519524SHoward Hinnant class _Alloc = allocator<_Value> > 411e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS unordered_set 4123e519524SHoward Hinnant{ 4133e519524SHoward Hinnantpublic: 4143e519524SHoward Hinnant // types 4153e519524SHoward Hinnant typedef _Value key_type; 4163e519524SHoward Hinnant typedef key_type value_type; 41709fa1d0eSArthur O'Dwyer typedef __identity_t<_Hash> hasher; 41809fa1d0eSArthur O'Dwyer typedef __identity_t<_Pred> key_equal; 41909fa1d0eSArthur O'Dwyer typedef __identity_t<_Alloc> allocator_type; 4203e519524SHoward Hinnant typedef value_type& reference; 4213e519524SHoward Hinnant typedef const value_type& const_reference; 422b24c8024SHoward Hinnant static_assert((is_same<value_type, typename allocator_type::value_type>::value), 423b24c8024SHoward Hinnant "Invalid allocator::value_type"); 4243e519524SHoward Hinnant 4253e519524SHoward Hinnantprivate: 4263e519524SHoward Hinnant typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; 4273e519524SHoward Hinnant 4283e519524SHoward Hinnant __table __table_; 4293e519524SHoward Hinnant 4303e519524SHoward Hinnantpublic: 4313e519524SHoward Hinnant typedef typename __table::pointer pointer; 4323e519524SHoward Hinnant typedef typename __table::const_pointer const_pointer; 4333e519524SHoward Hinnant typedef typename __table::size_type size_type; 4343e519524SHoward Hinnant typedef typename __table::difference_type difference_type; 4353e519524SHoward Hinnant 4363e519524SHoward Hinnant typedef typename __table::const_iterator iterator; 4373e519524SHoward Hinnant typedef typename __table::const_iterator const_iterator; 4383e519524SHoward Hinnant typedef typename __table::const_local_iterator local_iterator; 4393e519524SHoward Hinnant typedef typename __table::const_local_iterator const_local_iterator; 4403e519524SHoward Hinnant 441b0386a51SErik Pilkington#if _LIBCPP_STD_VER > 14 442b0386a51SErik Pilkington typedef __set_node_handle<typename __table::__node, allocator_type> node_type; 443b0386a51SErik Pilkington typedef __insert_return_type<iterator, node_type> insert_return_type; 444b0386a51SErik Pilkington#endif 445b0386a51SErik Pilkington 4465c4e07aeSErik Pilkington template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 4475c4e07aeSErik Pilkington friend class _LIBCPP_TEMPLATE_VIS unordered_set; 4485c4e07aeSErik Pilkington template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 4495c4e07aeSErik Pilkington friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; 4505c4e07aeSErik Pilkington 451789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 452557da866SHoward Hinnant unordered_set() 453557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 454b24c8024SHoward Hinnant { 45531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 456b24c8024SHoward Hinnant __get_db()->__insert_c(this); 457b24c8024SHoward Hinnant#endif 458b24c8024SHoward Hinnant } 4593e519524SHoward Hinnant explicit unordered_set(size_type __n, const hasher& __hf = hasher(), 4603e519524SHoward Hinnant const key_equal& __eql = key_equal()); 46145b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 46245b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 46345b983c4SMarshall Clow unordered_set(size_type __n, const allocator_type& __a) 46445b983c4SMarshall Clow : unordered_set(__n, hasher(), key_equal(), __a) {} 46545b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 46645b983c4SMarshall Clow unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) 46745b983c4SMarshall Clow : unordered_set(__n, __hf, key_equal(), __a) {} 46845b983c4SMarshall Clow#endif 4693e519524SHoward Hinnant unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, 4703e519524SHoward Hinnant const allocator_type& __a); 4713e519524SHoward Hinnant template <class _InputIterator> 4723e519524SHoward Hinnant unordered_set(_InputIterator __first, _InputIterator __last); 4733e519524SHoward Hinnant template <class _InputIterator> 4743e519524SHoward Hinnant unordered_set(_InputIterator __first, _InputIterator __last, 4753e519524SHoward Hinnant size_type __n, const hasher& __hf = hasher(), 4763e519524SHoward Hinnant const key_equal& __eql = key_equal()); 4773e519524SHoward Hinnant template <class _InputIterator> 4783e519524SHoward Hinnant unordered_set(_InputIterator __first, _InputIterator __last, 4793e519524SHoward Hinnant size_type __n, const hasher& __hf, const key_equal& __eql, 4803e519524SHoward Hinnant const allocator_type& __a); 48145b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 48245b983c4SMarshall Clow template <class _InputIterator> 48345b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 48445b983c4SMarshall Clow unordered_set(_InputIterator __first, _InputIterator __last, 48545b983c4SMarshall Clow size_type __n, const allocator_type& __a) 48645b983c4SMarshall Clow : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} 48745b983c4SMarshall Clow template <class _InputIterator> 48845b983c4SMarshall Clow unordered_set(_InputIterator __first, _InputIterator __last, 48945b983c4SMarshall Clow size_type __n, const hasher& __hf, const allocator_type& __a) 49045b983c4SMarshall Clow : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} 49145b983c4SMarshall Clow#endif 492cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 4933e519524SHoward Hinnant explicit unordered_set(const allocator_type& __a); 4943e519524SHoward Hinnant unordered_set(const unordered_set& __u); 4953e519524SHoward Hinnant unordered_set(const unordered_set& __u, const allocator_type& __a); 496f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 497cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 498557da866SHoward Hinnant unordered_set(unordered_set&& __u) 499557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 5003e519524SHoward Hinnant unordered_set(unordered_set&& __u, const allocator_type& __a); 5013e519524SHoward Hinnant unordered_set(initializer_list<value_type> __il); 5023e519524SHoward Hinnant unordered_set(initializer_list<value_type> __il, size_type __n, 5033e519524SHoward Hinnant const hasher& __hf = hasher(), 5043e519524SHoward Hinnant const key_equal& __eql = key_equal()); 5053e519524SHoward Hinnant unordered_set(initializer_list<value_type> __il, size_type __n, 5063e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql, 5073e519524SHoward Hinnant const allocator_type& __a); 50845b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 50945b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 51045b983c4SMarshall Clow unordered_set(initializer_list<value_type> __il, size_type __n, 51145b983c4SMarshall Clow const allocator_type& __a) 51245b983c4SMarshall Clow : unordered_set(__il, __n, hasher(), key_equal(), __a) {} 51345b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 51445b983c4SMarshall Clow unordered_set(initializer_list<value_type> __il, size_type __n, 51545b983c4SMarshall Clow const hasher& __hf, const allocator_type& __a) 51645b983c4SMarshall Clow : unordered_set(__il, __n, __hf, key_equal(), __a) {} 51745b983c4SMarshall Clow#endif 518f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5197c142fccSLouis Dionne _LIBCPP_INLINE_VISIBILITY 5207c142fccSLouis Dionne ~unordered_set() { 5217c142fccSLouis Dionne static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); 5227c142fccSLouis Dionne } 5237c142fccSLouis Dionne 5245a33687dSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5255a33687dSHoward Hinnant unordered_set& operator=(const unordered_set& __u) 5265a33687dSHoward Hinnant { 5275a33687dSHoward Hinnant __table_ = __u.__table_; 5285a33687dSHoward Hinnant return *this; 5295a33687dSHoward Hinnant } 530f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 531cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 532557da866SHoward Hinnant unordered_set& operator=(unordered_set&& __u) 533557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 534cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5353e519524SHoward Hinnant unordered_set& operator=(initializer_list<value_type> __il); 536f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5373e519524SHoward Hinnant 538789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 539557da866SHoward Hinnant allocator_type get_allocator() const _NOEXCEPT 5403e519524SHoward Hinnant {return allocator_type(__table_.__node_alloc());} 5413e519524SHoward Hinnant 54272c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 543557da866SHoward Hinnant bool empty() const _NOEXCEPT {return __table_.size() == 0;} 544789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 545557da866SHoward Hinnant size_type size() const _NOEXCEPT {return __table_.size();} 546789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 547557da866SHoward Hinnant size_type max_size() const _NOEXCEPT {return __table_.max_size();} 5483e519524SHoward Hinnant 549789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 550557da866SHoward Hinnant iterator begin() _NOEXCEPT {return __table_.begin();} 551789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 552557da866SHoward Hinnant iterator end() _NOEXCEPT {return __table_.end();} 553789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 554557da866SHoward Hinnant const_iterator begin() const _NOEXCEPT {return __table_.begin();} 555789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 556557da866SHoward Hinnant const_iterator end() const _NOEXCEPT {return __table_.end();} 557789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 558557da866SHoward Hinnant const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 559789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 560557da866SHoward Hinnant const_iterator cend() const _NOEXCEPT {return __table_.end();} 5613e519524SHoward Hinnant 562f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5633e519524SHoward Hinnant template <class... _Args> 564789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5653e519524SHoward Hinnant pair<iterator, bool> emplace(_Args&&... __args) 566ce48a113SHoward Hinnant {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} 5673e519524SHoward Hinnant template <class... _Args> 568789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 56931e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 570b24c8024SHoward Hinnant iterator emplace_hint(const_iterator __p, _Args&&... __args) 571b24c8024SHoward Hinnant { 572b24c8024SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 573b24c8024SHoward Hinnant "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not" 574b24c8024SHoward Hinnant " referring to this unordered_set"); 575b24c8024SHoward Hinnant return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; 576b24c8024SHoward Hinnant } 577b24c8024SHoward Hinnant#else 5783e519524SHoward Hinnant iterator emplace_hint(const_iterator, _Args&&... __args) 579ce48a113SHoward Hinnant {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;} 580b24c8024SHoward Hinnant#endif 581f0f86ef9SEric Fiselier 582789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5833e519524SHoward Hinnant pair<iterator, bool> insert(value_type&& __x) 584ce48a113SHoward Hinnant {return __table_.__insert_unique(_VSTD::move(__x));} 585789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 58631e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 587b24c8024SHoward Hinnant iterator insert(const_iterator __p, value_type&& __x) 588b24c8024SHoward Hinnant { 589b24c8024SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 590b24c8024SHoward Hinnant "unordered_set::insert(const_iterator, value_type&&) called with an iterator not" 591b24c8024SHoward Hinnant " referring to this unordered_set"); 592b24c8024SHoward Hinnant return insert(_VSTD::move(__x)).first; 593b24c8024SHoward Hinnant } 594b24c8024SHoward Hinnant#else 5953e519524SHoward Hinnant iterator insert(const_iterator, value_type&& __x) 596ce48a113SHoward Hinnant {return insert(_VSTD::move(__x)).first;} 597b24c8024SHoward Hinnant#endif 598789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5993e519524SHoward Hinnant void insert(initializer_list<value_type> __il) 6003e519524SHoward Hinnant {insert(__il.begin(), __il.end());} 601f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 602f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 603f0f86ef9SEric Fiselier pair<iterator, bool> insert(const value_type& __x) 604f0f86ef9SEric Fiselier {return __table_.__insert_unique(__x);} 605f0f86ef9SEric Fiselier 606f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 60731e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 608f0f86ef9SEric Fiselier iterator insert(const_iterator __p, const value_type& __x) 609f0f86ef9SEric Fiselier { 610f0f86ef9SEric Fiselier _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 611f0f86ef9SEric Fiselier "unordered_set::insert(const_iterator, const value_type&) called with an iterator not" 612f0f86ef9SEric Fiselier " referring to this unordered_set"); 613f0f86ef9SEric Fiselier return insert(__x).first; 614f0f86ef9SEric Fiselier } 615f0f86ef9SEric Fiselier#else 616f0f86ef9SEric Fiselier iterator insert(const_iterator, const value_type& __x) 617f0f86ef9SEric Fiselier {return insert(__x).first;} 618f0f86ef9SEric Fiselier#endif 619f0f86ef9SEric Fiselier template <class _InputIterator> 620f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 621f0f86ef9SEric Fiselier void insert(_InputIterator __first, _InputIterator __last); 6223e519524SHoward Hinnant 623789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6243e519524SHoward Hinnant iterator erase(const_iterator __p) {return __table_.erase(__p);} 625789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6263e519524SHoward Hinnant size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 627789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6283e519524SHoward Hinnant iterator erase(const_iterator __first, const_iterator __last) 6293e519524SHoward Hinnant {return __table_.erase(__first, __last);} 630789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 631557da866SHoward Hinnant void clear() _NOEXCEPT {__table_.clear();} 6323e519524SHoward Hinnant 633b0386a51SErik Pilkington#if _LIBCPP_STD_VER > 14 634b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 635b0386a51SErik Pilkington insert_return_type insert(node_type&& __nh) 636b0386a51SErik Pilkington { 637b0386a51SErik Pilkington _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 638b0386a51SErik Pilkington "node_type with incompatible allocator passed to unordered_set::insert()"); 639b0386a51SErik Pilkington return __table_.template __node_handle_insert_unique< 640b0386a51SErik Pilkington node_type, insert_return_type>(_VSTD::move(__nh)); 641b0386a51SErik Pilkington } 642b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 643b0386a51SErik Pilkington iterator insert(const_iterator __h, node_type&& __nh) 644b0386a51SErik Pilkington { 645b0386a51SErik Pilkington _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 646b0386a51SErik Pilkington "node_type with incompatible allocator passed to unordered_set::insert()"); 647b0386a51SErik Pilkington return __table_.template __node_handle_insert_unique<node_type>( 648b0386a51SErik Pilkington __h, _VSTD::move(__nh)); 649b0386a51SErik Pilkington } 650b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 651b0386a51SErik Pilkington node_type extract(key_type const& __key) 652b0386a51SErik Pilkington { 653b0386a51SErik Pilkington return __table_.template __node_handle_extract<node_type>(__key); 654b0386a51SErik Pilkington } 655b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 656b0386a51SErik Pilkington node_type extract(const_iterator __it) 657b0386a51SErik Pilkington { 658b0386a51SErik Pilkington return __table_.template __node_handle_extract<node_type>(__it); 659b0386a51SErik Pilkington } 6605c4e07aeSErik Pilkington 6615c4e07aeSErik Pilkington template<class _H2, class _P2> 6625c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 6635c4e07aeSErik Pilkington void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) 6645c4e07aeSErik Pilkington { 6655c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 6665c4e07aeSErik Pilkington "merging container with incompatible allocator"); 6675c4e07aeSErik Pilkington __table_.__node_handle_merge_unique(__source.__table_); 6685c4e07aeSErik Pilkington } 6695c4e07aeSErik Pilkington template<class _H2, class _P2> 6705c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 6715c4e07aeSErik Pilkington void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) 6725c4e07aeSErik Pilkington { 6735c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 6745c4e07aeSErik Pilkington "merging container with incompatible allocator"); 6755c4e07aeSErik Pilkington __table_.__node_handle_merge_unique(__source.__table_); 6765c4e07aeSErik Pilkington } 6775c4e07aeSErik Pilkington template<class _H2, class _P2> 6785c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 6795c4e07aeSErik Pilkington void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) 6805c4e07aeSErik Pilkington { 6815c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 6825c4e07aeSErik Pilkington "merging container with incompatible allocator"); 6835c4e07aeSErik Pilkington __table_.__node_handle_merge_unique(__source.__table_); 6845c4e07aeSErik Pilkington } 6855c4e07aeSErik Pilkington template<class _H2, class _P2> 6865c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 6875c4e07aeSErik Pilkington void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) 6885c4e07aeSErik Pilkington { 6895c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 6905c4e07aeSErik Pilkington "merging container with incompatible allocator"); 6915c4e07aeSErik Pilkington __table_.__node_handle_merge_unique(__source.__table_); 6925c4e07aeSErik Pilkington } 693b0386a51SErik Pilkington#endif 694b0386a51SErik Pilkington 695789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 696557da866SHoward Hinnant void swap(unordered_set& __u) 697557da866SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 698557da866SHoward Hinnant {__table_.swap(__u.__table_);} 6993e519524SHoward Hinnant 700789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7013e519524SHoward Hinnant hasher hash_function() const {return __table_.hash_function();} 702789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7033e519524SHoward Hinnant key_equal key_eq() const {return __table_.key_eq();} 7043e519524SHoward Hinnant 705789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7063e519524SHoward Hinnant iterator find(const key_type& __k) {return __table_.find(__k);} 707789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7083e519524SHoward Hinnant const_iterator find(const key_type& __k) const {return __table_.find(__k);} 709e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 710e5ec94a1SRuslan Arutyunyan template <typename _K2> 711e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 712*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> 713e5ec94a1SRuslan Arutyunyan find(const _K2& __k) {return __table_.find(__k);} 714e5ec94a1SRuslan Arutyunyan template <typename _K2> 715e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 716*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> 717e5ec94a1SRuslan Arutyunyan find(const _K2& __k) const {return __table_.find(__k);} 718e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 719789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7203e519524SHoward Hinnant size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 721a17b1aedSZoe Carver #if _LIBCPP_STD_VER > 17 722e5ec94a1SRuslan Arutyunyan template <typename _K2> 723e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 724*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> 725e5ec94a1SRuslan Arutyunyan count(const _K2& __k) const {return __table_.__count_unique(__k);} 726e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 727e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 728a17b1aedSZoe Carver _LIBCPP_INLINE_VISIBILITY 729a17b1aedSZoe Carver bool contains(const key_type& __k) const {return find(__k) != end();} 730e5ec94a1SRuslan Arutyunyan 731e5ec94a1SRuslan Arutyunyan template <typename _K2> 732e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 733*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> 734e5ec94a1SRuslan Arutyunyan contains(const _K2& __k) const {return find(__k) != end();} 735a17b1aedSZoe Carver #endif // _LIBCPP_STD_VER > 17 736789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7373e519524SHoward Hinnant pair<iterator, iterator> equal_range(const key_type& __k) 7383e519524SHoward Hinnant {return __table_.__equal_range_unique(__k);} 739789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7403e519524SHoward Hinnant pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 7413e519524SHoward Hinnant {return __table_.__equal_range_unique(__k);} 742e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 743e5ec94a1SRuslan Arutyunyan template <typename _K2> 744e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 745*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> 746e5ec94a1SRuslan Arutyunyan equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);} 747e5ec94a1SRuslan Arutyunyan template <typename _K2> 748e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 749*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> 750e5ec94a1SRuslan Arutyunyan equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);} 751e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 7523e519524SHoward Hinnant 753789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 754557da866SHoward Hinnant size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 755789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 756557da866SHoward Hinnant size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} 7573e519524SHoward Hinnant 758789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7593e519524SHoward Hinnant size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} 760789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7613e519524SHoward Hinnant size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 7623e519524SHoward Hinnant 763789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7643e519524SHoward Hinnant local_iterator begin(size_type __n) {return __table_.begin(__n);} 765789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7663e519524SHoward Hinnant local_iterator end(size_type __n) {return __table_.end(__n);} 767789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7683e519524SHoward Hinnant const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 769789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7703e519524SHoward Hinnant const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 771789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7723e519524SHoward Hinnant const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 773789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7743e519524SHoward Hinnant const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 7753e519524SHoward Hinnant 776789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 777557da866SHoward Hinnant float load_factor() const _NOEXCEPT {return __table_.load_factor();} 778789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 779557da866SHoward Hinnant float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 780789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7813e519524SHoward Hinnant void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 782789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7833e519524SHoward Hinnant void rehash(size_type __n) {__table_.rehash(__n);} 784789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7853e519524SHoward Hinnant void reserve(size_type __n) {__table_.reserve(__n);} 786b24c8024SHoward Hinnant 78731e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 788b24c8024SHoward Hinnant 789b24c8024SHoward Hinnant bool __dereferenceable(const const_iterator* __i) const 790b24c8024SHoward Hinnant {return __table_.__dereferenceable(__i);} 791b24c8024SHoward Hinnant bool __decrementable(const const_iterator* __i) const 792b24c8024SHoward Hinnant {return __table_.__decrementable(__i);} 793b24c8024SHoward Hinnant bool __addable(const const_iterator* __i, ptrdiff_t __n) const 794b24c8024SHoward Hinnant {return __table_.__addable(__i, __n);} 795b24c8024SHoward Hinnant bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const 796b24c8024SHoward Hinnant {return __table_.__addable(__i, __n);} 797b24c8024SHoward Hinnant 79831e82037SLouis Dionne#endif // _LIBCPP_DEBUG_LEVEL == 2 799b24c8024SHoward Hinnant 8003e519524SHoward Hinnant}; 8013e519524SHoward Hinnant 80201666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 803296a8010SLouis Dionnetemplate<class _InputIterator, 804296a8010SLouis Dionne class _Hash = hash<__iter_value_type<_InputIterator>>, 805296a8010SLouis Dionne class _Pred = equal_to<__iter_value_type<_InputIterator>>, 806296a8010SLouis Dionne class _Allocator = allocator<__iter_value_type<_InputIterator>>, 807*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 808*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 809*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Pred>::value>, 810*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 811296a8010SLouis Dionneunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, 812296a8010SLouis Dionne _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 813296a8010SLouis Dionne -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; 814296a8010SLouis Dionne 815296a8010SLouis Dionnetemplate<class _Tp, class _Hash = hash<_Tp>, 816296a8010SLouis Dionne class _Pred = equal_to<_Tp>, 817296a8010SLouis Dionne class _Allocator = allocator<_Tp>, 818*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 819*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 820*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Pred>::value>, 821*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 822296a8010SLouis Dionneunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, 823296a8010SLouis Dionne _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 824296a8010SLouis Dionne -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; 825296a8010SLouis Dionne 826296a8010SLouis Dionnetemplate<class _InputIterator, class _Allocator, 827*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 828296a8010SLouis Dionneunordered_set(_InputIterator, _InputIterator, 829296a8010SLouis Dionne typename allocator_traits<_Allocator>::size_type, _Allocator) 830296a8010SLouis Dionne -> unordered_set<__iter_value_type<_InputIterator>, 831296a8010SLouis Dionne hash<__iter_value_type<_InputIterator>>, 832296a8010SLouis Dionne equal_to<__iter_value_type<_InputIterator>>, 833296a8010SLouis Dionne _Allocator>; 834296a8010SLouis Dionne 835296a8010SLouis Dionnetemplate<class _InputIterator, class _Hash, class _Allocator, 836*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 837*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 838*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 839296a8010SLouis Dionneunordered_set(_InputIterator, _InputIterator, 840296a8010SLouis Dionne typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 841296a8010SLouis Dionne -> unordered_set<__iter_value_type<_InputIterator>, _Hash, 842296a8010SLouis Dionne equal_to<__iter_value_type<_InputIterator>>, 843296a8010SLouis Dionne _Allocator>; 844296a8010SLouis Dionne 845296a8010SLouis Dionnetemplate<class _Tp, class _Allocator, 846*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 847296a8010SLouis Dionneunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) 848296a8010SLouis Dionne -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; 849296a8010SLouis Dionne 850296a8010SLouis Dionnetemplate<class _Tp, class _Hash, class _Allocator, 851*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 852*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 853*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 854296a8010SLouis Dionneunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 855296a8010SLouis Dionne -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; 856296a8010SLouis Dionne#endif 857296a8010SLouis Dionne 8583e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 8593e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, 8603e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql) 8613e519524SHoward Hinnant : __table_(__hf, __eql) 8623e519524SHoward Hinnant{ 86331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 864b24c8024SHoward Hinnant __get_db()->__insert_c(this); 865b24c8024SHoward Hinnant#endif 8663e519524SHoward Hinnant __table_.rehash(__n); 8673e519524SHoward Hinnant} 8683e519524SHoward Hinnant 8693e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 8703e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, 8713e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 8723e519524SHoward Hinnant : __table_(__hf, __eql, __a) 8733e519524SHoward Hinnant{ 87431e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 875b24c8024SHoward Hinnant __get_db()->__insert_c(this); 876b24c8024SHoward Hinnant#endif 8773e519524SHoward Hinnant __table_.rehash(__n); 8783e519524SHoward Hinnant} 8793e519524SHoward Hinnant 8803e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 8813e519524SHoward Hinnanttemplate <class _InputIterator> 8823e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 8833e519524SHoward Hinnant _InputIterator __first, _InputIterator __last) 8843e519524SHoward Hinnant{ 88531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 886b24c8024SHoward Hinnant __get_db()->__insert_c(this); 887b24c8024SHoward Hinnant#endif 8883e519524SHoward Hinnant insert(__first, __last); 8893e519524SHoward Hinnant} 8903e519524SHoward Hinnant 8913e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 8923e519524SHoward Hinnanttemplate <class _InputIterator> 8933e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 8943e519524SHoward Hinnant _InputIterator __first, _InputIterator __last, size_type __n, 8953e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql) 8963e519524SHoward Hinnant : __table_(__hf, __eql) 8973e519524SHoward Hinnant{ 89831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 899b24c8024SHoward Hinnant __get_db()->__insert_c(this); 900b24c8024SHoward Hinnant#endif 9013e519524SHoward Hinnant __table_.rehash(__n); 9023e519524SHoward Hinnant insert(__first, __last); 9033e519524SHoward Hinnant} 9043e519524SHoward Hinnant 9053e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 9063e519524SHoward Hinnanttemplate <class _InputIterator> 9073e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9083e519524SHoward Hinnant _InputIterator __first, _InputIterator __last, size_type __n, 9093e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 9103e519524SHoward Hinnant : __table_(__hf, __eql, __a) 9113e519524SHoward Hinnant{ 91231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 913b24c8024SHoward Hinnant __get_db()->__insert_c(this); 914b24c8024SHoward Hinnant#endif 9153e519524SHoward Hinnant __table_.rehash(__n); 9163e519524SHoward Hinnant insert(__first, __last); 9173e519524SHoward Hinnant} 9183e519524SHoward Hinnant 9193e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 920cd31b434SEvgeniy Stepanovinline 9213e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9223e519524SHoward Hinnant const allocator_type& __a) 9233e519524SHoward Hinnant : __table_(__a) 9243e519524SHoward Hinnant{ 92531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 926b24c8024SHoward Hinnant __get_db()->__insert_c(this); 927b24c8024SHoward Hinnant#endif 9283e519524SHoward Hinnant} 9293e519524SHoward Hinnant 9303e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 9313e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9323e519524SHoward Hinnant const unordered_set& __u) 9333e519524SHoward Hinnant : __table_(__u.__table_) 9343e519524SHoward Hinnant{ 93531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 936b24c8024SHoward Hinnant __get_db()->__insert_c(this); 937b24c8024SHoward Hinnant#endif 9383e519524SHoward Hinnant __table_.rehash(__u.bucket_count()); 9393e519524SHoward Hinnant insert(__u.begin(), __u.end()); 9403e519524SHoward Hinnant} 9413e519524SHoward Hinnant 9423e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 9433e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9443e519524SHoward Hinnant const unordered_set& __u, const allocator_type& __a) 9453e519524SHoward Hinnant : __table_(__u.__table_, __a) 9463e519524SHoward Hinnant{ 94731e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 948b24c8024SHoward Hinnant __get_db()->__insert_c(this); 949b24c8024SHoward Hinnant#endif 9503e519524SHoward Hinnant __table_.rehash(__u.bucket_count()); 9513e519524SHoward Hinnant insert(__u.begin(), __u.end()); 9523e519524SHoward Hinnant} 9533e519524SHoward Hinnant 954f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 9553e519524SHoward Hinnant 9563e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 957cd31b434SEvgeniy Stepanovinline 9583e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9593e519524SHoward Hinnant unordered_set&& __u) 960557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 961ce48a113SHoward Hinnant : __table_(_VSTD::move(__u.__table_)) 9623e519524SHoward Hinnant{ 96331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 964b24c8024SHoward Hinnant __get_db()->__insert_c(this); 965b24c8024SHoward Hinnant __get_db()->swap(this, &__u); 966b24c8024SHoward Hinnant#endif 9673e519524SHoward Hinnant} 9683e519524SHoward Hinnant 9693e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 9703e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9713e519524SHoward Hinnant unordered_set&& __u, const allocator_type& __a) 972ce48a113SHoward Hinnant : __table_(_VSTD::move(__u.__table_), __a) 9733e519524SHoward Hinnant{ 97431e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 975b24c8024SHoward Hinnant __get_db()->__insert_c(this); 976b24c8024SHoward Hinnant#endif 9773e519524SHoward Hinnant if (__a != __u.get_allocator()) 9783e519524SHoward Hinnant { 9793e519524SHoward Hinnant iterator __i = __u.begin(); 9803e519524SHoward Hinnant while (__u.size() != 0) 981ce48a113SHoward Hinnant __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); 9823e519524SHoward Hinnant } 98331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 984b24c8024SHoward Hinnant else 985b24c8024SHoward Hinnant __get_db()->swap(this, &__u); 986b24c8024SHoward Hinnant#endif 9873e519524SHoward Hinnant} 9883e519524SHoward Hinnant 9893e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 9903e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 9913e519524SHoward Hinnant initializer_list<value_type> __il) 9923e519524SHoward Hinnant{ 99331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 994b24c8024SHoward Hinnant __get_db()->__insert_c(this); 995b24c8024SHoward Hinnant#endif 9963e519524SHoward Hinnant insert(__il.begin(), __il.end()); 9973e519524SHoward Hinnant} 9983e519524SHoward Hinnant 9993e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10003e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 10013e519524SHoward Hinnant initializer_list<value_type> __il, size_type __n, const hasher& __hf, 10023e519524SHoward Hinnant const key_equal& __eql) 10033e519524SHoward Hinnant : __table_(__hf, __eql) 10043e519524SHoward Hinnant{ 100531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1006b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1007b24c8024SHoward Hinnant#endif 10083e519524SHoward Hinnant __table_.rehash(__n); 10093e519524SHoward Hinnant insert(__il.begin(), __il.end()); 10103e519524SHoward Hinnant} 10113e519524SHoward Hinnant 10123e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10133e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( 10143e519524SHoward Hinnant initializer_list<value_type> __il, size_type __n, const hasher& __hf, 10153e519524SHoward Hinnant const key_equal& __eql, const allocator_type& __a) 10163e519524SHoward Hinnant : __table_(__hf, __eql, __a) 10173e519524SHoward Hinnant{ 101831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1019b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1020b24c8024SHoward Hinnant#endif 10213e519524SHoward Hinnant __table_.rehash(__n); 10223e519524SHoward Hinnant insert(__il.begin(), __il.end()); 10233e519524SHoward Hinnant} 10243e519524SHoward Hinnant 10253e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1026cd31b434SEvgeniy Stepanovinline 10273e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>& 10283e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u) 1029557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 10303e519524SHoward Hinnant{ 1031ce48a113SHoward Hinnant __table_ = _VSTD::move(__u.__table_); 10323e519524SHoward Hinnant return *this; 10333e519524SHoward Hinnant} 10343e519524SHoward Hinnant 10353e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1036cd31b434SEvgeniy Stepanovinline 10373e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>& 10383e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=( 10393e519524SHoward Hinnant initializer_list<value_type> __il) 10403e519524SHoward Hinnant{ 10413e519524SHoward Hinnant __table_.__assign_unique(__il.begin(), __il.end()); 10423e519524SHoward Hinnant return *this; 10433e519524SHoward Hinnant} 10443e519524SHoward Hinnant 1045f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 104654976f26SHoward Hinnant 10473e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10483e519524SHoward Hinnanttemplate <class _InputIterator> 1049cd31b434SEvgeniy Stepanovinline 10503e519524SHoward Hinnantvoid 10513e519524SHoward Hinnantunordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 10523e519524SHoward Hinnant _InputIterator __last) 10533e519524SHoward Hinnant{ 10543e519524SHoward Hinnant for (; __first != __last; ++__first) 10553e519524SHoward Hinnant __table_.__insert_unique(*__first); 10563e519524SHoward Hinnant} 10573e519524SHoward Hinnant 10583e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1059789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 10603e519524SHoward Hinnantvoid 10613e519524SHoward Hinnantswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 10623e519524SHoward Hinnant unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 1063557da866SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 10643e519524SHoward Hinnant{ 10653e519524SHoward Hinnant __x.swap(__y); 10663e519524SHoward Hinnant} 10673e519524SHoward Hinnant 1068f60c63c0SMarshall Clow#if _LIBCPP_STD_VER > 17 10693e895085SMarek Kurdejtemplate <class _Value, class _Hash, class _Pred, class _Alloc, 10703e895085SMarek Kurdej class _Predicate> 1071f60c63c0SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY 10723e895085SMarek Kurdej typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type 10733e895085SMarek Kurdej erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, 10743e895085SMarek Kurdej _Predicate __pred) { 10752ac6babcSArthur O'Dwyer return _VSTD::__libcpp_erase_if_container(__c, __pred); 10763e895085SMarek Kurdej} 1077f60c63c0SMarshall Clow#endif 1078f60c63c0SMarshall Clow 10793e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 10803e519524SHoward Hinnantbool 10813e519524SHoward Hinnantoperator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 10823e519524SHoward Hinnant const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 10833e519524SHoward Hinnant{ 10843e519524SHoward Hinnant if (__x.size() != __y.size()) 10853e519524SHoward Hinnant return false; 10863e519524SHoward Hinnant typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator 10873e519524SHoward Hinnant const_iterator; 10883e519524SHoward Hinnant for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 10893e519524SHoward Hinnant __i != __ex; ++__i) 10903e519524SHoward Hinnant { 10913e519524SHoward Hinnant const_iterator __j = __y.find(*__i); 10923e519524SHoward Hinnant if (__j == __ey || !(*__i == *__j)) 10933e519524SHoward Hinnant return false; 10943e519524SHoward Hinnant } 10953e519524SHoward Hinnant return true; 10963e519524SHoward Hinnant} 10973e519524SHoward Hinnant 10983e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1099789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 11003e519524SHoward Hinnantbool 11013e519524SHoward Hinnantoperator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, 11023e519524SHoward Hinnant const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) 11033e519524SHoward Hinnant{ 11043e519524SHoward Hinnant return !(__x == __y); 11053e519524SHoward Hinnant} 11063e519524SHoward Hinnant 11073e519524SHoward Hinnanttemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, 11083e519524SHoward Hinnant class _Alloc = allocator<_Value> > 1109e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS unordered_multiset 11103e519524SHoward Hinnant{ 11113e519524SHoward Hinnantpublic: 11123e519524SHoward Hinnant // types 11133e519524SHoward Hinnant typedef _Value key_type; 11143e519524SHoward Hinnant typedef key_type value_type; 111509fa1d0eSArthur O'Dwyer typedef __identity_t<_Hash> hasher; 111609fa1d0eSArthur O'Dwyer typedef __identity_t<_Pred> key_equal; 111709fa1d0eSArthur O'Dwyer typedef __identity_t<_Alloc> allocator_type; 11183e519524SHoward Hinnant typedef value_type& reference; 11193e519524SHoward Hinnant typedef const value_type& const_reference; 1120b24c8024SHoward Hinnant static_assert((is_same<value_type, typename allocator_type::value_type>::value), 1121b24c8024SHoward Hinnant "Invalid allocator::value_type"); 11223e519524SHoward Hinnant 11233e519524SHoward Hinnantprivate: 11243e519524SHoward Hinnant typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; 11253e519524SHoward Hinnant 11263e519524SHoward Hinnant __table __table_; 11273e519524SHoward Hinnant 11283e519524SHoward Hinnantpublic: 11293e519524SHoward Hinnant typedef typename __table::pointer pointer; 11303e519524SHoward Hinnant typedef typename __table::const_pointer const_pointer; 11313e519524SHoward Hinnant typedef typename __table::size_type size_type; 11323e519524SHoward Hinnant typedef typename __table::difference_type difference_type; 11333e519524SHoward Hinnant 11343e519524SHoward Hinnant typedef typename __table::const_iterator iterator; 11353e519524SHoward Hinnant typedef typename __table::const_iterator const_iterator; 11363e519524SHoward Hinnant typedef typename __table::const_local_iterator local_iterator; 11373e519524SHoward Hinnant typedef typename __table::const_local_iterator const_local_iterator; 11383e519524SHoward Hinnant 1139b0386a51SErik Pilkington#if _LIBCPP_STD_VER > 14 1140b0386a51SErik Pilkington typedef __set_node_handle<typename __table::__node, allocator_type> node_type; 1141b0386a51SErik Pilkington#endif 1142b0386a51SErik Pilkington 11435c4e07aeSErik Pilkington template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 11445c4e07aeSErik Pilkington friend class _LIBCPP_TEMPLATE_VIS unordered_set; 11455c4e07aeSErik Pilkington template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> 11465c4e07aeSErik Pilkington friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; 11475c4e07aeSErik Pilkington 1148789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1149557da866SHoward Hinnant unordered_multiset() 1150557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 1151b24c8024SHoward Hinnant { 115231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1153b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1154b24c8024SHoward Hinnant#endif 1155b24c8024SHoward Hinnant } 11563e519524SHoward Hinnant explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(), 11573e519524SHoward Hinnant const key_equal& __eql = key_equal()); 11583e519524SHoward Hinnant unordered_multiset(size_type __n, const hasher& __hf, 11593e519524SHoward Hinnant const key_equal& __eql, const allocator_type& __a); 116045b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 116145b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 116245b983c4SMarshall Clow unordered_multiset(size_type __n, const allocator_type& __a) 116345b983c4SMarshall Clow : unordered_multiset(__n, hasher(), key_equal(), __a) {} 116445b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 116545b983c4SMarshall Clow unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) 116645b983c4SMarshall Clow : unordered_multiset(__n, __hf, key_equal(), __a) {} 116745b983c4SMarshall Clow#endif 11683e519524SHoward Hinnant template <class _InputIterator> 11693e519524SHoward Hinnant unordered_multiset(_InputIterator __first, _InputIterator __last); 11703e519524SHoward Hinnant template <class _InputIterator> 11713e519524SHoward Hinnant unordered_multiset(_InputIterator __first, _InputIterator __last, 11723e519524SHoward Hinnant size_type __n, const hasher& __hf = hasher(), 11733e519524SHoward Hinnant const key_equal& __eql = key_equal()); 11743e519524SHoward Hinnant template <class _InputIterator> 11753e519524SHoward Hinnant unordered_multiset(_InputIterator __first, _InputIterator __last, 11763e519524SHoward Hinnant size_type __n , const hasher& __hf, 11773e519524SHoward Hinnant const key_equal& __eql, const allocator_type& __a); 117845b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 117945b983c4SMarshall Clow template <class _InputIterator> 118045b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 118145b983c4SMarshall Clow unordered_multiset(_InputIterator __first, _InputIterator __last, 118245b983c4SMarshall Clow size_type __n, const allocator_type& __a) 118345b983c4SMarshall Clow : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} 118445b983c4SMarshall Clow template <class _InputIterator> 118545b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 118645b983c4SMarshall Clow unordered_multiset(_InputIterator __first, _InputIterator __last, 118745b983c4SMarshall Clow size_type __n, const hasher& __hf, const allocator_type& __a) 118845b983c4SMarshall Clow : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} 118945b983c4SMarshall Clow#endif 1190cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 11913e519524SHoward Hinnant explicit unordered_multiset(const allocator_type& __a); 11923e519524SHoward Hinnant unordered_multiset(const unordered_multiset& __u); 11933e519524SHoward Hinnant unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); 1194f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 1195cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 1196557da866SHoward Hinnant unordered_multiset(unordered_multiset&& __u) 1197557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 11983e519524SHoward Hinnant unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); 11993e519524SHoward Hinnant unordered_multiset(initializer_list<value_type> __il); 12003e519524SHoward Hinnant unordered_multiset(initializer_list<value_type> __il, size_type __n, 12013e519524SHoward Hinnant const hasher& __hf = hasher(), 12023e519524SHoward Hinnant const key_equal& __eql = key_equal()); 12033e519524SHoward Hinnant unordered_multiset(initializer_list<value_type> __il, size_type __n, 12043e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql, 12053e519524SHoward Hinnant const allocator_type& __a); 120645b983c4SMarshall Clow#if _LIBCPP_STD_VER > 11 120745b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 120845b983c4SMarshall Clow unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) 120945b983c4SMarshall Clow : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} 121045b983c4SMarshall Clow inline _LIBCPP_INLINE_VISIBILITY 121145b983c4SMarshall Clow unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) 121245b983c4SMarshall Clow : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} 121345b983c4SMarshall Clow#endif 1214f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 12157c142fccSLouis Dionne _LIBCPP_INLINE_VISIBILITY 12167c142fccSLouis Dionne ~unordered_multiset() { 12177c142fccSLouis Dionne static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); 12187c142fccSLouis Dionne } 12197c142fccSLouis Dionne 12205a33687dSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12215a33687dSHoward Hinnant unordered_multiset& operator=(const unordered_multiset& __u) 12225a33687dSHoward Hinnant { 12235a33687dSHoward Hinnant __table_ = __u.__table_; 12245a33687dSHoward Hinnant return *this; 12255a33687dSHoward Hinnant } 1226f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 1227cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 1228557da866SHoward Hinnant unordered_multiset& operator=(unordered_multiset&& __u) 1229557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 12303e519524SHoward Hinnant unordered_multiset& operator=(initializer_list<value_type> __il); 1231f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 12323e519524SHoward Hinnant 1233789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1234557da866SHoward Hinnant allocator_type get_allocator() const _NOEXCEPT 12353e519524SHoward Hinnant {return allocator_type(__table_.__node_alloc());} 12363e519524SHoward Hinnant 123772c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 1238557da866SHoward Hinnant bool empty() const _NOEXCEPT {return __table_.size() == 0;} 1239789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1240557da866SHoward Hinnant size_type size() const _NOEXCEPT {return __table_.size();} 1241789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1242557da866SHoward Hinnant size_type max_size() const _NOEXCEPT {return __table_.max_size();} 12433e519524SHoward Hinnant 1244789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1245557da866SHoward Hinnant iterator begin() _NOEXCEPT {return __table_.begin();} 1246789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1247557da866SHoward Hinnant iterator end() _NOEXCEPT {return __table_.end();} 1248789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1249557da866SHoward Hinnant const_iterator begin() const _NOEXCEPT {return __table_.begin();} 1250789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1251557da866SHoward Hinnant const_iterator end() const _NOEXCEPT {return __table_.end();} 1252789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1253557da866SHoward Hinnant const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 1254789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1255557da866SHoward Hinnant const_iterator cend() const _NOEXCEPT {return __table_.end();} 12563e519524SHoward Hinnant 1257f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 12583e519524SHoward Hinnant template <class... _Args> 1259789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12603e519524SHoward Hinnant iterator emplace(_Args&&... __args) 1261ce48a113SHoward Hinnant {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} 12623e519524SHoward Hinnant template <class... _Args> 1263789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12643e519524SHoward Hinnant iterator emplace_hint(const_iterator __p, _Args&&... __args) 1265ce48a113SHoward Hinnant {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} 1266f0f86ef9SEric Fiselier 1267789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1268ce48a113SHoward Hinnant iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));} 1269789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12703e519524SHoward Hinnant iterator insert(const_iterator __p, value_type&& __x) 1271ce48a113SHoward Hinnant {return __table_.__insert_multi(__p, _VSTD::move(__x));} 1272789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 12733e519524SHoward Hinnant void insert(initializer_list<value_type> __il) 12743e519524SHoward Hinnant {insert(__il.begin(), __il.end());} 1275f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 1276f0f86ef9SEric Fiselier 1277f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 1278f0f86ef9SEric Fiselier iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 1279f0f86ef9SEric Fiselier 1280f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 1281f0f86ef9SEric Fiselier iterator insert(const_iterator __p, const value_type& __x) 1282f0f86ef9SEric Fiselier {return __table_.__insert_multi(__p, __x);} 1283f0f86ef9SEric Fiselier 1284f0f86ef9SEric Fiselier template <class _InputIterator> 1285f0f86ef9SEric Fiselier _LIBCPP_INLINE_VISIBILITY 1286f0f86ef9SEric Fiselier void insert(_InputIterator __first, _InputIterator __last); 12873e519524SHoward Hinnant 1288b0386a51SErik Pilkington#if _LIBCPP_STD_VER > 14 1289b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 1290b0386a51SErik Pilkington iterator insert(node_type&& __nh) 1291b0386a51SErik Pilkington { 1292b0386a51SErik Pilkington _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 1293b0386a51SErik Pilkington "node_type with incompatible allocator passed to unordered_multiset::insert()"); 1294b0386a51SErik Pilkington return __table_.template __node_handle_insert_multi<node_type>( 1295b0386a51SErik Pilkington _VSTD::move(__nh)); 1296b0386a51SErik Pilkington } 1297b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 1298b0386a51SErik Pilkington iterator insert(const_iterator __hint, node_type&& __nh) 1299b0386a51SErik Pilkington { 1300b0386a51SErik Pilkington _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 1301b0386a51SErik Pilkington "node_type with incompatible allocator passed to unordered_multiset::insert()"); 1302b0386a51SErik Pilkington return __table_.template __node_handle_insert_multi<node_type>( 1303b0386a51SErik Pilkington __hint, _VSTD::move(__nh)); 1304b0386a51SErik Pilkington } 1305b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 1306b0386a51SErik Pilkington node_type extract(const_iterator __position) 1307b0386a51SErik Pilkington { 1308b0386a51SErik Pilkington return __table_.template __node_handle_extract<node_type>( 1309b0386a51SErik Pilkington __position); 1310b0386a51SErik Pilkington } 1311b0386a51SErik Pilkington _LIBCPP_INLINE_VISIBILITY 1312b0386a51SErik Pilkington node_type extract(key_type const& __key) 1313b0386a51SErik Pilkington { 1314b0386a51SErik Pilkington return __table_.template __node_handle_extract<node_type>(__key); 1315b0386a51SErik Pilkington } 13165c4e07aeSErik Pilkington 13175c4e07aeSErik Pilkington template <class _H2, class _P2> 13185c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 13195c4e07aeSErik Pilkington void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) 13205c4e07aeSErik Pilkington { 13215c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 13225c4e07aeSErik Pilkington "merging container with incompatible allocator"); 13235c4e07aeSErik Pilkington return __table_.__node_handle_merge_multi(__source.__table_); 13245c4e07aeSErik Pilkington } 13255c4e07aeSErik Pilkington template <class _H2, class _P2> 13265c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 13275c4e07aeSErik Pilkington void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) 13285c4e07aeSErik Pilkington { 13295c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 13305c4e07aeSErik Pilkington "merging container with incompatible allocator"); 13315c4e07aeSErik Pilkington return __table_.__node_handle_merge_multi(__source.__table_); 13325c4e07aeSErik Pilkington } 13335c4e07aeSErik Pilkington template <class _H2, class _P2> 13345c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 13355c4e07aeSErik Pilkington void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) 13365c4e07aeSErik Pilkington { 13375c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 13385c4e07aeSErik Pilkington "merging container with incompatible allocator"); 13395c4e07aeSErik Pilkington return __table_.__node_handle_merge_multi(__source.__table_); 13405c4e07aeSErik Pilkington } 13415c4e07aeSErik Pilkington template <class _H2, class _P2> 13425c4e07aeSErik Pilkington _LIBCPP_INLINE_VISIBILITY 13435c4e07aeSErik Pilkington void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) 13445c4e07aeSErik Pilkington { 13455c4e07aeSErik Pilkington _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 13465c4e07aeSErik Pilkington "merging container with incompatible allocator"); 13475c4e07aeSErik Pilkington return __table_.__node_handle_merge_multi(__source.__table_); 13485c4e07aeSErik Pilkington } 1349b0386a51SErik Pilkington#endif 1350b0386a51SErik Pilkington 1351789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13523e519524SHoward Hinnant iterator erase(const_iterator __p) {return __table_.erase(__p);} 1353789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13543e519524SHoward Hinnant size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 1355789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13563e519524SHoward Hinnant iterator erase(const_iterator __first, const_iterator __last) 13573e519524SHoward Hinnant {return __table_.erase(__first, __last);} 1358789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1359557da866SHoward Hinnant void clear() _NOEXCEPT {__table_.clear();} 13603e519524SHoward Hinnant 1361789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1362557da866SHoward Hinnant void swap(unordered_multiset& __u) 1363557da866SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 1364557da866SHoward Hinnant {__table_.swap(__u.__table_);} 13653e519524SHoward Hinnant 1366789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13673e519524SHoward Hinnant hasher hash_function() const {return __table_.hash_function();} 1368789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13693e519524SHoward Hinnant key_equal key_eq() const {return __table_.key_eq();} 13703e519524SHoward Hinnant 1371789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13723e519524SHoward Hinnant iterator find(const key_type& __k) {return __table_.find(__k);} 1373789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13743e519524SHoward Hinnant const_iterator find(const key_type& __k) const {return __table_.find(__k);} 1375e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 1376e5ec94a1SRuslan Arutyunyan template <typename _K2> 1377e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1378*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> 1379e5ec94a1SRuslan Arutyunyan find(const _K2& __k) {return __table_.find(__k);} 1380e5ec94a1SRuslan Arutyunyan template <typename _K2> 1381e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1382*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> 1383e5ec94a1SRuslan Arutyunyan find(const _K2& __k) const {return __table_.find(__k);} 1384e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 1385789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 13863e519524SHoward Hinnant size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 1387a17b1aedSZoe Carver #if _LIBCPP_STD_VER > 17 1388e5ec94a1SRuslan Arutyunyan template <typename _K2> 1389e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1390*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> 1391e5ec94a1SRuslan Arutyunyan count(const _K2& __k) const {return __table_.__count_multi(__k);} 1392e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 1393e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 1394a17b1aedSZoe Carver _LIBCPP_INLINE_VISIBILITY 1395a17b1aedSZoe Carver bool contains(const key_type& __k) const {return find(__k) != end();} 1396e5ec94a1SRuslan Arutyunyan 1397e5ec94a1SRuslan Arutyunyan template <typename _K2> 1398e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1399*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> 1400e5ec94a1SRuslan Arutyunyan contains(const _K2& __k) const {return find(__k) != end();} 1401a17b1aedSZoe Carver #endif // _LIBCPP_STD_VER > 17 1402789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14033e519524SHoward Hinnant pair<iterator, iterator> equal_range(const key_type& __k) 14043e519524SHoward Hinnant {return __table_.__equal_range_multi(__k);} 1405789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14063e519524SHoward Hinnant pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 14073e519524SHoward Hinnant {return __table_.__equal_range_multi(__k);} 1408e5ec94a1SRuslan Arutyunyan #if _LIBCPP_STD_VER > 17 1409e5ec94a1SRuslan Arutyunyan template <typename _K2> 1410e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1411*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> 1412e5ec94a1SRuslan Arutyunyan equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);} 1413e5ec94a1SRuslan Arutyunyan template <typename _K2> 1414e5ec94a1SRuslan Arutyunyan _LIBCPP_INLINE_VISIBILITY 1415*4e0ea2cfSLouis Dionne enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> 1416e5ec94a1SRuslan Arutyunyan equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);} 1417e5ec94a1SRuslan Arutyunyan #endif // _LIBCPP_STD_VER > 17 14183e519524SHoward Hinnant 1419789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1420557da866SHoward Hinnant size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 1421789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1422557da866SHoward Hinnant size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} 14233e519524SHoward Hinnant 1424789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14253e519524SHoward Hinnant size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);} 1426789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14273e519524SHoward Hinnant size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 14283e519524SHoward Hinnant 1429789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14303e519524SHoward Hinnant local_iterator begin(size_type __n) {return __table_.begin(__n);} 1431789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14323e519524SHoward Hinnant local_iterator end(size_type __n) {return __table_.end(__n);} 1433789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14343e519524SHoward Hinnant const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 1435789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14363e519524SHoward Hinnant const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 1437789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14383e519524SHoward Hinnant const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 1439789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14403e519524SHoward Hinnant const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 14413e519524SHoward Hinnant 1442789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1443557da866SHoward Hinnant float load_factor() const _NOEXCEPT {return __table_.load_factor();} 1444789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1445557da866SHoward Hinnant float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 1446789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14473e519524SHoward Hinnant void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 1448789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14493e519524SHoward Hinnant void rehash(size_type __n) {__table_.rehash(__n);} 1450789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 14513e519524SHoward Hinnant void reserve(size_type __n) {__table_.reserve(__n);} 1452b24c8024SHoward Hinnant 145331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1454b24c8024SHoward Hinnant 1455b24c8024SHoward Hinnant bool __dereferenceable(const const_iterator* __i) const 1456b24c8024SHoward Hinnant {return __table_.__dereferenceable(__i);} 1457b24c8024SHoward Hinnant bool __decrementable(const const_iterator* __i) const 1458b24c8024SHoward Hinnant {return __table_.__decrementable(__i);} 1459b24c8024SHoward Hinnant bool __addable(const const_iterator* __i, ptrdiff_t __n) const 1460b24c8024SHoward Hinnant {return __table_.__addable(__i, __n);} 1461b24c8024SHoward Hinnant bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const 1462b24c8024SHoward Hinnant {return __table_.__addable(__i, __n);} 1463b24c8024SHoward Hinnant 146431e82037SLouis Dionne#endif // _LIBCPP_DEBUG_LEVEL == 2 1465b24c8024SHoward Hinnant 14663e519524SHoward Hinnant}; 14673e519524SHoward Hinnant 146801666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 1469296a8010SLouis Dionnetemplate<class _InputIterator, 1470296a8010SLouis Dionne class _Hash = hash<__iter_value_type<_InputIterator>>, 1471296a8010SLouis Dionne class _Pred = equal_to<__iter_value_type<_InputIterator>>, 1472296a8010SLouis Dionne class _Allocator = allocator<__iter_value_type<_InputIterator>>, 1473*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 1474*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 1475*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Pred>::value>, 1476*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1477296a8010SLouis Dionneunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, 1478296a8010SLouis Dionne _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 1479296a8010SLouis Dionne -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; 1480296a8010SLouis Dionne 1481296a8010SLouis Dionnetemplate<class _Tp, class _Hash = hash<_Tp>, 1482296a8010SLouis Dionne class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>, 1483*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 1484*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 1485*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Pred>::value>, 1486*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1487296a8010SLouis Dionneunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, 1488296a8010SLouis Dionne _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) 1489296a8010SLouis Dionne -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; 1490296a8010SLouis Dionne 1491296a8010SLouis Dionnetemplate<class _InputIterator, class _Allocator, 1492*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1493296a8010SLouis Dionneunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) 1494296a8010SLouis Dionne -> unordered_multiset<__iter_value_type<_InputIterator>, 1495296a8010SLouis Dionne hash<__iter_value_type<_InputIterator>>, 1496296a8010SLouis Dionne equal_to<__iter_value_type<_InputIterator>>, 1497296a8010SLouis Dionne _Allocator>; 1498296a8010SLouis Dionne 1499296a8010SLouis Dionnetemplate<class _InputIterator, class _Hash, class _Allocator, 1500*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 1501*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 1502*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1503296a8010SLouis Dionneunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, 1504296a8010SLouis Dionne _Hash, _Allocator) 1505296a8010SLouis Dionne -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, 1506296a8010SLouis Dionne equal_to<__iter_value_type<_InputIterator>>, 1507296a8010SLouis Dionne _Allocator>; 1508296a8010SLouis Dionne 1509296a8010SLouis Dionnetemplate<class _Tp, class _Allocator, 1510*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1511296a8010SLouis Dionneunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) 1512296a8010SLouis Dionne -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; 1513296a8010SLouis Dionne 1514296a8010SLouis Dionnetemplate<class _Tp, class _Hash, class _Allocator, 1515*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Hash>::value>, 1516*4e0ea2cfSLouis Dionne class = enable_if_t<!is_integral<_Hash>::value>, 1517*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value>> 1518296a8010SLouis Dionneunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) 1519296a8010SLouis Dionne -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; 1520296a8010SLouis Dionne#endif 1521296a8010SLouis Dionne 15223e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15233e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15243e519524SHoward Hinnant size_type __n, const hasher& __hf, const key_equal& __eql) 15253e519524SHoward Hinnant : __table_(__hf, __eql) 15263e519524SHoward Hinnant{ 152731e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1528b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1529b24c8024SHoward Hinnant#endif 15303e519524SHoward Hinnant __table_.rehash(__n); 15313e519524SHoward Hinnant} 15323e519524SHoward Hinnant 15333e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15343e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15353e519524SHoward Hinnant size_type __n, const hasher& __hf, const key_equal& __eql, 15363e519524SHoward Hinnant const allocator_type& __a) 15373e519524SHoward Hinnant : __table_(__hf, __eql, __a) 15383e519524SHoward Hinnant{ 153931e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1540b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1541b24c8024SHoward Hinnant#endif 15423e519524SHoward Hinnant __table_.rehash(__n); 15433e519524SHoward Hinnant} 15443e519524SHoward Hinnant 15453e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15463e519524SHoward Hinnanttemplate <class _InputIterator> 15473e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15483e519524SHoward Hinnant _InputIterator __first, _InputIterator __last) 15493e519524SHoward Hinnant{ 155031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1551b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1552b24c8024SHoward Hinnant#endif 15533e519524SHoward Hinnant insert(__first, __last); 15543e519524SHoward Hinnant} 15553e519524SHoward Hinnant 15563e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15573e519524SHoward Hinnanttemplate <class _InputIterator> 15583e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15593e519524SHoward Hinnant _InputIterator __first, _InputIterator __last, size_type __n, 15603e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql) 15613e519524SHoward Hinnant : __table_(__hf, __eql) 15623e519524SHoward Hinnant{ 156331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1564b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1565b24c8024SHoward Hinnant#endif 15663e519524SHoward Hinnant __table_.rehash(__n); 15673e519524SHoward Hinnant insert(__first, __last); 15683e519524SHoward Hinnant} 15693e519524SHoward Hinnant 15703e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15713e519524SHoward Hinnanttemplate <class _InputIterator> 15723e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15733e519524SHoward Hinnant _InputIterator __first, _InputIterator __last, size_type __n, 15743e519524SHoward Hinnant const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 15753e519524SHoward Hinnant : __table_(__hf, __eql, __a) 15763e519524SHoward Hinnant{ 157731e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1578b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1579b24c8024SHoward Hinnant#endif 15803e519524SHoward Hinnant __table_.rehash(__n); 15813e519524SHoward Hinnant insert(__first, __last); 15823e519524SHoward Hinnant} 15833e519524SHoward Hinnant 15843e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1585cd31b434SEvgeniy Stepanovinline 15863e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15873e519524SHoward Hinnant const allocator_type& __a) 15883e519524SHoward Hinnant : __table_(__a) 15893e519524SHoward Hinnant{ 159031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1591b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1592b24c8024SHoward Hinnant#endif 15933e519524SHoward Hinnant} 15943e519524SHoward Hinnant 15953e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 15963e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 15973e519524SHoward Hinnant const unordered_multiset& __u) 15983e519524SHoward Hinnant : __table_(__u.__table_) 15993e519524SHoward Hinnant{ 160031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1601b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1602b24c8024SHoward Hinnant#endif 16033e519524SHoward Hinnant __table_.rehash(__u.bucket_count()); 16043e519524SHoward Hinnant insert(__u.begin(), __u.end()); 16053e519524SHoward Hinnant} 16063e519524SHoward Hinnant 16073e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 16083e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16093e519524SHoward Hinnant const unordered_multiset& __u, const allocator_type& __a) 16103e519524SHoward Hinnant : __table_(__u.__table_, __a) 16113e519524SHoward Hinnant{ 161231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1613b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1614b24c8024SHoward Hinnant#endif 16153e519524SHoward Hinnant __table_.rehash(__u.bucket_count()); 16163e519524SHoward Hinnant insert(__u.begin(), __u.end()); 16173e519524SHoward Hinnant} 16183e519524SHoward Hinnant 1619f0f86ef9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 16203e519524SHoward Hinnant 16213e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1622cd31b434SEvgeniy Stepanovinline 16233e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16243e519524SHoward Hinnant unordered_multiset&& __u) 1625557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 1626ce48a113SHoward Hinnant : __table_(_VSTD::move(__u.__table_)) 16273e519524SHoward Hinnant{ 162831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1629b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1630b24c8024SHoward Hinnant __get_db()->swap(this, &__u); 1631b24c8024SHoward Hinnant#endif 16323e519524SHoward Hinnant} 16333e519524SHoward Hinnant 16343e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 16353e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16363e519524SHoward Hinnant unordered_multiset&& __u, const allocator_type& __a) 1637ce48a113SHoward Hinnant : __table_(_VSTD::move(__u.__table_), __a) 16383e519524SHoward Hinnant{ 163931e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1640b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1641b24c8024SHoward Hinnant#endif 16423e519524SHoward Hinnant if (__a != __u.get_allocator()) 16433e519524SHoward Hinnant { 16443e519524SHoward Hinnant iterator __i = __u.begin(); 16453e519524SHoward Hinnant while (__u.size() != 0) 1646ce48a113SHoward Hinnant __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); 16473e519524SHoward Hinnant } 164831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1649b24c8024SHoward Hinnant else 1650b24c8024SHoward Hinnant __get_db()->swap(this, &__u); 1651b24c8024SHoward Hinnant#endif 16523e519524SHoward Hinnant} 16533e519524SHoward Hinnant 16543e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 16553e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16563e519524SHoward Hinnant initializer_list<value_type> __il) 16573e519524SHoward Hinnant{ 165831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1659b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1660b24c8024SHoward Hinnant#endif 16613e519524SHoward Hinnant insert(__il.begin(), __il.end()); 16623e519524SHoward Hinnant} 16633e519524SHoward Hinnant 16643e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 16653e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16663e519524SHoward Hinnant initializer_list<value_type> __il, size_type __n, const hasher& __hf, 16673e519524SHoward Hinnant const key_equal& __eql) 16683e519524SHoward Hinnant : __table_(__hf, __eql) 16693e519524SHoward Hinnant{ 167031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1671b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1672b24c8024SHoward Hinnant#endif 16733e519524SHoward Hinnant __table_.rehash(__n); 16743e519524SHoward Hinnant insert(__il.begin(), __il.end()); 16753e519524SHoward Hinnant} 16763e519524SHoward Hinnant 16773e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 16783e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( 16793e519524SHoward Hinnant initializer_list<value_type> __il, size_type __n, const hasher& __hf, 16803e519524SHoward Hinnant const key_equal& __eql, const allocator_type& __a) 16813e519524SHoward Hinnant : __table_(__hf, __eql, __a) 16823e519524SHoward Hinnant{ 168331e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1684b24c8024SHoward Hinnant __get_db()->__insert_c(this); 1685b24c8024SHoward Hinnant#endif 16863e519524SHoward Hinnant __table_.rehash(__n); 16873e519524SHoward Hinnant insert(__il.begin(), __il.end()); 16883e519524SHoward Hinnant} 16893e519524SHoward Hinnant 16903e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1691cd31b434SEvgeniy Stepanovinline 16923e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>& 16933e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=( 16943e519524SHoward Hinnant unordered_multiset&& __u) 1695557da866SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 16963e519524SHoward Hinnant{ 1697ce48a113SHoward Hinnant __table_ = _VSTD::move(__u.__table_); 16983e519524SHoward Hinnant return *this; 16993e519524SHoward Hinnant} 17003e519524SHoward Hinnant 17013e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17023e519524SHoward Hinnantinline 17033e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>& 17043e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=( 17053e519524SHoward Hinnant initializer_list<value_type> __il) 17063e519524SHoward Hinnant{ 17073e519524SHoward Hinnant __table_.__assign_multi(__il.begin(), __il.end()); 17083e519524SHoward Hinnant return *this; 17093e519524SHoward Hinnant} 17103e519524SHoward Hinnant 1711f0f86ef9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 171254976f26SHoward Hinnant 17133e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17143e519524SHoward Hinnanttemplate <class _InputIterator> 1715cd31b434SEvgeniy Stepanovinline 17163e519524SHoward Hinnantvoid 17173e519524SHoward Hinnantunordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 17183e519524SHoward Hinnant _InputIterator __last) 17193e519524SHoward Hinnant{ 17203e519524SHoward Hinnant for (; __first != __last; ++__first) 17213e519524SHoward Hinnant __table_.__insert_multi(*__first); 17223e519524SHoward Hinnant} 17233e519524SHoward Hinnant 17243e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1725789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 17263e519524SHoward Hinnantvoid 17273e519524SHoward Hinnantswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 17283e519524SHoward Hinnant unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 1729557da866SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 17303e519524SHoward Hinnant{ 17313e519524SHoward Hinnant __x.swap(__y); 17323e519524SHoward Hinnant} 17333e519524SHoward Hinnant 1734f60c63c0SMarshall Clow#if _LIBCPP_STD_VER > 17 17353e895085SMarek Kurdejtemplate <class _Value, class _Hash, class _Pred, class _Alloc, 17363e895085SMarek Kurdej class _Predicate> 1737f60c63c0SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY 17383e895085SMarek Kurdej typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type 17393e895085SMarek Kurdej erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, 17403e895085SMarek Kurdej _Predicate __pred) { 17412ac6babcSArthur O'Dwyer return _VSTD::__libcpp_erase_if_container(__c, __pred); 17423e895085SMarek Kurdej} 1743f60c63c0SMarshall Clow#endif 1744f60c63c0SMarshall Clow 17453e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 17463e519524SHoward Hinnantbool 17473e519524SHoward Hinnantoperator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 17483e519524SHoward Hinnant const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 17493e519524SHoward Hinnant{ 17503e519524SHoward Hinnant if (__x.size() != __y.size()) 17513e519524SHoward Hinnant return false; 17523e519524SHoward Hinnant typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator 17533e519524SHoward Hinnant const_iterator; 17543e519524SHoward Hinnant typedef pair<const_iterator, const_iterator> _EqRng; 17553e519524SHoward Hinnant for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 17563e519524SHoward Hinnant { 17573e519524SHoward Hinnant _EqRng __xeq = __x.equal_range(*__i); 17583e519524SHoward Hinnant _EqRng __yeq = __y.equal_range(*__i); 1759ce48a113SHoward Hinnant if (_VSTD::distance(__xeq.first, __xeq.second) != 1760ce48a113SHoward Hinnant _VSTD::distance(__yeq.first, __yeq.second) || 1761ce48a113SHoward Hinnant !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 17623e519524SHoward Hinnant return false; 17633e519524SHoward Hinnant __i = __xeq.second; 17643e519524SHoward Hinnant } 17653e519524SHoward Hinnant return true; 17663e519524SHoward Hinnant} 17673e519524SHoward Hinnant 17683e519524SHoward Hinnanttemplate <class _Value, class _Hash, class _Pred, class _Alloc> 1769789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 17703e519524SHoward Hinnantbool 17713e519524SHoward Hinnantoperator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, 17723e519524SHoward Hinnant const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) 17733e519524SHoward Hinnant{ 17743e519524SHoward Hinnant return !(__x == __y); 17753e519524SHoward Hinnant} 17763e519524SHoward Hinnant 17773e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 17783e519524SHoward Hinnant 17793e519524SHoward Hinnant#endif // _LIBCPP_UNORDERED_SET 1780