17a984708SDavid Chisnall// -*- C++ -*-
27a984708SDavid Chisnall//===-------------------------- unordered_set -----------------------------===//
37a984708SDavid Chisnall//
47a984708SDavid Chisnall//                     The LLVM Compiler Infrastructure
57a984708SDavid Chisnall//
67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open
77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details.
87a984708SDavid Chisnall//
97a984708SDavid Chisnall//===----------------------------------------------------------------------===//
107a984708SDavid Chisnall
117a984708SDavid Chisnall#ifndef _LIBCPP_UNORDERED_SET
127a984708SDavid Chisnall#define _LIBCPP_UNORDERED_SET
137a984708SDavid Chisnall
147a984708SDavid Chisnall/*
157a984708SDavid Chisnall
167a984708SDavid Chisnall    unordered_set synopsis
177a984708SDavid Chisnall
187a984708SDavid Chisnall#include <initializer_list>
197a984708SDavid Chisnall
207a984708SDavid Chisnallnamespace std
217a984708SDavid Chisnall{
227a984708SDavid Chisnall
237a984708SDavid Chisnalltemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
247a984708SDavid Chisnall          class Alloc = allocator<Value>>
257a984708SDavid Chisnallclass unordered_set
267a984708SDavid Chisnall{
277a984708SDavid Chisnallpublic:
287a984708SDavid Chisnall    // types
297a984708SDavid Chisnall    typedef Value                                                      key_type;
307a984708SDavid Chisnall    typedef key_type                                                   value_type;
317a984708SDavid Chisnall    typedef Hash                                                       hasher;
327a984708SDavid Chisnall    typedef Pred                                                       key_equal;
337a984708SDavid Chisnall    typedef Alloc                                                      allocator_type;
347a984708SDavid Chisnall    typedef value_type&                                                reference;
357a984708SDavid Chisnall    typedef const value_type&                                          const_reference;
367a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::pointer         pointer;
377a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
387a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::size_type       size_type;
397a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
407a984708SDavid Chisnall
417a984708SDavid Chisnall    typedef /unspecified/ iterator;
427a984708SDavid Chisnall    typedef /unspecified/ const_iterator;
437a984708SDavid Chisnall    typedef /unspecified/ local_iterator;
447a984708SDavid Chisnall    typedef /unspecified/ const_local_iterator;
457a984708SDavid Chisnall
464ba319b5SDimitry Andric    typedef unspecified node_type unspecified;                            // C++17
474ba319b5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
484ba319b5SDimitry Andric
497a984708SDavid Chisnall    unordered_set()
507a984708SDavid Chisnall        noexcept(
517a984708SDavid Chisnall            is_nothrow_default_constructible<hasher>::value &&
527a984708SDavid Chisnall            is_nothrow_default_constructible<key_equal>::value &&
537a984708SDavid Chisnall            is_nothrow_default_constructible<allocator_type>::value);
547a984708SDavid Chisnall    explicit unordered_set(size_type n, const hasher& hf = hasher(),
557a984708SDavid Chisnall                           const key_equal& eql = key_equal(),
567a984708SDavid Chisnall                           const allocator_type& a = allocator_type());
577a984708SDavid Chisnall    template <class InputIterator>
587a984708SDavid Chisnall        unordered_set(InputIterator f, InputIterator l,
597a984708SDavid Chisnall                      size_type n = 0, const hasher& hf = hasher(),
607a984708SDavid Chisnall                      const key_equal& eql = key_equal(),
617a984708SDavid Chisnall                      const allocator_type& a = allocator_type());
627a984708SDavid Chisnall    explicit unordered_set(const allocator_type&);
637a984708SDavid Chisnall    unordered_set(const unordered_set&);
647a984708SDavid Chisnall    unordered_set(const unordered_set&, const Allocator&);
657a984708SDavid Chisnall    unordered_set(unordered_set&&)
667a984708SDavid Chisnall        noexcept(
677a984708SDavid Chisnall            is_nothrow_move_constructible<hasher>::value &&
687a984708SDavid Chisnall            is_nothrow_move_constructible<key_equal>::value &&
697a984708SDavid Chisnall            is_nothrow_move_constructible<allocator_type>::value);
707a984708SDavid Chisnall    unordered_set(unordered_set&&, const Allocator&);
717a984708SDavid Chisnall    unordered_set(initializer_list<value_type>, size_type n = 0,
727a984708SDavid Chisnall                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
737a984708SDavid Chisnall                  const allocator_type& a = allocator_type());
744f7ab58eSDimitry Andric    unordered_set(size_type n, const allocator_type& a); // C++14
754f7ab58eSDimitry Andric    unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
764f7ab58eSDimitry Andric    template <class InputIterator>
774f7ab58eSDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
784f7ab58eSDimitry Andric    template <class InputIterator>
794f7ab58eSDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n,
804f7ab58eSDimitry Andric                    const hasher& hf,  const allocator_type& a); // C++14
814f7ab58eSDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
824f7ab58eSDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n,
834f7ab58eSDimitry Andric                  const hasher& hf,  const allocator_type& a); // C++14
847a984708SDavid Chisnall    ~unordered_set();
857a984708SDavid Chisnall    unordered_set& operator=(const unordered_set&);
867a984708SDavid Chisnall    unordered_set& operator=(unordered_set&&)
877a984708SDavid Chisnall        noexcept(
887a984708SDavid Chisnall            allocator_type::propagate_on_container_move_assignment::value &&
897a984708SDavid Chisnall            is_nothrow_move_assignable<allocator_type>::value &&
907a984708SDavid Chisnall            is_nothrow_move_assignable<hasher>::value &&
917a984708SDavid Chisnall            is_nothrow_move_assignable<key_equal>::value);
927a984708SDavid Chisnall    unordered_set& operator=(initializer_list<value_type>);
937a984708SDavid Chisnall
947a984708SDavid Chisnall    allocator_type get_allocator() const noexcept;
957a984708SDavid Chisnall
967a984708SDavid Chisnall    bool      empty() const noexcept;
977a984708SDavid Chisnall    size_type size() const noexcept;
987a984708SDavid Chisnall    size_type max_size() const noexcept;
997a984708SDavid Chisnall
1007a984708SDavid Chisnall    iterator       begin() noexcept;
1017a984708SDavid Chisnall    iterator       end() noexcept;
1027a984708SDavid Chisnall    const_iterator begin()  const noexcept;
1037a984708SDavid Chisnall    const_iterator end()    const noexcept;
1047a984708SDavid Chisnall    const_iterator cbegin() const noexcept;
1057a984708SDavid Chisnall    const_iterator cend()   const noexcept;
1067a984708SDavid Chisnall
1077a984708SDavid Chisnall    template <class... Args>
1087a984708SDavid Chisnall        pair<iterator, bool> emplace(Args&&... args);
1097a984708SDavid Chisnall    template <class... Args>
1107a984708SDavid Chisnall        iterator emplace_hint(const_iterator position, Args&&... args);
1117a984708SDavid Chisnall    pair<iterator, bool> insert(const value_type& obj);
1127a984708SDavid Chisnall    pair<iterator, bool> insert(value_type&& obj);
1137a984708SDavid Chisnall    iterator insert(const_iterator hint, const value_type& obj);
1147a984708SDavid Chisnall    iterator insert(const_iterator hint, value_type&& obj);
1157a984708SDavid Chisnall    template <class InputIterator>
1167a984708SDavid Chisnall        void insert(InputIterator first, InputIterator last);
1177a984708SDavid Chisnall    void insert(initializer_list<value_type>);
1187a984708SDavid Chisnall
1194ba319b5SDimitry Andric    node_type extract(const_iterator position);                       // C++17
1204ba319b5SDimitry Andric    node_type extract(const key_type& x);                             // C++17
1214ba319b5SDimitry Andric    insert_return_type insert(node_type&& nh);                        // C++17
1224ba319b5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);   // C++17
1234ba319b5SDimitry Andric
1247a984708SDavid Chisnall    iterator erase(const_iterator position);
125854fa44bSDimitry Andric    iterator erase(iterator position);  // C++14
1267a984708SDavid Chisnall    size_type erase(const key_type& k);
1277a984708SDavid Chisnall    iterator erase(const_iterator first, const_iterator last);
1287a984708SDavid Chisnall    void clear() noexcept;
1297a984708SDavid Chisnall
130*b5893f02SDimitry Andric    template<class H2, class P2>
131*b5893f02SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
132*b5893f02SDimitry Andric    template<class H2, class P2>
133*b5893f02SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
134*b5893f02SDimitry Andric    template<class H2, class P2>
135*b5893f02SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
136*b5893f02SDimitry Andric    template<class H2, class P2>
137*b5893f02SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
138*b5893f02SDimitry Andric
1397a984708SDavid Chisnall    void swap(unordered_set&)
140854fa44bSDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
141854fa44bSDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
142854fa44bSDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
1437a984708SDavid Chisnall
1447a984708SDavid Chisnall    hasher hash_function() const;
1457a984708SDavid Chisnall    key_equal key_eq() const;
1467a984708SDavid Chisnall
1477a984708SDavid Chisnall    iterator       find(const key_type& k);
1487a984708SDavid Chisnall    const_iterator find(const key_type& k) const;
1497a984708SDavid Chisnall    size_type count(const key_type& k) const;
1507a984708SDavid Chisnall    pair<iterator, iterator>             equal_range(const key_type& k);
1517a984708SDavid Chisnall    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
1527a984708SDavid Chisnall
1537a984708SDavid Chisnall    size_type bucket_count() const noexcept;
1547a984708SDavid Chisnall    size_type max_bucket_count() const noexcept;
1557a984708SDavid Chisnall
1567a984708SDavid Chisnall    size_type bucket_size(size_type n) const;
1577a984708SDavid Chisnall    size_type bucket(const key_type& k) const;
1587a984708SDavid Chisnall
1597a984708SDavid Chisnall    local_iterator       begin(size_type n);
1607a984708SDavid Chisnall    local_iterator       end(size_type n);
1617a984708SDavid Chisnall    const_local_iterator begin(size_type n) const;
1627a984708SDavid Chisnall    const_local_iterator end(size_type n) const;
1637a984708SDavid Chisnall    const_local_iterator cbegin(size_type n) const;
1647a984708SDavid Chisnall    const_local_iterator cend(size_type n) const;
1657a984708SDavid Chisnall
1667a984708SDavid Chisnall    float load_factor() const noexcept;
1677a984708SDavid Chisnall    float max_load_factor() const noexcept;
1687a984708SDavid Chisnall    void max_load_factor(float z);
1697a984708SDavid Chisnall    void rehash(size_type n);
1707a984708SDavid Chisnall    void reserve(size_type n);
1717a984708SDavid Chisnall};
1727a984708SDavid Chisnall
1737a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
1747a984708SDavid Chisnall    void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
1757a984708SDavid Chisnall              unordered_set<Value, Hash, Pred, Alloc>& y)
1767a984708SDavid Chisnall              noexcept(noexcept(x.swap(y)));
1777a984708SDavid Chisnall
1787a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
1797a984708SDavid Chisnall    bool
1807a984708SDavid Chisnall    operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
1817a984708SDavid Chisnall               const unordered_set<Value, Hash, Pred, Alloc>& y);
1827a984708SDavid Chisnall
1837a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
1847a984708SDavid Chisnall    bool
1857a984708SDavid Chisnall    operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
1867a984708SDavid Chisnall               const unordered_set<Value, Hash, Pred, Alloc>& y);
1877a984708SDavid Chisnall
1887a984708SDavid Chisnalltemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
1897a984708SDavid Chisnall          class Alloc = allocator<Value>>
1907a984708SDavid Chisnallclass unordered_multiset
1917a984708SDavid Chisnall{
1927a984708SDavid Chisnallpublic:
1937a984708SDavid Chisnall    // types
1947a984708SDavid Chisnall    typedef Value                                                      key_type;
1957a984708SDavid Chisnall    typedef key_type                                                   value_type;
1967a984708SDavid Chisnall    typedef Hash                                                       hasher;
1977a984708SDavid Chisnall    typedef Pred                                                       key_equal;
1987a984708SDavid Chisnall    typedef Alloc                                                      allocator_type;
1997a984708SDavid Chisnall    typedef value_type&                                                reference;
2007a984708SDavid Chisnall    typedef const value_type&                                          const_reference;
2017a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::pointer         pointer;
2027a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
2037a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::size_type       size_type;
2047a984708SDavid Chisnall    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
2057a984708SDavid Chisnall
2067a984708SDavid Chisnall    typedef /unspecified/ iterator;
2077a984708SDavid Chisnall    typedef /unspecified/ const_iterator;
2087a984708SDavid Chisnall    typedef /unspecified/ local_iterator;
2097a984708SDavid Chisnall    typedef /unspecified/ const_local_iterator;
2107a984708SDavid Chisnall
2114ba319b5SDimitry Andric    typedef unspecified node_type unspecified;   // C++17
2124ba319b5SDimitry Andric
2137a984708SDavid Chisnall    unordered_multiset()
2147a984708SDavid Chisnall        noexcept(
2157a984708SDavid Chisnall            is_nothrow_default_constructible<hasher>::value &&
2167a984708SDavid Chisnall            is_nothrow_default_constructible<key_equal>::value &&
2177a984708SDavid Chisnall            is_nothrow_default_constructible<allocator_type>::value);
2187a984708SDavid Chisnall    explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
2197a984708SDavid Chisnall                           const key_equal& eql = key_equal(),
2207a984708SDavid Chisnall                           const allocator_type& a = allocator_type());
2217a984708SDavid Chisnall    template <class InputIterator>
2227a984708SDavid Chisnall        unordered_multiset(InputIterator f, InputIterator l,
2237a984708SDavid Chisnall                      size_type n = 0, const hasher& hf = hasher(),
2247a984708SDavid Chisnall                      const key_equal& eql = key_equal(),
2257a984708SDavid Chisnall                      const allocator_type& a = allocator_type());
2267a984708SDavid Chisnall    explicit unordered_multiset(const allocator_type&);
2277a984708SDavid Chisnall    unordered_multiset(const unordered_multiset&);
2287a984708SDavid Chisnall    unordered_multiset(const unordered_multiset&, const Allocator&);
2297a984708SDavid Chisnall    unordered_multiset(unordered_multiset&&)
2307a984708SDavid Chisnall        noexcept(
2317a984708SDavid Chisnall            is_nothrow_move_constructible<hasher>::value &&
2327a984708SDavid Chisnall            is_nothrow_move_constructible<key_equal>::value &&
2337a984708SDavid Chisnall            is_nothrow_move_constructible<allocator_type>::value);
2347a984708SDavid Chisnall    unordered_multiset(unordered_multiset&&, const Allocator&);
2357a984708SDavid Chisnall    unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
2367a984708SDavid Chisnall                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
2377a984708SDavid Chisnall                  const allocator_type& a = allocator_type());
2384f7ab58eSDimitry Andric    unordered_multiset(size_type n, const allocator_type& a); // C++14
2394f7ab58eSDimitry Andric    unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
2404f7ab58eSDimitry Andric    template <class InputIterator>
2414f7ab58eSDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
2424f7ab58eSDimitry Andric    template <class InputIterator>
2434f7ab58eSDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n,
2444f7ab58eSDimitry Andric                         const hasher& hf, const allocator_type& a); // C++14
2454f7ab58eSDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
2464f7ab58eSDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n,
2474f7ab58eSDimitry Andric                       const hasher& hf,  const allocator_type& a); // C++14
2487a984708SDavid Chisnall    ~unordered_multiset();
2497a984708SDavid Chisnall    unordered_multiset& operator=(const unordered_multiset&);
2507a984708SDavid Chisnall    unordered_multiset& operator=(unordered_multiset&&)
2517a984708SDavid Chisnall        noexcept(
2527a984708SDavid Chisnall            allocator_type::propagate_on_container_move_assignment::value &&
2537a984708SDavid Chisnall            is_nothrow_move_assignable<allocator_type>::value &&
2547a984708SDavid Chisnall            is_nothrow_move_assignable<hasher>::value &&
2557a984708SDavid Chisnall            is_nothrow_move_assignable<key_equal>::value);
2567a984708SDavid Chisnall    unordered_multiset& operator=(initializer_list<value_type>);
2577a984708SDavid Chisnall
2587a984708SDavid Chisnall    allocator_type get_allocator() const noexcept;
2597a984708SDavid Chisnall
2607a984708SDavid Chisnall    bool      empty() const noexcept;
2617a984708SDavid Chisnall    size_type size() const noexcept;
2627a984708SDavid Chisnall    size_type max_size() const noexcept;
2637a984708SDavid Chisnall
2647a984708SDavid Chisnall    iterator       begin() noexcept;
2657a984708SDavid Chisnall    iterator       end() noexcept;
2667a984708SDavid Chisnall    const_iterator begin()  const noexcept;
2677a984708SDavid Chisnall    const_iterator end()    const noexcept;
2687a984708SDavid Chisnall    const_iterator cbegin() const noexcept;
2697a984708SDavid Chisnall    const_iterator cend()   const noexcept;
2707a984708SDavid Chisnall
2717a984708SDavid Chisnall    template <class... Args>
2727a984708SDavid Chisnall        iterator emplace(Args&&... args);
2737a984708SDavid Chisnall    template <class... Args>
2747a984708SDavid Chisnall        iterator emplace_hint(const_iterator position, Args&&... args);
2757a984708SDavid Chisnall    iterator insert(const value_type& obj);
2767a984708SDavid Chisnall    iterator insert(value_type&& obj);
2777a984708SDavid Chisnall    iterator insert(const_iterator hint, const value_type& obj);
2787a984708SDavid Chisnall    iterator insert(const_iterator hint, value_type&& obj);
2797a984708SDavid Chisnall    template <class InputIterator>
2807a984708SDavid Chisnall        void insert(InputIterator first, InputIterator last);
2817a984708SDavid Chisnall    void insert(initializer_list<value_type>);
2827a984708SDavid Chisnall
2834ba319b5SDimitry Andric    node_type extract(const_iterator position);             // C++17
2844ba319b5SDimitry Andric    node_type extract(const key_type& x);                   // C++17
2854ba319b5SDimitry Andric    iterator insert(node_type&& nh);                        // C++17
2864ba319b5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);   // C++17
2874ba319b5SDimitry Andric
2887a984708SDavid Chisnall    iterator erase(const_iterator position);
289854fa44bSDimitry Andric    iterator erase(iterator position);  // C++14
2907a984708SDavid Chisnall    size_type erase(const key_type& k);
2917a984708SDavid Chisnall    iterator erase(const_iterator first, const_iterator last);
2927a984708SDavid Chisnall    void clear() noexcept;
2937a984708SDavid Chisnall
294*b5893f02SDimitry Andric    template<class H2, class P2>
295*b5893f02SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
296*b5893f02SDimitry Andric    template<class H2, class P2>
297*b5893f02SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
298*b5893f02SDimitry Andric    template<class H2, class P2>
299*b5893f02SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
300*b5893f02SDimitry Andric    template<class H2, class P2>
301*b5893f02SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
302*b5893f02SDimitry Andric
3037a984708SDavid Chisnall    void swap(unordered_multiset&)
304854fa44bSDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
305854fa44bSDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
306854fa44bSDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
3077a984708SDavid Chisnall
3087a984708SDavid Chisnall    hasher hash_function() const;
3097a984708SDavid Chisnall    key_equal key_eq() const;
3107a984708SDavid Chisnall
3117a984708SDavid Chisnall    iterator       find(const key_type& k);
3127a984708SDavid Chisnall    const_iterator find(const key_type& k) const;
3137a984708SDavid Chisnall    size_type count(const key_type& k) const;
3147a984708SDavid Chisnall    pair<iterator, iterator>             equal_range(const key_type& k);
3157a984708SDavid Chisnall    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
3167a984708SDavid Chisnall
3177a984708SDavid Chisnall    size_type bucket_count() const noexcept;
3187a984708SDavid Chisnall    size_type max_bucket_count() const noexcept;
3197a984708SDavid Chisnall
3207a984708SDavid Chisnall    size_type bucket_size(size_type n) const;
3217a984708SDavid Chisnall    size_type bucket(const key_type& k) const;
3227a984708SDavid Chisnall
3237a984708SDavid Chisnall    local_iterator       begin(size_type n);
3247a984708SDavid Chisnall    local_iterator       end(size_type n);
3257a984708SDavid Chisnall    const_local_iterator begin(size_type n) const;
3267a984708SDavid Chisnall    const_local_iterator end(size_type n) const;
3277a984708SDavid Chisnall    const_local_iterator cbegin(size_type n) const;
3287a984708SDavid Chisnall    const_local_iterator cend(size_type n) const;
3297a984708SDavid Chisnall
3307a984708SDavid Chisnall    float load_factor() const noexcept;
3317a984708SDavid Chisnall    float max_load_factor() const noexcept;
3327a984708SDavid Chisnall    void max_load_factor(float z);
3337a984708SDavid Chisnall    void rehash(size_type n);
3347a984708SDavid Chisnall    void reserve(size_type n);
3357a984708SDavid Chisnall};
3367a984708SDavid Chisnall
3377a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
3387a984708SDavid Chisnall    void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
3397a984708SDavid Chisnall              unordered_multiset<Value, Hash, Pred, Alloc>& y)
3407a984708SDavid Chisnall              noexcept(noexcept(x.swap(y)));
3417a984708SDavid Chisnall
342*b5893f02SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
343*b5893f02SDimitry Andric    void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred);       // C++20
344*b5893f02SDimitry Andric
345*b5893f02SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
346*b5893f02SDimitry Andric    void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred);  // C++20
347*b5893f02SDimitry Andric
348*b5893f02SDimitry Andric
3497a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
3507a984708SDavid Chisnall    bool
3517a984708SDavid Chisnall    operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
3527a984708SDavid Chisnall               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
3537a984708SDavid Chisnall
3547a984708SDavid Chisnalltemplate <class Value, class Hash, class Pred, class Alloc>
3557a984708SDavid Chisnall    bool
3567a984708SDavid Chisnall    operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
3577a984708SDavid Chisnall               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
3587a984708SDavid Chisnall}  // std
3597a984708SDavid Chisnall
3607a984708SDavid Chisnall*/
3617a984708SDavid Chisnall
3627a984708SDavid Chisnall#include <__config>
3637a984708SDavid Chisnall#include <__hash_table>
3644ba319b5SDimitry Andric#include <__node_handle>
3657a984708SDavid Chisnall#include <functional>
366*b5893f02SDimitry Andric#include <version>
3677a984708SDavid Chisnall
368d72607e9SDimitry Andric#include <__debug>
369d72607e9SDimitry Andric
3707a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3717a984708SDavid Chisnall#pragma GCC system_header
3727a984708SDavid Chisnall#endif
3737a984708SDavid Chisnall
3747a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD
3757a984708SDavid Chisnall
376*b5893f02SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
377*b5893f02SDimitry Andricclass unordered_multiset;
378*b5893f02SDimitry Andric
3797a984708SDavid Chisnalltemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
3807a984708SDavid Chisnall          class _Alloc = allocator<_Value> >
381aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_set
3827a984708SDavid Chisnall{
3837a984708SDavid Chisnallpublic:
3847a984708SDavid Chisnall    // types
3857a984708SDavid Chisnall    typedef _Value                                                     key_type;
3867a984708SDavid Chisnall    typedef key_type                                                   value_type;
3877a984708SDavid Chisnall    typedef _Hash                                                      hasher;
3887a984708SDavid Chisnall    typedef _Pred                                                      key_equal;
3897a984708SDavid Chisnall    typedef _Alloc                                                     allocator_type;
3907a984708SDavid Chisnall    typedef value_type&                                                reference;
3917a984708SDavid Chisnall    typedef const value_type&                                          const_reference;
3924f7ab58eSDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
3934f7ab58eSDimitry Andric                  "Invalid allocator::value_type");
394*b5893f02SDimitry Andric    static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
3957a984708SDavid Chisnall
3967a984708SDavid Chisnallprivate:
3977a984708SDavid Chisnall    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
3987a984708SDavid Chisnall
3997a984708SDavid Chisnall    __table __table_;
4007a984708SDavid Chisnall
4017a984708SDavid Chisnallpublic:
4027a984708SDavid Chisnall    typedef typename __table::pointer         pointer;
4037a984708SDavid Chisnall    typedef typename __table::const_pointer   const_pointer;
4047a984708SDavid Chisnall    typedef typename __table::size_type       size_type;
4057a984708SDavid Chisnall    typedef typename __table::difference_type difference_type;
4067a984708SDavid Chisnall
4077a984708SDavid Chisnall    typedef typename __table::const_iterator       iterator;
4087a984708SDavid Chisnall    typedef typename __table::const_iterator       const_iterator;
4097a984708SDavid Chisnall    typedef typename __table::const_local_iterator local_iterator;
4107a984708SDavid Chisnall    typedef typename __table::const_local_iterator const_local_iterator;
4117a984708SDavid Chisnall
4124ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14
4134ba319b5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
4144ba319b5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
4154ba319b5SDimitry Andric#endif
4164ba319b5SDimitry Andric
417*b5893f02SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
418*b5893f02SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
419*b5893f02SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
420*b5893f02SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
421*b5893f02SDimitry Andric
4227a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4237a984708SDavid Chisnall    unordered_set()
4247a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
4254f7ab58eSDimitry Andric        {
4264f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
4274f7ab58eSDimitry Andric            __get_db()->__insert_c(this);
4284f7ab58eSDimitry Andric#endif
4294f7ab58eSDimitry Andric        }
4307a984708SDavid Chisnall    explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
4317a984708SDavid Chisnall                           const key_equal& __eql = key_equal());
4324f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
4334f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4344f7ab58eSDimitry Andric    unordered_set(size_type __n, const allocator_type& __a)
4354f7ab58eSDimitry Andric        : unordered_set(__n, hasher(), key_equal(), __a) {}
4364f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4374f7ab58eSDimitry Andric    unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
4384f7ab58eSDimitry Andric        : unordered_set(__n, __hf, key_equal(), __a) {}
4394f7ab58eSDimitry Andric#endif
4407a984708SDavid Chisnall    unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
4417a984708SDavid Chisnall                  const allocator_type& __a);
4427a984708SDavid Chisnall    template <class _InputIterator>
4437a984708SDavid Chisnall        unordered_set(_InputIterator __first, _InputIterator __last);
4447a984708SDavid Chisnall    template <class _InputIterator>
4457a984708SDavid Chisnall        unordered_set(_InputIterator __first, _InputIterator __last,
4467a984708SDavid Chisnall                      size_type __n, const hasher& __hf = hasher(),
4477a984708SDavid Chisnall                      const key_equal& __eql = key_equal());
4487a984708SDavid Chisnall    template <class _InputIterator>
4497a984708SDavid Chisnall        unordered_set(_InputIterator __first, _InputIterator __last,
4507a984708SDavid Chisnall                      size_type __n, const hasher& __hf, const key_equal& __eql,
4517a984708SDavid Chisnall                      const allocator_type& __a);
4524f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
4534f7ab58eSDimitry Andric    template <class _InputIterator>
4544f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4554f7ab58eSDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4564f7ab58eSDimitry Andric                    size_type __n, const allocator_type& __a)
4574f7ab58eSDimitry Andric            : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
4584f7ab58eSDimitry Andric    template <class _InputIterator>
4594f7ab58eSDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4604f7ab58eSDimitry Andric                      size_type __n, const hasher& __hf, const allocator_type& __a)
4614f7ab58eSDimitry Andric            : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
4624f7ab58eSDimitry Andric#endif
4637c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4647a984708SDavid Chisnall    explicit unordered_set(const allocator_type& __a);
4657a984708SDavid Chisnall    unordered_set(const unordered_set& __u);
4667a984708SDavid Chisnall    unordered_set(const unordered_set& __u, const allocator_type& __a);
467540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4687c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4697a984708SDavid Chisnall    unordered_set(unordered_set&& __u)
4707a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
4717a984708SDavid Chisnall    unordered_set(unordered_set&& __u, const allocator_type& __a);
4727a984708SDavid Chisnall    unordered_set(initializer_list<value_type> __il);
4737a984708SDavid Chisnall    unordered_set(initializer_list<value_type> __il, size_type __n,
4747a984708SDavid Chisnall                  const hasher& __hf = hasher(),
4757a984708SDavid Chisnall                  const key_equal& __eql = key_equal());
4767a984708SDavid Chisnall    unordered_set(initializer_list<value_type> __il, size_type __n,
4777a984708SDavid Chisnall                  const hasher& __hf, const key_equal& __eql,
4787a984708SDavid Chisnall                  const allocator_type& __a);
4794f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
4804f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4814f7ab58eSDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4824f7ab58eSDimitry Andric                                                      const allocator_type& __a)
4834f7ab58eSDimitry Andric        : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
4844f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4854f7ab58eSDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4864f7ab58eSDimitry Andric                                  const hasher& __hf, const allocator_type& __a)
4874f7ab58eSDimitry Andric        : unordered_set(__il, __n, __hf, key_equal(), __a) {}
4884f7ab58eSDimitry Andric#endif
489540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4907a984708SDavid Chisnall    // ~unordered_set() = default;
4917a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4927a984708SDavid Chisnall    unordered_set& operator=(const unordered_set& __u)
4937a984708SDavid Chisnall    {
4947a984708SDavid Chisnall        __table_ = __u.__table_;
4957a984708SDavid Chisnall        return *this;
4967a984708SDavid Chisnall    }
497540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4987c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4997a984708SDavid Chisnall    unordered_set& operator=(unordered_set&& __u)
5007a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
5017c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5027a984708SDavid Chisnall    unordered_set& operator=(initializer_list<value_type> __il);
503540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5047a984708SDavid Chisnall
5057a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5067a984708SDavid Chisnall    allocator_type get_allocator() const _NOEXCEPT
5077a984708SDavid Chisnall        {return allocator_type(__table_.__node_alloc());}
5087a984708SDavid Chisnall
509b2c7081bSDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5107a984708SDavid Chisnall    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
5117a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5127a984708SDavid Chisnall    size_type size() const _NOEXCEPT  {return __table_.size();}
5137a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5147a984708SDavid Chisnall    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
5157a984708SDavid Chisnall
5167a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5177a984708SDavid Chisnall    iterator       begin() _NOEXCEPT        {return __table_.begin();}
5187a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5197a984708SDavid Chisnall    iterator       end() _NOEXCEPT          {return __table_.end();}
5207a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5217a984708SDavid Chisnall    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
5227a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5237a984708SDavid Chisnall    const_iterator end()    const _NOEXCEPT {return __table_.end();}
5247a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5257a984708SDavid Chisnall    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
5267a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5277a984708SDavid Chisnall    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
5287a984708SDavid Chisnall
529540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5307a984708SDavid Chisnall    template <class... _Args>
5317a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
5327a984708SDavid Chisnall        pair<iterator, bool> emplace(_Args&&... __args)
5337a984708SDavid Chisnall            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
5347a984708SDavid Chisnall    template <class... _Args>
5357a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
5364f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
5374f7ab58eSDimitry Andric        iterator emplace_hint(const_iterator __p, _Args&&... __args)
5384f7ab58eSDimitry Andric        {
5394f7ab58eSDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
5404f7ab58eSDimitry Andric                "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
5414f7ab58eSDimitry Andric                " referring to this unordered_set");
5424f7ab58eSDimitry Andric            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
5434f7ab58eSDimitry Andric        }
5444f7ab58eSDimitry Andric#else
5457a984708SDavid Chisnall        iterator emplace_hint(const_iterator, _Args&&... __args)
5467a984708SDavid Chisnall            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
5474f7ab58eSDimitry Andric#endif
548540d2a8bSDimitry Andric
5497a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5507a984708SDavid Chisnall    pair<iterator, bool> insert(value_type&& __x)
5517a984708SDavid Chisnall        {return __table_.__insert_unique(_VSTD::move(__x));}
5527a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5534f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
5544f7ab58eSDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
5554f7ab58eSDimitry Andric        {
5564f7ab58eSDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
5574f7ab58eSDimitry Andric                "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
5584f7ab58eSDimitry Andric                " referring to this unordered_set");
5594f7ab58eSDimitry Andric            return insert(_VSTD::move(__x)).first;
5604f7ab58eSDimitry Andric        }
5614f7ab58eSDimitry Andric#else
5627a984708SDavid Chisnall    iterator insert(const_iterator, value_type&& __x)
5637a984708SDavid Chisnall        {return insert(_VSTD::move(__x)).first;}
5644f7ab58eSDimitry Andric#endif
5657a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5667a984708SDavid Chisnall    void insert(initializer_list<value_type> __il)
5677a984708SDavid Chisnall        {insert(__il.begin(), __il.end());}
568540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
569540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
570540d2a8bSDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
571540d2a8bSDimitry Andric        {return __table_.__insert_unique(__x);}
572540d2a8bSDimitry Andric
573540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
574540d2a8bSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
575540d2a8bSDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
576540d2a8bSDimitry Andric        {
577540d2a8bSDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
578540d2a8bSDimitry Andric                "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
579540d2a8bSDimitry Andric                " referring to this unordered_set");
580540d2a8bSDimitry Andric            return insert(__x).first;
581540d2a8bSDimitry Andric        }
582540d2a8bSDimitry Andric#else
583540d2a8bSDimitry Andric    iterator insert(const_iterator, const value_type& __x)
584540d2a8bSDimitry Andric        {return insert(__x).first;}
585540d2a8bSDimitry Andric#endif
586540d2a8bSDimitry Andric    template <class _InputIterator>
587540d2a8bSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
588540d2a8bSDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
5897a984708SDavid Chisnall
5907a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5917a984708SDavid Chisnall    iterator erase(const_iterator __p) {return __table_.erase(__p);}
5927a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5937a984708SDavid Chisnall    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
5947a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5957a984708SDavid Chisnall    iterator erase(const_iterator __first, const_iterator __last)
5967a984708SDavid Chisnall        {return __table_.erase(__first, __last);}
5977a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5987a984708SDavid Chisnall    void clear() _NOEXCEPT {__table_.clear();}
5997a984708SDavid Chisnall
6004ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14
6014ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6024ba319b5SDimitry Andric    insert_return_type insert(node_type&& __nh)
6034ba319b5SDimitry Andric    {
6044ba319b5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
6054ba319b5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
6064ba319b5SDimitry Andric        return __table_.template __node_handle_insert_unique<
6074ba319b5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
6084ba319b5SDimitry Andric    }
6094ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6104ba319b5SDimitry Andric    iterator insert(const_iterator __h, node_type&& __nh)
6114ba319b5SDimitry Andric    {
6124ba319b5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
6134ba319b5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
6144ba319b5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
6154ba319b5SDimitry Andric            __h, _VSTD::move(__nh));
6164ba319b5SDimitry Andric    }
6174ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6184ba319b5SDimitry Andric    node_type extract(key_type const& __key)
6194ba319b5SDimitry Andric    {
6204ba319b5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
6214ba319b5SDimitry Andric    }
6224ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6234ba319b5SDimitry Andric    node_type extract(const_iterator __it)
6244ba319b5SDimitry Andric    {
6254ba319b5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__it);
6264ba319b5SDimitry Andric    }
627*b5893f02SDimitry Andric
628*b5893f02SDimitry Andric    template<class _H2, class _P2>
629*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
630*b5893f02SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
631*b5893f02SDimitry Andric    {
632*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
633*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
634*b5893f02SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
635*b5893f02SDimitry Andric    }
636*b5893f02SDimitry Andric    template<class _H2, class _P2>
637*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
638*b5893f02SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
639*b5893f02SDimitry Andric    {
640*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
641*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
642*b5893f02SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
643*b5893f02SDimitry Andric    }
644*b5893f02SDimitry Andric    template<class _H2, class _P2>
645*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
646*b5893f02SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
647*b5893f02SDimitry Andric    {
648*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
649*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
650*b5893f02SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
651*b5893f02SDimitry Andric    }
652*b5893f02SDimitry Andric    template<class _H2, class _P2>
653*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
654*b5893f02SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
655*b5893f02SDimitry Andric    {
656*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
657*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
658*b5893f02SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
659*b5893f02SDimitry Andric    }
6604ba319b5SDimitry Andric#endif
6614ba319b5SDimitry Andric
6627a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6637a984708SDavid Chisnall    void swap(unordered_set& __u)
6647a984708SDavid Chisnall        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
6657a984708SDavid Chisnall        {__table_.swap(__u.__table_);}
6667a984708SDavid Chisnall
6677a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6687a984708SDavid Chisnall    hasher hash_function() const {return __table_.hash_function();}
6697a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6707a984708SDavid Chisnall    key_equal key_eq() const {return __table_.key_eq();}
6717a984708SDavid Chisnall
6727a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6737a984708SDavid Chisnall    iterator       find(const key_type& __k)       {return __table_.find(__k);}
6747a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6757a984708SDavid Chisnall    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
6767a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6777a984708SDavid Chisnall    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
6787a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6797a984708SDavid Chisnall    pair<iterator, iterator>             equal_range(const key_type& __k)
6807a984708SDavid Chisnall        {return __table_.__equal_range_unique(__k);}
6817a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6827a984708SDavid Chisnall    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
6837a984708SDavid Chisnall        {return __table_.__equal_range_unique(__k);}
6847a984708SDavid Chisnall
6857a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6867a984708SDavid Chisnall    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
6877a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6887a984708SDavid Chisnall    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
6897a984708SDavid Chisnall
6907a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6917a984708SDavid Chisnall    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
6927a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6937a984708SDavid Chisnall    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
6947a984708SDavid Chisnall
6957a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6967a984708SDavid Chisnall    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
6977a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
6987a984708SDavid Chisnall    local_iterator       end(size_type __n)          {return __table_.end(__n);}
6997a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7007a984708SDavid Chisnall    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
7017a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7027a984708SDavid Chisnall    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
7037a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7047a984708SDavid Chisnall    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
7057a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7067a984708SDavid Chisnall    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
7077a984708SDavid Chisnall
7087a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7097a984708SDavid Chisnall    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
7107a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7117a984708SDavid Chisnall    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
7127a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7137a984708SDavid Chisnall    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
7147a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7157a984708SDavid Chisnall    void rehash(size_type __n) {__table_.rehash(__n);}
7167a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
7177a984708SDavid Chisnall    void reserve(size_type __n) {__table_.reserve(__n);}
7184f7ab58eSDimitry Andric
7194f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7204f7ab58eSDimitry Andric
7214f7ab58eSDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
7224f7ab58eSDimitry Andric        {return __table_.__dereferenceable(__i);}
7234f7ab58eSDimitry Andric    bool __decrementable(const const_iterator* __i) const
7244f7ab58eSDimitry Andric        {return __table_.__decrementable(__i);}
7254f7ab58eSDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
7264f7ab58eSDimitry Andric        {return __table_.__addable(__i, __n);}
7274f7ab58eSDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
7284f7ab58eSDimitry Andric        {return __table_.__addable(__i, __n);}
7294f7ab58eSDimitry Andric
7304f7ab58eSDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
7314f7ab58eSDimitry Andric
7327a984708SDavid Chisnall};
7337a984708SDavid Chisnall
7347a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7357a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
7367a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql)
7377a984708SDavid Chisnall    : __table_(__hf, __eql)
7387a984708SDavid Chisnall{
7394f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7404f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
7414f7ab58eSDimitry Andric#endif
7427a984708SDavid Chisnall    __table_.rehash(__n);
7437a984708SDavid Chisnall}
7447a984708SDavid Chisnall
7457a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7467a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
7477a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
7487a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
7497a984708SDavid Chisnall{
7504f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7514f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
7524f7ab58eSDimitry Andric#endif
7537a984708SDavid Chisnall    __table_.rehash(__n);
7547a984708SDavid Chisnall}
7557a984708SDavid Chisnall
7567a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7577a984708SDavid Chisnalltemplate <class _InputIterator>
7587a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
7597a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last)
7607a984708SDavid Chisnall{
7614f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7624f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
7634f7ab58eSDimitry Andric#endif
7647a984708SDavid Chisnall    insert(__first, __last);
7657a984708SDavid Chisnall}
7667a984708SDavid Chisnall
7677a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7687a984708SDavid Chisnalltemplate <class _InputIterator>
7697a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
7707a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last, size_type __n,
7717a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql)
7727a984708SDavid Chisnall    : __table_(__hf, __eql)
7737a984708SDavid Chisnall{
7744f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7754f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
7764f7ab58eSDimitry Andric#endif
7777a984708SDavid Chisnall    __table_.rehash(__n);
7787a984708SDavid Chisnall    insert(__first, __last);
7797a984708SDavid Chisnall}
7807a984708SDavid Chisnall
7817a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7827a984708SDavid Chisnalltemplate <class _InputIterator>
7837a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
7847a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last, size_type __n,
7857a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
7867a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
7877a984708SDavid Chisnall{
7884f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7894f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
7904f7ab58eSDimitry Andric#endif
7917a984708SDavid Chisnall    __table_.rehash(__n);
7927a984708SDavid Chisnall    insert(__first, __last);
7937a984708SDavid Chisnall}
7947a984708SDavid Chisnall
7957a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
7967c82a1ecSDimitry Andricinline
7977a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
7987a984708SDavid Chisnall        const allocator_type& __a)
7997a984708SDavid Chisnall    : __table_(__a)
8007a984708SDavid Chisnall{
8014f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8024f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8034f7ab58eSDimitry Andric#endif
8047a984708SDavid Chisnall}
8057a984708SDavid Chisnall
8067a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8077a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8087a984708SDavid Chisnall        const unordered_set& __u)
8097a984708SDavid Chisnall    : __table_(__u.__table_)
8107a984708SDavid Chisnall{
8114f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8124f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8134f7ab58eSDimitry Andric#endif
8147a984708SDavid Chisnall    __table_.rehash(__u.bucket_count());
8157a984708SDavid Chisnall    insert(__u.begin(), __u.end());
8167a984708SDavid Chisnall}
8177a984708SDavid Chisnall
8187a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8197a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8207a984708SDavid Chisnall        const unordered_set& __u, const allocator_type& __a)
8217a984708SDavid Chisnall    : __table_(__u.__table_, __a)
8227a984708SDavid Chisnall{
8234f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8244f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8254f7ab58eSDimitry Andric#endif
8267a984708SDavid Chisnall    __table_.rehash(__u.bucket_count());
8277a984708SDavid Chisnall    insert(__u.begin(), __u.end());
8287a984708SDavid Chisnall}
8297a984708SDavid Chisnall
830540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8317a984708SDavid Chisnall
8327a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8337c82a1ecSDimitry Andricinline
8347a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8357a984708SDavid Chisnall        unordered_set&& __u)
8367a984708SDavid Chisnall    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
8377a984708SDavid Chisnall    : __table_(_VSTD::move(__u.__table_))
8387a984708SDavid Chisnall{
8394f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8404f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8414f7ab58eSDimitry Andric    __get_db()->swap(this, &__u);
8424f7ab58eSDimitry Andric#endif
8437a984708SDavid Chisnall}
8447a984708SDavid Chisnall
8457a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8467a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8477a984708SDavid Chisnall        unordered_set&& __u, const allocator_type& __a)
8487a984708SDavid Chisnall    : __table_(_VSTD::move(__u.__table_), __a)
8497a984708SDavid Chisnall{
8504f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8514f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8524f7ab58eSDimitry Andric#endif
8537a984708SDavid Chisnall    if (__a != __u.get_allocator())
8547a984708SDavid Chisnall    {
8557a984708SDavid Chisnall        iterator __i = __u.begin();
8567a984708SDavid Chisnall        while (__u.size() != 0)
8577a984708SDavid Chisnall            __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
8587a984708SDavid Chisnall    }
8594f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8604f7ab58eSDimitry Andric    else
8614f7ab58eSDimitry Andric        __get_db()->swap(this, &__u);
8624f7ab58eSDimitry Andric#endif
8637a984708SDavid Chisnall}
8647a984708SDavid Chisnall
8657a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8667a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8677a984708SDavid Chisnall        initializer_list<value_type> __il)
8687a984708SDavid Chisnall{
8694f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8704f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8714f7ab58eSDimitry Andric#endif
8727a984708SDavid Chisnall    insert(__il.begin(), __il.end());
8737a984708SDavid Chisnall}
8747a984708SDavid Chisnall
8757a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8767a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8777a984708SDavid Chisnall        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
8787a984708SDavid Chisnall        const key_equal& __eql)
8797a984708SDavid Chisnall    : __table_(__hf, __eql)
8807a984708SDavid Chisnall{
8814f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8824f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8834f7ab58eSDimitry Andric#endif
8847a984708SDavid Chisnall    __table_.rehash(__n);
8857a984708SDavid Chisnall    insert(__il.begin(), __il.end());
8867a984708SDavid Chisnall}
8877a984708SDavid Chisnall
8887a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8897a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8907a984708SDavid Chisnall        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
8917a984708SDavid Chisnall        const key_equal& __eql, const allocator_type& __a)
8927a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
8937a984708SDavid Chisnall{
8944f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8954f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
8964f7ab58eSDimitry Andric#endif
8977a984708SDavid Chisnall    __table_.rehash(__n);
8987a984708SDavid Chisnall    insert(__il.begin(), __il.end());
8997a984708SDavid Chisnall}
9007a984708SDavid Chisnall
9017a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9027c82a1ecSDimitry Andricinline
9037a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>&
9047a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
9057a984708SDavid Chisnall    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
9067a984708SDavid Chisnall{
9077a984708SDavid Chisnall    __table_ = _VSTD::move(__u.__table_);
9087a984708SDavid Chisnall    return *this;
9097a984708SDavid Chisnall}
9107a984708SDavid Chisnall
9117a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9127c82a1ecSDimitry Andricinline
9137a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>&
9147a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
9157a984708SDavid Chisnall        initializer_list<value_type> __il)
9167a984708SDavid Chisnall{
9177a984708SDavid Chisnall    __table_.__assign_unique(__il.begin(), __il.end());
9187a984708SDavid Chisnall    return *this;
9197a984708SDavid Chisnall}
9207a984708SDavid Chisnall
921540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
9227a984708SDavid Chisnall
9237a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9247a984708SDavid Chisnalltemplate <class _InputIterator>
9257c82a1ecSDimitry Andricinline
9267a984708SDavid Chisnallvoid
9277a984708SDavid Chisnallunordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
9287a984708SDavid Chisnall                                                    _InputIterator __last)
9297a984708SDavid Chisnall{
9307a984708SDavid Chisnall    for (; __first != __last; ++__first)
9317a984708SDavid Chisnall        __table_.__insert_unique(*__first);
9327a984708SDavid Chisnall}
9337a984708SDavid Chisnall
9347a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9357a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
9367a984708SDavid Chisnallvoid
9377a984708SDavid Chisnallswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
9387a984708SDavid Chisnall     unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
9397a984708SDavid Chisnall    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
9407a984708SDavid Chisnall{
9417a984708SDavid Chisnall    __x.swap(__y);
9427a984708SDavid Chisnall}
9437a984708SDavid Chisnall
944*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17
945*b5893f02SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
946*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
947*b5893f02SDimitry Andricvoid erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
948*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
949*b5893f02SDimitry Andric#endif
950*b5893f02SDimitry Andric
9517a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9527a984708SDavid Chisnallbool
9537a984708SDavid Chisnalloperator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
9547a984708SDavid Chisnall           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
9557a984708SDavid Chisnall{
9567a984708SDavid Chisnall    if (__x.size() != __y.size())
9577a984708SDavid Chisnall        return false;
9587a984708SDavid Chisnall    typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
9597a984708SDavid Chisnall                                                                 const_iterator;
9607a984708SDavid Chisnall    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
9617a984708SDavid Chisnall            __i != __ex; ++__i)
9627a984708SDavid Chisnall    {
9637a984708SDavid Chisnall        const_iterator __j = __y.find(*__i);
9647a984708SDavid Chisnall        if (__j == __ey || !(*__i == *__j))
9657a984708SDavid Chisnall            return false;
9667a984708SDavid Chisnall    }
9677a984708SDavid Chisnall    return true;
9687a984708SDavid Chisnall}
9697a984708SDavid Chisnall
9707a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9717a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
9727a984708SDavid Chisnallbool
9737a984708SDavid Chisnalloperator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
9747a984708SDavid Chisnall           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
9757a984708SDavid Chisnall{
9767a984708SDavid Chisnall    return !(__x == __y);
9777a984708SDavid Chisnall}
9787a984708SDavid Chisnall
9797a984708SDavid Chisnalltemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
9807a984708SDavid Chisnall          class _Alloc = allocator<_Value> >
981aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multiset
9827a984708SDavid Chisnall{
9837a984708SDavid Chisnallpublic:
9847a984708SDavid Chisnall    // types
9857a984708SDavid Chisnall    typedef _Value                                                     key_type;
9867a984708SDavid Chisnall    typedef key_type                                                   value_type;
9877a984708SDavid Chisnall    typedef _Hash                                                      hasher;
9887a984708SDavid Chisnall    typedef _Pred                                                      key_equal;
9897a984708SDavid Chisnall    typedef _Alloc                                                     allocator_type;
9907a984708SDavid Chisnall    typedef value_type&                                                reference;
9917a984708SDavid Chisnall    typedef const value_type&                                          const_reference;
9924f7ab58eSDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
9934f7ab58eSDimitry Andric                  "Invalid allocator::value_type");
994*b5893f02SDimitry Andric    static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
9957a984708SDavid Chisnall
9967a984708SDavid Chisnallprivate:
9977a984708SDavid Chisnall    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
9987a984708SDavid Chisnall
9997a984708SDavid Chisnall    __table __table_;
10007a984708SDavid Chisnall
10017a984708SDavid Chisnallpublic:
10027a984708SDavid Chisnall    typedef typename __table::pointer         pointer;
10037a984708SDavid Chisnall    typedef typename __table::const_pointer   const_pointer;
10047a984708SDavid Chisnall    typedef typename __table::size_type       size_type;
10057a984708SDavid Chisnall    typedef typename __table::difference_type difference_type;
10067a984708SDavid Chisnall
10077a984708SDavid Chisnall    typedef typename __table::const_iterator       iterator;
10087a984708SDavid Chisnall    typedef typename __table::const_iterator       const_iterator;
10097a984708SDavid Chisnall    typedef typename __table::const_local_iterator local_iterator;
10107a984708SDavid Chisnall    typedef typename __table::const_local_iterator const_local_iterator;
10117a984708SDavid Chisnall
10124ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14
10134ba319b5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
10144ba319b5SDimitry Andric#endif
10154ba319b5SDimitry Andric
1016*b5893f02SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1017*b5893f02SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
1018*b5893f02SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1019*b5893f02SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
1020*b5893f02SDimitry Andric
10217a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
10227a984708SDavid Chisnall    unordered_multiset()
10237a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
10244f7ab58eSDimitry Andric        {
10254f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
10264f7ab58eSDimitry Andric            __get_db()->__insert_c(this);
10274f7ab58eSDimitry Andric#endif
10284f7ab58eSDimitry Andric        }
10297a984708SDavid Chisnall    explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
10307a984708SDavid Chisnall                                const key_equal& __eql = key_equal());
10317a984708SDavid Chisnall    unordered_multiset(size_type __n, const hasher& __hf,
10327a984708SDavid Chisnall                       const key_equal& __eql, const allocator_type& __a);
10334f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
10344f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10354f7ab58eSDimitry Andric    unordered_multiset(size_type __n, const allocator_type& __a)
10364f7ab58eSDimitry Andric        : unordered_multiset(__n, hasher(), key_equal(), __a) {}
10374f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10384f7ab58eSDimitry Andric    unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
10394f7ab58eSDimitry Andric        : unordered_multiset(__n, __hf, key_equal(), __a) {}
10404f7ab58eSDimitry Andric#endif
10417a984708SDavid Chisnall    template <class _InputIterator>
10427a984708SDavid Chisnall        unordered_multiset(_InputIterator __first, _InputIterator __last);
10437a984708SDavid Chisnall    template <class _InputIterator>
10447a984708SDavid Chisnall        unordered_multiset(_InputIterator __first, _InputIterator __last,
10457a984708SDavid Chisnall                      size_type __n, const hasher& __hf = hasher(),
10467a984708SDavid Chisnall                      const key_equal& __eql = key_equal());
10477a984708SDavid Chisnall    template <class _InputIterator>
10487a984708SDavid Chisnall        unordered_multiset(_InputIterator __first, _InputIterator __last,
10497a984708SDavid Chisnall                      size_type __n , const hasher& __hf,
10507a984708SDavid Chisnall                      const key_equal& __eql, const allocator_type& __a);
10514f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
10524f7ab58eSDimitry Andric    template <class _InputIterator>
10534f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10544f7ab58eSDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
10554f7ab58eSDimitry Andric                       size_type __n, const allocator_type& __a)
10564f7ab58eSDimitry Andric        : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
10574f7ab58eSDimitry Andric    template <class _InputIterator>
10584f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10594f7ab58eSDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
10604f7ab58eSDimitry Andric                       size_type __n, const hasher& __hf, const allocator_type& __a)
10614f7ab58eSDimitry Andric        : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
10624f7ab58eSDimitry Andric#endif
10637c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10647a984708SDavid Chisnall    explicit unordered_multiset(const allocator_type& __a);
10657a984708SDavid Chisnall    unordered_multiset(const unordered_multiset& __u);
10667a984708SDavid Chisnall    unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
1067540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10687c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10697a984708SDavid Chisnall    unordered_multiset(unordered_multiset&& __u)
10707a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
10717a984708SDavid Chisnall    unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
10727a984708SDavid Chisnall    unordered_multiset(initializer_list<value_type> __il);
10737a984708SDavid Chisnall    unordered_multiset(initializer_list<value_type> __il, size_type __n,
10747a984708SDavid Chisnall                       const hasher& __hf = hasher(),
10757a984708SDavid Chisnall                       const key_equal& __eql = key_equal());
10767a984708SDavid Chisnall    unordered_multiset(initializer_list<value_type> __il, size_type __n,
10777a984708SDavid Chisnall                       const hasher& __hf, const key_equal& __eql,
10787a984708SDavid Chisnall                       const allocator_type& __a);
10794f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11
10804f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10814f7ab58eSDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
10824f7ab58eSDimitry Andric      : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
10834f7ab58eSDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
10844f7ab58eSDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
10854f7ab58eSDimitry Andric      : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
10864f7ab58eSDimitry Andric#endif
1087540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
10887a984708SDavid Chisnall    // ~unordered_multiset() = default;
10897a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
10907a984708SDavid Chisnall    unordered_multiset& operator=(const unordered_multiset& __u)
10917a984708SDavid Chisnall    {
10927a984708SDavid Chisnall        __table_ = __u.__table_;
10937a984708SDavid Chisnall        return *this;
10947a984708SDavid Chisnall    }
1095540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10967c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10977a984708SDavid Chisnall    unordered_multiset& operator=(unordered_multiset&& __u)
10987a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
10997a984708SDavid Chisnall    unordered_multiset& operator=(initializer_list<value_type> __il);
1100540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
11017a984708SDavid Chisnall
11027a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11037a984708SDavid Chisnall    allocator_type get_allocator() const _NOEXCEPT
11047a984708SDavid Chisnall        {return allocator_type(__table_.__node_alloc());}
11057a984708SDavid Chisnall
1106b2c7081bSDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
11077a984708SDavid Chisnall    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
11087a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11097a984708SDavid Chisnall    size_type size() const _NOEXCEPT  {return __table_.size();}
11107a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11117a984708SDavid Chisnall    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
11127a984708SDavid Chisnall
11137a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11147a984708SDavid Chisnall    iterator       begin() _NOEXCEPT        {return __table_.begin();}
11157a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11167a984708SDavid Chisnall    iterator       end() _NOEXCEPT          {return __table_.end();}
11177a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11187a984708SDavid Chisnall    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
11197a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11207a984708SDavid Chisnall    const_iterator end()    const _NOEXCEPT {return __table_.end();}
11217a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11227a984708SDavid Chisnall    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
11237a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11247a984708SDavid Chisnall    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
11257a984708SDavid Chisnall
1126540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11277a984708SDavid Chisnall    template <class... _Args>
11287a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
11297a984708SDavid Chisnall        iterator emplace(_Args&&... __args)
11307a984708SDavid Chisnall            {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
11317a984708SDavid Chisnall    template <class... _Args>
11327a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
11337a984708SDavid Chisnall        iterator emplace_hint(const_iterator __p, _Args&&... __args)
11347a984708SDavid Chisnall            {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
1135540d2a8bSDimitry Andric
11367a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11377a984708SDavid Chisnall    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
11387a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11397a984708SDavid Chisnall    iterator insert(const_iterator __p, value_type&& __x)
11407a984708SDavid Chisnall        {return __table_.__insert_multi(__p, _VSTD::move(__x));}
11417a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
11427a984708SDavid Chisnall    void insert(initializer_list<value_type> __il)
11437a984708SDavid Chisnall        {insert(__il.begin(), __il.end());}
1144540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1145540d2a8bSDimitry Andric
1146540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1147540d2a8bSDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1148540d2a8bSDimitry Andric
1149540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1150540d2a8bSDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
1151540d2a8bSDimitry Andric        {return __table_.__insert_multi(__p, __x);}
1152540d2a8bSDimitry Andric
1153540d2a8bSDimitry Andric    template <class _InputIterator>
1154540d2a8bSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1155540d2a8bSDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
11567a984708SDavid Chisnall
11574ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14
11584ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11594ba319b5SDimitry Andric    iterator insert(node_type&& __nh)
11604ba319b5SDimitry Andric    {
11614ba319b5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
11624ba319b5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
11634ba319b5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
11644ba319b5SDimitry Andric            _VSTD::move(__nh));
11654ba319b5SDimitry Andric    }
11664ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11674ba319b5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
11684ba319b5SDimitry Andric    {
11694ba319b5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
11704ba319b5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
11714ba319b5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
11724ba319b5SDimitry Andric            __hint, _VSTD::move(__nh));
11734ba319b5SDimitry Andric    }
11744ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11754ba319b5SDimitry Andric    node_type extract(const_iterator __position)
11764ba319b5SDimitry Andric    {
11774ba319b5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
11784ba319b5SDimitry Andric            __position);
11794ba319b5SDimitry Andric    }
11804ba319b5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11814ba319b5SDimitry Andric    node_type extract(key_type const& __key)
11824ba319b5SDimitry Andric    {
11834ba319b5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
11844ba319b5SDimitry Andric    }
1185*b5893f02SDimitry Andric
1186*b5893f02SDimitry Andric    template <class _H2, class _P2>
1187*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1188*b5893f02SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
1189*b5893f02SDimitry Andric    {
1190*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1191*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
1192*b5893f02SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1193*b5893f02SDimitry Andric    }
1194*b5893f02SDimitry Andric    template <class _H2, class _P2>
1195*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1196*b5893f02SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
1197*b5893f02SDimitry Andric    {
1198*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1199*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
1200*b5893f02SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1201*b5893f02SDimitry Andric    }
1202*b5893f02SDimitry Andric    template <class _H2, class _P2>
1203*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1204*b5893f02SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
1205*b5893f02SDimitry Andric    {
1206*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1207*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
1208*b5893f02SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1209*b5893f02SDimitry Andric    }
1210*b5893f02SDimitry Andric    template <class _H2, class _P2>
1211*b5893f02SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1212*b5893f02SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
1213*b5893f02SDimitry Andric    {
1214*b5893f02SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1215*b5893f02SDimitry Andric                       "merging container with incompatible allocator");
1216*b5893f02SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1217*b5893f02SDimitry Andric    }
12184ba319b5SDimitry Andric#endif
12194ba319b5SDimitry Andric
12207a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12217a984708SDavid Chisnall    iterator erase(const_iterator __p) {return __table_.erase(__p);}
12227a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12237a984708SDavid Chisnall    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
12247a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12257a984708SDavid Chisnall    iterator erase(const_iterator __first, const_iterator __last)
12267a984708SDavid Chisnall        {return __table_.erase(__first, __last);}
12277a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12287a984708SDavid Chisnall    void clear() _NOEXCEPT {__table_.clear();}
12297a984708SDavid Chisnall
12307a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12317a984708SDavid Chisnall    void swap(unordered_multiset& __u)
12327a984708SDavid Chisnall        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
12337a984708SDavid Chisnall        {__table_.swap(__u.__table_);}
12347a984708SDavid Chisnall
12357a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12367a984708SDavid Chisnall    hasher hash_function() const {return __table_.hash_function();}
12377a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12387a984708SDavid Chisnall    key_equal key_eq() const {return __table_.key_eq();}
12397a984708SDavid Chisnall
12407a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12417a984708SDavid Chisnall    iterator       find(const key_type& __k)       {return __table_.find(__k);}
12427a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12437a984708SDavid Chisnall    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
12447a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12457a984708SDavid Chisnall    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
12467a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12477a984708SDavid Chisnall    pair<iterator, iterator>             equal_range(const key_type& __k)
12487a984708SDavid Chisnall        {return __table_.__equal_range_multi(__k);}
12497a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12507a984708SDavid Chisnall    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
12517a984708SDavid Chisnall        {return __table_.__equal_range_multi(__k);}
12527a984708SDavid Chisnall
12537a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12547a984708SDavid Chisnall    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
12557a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12567a984708SDavid Chisnall    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
12577a984708SDavid Chisnall
12587a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12597a984708SDavid Chisnall    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
12607a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12617a984708SDavid Chisnall    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
12627a984708SDavid Chisnall
12637a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12647a984708SDavid Chisnall    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
12657a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12667a984708SDavid Chisnall    local_iterator       end(size_type __n)          {return __table_.end(__n);}
12677a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12687a984708SDavid Chisnall    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
12697a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12707a984708SDavid Chisnall    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
12717a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12727a984708SDavid Chisnall    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
12737a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12747a984708SDavid Chisnall    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
12757a984708SDavid Chisnall
12767a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12777a984708SDavid Chisnall    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
12787a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12797a984708SDavid Chisnall    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
12807a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12817a984708SDavid Chisnall    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
12827a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12837a984708SDavid Chisnall    void rehash(size_type __n) {__table_.rehash(__n);}
12847a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
12857a984708SDavid Chisnall    void reserve(size_type __n) {__table_.reserve(__n);}
12864f7ab58eSDimitry Andric
12874f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
12884f7ab58eSDimitry Andric
12894f7ab58eSDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
12904f7ab58eSDimitry Andric        {return __table_.__dereferenceable(__i);}
12914f7ab58eSDimitry Andric    bool __decrementable(const const_iterator* __i) const
12924f7ab58eSDimitry Andric        {return __table_.__decrementable(__i);}
12934f7ab58eSDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
12944f7ab58eSDimitry Andric        {return __table_.__addable(__i, __n);}
12954f7ab58eSDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
12964f7ab58eSDimitry Andric        {return __table_.__addable(__i, __n);}
12974f7ab58eSDimitry Andric
12984f7ab58eSDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
12994f7ab58eSDimitry Andric
13007a984708SDavid Chisnall};
13017a984708SDavid Chisnall
13027a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13037a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13047a984708SDavid Chisnall        size_type __n, const hasher& __hf, const key_equal& __eql)
13057a984708SDavid Chisnall    : __table_(__hf, __eql)
13067a984708SDavid Chisnall{
13074f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13084f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13094f7ab58eSDimitry Andric#endif
13107a984708SDavid Chisnall    __table_.rehash(__n);
13117a984708SDavid Chisnall}
13127a984708SDavid Chisnall
13137a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13147a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13157a984708SDavid Chisnall        size_type __n, const hasher& __hf, const key_equal& __eql,
13167a984708SDavid Chisnall        const allocator_type& __a)
13177a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
13187a984708SDavid Chisnall{
13194f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13204f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13214f7ab58eSDimitry Andric#endif
13227a984708SDavid Chisnall    __table_.rehash(__n);
13237a984708SDavid Chisnall}
13247a984708SDavid Chisnall
13257a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13267a984708SDavid Chisnalltemplate <class _InputIterator>
13277a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13287a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last)
13297a984708SDavid Chisnall{
13304f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13314f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13324f7ab58eSDimitry Andric#endif
13337a984708SDavid Chisnall    insert(__first, __last);
13347a984708SDavid Chisnall}
13357a984708SDavid Chisnall
13367a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13377a984708SDavid Chisnalltemplate <class _InputIterator>
13387a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13397a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last, size_type __n,
13407a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql)
13417a984708SDavid Chisnall    : __table_(__hf, __eql)
13427a984708SDavid Chisnall{
13434f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13444f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13454f7ab58eSDimitry Andric#endif
13467a984708SDavid Chisnall    __table_.rehash(__n);
13477a984708SDavid Chisnall    insert(__first, __last);
13487a984708SDavid Chisnall}
13497a984708SDavid Chisnall
13507a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13517a984708SDavid Chisnalltemplate <class _InputIterator>
13527a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13537a984708SDavid Chisnall        _InputIterator __first, _InputIterator __last, size_type __n,
13547a984708SDavid Chisnall        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
13557a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
13567a984708SDavid Chisnall{
13574f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13584f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13594f7ab58eSDimitry Andric#endif
13607a984708SDavid Chisnall    __table_.rehash(__n);
13617a984708SDavid Chisnall    insert(__first, __last);
13627a984708SDavid Chisnall}
13637a984708SDavid Chisnall
13647a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13657c82a1ecSDimitry Andricinline
13667a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13677a984708SDavid Chisnall        const allocator_type& __a)
13687a984708SDavid Chisnall    : __table_(__a)
13697a984708SDavid Chisnall{
13704f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13714f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13724f7ab58eSDimitry Andric#endif
13737a984708SDavid Chisnall}
13747a984708SDavid Chisnall
13757a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13767a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13777a984708SDavid Chisnall        const unordered_multiset& __u)
13787a984708SDavid Chisnall    : __table_(__u.__table_)
13797a984708SDavid Chisnall{
13804f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13814f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13824f7ab58eSDimitry Andric#endif
13837a984708SDavid Chisnall    __table_.rehash(__u.bucket_count());
13847a984708SDavid Chisnall    insert(__u.begin(), __u.end());
13857a984708SDavid Chisnall}
13867a984708SDavid Chisnall
13877a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
13887a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
13897a984708SDavid Chisnall        const unordered_multiset& __u, const allocator_type& __a)
13907a984708SDavid Chisnall    : __table_(__u.__table_, __a)
13917a984708SDavid Chisnall{
13924f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13934f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
13944f7ab58eSDimitry Andric#endif
13957a984708SDavid Chisnall    __table_.rehash(__u.bucket_count());
13967a984708SDavid Chisnall    insert(__u.begin(), __u.end());
13977a984708SDavid Chisnall}
13987a984708SDavid Chisnall
1399540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
14007a984708SDavid Chisnall
14017a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14027c82a1ecSDimitry Andricinline
14037a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14047a984708SDavid Chisnall        unordered_multiset&& __u)
14057a984708SDavid Chisnall    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
14067a984708SDavid Chisnall    : __table_(_VSTD::move(__u.__table_))
14077a984708SDavid Chisnall{
14084f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14094f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
14104f7ab58eSDimitry Andric    __get_db()->swap(this, &__u);
14114f7ab58eSDimitry Andric#endif
14127a984708SDavid Chisnall}
14137a984708SDavid Chisnall
14147a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14157a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14167a984708SDavid Chisnall        unordered_multiset&& __u, const allocator_type& __a)
14177a984708SDavid Chisnall    : __table_(_VSTD::move(__u.__table_), __a)
14187a984708SDavid Chisnall{
14194f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14204f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
14214f7ab58eSDimitry Andric#endif
14227a984708SDavid Chisnall    if (__a != __u.get_allocator())
14237a984708SDavid Chisnall    {
14247a984708SDavid Chisnall        iterator __i = __u.begin();
14257a984708SDavid Chisnall        while (__u.size() != 0)
14267a984708SDavid Chisnall            __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
14277a984708SDavid Chisnall    }
14284f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14294f7ab58eSDimitry Andric    else
14304f7ab58eSDimitry Andric        __get_db()->swap(this, &__u);
14314f7ab58eSDimitry Andric#endif
14327a984708SDavid Chisnall}
14337a984708SDavid Chisnall
14347a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14357a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14367a984708SDavid Chisnall        initializer_list<value_type> __il)
14377a984708SDavid Chisnall{
14384f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14394f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
14404f7ab58eSDimitry Andric#endif
14417a984708SDavid Chisnall    insert(__il.begin(), __il.end());
14427a984708SDavid Chisnall}
14437a984708SDavid Chisnall
14447a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14457a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14467a984708SDavid Chisnall        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
14477a984708SDavid Chisnall        const key_equal& __eql)
14487a984708SDavid Chisnall    : __table_(__hf, __eql)
14497a984708SDavid Chisnall{
14504f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14514f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
14524f7ab58eSDimitry Andric#endif
14537a984708SDavid Chisnall    __table_.rehash(__n);
14547a984708SDavid Chisnall    insert(__il.begin(), __il.end());
14557a984708SDavid Chisnall}
14567a984708SDavid Chisnall
14577a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14587a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14597a984708SDavid Chisnall        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
14607a984708SDavid Chisnall        const key_equal& __eql, const allocator_type& __a)
14617a984708SDavid Chisnall    : __table_(__hf, __eql, __a)
14627a984708SDavid Chisnall{
14634f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14644f7ab58eSDimitry Andric    __get_db()->__insert_c(this);
14654f7ab58eSDimitry Andric#endif
14667a984708SDavid Chisnall    __table_.rehash(__n);
14677a984708SDavid Chisnall    insert(__il.begin(), __il.end());
14687a984708SDavid Chisnall}
14697a984708SDavid Chisnall
14707a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14717c82a1ecSDimitry Andricinline
14727a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
14737a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
14747a984708SDavid Chisnall        unordered_multiset&& __u)
14757a984708SDavid Chisnall    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
14767a984708SDavid Chisnall{
14777a984708SDavid Chisnall    __table_ = _VSTD::move(__u.__table_);
14787a984708SDavid Chisnall    return *this;
14797a984708SDavid Chisnall}
14807a984708SDavid Chisnall
14817a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14827a984708SDavid Chisnallinline
14837a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
14847a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
14857a984708SDavid Chisnall        initializer_list<value_type> __il)
14867a984708SDavid Chisnall{
14877a984708SDavid Chisnall    __table_.__assign_multi(__il.begin(), __il.end());
14887a984708SDavid Chisnall    return *this;
14897a984708SDavid Chisnall}
14907a984708SDavid Chisnall
1491540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
14927a984708SDavid Chisnall
14937a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14947a984708SDavid Chisnalltemplate <class _InputIterator>
14957c82a1ecSDimitry Andricinline
14967a984708SDavid Chisnallvoid
14977a984708SDavid Chisnallunordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
14987a984708SDavid Chisnall                                                         _InputIterator __last)
14997a984708SDavid Chisnall{
15007a984708SDavid Chisnall    for (; __first != __last; ++__first)
15017a984708SDavid Chisnall        __table_.__insert_multi(*__first);
15027a984708SDavid Chisnall}
15037a984708SDavid Chisnall
15047a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15057a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
15067a984708SDavid Chisnallvoid
15077a984708SDavid Chisnallswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
15087a984708SDavid Chisnall     unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
15097a984708SDavid Chisnall    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
15107a984708SDavid Chisnall{
15117a984708SDavid Chisnall    __x.swap(__y);
15127a984708SDavid Chisnall}
15137a984708SDavid Chisnall
1514*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17
1515*b5893f02SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1516*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1517*b5893f02SDimitry Andricvoid erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
1518*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
1519*b5893f02SDimitry Andric#endif
1520*b5893f02SDimitry Andric
15217a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15227a984708SDavid Chisnallbool
15237a984708SDavid Chisnalloperator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
15247a984708SDavid Chisnall           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
15257a984708SDavid Chisnall{
15267a984708SDavid Chisnall    if (__x.size() != __y.size())
15277a984708SDavid Chisnall        return false;
15287a984708SDavid Chisnall    typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
15297a984708SDavid Chisnall                                                                 const_iterator;
15307a984708SDavid Chisnall    typedef pair<const_iterator, const_iterator> _EqRng;
15317a984708SDavid Chisnall    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
15327a984708SDavid Chisnall    {
15337a984708SDavid Chisnall        _EqRng __xeq = __x.equal_range(*__i);
15347a984708SDavid Chisnall        _EqRng __yeq = __y.equal_range(*__i);
15357a984708SDavid Chisnall        if (_VSTD::distance(__xeq.first, __xeq.second) !=
15367a984708SDavid Chisnall            _VSTD::distance(__yeq.first, __yeq.second) ||
15377a984708SDavid Chisnall                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
15387a984708SDavid Chisnall            return false;
15397a984708SDavid Chisnall        __i = __xeq.second;
15407a984708SDavid Chisnall    }
15417a984708SDavid Chisnall    return true;
15427a984708SDavid Chisnall}
15437a984708SDavid Chisnall
15447a984708SDavid Chisnalltemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15457a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
15467a984708SDavid Chisnallbool
15477a984708SDavid Chisnalloperator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
15487a984708SDavid Chisnall           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
15497a984708SDavid Chisnall{
15507a984708SDavid Chisnall    return !(__x == __y);
15517a984708SDavid Chisnall}
15527a984708SDavid Chisnall
15537a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD
15547a984708SDavid Chisnall
15557a984708SDavid Chisnall#endif  // _LIBCPP_UNORDERED_SET
1556