17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===-------------------------- unordered_map -----------------------------===// 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_MAP 127a984708SDavid Chisnall#define _LIBCPP_UNORDERED_MAP 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall 167a984708SDavid Chisnall unordered_map synopsis 177a984708SDavid Chisnall 187a984708SDavid Chisnall#include <initializer_list> 197a984708SDavid Chisnall 207a984708SDavid Chisnallnamespace std 217a984708SDavid Chisnall{ 227a984708SDavid Chisnall 237a984708SDavid Chisnalltemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 247a984708SDavid Chisnall class Alloc = allocator<pair<const Key, T>>> 257a984708SDavid Chisnallclass unordered_map 267a984708SDavid Chisnall{ 277a984708SDavid Chisnallpublic: 287a984708SDavid Chisnall // types 297a984708SDavid Chisnall typedef Key key_type; 307a984708SDavid Chisnall typedef T mapped_type; 317a984708SDavid Chisnall typedef Hash hasher; 327a984708SDavid Chisnall typedef Pred key_equal; 337a984708SDavid Chisnall typedef Alloc allocator_type; 347a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 357a984708SDavid Chisnall typedef value_type& reference; 367a984708SDavid Chisnall typedef const value_type& const_reference; 377a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::pointer pointer; 387a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 397a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::size_type size_type; 407a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::difference_type difference_type; 417a984708SDavid Chisnall 427a984708SDavid Chisnall typedef /unspecified/ iterator; 437a984708SDavid Chisnall typedef /unspecified/ const_iterator; 447a984708SDavid Chisnall typedef /unspecified/ local_iterator; 457a984708SDavid Chisnall typedef /unspecified/ const_local_iterator; 467a984708SDavid Chisnall 474ba319b5SDimitry Andric typedef unspecified node_type; // C++17 484ba319b5SDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 494ba319b5SDimitry Andric 507a984708SDavid Chisnall unordered_map() 517a984708SDavid Chisnall noexcept( 527a984708SDavid Chisnall is_nothrow_default_constructible<hasher>::value && 537a984708SDavid Chisnall is_nothrow_default_constructible<key_equal>::value && 547a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value); 557a984708SDavid Chisnall explicit unordered_map(size_type n, const hasher& hf = hasher(), 567a984708SDavid Chisnall const key_equal& eql = key_equal(), 577a984708SDavid Chisnall const allocator_type& a = allocator_type()); 587a984708SDavid Chisnall template <class InputIterator> 597a984708SDavid Chisnall unordered_map(InputIterator f, InputIterator l, 607a984708SDavid Chisnall size_type n = 0, const hasher& hf = hasher(), 617a984708SDavid Chisnall const key_equal& eql = key_equal(), 627a984708SDavid Chisnall const allocator_type& a = allocator_type()); 637a984708SDavid Chisnall explicit unordered_map(const allocator_type&); 647a984708SDavid Chisnall unordered_map(const unordered_map&); 657a984708SDavid Chisnall unordered_map(const unordered_map&, const Allocator&); 667a984708SDavid Chisnall unordered_map(unordered_map&&) 677a984708SDavid Chisnall noexcept( 687a984708SDavid Chisnall is_nothrow_move_constructible<hasher>::value && 697a984708SDavid Chisnall is_nothrow_move_constructible<key_equal>::value && 707a984708SDavid Chisnall is_nothrow_move_constructible<allocator_type>::value); 717a984708SDavid Chisnall unordered_map(unordered_map&&, const Allocator&); 727a984708SDavid Chisnall unordered_map(initializer_list<value_type>, size_type n = 0, 737a984708SDavid Chisnall const hasher& hf = hasher(), const key_equal& eql = key_equal(), 747a984708SDavid Chisnall const allocator_type& a = allocator_type()); 754f7ab58eSDimitry Andric unordered_map(size_type n, const allocator_type& a) 764f7ab58eSDimitry Andric : unordered_map(n, hasher(), key_equal(), a) {} // C++14 774f7ab58eSDimitry Andric unordered_map(size_type n, const hasher& hf, const allocator_type& a) 784f7ab58eSDimitry Andric : unordered_map(n, hf, key_equal(), a) {} // C++14 794f7ab58eSDimitry Andric template <class InputIterator> 804f7ab58eSDimitry Andric unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) 814f7ab58eSDimitry Andric : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 824f7ab58eSDimitry Andric template <class InputIterator> 834f7ab58eSDimitry Andric unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, 844f7ab58eSDimitry Andric const allocator_type& a) 854f7ab58eSDimitry Andric : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 864f7ab58eSDimitry Andric unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a) 874f7ab58eSDimitry Andric : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 884f7ab58eSDimitry Andric unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, 894f7ab58eSDimitry Andric const allocator_type& a) 904f7ab58eSDimitry Andric : unordered_map(il, n, hf, key_equal(), a) {} // C++14 917a984708SDavid Chisnall ~unordered_map(); 927a984708SDavid Chisnall unordered_map& operator=(const unordered_map&); 937a984708SDavid Chisnall unordered_map& operator=(unordered_map&&) 947a984708SDavid Chisnall noexcept( 957a984708SDavid Chisnall allocator_type::propagate_on_container_move_assignment::value && 967a984708SDavid Chisnall is_nothrow_move_assignable<allocator_type>::value && 977a984708SDavid Chisnall is_nothrow_move_assignable<hasher>::value && 987a984708SDavid Chisnall is_nothrow_move_assignable<key_equal>::value); 997a984708SDavid Chisnall unordered_map& operator=(initializer_list<value_type>); 1007a984708SDavid Chisnall 1017a984708SDavid Chisnall allocator_type get_allocator() const noexcept; 1027a984708SDavid Chisnall 1037a984708SDavid Chisnall bool empty() const noexcept; 1047a984708SDavid Chisnall size_type size() const noexcept; 1057a984708SDavid Chisnall size_type max_size() const noexcept; 1067a984708SDavid Chisnall 1077a984708SDavid Chisnall iterator begin() noexcept; 1087a984708SDavid Chisnall iterator end() noexcept; 1097a984708SDavid Chisnall const_iterator begin() const noexcept; 1107a984708SDavid Chisnall const_iterator end() const noexcept; 1117a984708SDavid Chisnall const_iterator cbegin() const noexcept; 1127a984708SDavid Chisnall const_iterator cend() const noexcept; 1137a984708SDavid Chisnall 1147a984708SDavid Chisnall template <class... Args> 1157a984708SDavid Chisnall pair<iterator, bool> emplace(Args&&... args); 1167a984708SDavid Chisnall template <class... Args> 1177a984708SDavid Chisnall iterator emplace_hint(const_iterator position, Args&&... args); 1187a984708SDavid Chisnall pair<iterator, bool> insert(const value_type& obj); 1197a984708SDavid Chisnall template <class P> 1207a984708SDavid Chisnall pair<iterator, bool> insert(P&& obj); 1217a984708SDavid Chisnall iterator insert(const_iterator hint, const value_type& obj); 1227a984708SDavid Chisnall template <class P> 1237a984708SDavid Chisnall iterator insert(const_iterator hint, P&& obj); 1247a984708SDavid Chisnall template <class InputIterator> 1257a984708SDavid Chisnall void insert(InputIterator first, InputIterator last); 1267a984708SDavid Chisnall void insert(initializer_list<value_type>); 1277a984708SDavid Chisnall 1284ba319b5SDimitry Andric node_type extract(const_iterator position); // C++17 1294ba319b5SDimitry Andric node_type extract(const key_type& x); // C++17 1304ba319b5SDimitry Andric insert_return_type insert(node_type&& nh); // C++17 1314ba319b5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 1324ba319b5SDimitry Andric 133854fa44bSDimitry Andric template <class... Args> 134854fa44bSDimitry Andric pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 135854fa44bSDimitry Andric template <class... Args> 136854fa44bSDimitry Andric pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 137854fa44bSDimitry Andric template <class... Args> 138854fa44bSDimitry Andric iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 139854fa44bSDimitry Andric template <class... Args> 140854fa44bSDimitry Andric iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 141854fa44bSDimitry Andric template <class M> 142854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 143854fa44bSDimitry Andric template <class M> 144854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 145854fa44bSDimitry Andric template <class M> 146854fa44bSDimitry Andric iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 147854fa44bSDimitry Andric template <class M> 148854fa44bSDimitry Andric iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 149854fa44bSDimitry Andric 1507a984708SDavid Chisnall iterator erase(const_iterator position); 151854fa44bSDimitry Andric iterator erase(iterator position); // C++14 1527a984708SDavid Chisnall size_type erase(const key_type& k); 1537a984708SDavid Chisnall iterator erase(const_iterator first, const_iterator last); 1547a984708SDavid Chisnall void clear() noexcept; 1557a984708SDavid Chisnall 156*b5893f02SDimitry Andric template<class H2, class P2> 157*b5893f02SDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17 158*b5893f02SDimitry Andric template<class H2, class P2> 159*b5893f02SDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17 160*b5893f02SDimitry Andric template<class H2, class P2> 161*b5893f02SDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17 162*b5893f02SDimitry Andric template<class H2, class P2> 163*b5893f02SDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17 164*b5893f02SDimitry Andric 1657a984708SDavid Chisnall void swap(unordered_map&) 1667a984708SDavid Chisnall noexcept( 1677a984708SDavid Chisnall (!allocator_type::propagate_on_container_swap::value || 1687a984708SDavid Chisnall __is_nothrow_swappable<allocator_type>::value) && 1697a984708SDavid Chisnall __is_nothrow_swappable<hasher>::value && 1707a984708SDavid Chisnall __is_nothrow_swappable<key_equal>::value); 1717a984708SDavid Chisnall 1727a984708SDavid Chisnall hasher hash_function() const; 1737a984708SDavid Chisnall key_equal key_eq() const; 1747a984708SDavid Chisnall 1757a984708SDavid Chisnall iterator find(const key_type& k); 1767a984708SDavid Chisnall const_iterator find(const key_type& k) const; 1777a984708SDavid Chisnall size_type count(const key_type& k) const; 1787a984708SDavid Chisnall pair<iterator, iterator> equal_range(const key_type& k); 1797a984708SDavid Chisnall pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 1807a984708SDavid Chisnall 1817a984708SDavid Chisnall mapped_type& operator[](const key_type& k); 1827a984708SDavid Chisnall mapped_type& operator[](key_type&& k); 1837a984708SDavid Chisnall 1847a984708SDavid Chisnall mapped_type& at(const key_type& k); 1857a984708SDavid Chisnall const mapped_type& at(const key_type& k) const; 1867a984708SDavid Chisnall 1877a984708SDavid Chisnall size_type bucket_count() const noexcept; 1887a984708SDavid Chisnall size_type max_bucket_count() const noexcept; 1897a984708SDavid Chisnall 1907a984708SDavid Chisnall size_type bucket_size(size_type n) const; 1917a984708SDavid Chisnall size_type bucket(const key_type& k) const; 1927a984708SDavid Chisnall 1937a984708SDavid Chisnall local_iterator begin(size_type n); 1947a984708SDavid Chisnall local_iterator end(size_type n); 1957a984708SDavid Chisnall const_local_iterator begin(size_type n) const; 1967a984708SDavid Chisnall const_local_iterator end(size_type n) const; 1977a984708SDavid Chisnall const_local_iterator cbegin(size_type n) const; 1987a984708SDavid Chisnall const_local_iterator cend(size_type n) const; 1997a984708SDavid Chisnall 2007a984708SDavid Chisnall float load_factor() const noexcept; 2017a984708SDavid Chisnall float max_load_factor() const noexcept; 2027a984708SDavid Chisnall void max_load_factor(float z); 2037a984708SDavid Chisnall void rehash(size_type n); 2047a984708SDavid Chisnall void reserve(size_type n); 2057a984708SDavid Chisnall}; 2067a984708SDavid Chisnall 2077a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 2087a984708SDavid Chisnall void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, 2097a984708SDavid Chisnall unordered_map<Key, T, Hash, Pred, Alloc>& y) 2107a984708SDavid Chisnall noexcept(noexcept(x.swap(y))); 2117a984708SDavid Chisnall 2127a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 2137a984708SDavid Chisnall bool 2147a984708SDavid Chisnall operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x, 2157a984708SDavid Chisnall const unordered_map<Key, T, Hash, Pred, Alloc>& y); 2167a984708SDavid Chisnall 2177a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 2187a984708SDavid Chisnall bool 2197a984708SDavid Chisnall operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x, 2207a984708SDavid Chisnall const unordered_map<Key, T, Hash, Pred, Alloc>& y); 2217a984708SDavid Chisnall 2227a984708SDavid Chisnalltemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 2237a984708SDavid Chisnall class Alloc = allocator<pair<const Key, T>>> 2247a984708SDavid Chisnallclass unordered_multimap 2257a984708SDavid Chisnall{ 2267a984708SDavid Chisnallpublic: 2277a984708SDavid Chisnall // types 2287a984708SDavid Chisnall typedef Key key_type; 2297a984708SDavid Chisnall typedef T mapped_type; 2307a984708SDavid Chisnall typedef Hash hasher; 2317a984708SDavid Chisnall typedef Pred key_equal; 2327a984708SDavid Chisnall typedef Alloc allocator_type; 2337a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 2347a984708SDavid Chisnall typedef value_type& reference; 2357a984708SDavid Chisnall typedef const value_type& const_reference; 2367a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::pointer pointer; 2377a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 2387a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::size_type size_type; 2397a984708SDavid Chisnall typedef typename allocator_traits<allocator_type>::difference_type difference_type; 2407a984708SDavid Chisnall 2417a984708SDavid Chisnall typedef /unspecified/ iterator; 2427a984708SDavid Chisnall typedef /unspecified/ const_iterator; 2437a984708SDavid Chisnall typedef /unspecified/ local_iterator; 2447a984708SDavid Chisnall typedef /unspecified/ const_local_iterator; 2457a984708SDavid Chisnall 2464ba319b5SDimitry Andric typedef unspecified node_type; // C++17 2474ba319b5SDimitry Andric 2487a984708SDavid Chisnall unordered_multimap() 2497a984708SDavid Chisnall noexcept( 2507a984708SDavid Chisnall is_nothrow_default_constructible<hasher>::value && 2517a984708SDavid Chisnall is_nothrow_default_constructible<key_equal>::value && 2527a984708SDavid Chisnall is_nothrow_default_constructible<allocator_type>::value); 2537a984708SDavid Chisnall explicit unordered_multimap(size_type n, const hasher& hf = hasher(), 2547a984708SDavid Chisnall const key_equal& eql = key_equal(), 2557a984708SDavid Chisnall const allocator_type& a = allocator_type()); 2567a984708SDavid Chisnall template <class InputIterator> 2577a984708SDavid Chisnall unordered_multimap(InputIterator f, InputIterator l, 2587a984708SDavid Chisnall size_type n = 0, const hasher& hf = hasher(), 2597a984708SDavid Chisnall const key_equal& eql = key_equal(), 2607a984708SDavid Chisnall const allocator_type& a = allocator_type()); 2617a984708SDavid Chisnall explicit unordered_multimap(const allocator_type&); 2627a984708SDavid Chisnall unordered_multimap(const unordered_multimap&); 2637a984708SDavid Chisnall unordered_multimap(const unordered_multimap&, const Allocator&); 2647a984708SDavid Chisnall unordered_multimap(unordered_multimap&&) 2657a984708SDavid Chisnall noexcept( 2667a984708SDavid Chisnall is_nothrow_move_constructible<hasher>::value && 2677a984708SDavid Chisnall is_nothrow_move_constructible<key_equal>::value && 2687a984708SDavid Chisnall is_nothrow_move_constructible<allocator_type>::value); 2697a984708SDavid Chisnall unordered_multimap(unordered_multimap&&, const Allocator&); 2707a984708SDavid Chisnall unordered_multimap(initializer_list<value_type>, size_type n = 0, 2717a984708SDavid Chisnall const hasher& hf = hasher(), const key_equal& eql = key_equal(), 2727a984708SDavid Chisnall const allocator_type& a = allocator_type()); 2734f7ab58eSDimitry Andric unordered_multimap(size_type n, const allocator_type& a) 2744f7ab58eSDimitry Andric : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 2754f7ab58eSDimitry Andric unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) 2764f7ab58eSDimitry Andric : unordered_multimap(n, hf, key_equal(), a) {} // C++14 2774f7ab58eSDimitry Andric template <class InputIterator> 2784f7ab58eSDimitry Andric unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) 2794f7ab58eSDimitry Andric : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 2804f7ab58eSDimitry Andric template <class InputIterator> 2814f7ab58eSDimitry Andric unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, 2824f7ab58eSDimitry Andric const allocator_type& a) 2834f7ab58eSDimitry Andric : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 2844f7ab58eSDimitry Andric unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a) 2854f7ab58eSDimitry Andric : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 2864f7ab58eSDimitry Andric unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, 2874f7ab58eSDimitry Andric const allocator_type& a) 2884f7ab58eSDimitry Andric : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 2897a984708SDavid Chisnall ~unordered_multimap(); 2907a984708SDavid Chisnall unordered_multimap& operator=(const unordered_multimap&); 2917a984708SDavid Chisnall unordered_multimap& operator=(unordered_multimap&&) 2927a984708SDavid Chisnall noexcept( 2937a984708SDavid Chisnall allocator_type::propagate_on_container_move_assignment::value && 2947a984708SDavid Chisnall is_nothrow_move_assignable<allocator_type>::value && 2957a984708SDavid Chisnall is_nothrow_move_assignable<hasher>::value && 2967a984708SDavid Chisnall is_nothrow_move_assignable<key_equal>::value); 2977a984708SDavid Chisnall unordered_multimap& operator=(initializer_list<value_type>); 2987a984708SDavid Chisnall 2997a984708SDavid Chisnall allocator_type get_allocator() const noexcept; 3007a984708SDavid Chisnall 3017a984708SDavid Chisnall bool empty() const noexcept; 3027a984708SDavid Chisnall size_type size() const noexcept; 3037a984708SDavid Chisnall size_type max_size() const noexcept; 3047a984708SDavid Chisnall 3057a984708SDavid Chisnall iterator begin() noexcept; 3067a984708SDavid Chisnall iterator end() noexcept; 3077a984708SDavid Chisnall const_iterator begin() const noexcept; 3087a984708SDavid Chisnall const_iterator end() const noexcept; 3097a984708SDavid Chisnall const_iterator cbegin() const noexcept; 3107a984708SDavid Chisnall const_iterator cend() const noexcept; 3117a984708SDavid Chisnall 3127a984708SDavid Chisnall template <class... Args> 3137a984708SDavid Chisnall iterator emplace(Args&&... args); 3147a984708SDavid Chisnall template <class... Args> 3157a984708SDavid Chisnall iterator emplace_hint(const_iterator position, Args&&... args); 3167a984708SDavid Chisnall iterator insert(const value_type& obj); 3177a984708SDavid Chisnall template <class P> 3187a984708SDavid Chisnall iterator insert(P&& obj); 3197a984708SDavid Chisnall iterator insert(const_iterator hint, const value_type& obj); 3207a984708SDavid Chisnall template <class P> 3217a984708SDavid Chisnall iterator insert(const_iterator hint, P&& obj); 3227a984708SDavid Chisnall template <class InputIterator> 3237a984708SDavid Chisnall void insert(InputIterator first, InputIterator last); 3247a984708SDavid Chisnall void insert(initializer_list<value_type>); 3257a984708SDavid Chisnall 3264ba319b5SDimitry Andric node_type extract(const_iterator position); // C++17 3274ba319b5SDimitry Andric node_type extract(const key_type& x); // C++17 3284ba319b5SDimitry Andric iterator insert(node_type&& nh); // C++17 3294ba319b5SDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 3304ba319b5SDimitry Andric 3317a984708SDavid Chisnall iterator erase(const_iterator position); 332854fa44bSDimitry Andric iterator erase(iterator position); // C++14 3337a984708SDavid Chisnall size_type erase(const key_type& k); 3347a984708SDavid Chisnall iterator erase(const_iterator first, const_iterator last); 3357a984708SDavid Chisnall void clear() noexcept; 3367a984708SDavid Chisnall 337*b5893f02SDimitry Andric template<class H2, class P2> 338*b5893f02SDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17 339*b5893f02SDimitry Andric template<class H2, class P2> 340*b5893f02SDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17 341*b5893f02SDimitry Andric template<class H2, class P2> 342*b5893f02SDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17 343*b5893f02SDimitry Andric template<class H2, class P2> 344*b5893f02SDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17 345*b5893f02SDimitry Andric 3467a984708SDavid Chisnall void swap(unordered_multimap&) 3477a984708SDavid Chisnall noexcept( 3487a984708SDavid Chisnall (!allocator_type::propagate_on_container_swap::value || 3497a984708SDavid Chisnall __is_nothrow_swappable<allocator_type>::value) && 3507a984708SDavid Chisnall __is_nothrow_swappable<hasher>::value && 3517a984708SDavid Chisnall __is_nothrow_swappable<key_equal>::value); 3527a984708SDavid Chisnall 3537a984708SDavid Chisnall hasher hash_function() const; 3547a984708SDavid Chisnall key_equal key_eq() const; 3557a984708SDavid Chisnall 3567a984708SDavid Chisnall iterator find(const key_type& k); 3577a984708SDavid Chisnall const_iterator find(const key_type& k) const; 3587a984708SDavid Chisnall size_type count(const key_type& k) const; 3597a984708SDavid Chisnall pair<iterator, iterator> equal_range(const key_type& k); 3607a984708SDavid Chisnall pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 3617a984708SDavid Chisnall 3627a984708SDavid Chisnall size_type bucket_count() const noexcept; 3637a984708SDavid Chisnall size_type max_bucket_count() const noexcept; 3647a984708SDavid Chisnall 3657a984708SDavid Chisnall size_type bucket_size(size_type n) const; 3667a984708SDavid Chisnall size_type bucket(const key_type& k) const; 3677a984708SDavid Chisnall 3687a984708SDavid Chisnall local_iterator begin(size_type n); 3697a984708SDavid Chisnall local_iterator end(size_type n); 3707a984708SDavid Chisnall const_local_iterator begin(size_type n) const; 3717a984708SDavid Chisnall const_local_iterator end(size_type n) const; 3727a984708SDavid Chisnall const_local_iterator cbegin(size_type n) const; 3737a984708SDavid Chisnall const_local_iterator cend(size_type n) const; 3747a984708SDavid Chisnall 3757a984708SDavid Chisnall float load_factor() const noexcept; 3767a984708SDavid Chisnall float max_load_factor() const noexcept; 3777a984708SDavid Chisnall void max_load_factor(float z); 3787a984708SDavid Chisnall void rehash(size_type n); 3797a984708SDavid Chisnall void reserve(size_type n); 3807a984708SDavid Chisnall}; 3817a984708SDavid Chisnall 3827a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 3837a984708SDavid Chisnall void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 3847a984708SDavid Chisnall unordered_multimap<Key, T, Hash, Pred, Alloc>& y) 3857a984708SDavid Chisnall noexcept(noexcept(x.swap(y))); 3867a984708SDavid Chisnall 387*b5893f02SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 388*b5893f02SDimitry Andric void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20 389*b5893f02SDimitry Andric 390*b5893f02SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 391*b5893f02SDimitry Andric void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20 392*b5893f02SDimitry Andric 3937a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 3947a984708SDavid Chisnall bool 3957a984708SDavid Chisnall operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 3967a984708SDavid Chisnall const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); 3977a984708SDavid Chisnall 3987a984708SDavid Chisnalltemplate <class Key, class T, class Hash, class Pred, class Alloc> 3997a984708SDavid Chisnall bool 4007a984708SDavid Chisnall operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 4017a984708SDavid Chisnall const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); 4027a984708SDavid Chisnall 4037a984708SDavid Chisnall} // std 4047a984708SDavid Chisnall 4057a984708SDavid Chisnall*/ 4067a984708SDavid Chisnall 4077a984708SDavid Chisnall#include <__config> 4087a984708SDavid Chisnall#include <__hash_table> 4094ba319b5SDimitry Andric#include <__node_handle> 4107a984708SDavid Chisnall#include <functional> 4117a984708SDavid Chisnall#include <stdexcept> 4127c82a1ecSDimitry Andric#include <tuple> 413*b5893f02SDimitry Andric#include <version> 4147a984708SDavid Chisnall 415d72607e9SDimitry Andric#include <__debug> 416d72607e9SDimitry Andric 4177a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4187a984708SDavid Chisnall#pragma GCC system_header 4197a984708SDavid Chisnall#endif 4207a984708SDavid Chisnall 4217a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 4227a984708SDavid Chisnall 423*b5893f02SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, 424*b5893f02SDimitry Andric bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value> 4257a984708SDavid Chisnallclass __unordered_map_hasher 4267a984708SDavid Chisnall : private _Hash 4277a984708SDavid Chisnall{ 4287a984708SDavid Chisnallpublic: 4297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4307a984708SDavid Chisnall __unordered_map_hasher() 4317a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) 4327a984708SDavid Chisnall : _Hash() {} 4337a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4347a984708SDavid Chisnall __unordered_map_hasher(const _Hash& __h) 4357a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) 4367a984708SDavid Chisnall : _Hash(__h) {} 4377a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4387a984708SDavid Chisnall const _Hash& hash_function() const _NOEXCEPT {return *this;} 4397a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 44094e3ee44SDavid Chisnall size_t operator()(const _Cp& __x) const 4414ba319b5SDimitry Andric {return static_cast<const _Hash&>(*this)(__x.__get_value().first);} 44294e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 44394e3ee44SDavid Chisnall size_t operator()(const _Key& __x) const 4447a984708SDavid Chisnall {return static_cast<const _Hash&>(*this)(__x);} 445854fa44bSDimitry Andric void swap(__unordered_map_hasher&__y) 446854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) 447854fa44bSDimitry Andric { 448854fa44bSDimitry Andric using _VSTD::swap; 449540d2a8bSDimitry Andric swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); 450854fa44bSDimitry Andric } 4517a984708SDavid Chisnall}; 4527a984708SDavid Chisnall 4534bab9fd9SDavid Chisnalltemplate <class _Key, class _Cp, class _Hash> 4544bab9fd9SDavid Chisnallclass __unordered_map_hasher<_Key, _Cp, _Hash, false> 4557a984708SDavid Chisnall{ 4567a984708SDavid Chisnall _Hash __hash_; 4577a984708SDavid Chisnallpublic: 4587a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4597a984708SDavid Chisnall __unordered_map_hasher() 4607a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) 4617a984708SDavid Chisnall : __hash_() {} 4627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4637a984708SDavid Chisnall __unordered_map_hasher(const _Hash& __h) 4647a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) 4657a984708SDavid Chisnall : __hash_(__h) {} 4667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4677a984708SDavid Chisnall const _Hash& hash_function() const _NOEXCEPT {return __hash_;} 4687a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 46994e3ee44SDavid Chisnall size_t operator()(const _Cp& __x) const 4704ba319b5SDimitry Andric {return __hash_(__x.__get_value().first);} 47194e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 47294e3ee44SDavid Chisnall size_t operator()(const _Key& __x) const 4737a984708SDavid Chisnall {return __hash_(__x);} 474854fa44bSDimitry Andric void swap(__unordered_map_hasher&__y) 475854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) 476854fa44bSDimitry Andric { 477854fa44bSDimitry Andric using _VSTD::swap; 478854fa44bSDimitry Andric swap(__hash_, __y.__hash_); 479854fa44bSDimitry Andric } 4807a984708SDavid Chisnall}; 4817a984708SDavid Chisnall 482854fa44bSDimitry Andrictemplate <class _Key, class _Cp, class _Hash, bool __b> 483854fa44bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 484854fa44bSDimitry Andricvoid 485854fa44bSDimitry Andricswap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x, 486854fa44bSDimitry Andric __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y) 487854fa44bSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 488854fa44bSDimitry Andric{ 489854fa44bSDimitry Andric __x.swap(__y); 490854fa44bSDimitry Andric} 491854fa44bSDimitry Andric 492*b5893f02SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, 493*b5893f02SDimitry Andric bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value> 4947a984708SDavid Chisnallclass __unordered_map_equal 4957a984708SDavid Chisnall : private _Pred 4967a984708SDavid Chisnall{ 4977a984708SDavid Chisnallpublic: 4987a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 4997a984708SDavid Chisnall __unordered_map_equal() 5007a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) 5017a984708SDavid Chisnall : _Pred() {} 5027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5037a984708SDavid Chisnall __unordered_map_equal(const _Pred& __p) 5047a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) 5057a984708SDavid Chisnall : _Pred(__p) {} 5067a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5077a984708SDavid Chisnall const _Pred& key_eq() const _NOEXCEPT {return *this;} 5087a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 50994e3ee44SDavid Chisnall bool operator()(const _Cp& __x, const _Cp& __y) const 5104ba319b5SDimitry Andric {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);} 51194e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 51294e3ee44SDavid Chisnall bool operator()(const _Cp& __x, const _Key& __y) const 5134ba319b5SDimitry Andric {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);} 51494e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 51594e3ee44SDavid Chisnall bool operator()(const _Key& __x, const _Cp& __y) const 5164ba319b5SDimitry Andric {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);} 517854fa44bSDimitry Andric void swap(__unordered_map_equal&__y) 518854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) 519854fa44bSDimitry Andric { 520854fa44bSDimitry Andric using _VSTD::swap; 521540d2a8bSDimitry Andric swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); 522854fa44bSDimitry Andric } 5237a984708SDavid Chisnall}; 5247a984708SDavid Chisnall 5254bab9fd9SDavid Chisnalltemplate <class _Key, class _Cp, class _Pred> 5264bab9fd9SDavid Chisnallclass __unordered_map_equal<_Key, _Cp, _Pred, false> 5277a984708SDavid Chisnall{ 5287a984708SDavid Chisnall _Pred __pred_; 5297a984708SDavid Chisnallpublic: 5307a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5317a984708SDavid Chisnall __unordered_map_equal() 5327a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) 5337a984708SDavid Chisnall : __pred_() {} 5347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5357a984708SDavid Chisnall __unordered_map_equal(const _Pred& __p) 5367a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) 5377a984708SDavid Chisnall : __pred_(__p) {} 5387a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5397a984708SDavid Chisnall const _Pred& key_eq() const _NOEXCEPT {return __pred_;} 5407a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 54194e3ee44SDavid Chisnall bool operator()(const _Cp& __x, const _Cp& __y) const 5424ba319b5SDimitry Andric {return __pred_(__x.__get_value().first, __y.__get_value().first);} 54394e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 54494e3ee44SDavid Chisnall bool operator()(const _Cp& __x, const _Key& __y) const 5454ba319b5SDimitry Andric {return __pred_(__x.__get_value().first, __y);} 54694e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 54794e3ee44SDavid Chisnall bool operator()(const _Key& __x, const _Cp& __y) const 5484ba319b5SDimitry Andric {return __pred_(__x, __y.__get_value().first);} 549854fa44bSDimitry Andric void swap(__unordered_map_equal&__y) 550854fa44bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) 551854fa44bSDimitry Andric { 552854fa44bSDimitry Andric using _VSTD::swap; 553854fa44bSDimitry Andric swap(__pred_, __y.__pred_); 554854fa44bSDimitry Andric } 5557a984708SDavid Chisnall}; 5567a984708SDavid Chisnall 557854fa44bSDimitry Andrictemplate <class _Key, class _Cp, class _Pred, bool __b> 558854fa44bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 559854fa44bSDimitry Andricvoid 560854fa44bSDimitry Andricswap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x, 561854fa44bSDimitry Andric __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y) 562854fa44bSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 563854fa44bSDimitry Andric{ 564854fa44bSDimitry Andric __x.swap(__y); 565854fa44bSDimitry Andric} 566854fa44bSDimitry Andric 5677a984708SDavid Chisnalltemplate <class _Alloc> 5687a984708SDavid Chisnallclass __hash_map_node_destructor 5697a984708SDavid Chisnall{ 5707a984708SDavid Chisnall typedef _Alloc allocator_type; 5717a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 5727c82a1ecSDimitry Andric 5737a984708SDavid Chisnallpublic: 5747c82a1ecSDimitry Andric 5757a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 5767a984708SDavid Chisnallprivate: 5777a984708SDavid Chisnall 5787a984708SDavid Chisnall allocator_type& __na_; 5797a984708SDavid Chisnall 5807a984708SDavid Chisnall __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); 5817a984708SDavid Chisnall 5827a984708SDavid Chisnallpublic: 5837a984708SDavid Chisnall bool __first_constructed; 5847a984708SDavid Chisnall bool __second_constructed; 5857a984708SDavid Chisnall 5867a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5877a984708SDavid Chisnall explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT 5887a984708SDavid Chisnall : __na_(__na), 5897a984708SDavid Chisnall __first_constructed(false), 5907a984708SDavid Chisnall __second_constructed(false) 5917a984708SDavid Chisnall {} 5927a984708SDavid Chisnall 593540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5947a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 5957a984708SDavid Chisnall __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) 5967a984708SDavid Chisnall _NOEXCEPT 5977a984708SDavid Chisnall : __na_(__x.__na_), 5987a984708SDavid Chisnall __first_constructed(__x.__value_constructed), 5997a984708SDavid Chisnall __second_constructed(__x.__value_constructed) 6007a984708SDavid Chisnall { 6017a984708SDavid Chisnall __x.__value_constructed = false; 6027a984708SDavid Chisnall } 603540d2a8bSDimitry Andric#else // _LIBCPP_CXX03_LANG 6047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6057a984708SDavid Chisnall __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) 6067a984708SDavid Chisnall : __na_(__x.__na_), 6077a984708SDavid Chisnall __first_constructed(__x.__value_constructed), 6087a984708SDavid Chisnall __second_constructed(__x.__value_constructed) 6097a984708SDavid Chisnall { 6107a984708SDavid Chisnall const_cast<bool&>(__x.__value_constructed) = false; 6117a984708SDavid Chisnall } 612540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 6137a984708SDavid Chisnall 6147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6157a984708SDavid Chisnall void operator()(pointer __p) _NOEXCEPT 6167a984708SDavid Chisnall { 6177a984708SDavid Chisnall if (__second_constructed) 6184ba319b5SDimitry Andric __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second)); 6197a984708SDavid Chisnall if (__first_constructed) 6204ba319b5SDimitry Andric __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first)); 6217a984708SDavid Chisnall if (__p) 6227a984708SDavid Chisnall __alloc_traits::deallocate(__na_, __p, 1); 6237a984708SDavid Chisnall } 6247a984708SDavid Chisnall}; 6257a984708SDavid Chisnall 6267c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6274f7ab58eSDimitry Andrictemplate <class _Key, class _Tp> 6284ba319b5SDimitry Andricstruct __hash_value_type 6294f7ab58eSDimitry Andric{ 6304f7ab58eSDimitry Andric typedef _Key key_type; 6314f7ab58eSDimitry Andric typedef _Tp mapped_type; 6324f7ab58eSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 6334ba319b5SDimitry Andric typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; 6344ba319b5SDimitry Andric typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; 6354f7ab58eSDimitry Andric 6364ba319b5SDimitry Andricprivate: 6374f7ab58eSDimitry Andric value_type __cc; 6384ba319b5SDimitry Andric 6394ba319b5SDimitry Andricpublic: 6404ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6414ba319b5SDimitry Andric value_type& __get_value() 6424ba319b5SDimitry Andric { 6434ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 6444ba319b5SDimitry Andric return *_VSTD::launder(_VSTD::addressof(__cc)); 6454ba319b5SDimitry Andric#else 6464ba319b5SDimitry Andric return __cc; 6474ba319b5SDimitry Andric#endif 6484ba319b5SDimitry Andric } 6494ba319b5SDimitry Andric 6504ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6514ba319b5SDimitry Andric const value_type& __get_value() const 6524ba319b5SDimitry Andric { 6534ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 6544ba319b5SDimitry Andric return *_VSTD::launder(_VSTD::addressof(__cc)); 6554ba319b5SDimitry Andric#else 6564ba319b5SDimitry Andric return __cc; 6574ba319b5SDimitry Andric#endif 6584ba319b5SDimitry Andric } 6594ba319b5SDimitry Andric 6604ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6614ba319b5SDimitry Andric __nc_ref_pair_type __ref() 6624ba319b5SDimitry Andric { 6634ba319b5SDimitry Andric value_type& __v = __get_value(); 6644ba319b5SDimitry Andric return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); 6654ba319b5SDimitry Andric } 6664ba319b5SDimitry Andric 6674ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6684ba319b5SDimitry Andric __nc_rref_pair_type __move() 6694ba319b5SDimitry Andric { 6704ba319b5SDimitry Andric value_type& __v = __get_value(); 6714ba319b5SDimitry Andric return __nc_rref_pair_type( 6724ba319b5SDimitry Andric _VSTD::move(const_cast<key_type&>(__v.first)), 6734ba319b5SDimitry Andric _VSTD::move(__v.second)); 6744ba319b5SDimitry Andric } 6754f7ab58eSDimitry Andric 6764f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 6774f7ab58eSDimitry Andric __hash_value_type& operator=(const __hash_value_type& __v) 6784ba319b5SDimitry Andric { 6794ba319b5SDimitry Andric __ref() = __v.__get_value(); 6804ba319b5SDimitry Andric return *this; 6814ba319b5SDimitry Andric } 6824f7ab58eSDimitry Andric 6834f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 6844f7ab58eSDimitry Andric __hash_value_type& operator=(__hash_value_type&& __v) 6854ba319b5SDimitry Andric { 6864ba319b5SDimitry Andric __ref() = __v.__move(); 6874ba319b5SDimitry Andric return *this; 6884ba319b5SDimitry Andric } 6894f7ab58eSDimitry Andric 6907c82a1ecSDimitry Andric template <class _ValueTp, 6917c82a1ecSDimitry Andric class = typename enable_if< 6927c82a1ecSDimitry Andric __is_same_uncvref<_ValueTp, value_type>::value 6937c82a1ecSDimitry Andric >::type 6947c82a1ecSDimitry Andric > 6954f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 6964ba319b5SDimitry Andric __hash_value_type& operator=(_ValueTp&& __v) 6974ba319b5SDimitry Andric { 6984ba319b5SDimitry Andric __ref() = _VSTD::forward<_ValueTp>(__v); 6994ba319b5SDimitry Andric return *this; 7007c82a1ecSDimitry Andric } 7017c82a1ecSDimitry Andric 7027c82a1ecSDimitry Andricprivate: 7037c82a1ecSDimitry Andric __hash_value_type(const __hash_value_type& __v) = delete; 7047c82a1ecSDimitry Andric __hash_value_type(__hash_value_type&& __v) = delete; 7057c82a1ecSDimitry Andric template <class ..._Args> 7067c82a1ecSDimitry Andric explicit __hash_value_type(_Args&& ...__args) = delete; 7077c82a1ecSDimitry Andric 7087c82a1ecSDimitry Andric ~__hash_value_type() = delete; 7094f7ab58eSDimitry Andric}; 7104f7ab58eSDimitry Andric 7114f7ab58eSDimitry Andric#else 7124f7ab58eSDimitry Andric 7134f7ab58eSDimitry Andrictemplate <class _Key, class _Tp> 7144f7ab58eSDimitry Andricstruct __hash_value_type 7154f7ab58eSDimitry Andric{ 7164f7ab58eSDimitry Andric typedef _Key key_type; 7174f7ab58eSDimitry Andric typedef _Tp mapped_type; 7184f7ab58eSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 7194f7ab58eSDimitry Andric 7204ba319b5SDimitry Andricprivate: 7214f7ab58eSDimitry Andric value_type __cc; 7224f7ab58eSDimitry Andric 7234ba319b5SDimitry Andricpublic: 7244ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7254ba319b5SDimitry Andric value_type& __get_value() { return __cc; } 7264ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 7274ba319b5SDimitry Andric const value_type& __get_value() const { return __cc; } 7284ba319b5SDimitry Andric 7297c82a1ecSDimitry Andricprivate: 7307c82a1ecSDimitry Andric ~__hash_value_type(); 7314f7ab58eSDimitry Andric}; 7324f7ab58eSDimitry Andric 7334f7ab58eSDimitry Andric#endif 7344f7ab58eSDimitry Andric 7357a984708SDavid Chisnalltemplate <class _HashIterator> 736aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator 7377a984708SDavid Chisnall{ 7387a984708SDavid Chisnall _HashIterator __i_; 7397a984708SDavid Chisnall 7407c82a1ecSDimitry Andric typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; 7417c82a1ecSDimitry Andric 7427a984708SDavid Chisnallpublic: 7437a984708SDavid Chisnall typedef forward_iterator_tag iterator_category; 7447c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 7457c82a1ecSDimitry Andric typedef typename _NodeTypes::difference_type difference_type; 7467a984708SDavid Chisnall typedef value_type& reference; 7477c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type_pointer pointer; 7487a984708SDavid Chisnall 7497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7507a984708SDavid Chisnall __hash_map_iterator() _NOEXCEPT {} 7517a984708SDavid Chisnall 7527a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7537a984708SDavid Chisnall __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} 7547a984708SDavid Chisnall 7557a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7564ba319b5SDimitry Andric reference operator*() const {return __i_->__get_value();} 7577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7584ba319b5SDimitry Andric pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} 7597a984708SDavid Chisnall 7607a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7617a984708SDavid Chisnall __hash_map_iterator& operator++() {++__i_; return *this;} 7627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7637a984708SDavid Chisnall __hash_map_iterator operator++(int) 7647a984708SDavid Chisnall { 7657a984708SDavid Chisnall __hash_map_iterator __t(*this); 7667a984708SDavid Chisnall ++(*this); 7677a984708SDavid Chisnall return __t; 7687a984708SDavid Chisnall } 7697a984708SDavid Chisnall 7707a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 7717a984708SDavid Chisnall bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 7727a984708SDavid Chisnall {return __x.__i_ == __y.__i_;} 7737a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 7747a984708SDavid Chisnall bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 7757a984708SDavid Chisnall {return __x.__i_ != __y.__i_;} 7767a984708SDavid Chisnall 777aed8d94eSDimitry Andric template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map; 778aed8d94eSDimitry Andric template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 779aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 780aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 781aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; 7827a984708SDavid Chisnall}; 7837a984708SDavid Chisnall 7847a984708SDavid Chisnalltemplate <class _HashIterator> 785aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator 7867a984708SDavid Chisnall{ 7877a984708SDavid Chisnall _HashIterator __i_; 7887a984708SDavid Chisnall 7897c82a1ecSDimitry Andric typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; 7907c82a1ecSDimitry Andric 7917a984708SDavid Chisnallpublic: 7927a984708SDavid Chisnall typedef forward_iterator_tag iterator_category; 7937c82a1ecSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 7947c82a1ecSDimitry Andric typedef typename _NodeTypes::difference_type difference_type; 7957a984708SDavid Chisnall typedef const value_type& reference; 7967c82a1ecSDimitry Andric typedef typename _NodeTypes::__const_map_value_type_pointer pointer; 7977a984708SDavid Chisnall 7987a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 7997a984708SDavid Chisnall __hash_map_const_iterator() _NOEXCEPT {} 8007a984708SDavid Chisnall 8017a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8027a984708SDavid Chisnall __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} 8037a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8047a984708SDavid Chisnall __hash_map_const_iterator( 8057a984708SDavid Chisnall __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) 8067a984708SDavid Chisnall _NOEXCEPT 8077a984708SDavid Chisnall : __i_(__i.__i_) {} 8087a984708SDavid Chisnall 8097a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8104ba319b5SDimitry Andric reference operator*() const {return __i_->__get_value();} 8117a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8124ba319b5SDimitry Andric pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} 8137a984708SDavid Chisnall 8147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8157a984708SDavid Chisnall __hash_map_const_iterator& operator++() {++__i_; return *this;} 8167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8177a984708SDavid Chisnall __hash_map_const_iterator operator++(int) 8187a984708SDavid Chisnall { 8197a984708SDavid Chisnall __hash_map_const_iterator __t(*this); 8207a984708SDavid Chisnall ++(*this); 8217a984708SDavid Chisnall return __t; 8227a984708SDavid Chisnall } 8237a984708SDavid Chisnall 8247a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 8257a984708SDavid Chisnall bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 8267a984708SDavid Chisnall {return __x.__i_ == __y.__i_;} 8277a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 8287a984708SDavid Chisnall bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 8297a984708SDavid Chisnall {return __x.__i_ != __y.__i_;} 8307a984708SDavid Chisnall 831aed8d94eSDimitry Andric template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map; 832aed8d94eSDimitry Andric template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 833aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 834aed8d94eSDimitry Andric template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 8357a984708SDavid Chisnall}; 8367a984708SDavid Chisnall 837*b5893f02SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 838*b5893f02SDimitry Andricclass unordered_multimap; 839*b5893f02SDimitry Andric 8407a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 8417a984708SDavid Chisnall class _Alloc = allocator<pair<const _Key, _Tp> > > 842aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map 8437a984708SDavid Chisnall{ 8447a984708SDavid Chisnallpublic: 8457a984708SDavid Chisnall // types 8467a984708SDavid Chisnall typedef _Key key_type; 8477a984708SDavid Chisnall typedef _Tp mapped_type; 8487a984708SDavid Chisnall typedef _Hash hasher; 8497a984708SDavid Chisnall typedef _Pred key_equal; 8507a984708SDavid Chisnall typedef _Alloc allocator_type; 8517a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 8527a984708SDavid Chisnall typedef value_type& reference; 8537a984708SDavid Chisnall typedef const value_type& const_reference; 8544f7ab58eSDimitry Andric static_assert((is_same<value_type, typename allocator_type::value_type>::value), 8554f7ab58eSDimitry Andric "Invalid allocator::value_type"); 856*b5893f02SDimitry Andric static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); 8577a984708SDavid Chisnall 8587a984708SDavid Chisnallprivate: 8594f7ab58eSDimitry Andric typedef __hash_value_type<key_type, mapped_type> __value_type; 8604bab9fd9SDavid Chisnall typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; 8614bab9fd9SDavid Chisnall typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; 862854fa44bSDimitry Andric typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 863854fa44bSDimitry Andric __value_type>::type __allocator_type; 8647a984708SDavid Chisnall 8657a984708SDavid Chisnall typedef __hash_table<__value_type, __hasher, 8667a984708SDavid Chisnall __key_equal, __allocator_type> __table; 8677a984708SDavid Chisnall 8687a984708SDavid Chisnall __table __table_; 8697a984708SDavid Chisnall 8707c82a1ecSDimitry Andric typedef typename __table::_NodeTypes _NodeTypes; 8717a984708SDavid Chisnall typedef typename __table::__node_pointer __node_pointer; 8727a984708SDavid Chisnall typedef typename __table::__node_const_pointer __node_const_pointer; 8737a984708SDavid Chisnall typedef typename __table::__node_traits __node_traits; 8747a984708SDavid Chisnall typedef typename __table::__node_allocator __node_allocator; 8757a984708SDavid Chisnall typedef typename __table::__node __node; 87694e3ee44SDavid Chisnall typedef __hash_map_node_destructor<__node_allocator> _Dp; 87794e3ee44SDavid Chisnall typedef unique_ptr<__node, _Dp> __node_holder; 8787a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 8797c82a1ecSDimitry Andric 8807c82a1ecSDimitry Andric static_assert((is_same<typename __table::__container_value_type, value_type>::value), ""); 8817c82a1ecSDimitry Andric static_assert((is_same<typename __table::__node_value_type, __value_type>::value), ""); 8827a984708SDavid Chisnallpublic: 8837a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 8847a984708SDavid Chisnall typedef typename __alloc_traits::const_pointer const_pointer; 8857c82a1ecSDimitry Andric typedef typename __table::size_type size_type; 8867c82a1ecSDimitry Andric typedef typename __table::difference_type difference_type; 8877a984708SDavid Chisnall 8887a984708SDavid Chisnall typedef __hash_map_iterator<typename __table::iterator> iterator; 8897a984708SDavid Chisnall typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 8907a984708SDavid Chisnall typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; 8917a984708SDavid Chisnall typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; 8927a984708SDavid Chisnall 8934ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 8944ba319b5SDimitry Andric typedef __map_node_handle<__node, allocator_type> node_type; 8954ba319b5SDimitry Andric typedef __insert_return_type<iterator, node_type> insert_return_type; 8964ba319b5SDimitry Andric#endif 8974ba319b5SDimitry Andric 898*b5893f02SDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 899*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 900*b5893f02SDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 901*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 902*b5893f02SDimitry Andric 9037a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9047a984708SDavid Chisnall unordered_map() 9057a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 9064f7ab58eSDimitry Andric { 9074f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 9084f7ab58eSDimitry Andric __get_db()->__insert_c(this); 9094f7ab58eSDimitry Andric#endif 9104f7ab58eSDimitry Andric } 9117a984708SDavid Chisnall explicit unordered_map(size_type __n, const hasher& __hf = hasher(), 9127a984708SDavid Chisnall const key_equal& __eql = key_equal()); 9137a984708SDavid Chisnall unordered_map(size_type __n, const hasher& __hf, 9147a984708SDavid Chisnall const key_equal& __eql, 9157a984708SDavid Chisnall const allocator_type& __a); 9167a984708SDavid Chisnall template <class _InputIterator> 9177a984708SDavid Chisnall unordered_map(_InputIterator __first, _InputIterator __last); 9187a984708SDavid Chisnall template <class _InputIterator> 9197a984708SDavid Chisnall unordered_map(_InputIterator __first, _InputIterator __last, 9207a984708SDavid Chisnall size_type __n, const hasher& __hf = hasher(), 9217a984708SDavid Chisnall const key_equal& __eql = key_equal()); 9227a984708SDavid Chisnall template <class _InputIterator> 9237a984708SDavid Chisnall unordered_map(_InputIterator __first, _InputIterator __last, 9247a984708SDavid Chisnall size_type __n, const hasher& __hf, 9257a984708SDavid Chisnall const key_equal& __eql, 9267a984708SDavid Chisnall const allocator_type& __a); 9277c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9287a984708SDavid Chisnall explicit unordered_map(const allocator_type& __a); 9297a984708SDavid Chisnall unordered_map(const unordered_map& __u); 9307a984708SDavid Chisnall unordered_map(const unordered_map& __u, const allocator_type& __a); 931540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9327c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9337a984708SDavid Chisnall unordered_map(unordered_map&& __u) 9347a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 9357a984708SDavid Chisnall unordered_map(unordered_map&& __u, const allocator_type& __a); 9367a984708SDavid Chisnall unordered_map(initializer_list<value_type> __il); 9377a984708SDavid Chisnall unordered_map(initializer_list<value_type> __il, size_type __n, 9387a984708SDavid Chisnall const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); 9397a984708SDavid Chisnall unordered_map(initializer_list<value_type> __il, size_type __n, 9407a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql, 9417a984708SDavid Chisnall const allocator_type& __a); 942540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 9434f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 9444f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9454f7ab58eSDimitry Andric unordered_map(size_type __n, const allocator_type& __a) 9464f7ab58eSDimitry Andric : unordered_map(__n, hasher(), key_equal(), __a) {} 9474f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9484f7ab58eSDimitry Andric unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) 9494f7ab58eSDimitry Andric : unordered_map(__n, __hf, key_equal(), __a) {} 9504f7ab58eSDimitry Andric template <class _InputIterator> 9514f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9524f7ab58eSDimitry Andric unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) 9534f7ab58eSDimitry Andric : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {} 9544f7ab58eSDimitry Andric template <class _InputIterator> 9554f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9564f7ab58eSDimitry Andric unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 9574f7ab58eSDimitry Andric const allocator_type& __a) 9584f7ab58eSDimitry Andric : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} 9594f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9604f7ab58eSDimitry Andric unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) 9614f7ab58eSDimitry Andric : unordered_map(__il, __n, hasher(), key_equal(), __a) {} 9624f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9634f7ab58eSDimitry Andric unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 9644f7ab58eSDimitry Andric const allocator_type& __a) 9654f7ab58eSDimitry Andric : unordered_map(__il, __n, __hf, key_equal(), __a) {} 9664f7ab58eSDimitry Andric#endif 9677a984708SDavid Chisnall // ~unordered_map() = default; 9687a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9697a984708SDavid Chisnall unordered_map& operator=(const unordered_map& __u) 9707a984708SDavid Chisnall { 9717c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9727a984708SDavid Chisnall __table_ = __u.__table_; 9734bab9fd9SDavid Chisnall#else 974a0492a11SDimitry Andric if (this != &__u) { 9754bab9fd9SDavid Chisnall __table_.clear(); 9764bab9fd9SDavid Chisnall __table_.hash_function() = __u.__table_.hash_function(); 9774bab9fd9SDavid Chisnall __table_.key_eq() = __u.__table_.key_eq(); 9784bab9fd9SDavid Chisnall __table_.max_load_factor() = __u.__table_.max_load_factor(); 9794bab9fd9SDavid Chisnall __table_.__copy_assign_alloc(__u.__table_); 9804bab9fd9SDavid Chisnall insert(__u.begin(), __u.end()); 981a0492a11SDimitry Andric } 9824bab9fd9SDavid Chisnall#endif 9837a984708SDavid Chisnall return *this; 9847a984708SDavid Chisnall } 985540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9867c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9877a984708SDavid Chisnall unordered_map& operator=(unordered_map&& __u) 9887a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 9897c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9907a984708SDavid Chisnall unordered_map& operator=(initializer_list<value_type> __il); 991540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 9927a984708SDavid Chisnall 9937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9947a984708SDavid Chisnall allocator_type get_allocator() const _NOEXCEPT 9957a984708SDavid Chisnall {return allocator_type(__table_.__node_alloc());} 9967a984708SDavid Chisnall 997b2c7081bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 9987a984708SDavid Chisnall bool empty() const _NOEXCEPT {return __table_.size() == 0;} 9997a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10007a984708SDavid Chisnall size_type size() const _NOEXCEPT {return __table_.size();} 10017a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10027a984708SDavid Chisnall size_type max_size() const _NOEXCEPT {return __table_.max_size();} 10037a984708SDavid Chisnall 10047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10057a984708SDavid Chisnall iterator begin() _NOEXCEPT {return __table_.begin();} 10067a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10077a984708SDavid Chisnall iterator end() _NOEXCEPT {return __table_.end();} 10087a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10097a984708SDavid Chisnall const_iterator begin() const _NOEXCEPT {return __table_.begin();} 10107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10117a984708SDavid Chisnall const_iterator end() const _NOEXCEPT {return __table_.end();} 10127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10137a984708SDavid Chisnall const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 10147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10157a984708SDavid Chisnall const_iterator cend() const _NOEXCEPT {return __table_.end();} 10167a984708SDavid Chisnall 10177a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10187a984708SDavid Chisnall pair<iterator, bool> insert(const value_type& __x) 10197a984708SDavid Chisnall {return __table_.__insert_unique(__x);} 10207c82a1ecSDimitry Andric 10217c82a1ecSDimitry Andric iterator insert(const_iterator __p, const value_type& __x) { 10224f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 10234f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 10244f7ab58eSDimitry Andric "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" 10254f7ab58eSDimitry Andric " referring to this unordered_map"); 1026aed8d94eSDimitry Andric#else 1027aed8d94eSDimitry Andric ((void)__p); 10287c82a1ecSDimitry Andric#endif 10294f7ab58eSDimitry Andric return insert(__x).first; 10304f7ab58eSDimitry Andric } 10317c82a1ecSDimitry Andric 10327a984708SDavid Chisnall template <class _InputIterator> 10337c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10347a984708SDavid Chisnall void insert(_InputIterator __first, _InputIterator __last); 10357c82a1ecSDimitry Andric 1036540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10377a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10387a984708SDavid Chisnall void insert(initializer_list<value_type> __il) 10397a984708SDavid Chisnall {insert(__il.begin(), __il.end());} 10407a984708SDavid Chisnall 10417c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10427c82a1ecSDimitry Andric pair<iterator, bool> insert(value_type&& __x) 10437c82a1ecSDimitry Andric {return __table_.__insert_unique(_VSTD::move(__x));} 10447c82a1ecSDimitry Andric 10457c82a1ecSDimitry Andric iterator insert(const_iterator __p, value_type&& __x) { 10467c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 10477c82a1ecSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 10487c82a1ecSDimitry Andric "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" 10497c82a1ecSDimitry Andric " referring to this unordered_map"); 1050aed8d94eSDimitry Andric#else 1051aed8d94eSDimitry Andric ((void)__p); 10527c82a1ecSDimitry Andric#endif 10537c82a1ecSDimitry Andric return __table_.__insert_unique(_VSTD::move(__x)).first; 10547c82a1ecSDimitry Andric } 10557c82a1ecSDimitry Andric 10567c82a1ecSDimitry Andric template <class _Pp, 10577c82a1ecSDimitry Andric class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 10587c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10597c82a1ecSDimitry Andric pair<iterator, bool> insert(_Pp&& __x) 10607c82a1ecSDimitry Andric {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} 10617c82a1ecSDimitry Andric 10627c82a1ecSDimitry Andric template <class _Pp, 10637c82a1ecSDimitry Andric class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 10647c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10657c82a1ecSDimitry Andric iterator insert(const_iterator __p, _Pp&& __x) 10667c82a1ecSDimitry Andric { 10677c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 10687c82a1ecSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 10697c82a1ecSDimitry Andric "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" 10707c82a1ecSDimitry Andric " referring to this unordered_map"); 1071aed8d94eSDimitry Andric#else 1072aed8d94eSDimitry Andric ((void)__p); 10737c82a1ecSDimitry Andric#endif 10747c82a1ecSDimitry Andric return insert(_VSTD::forward<_Pp>(__x)).first; 10757c82a1ecSDimitry Andric } 10767c82a1ecSDimitry Andric 10777c82a1ecSDimitry Andric template <class... _Args> 10787c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10797c82a1ecSDimitry Andric pair<iterator, bool> emplace(_Args&&... __args) { 10807c82a1ecSDimitry Andric return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...); 10817c82a1ecSDimitry Andric } 10827c82a1ecSDimitry Andric 10837c82a1ecSDimitry Andric template <class... _Args> 10847c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10857c82a1ecSDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) { 10867c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 10877c82a1ecSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, 10887c82a1ecSDimitry Andric "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" 10897c82a1ecSDimitry Andric " referring to this unordered_map"); 1090aed8d94eSDimitry Andric#else 1091aed8d94eSDimitry Andric ((void)__p); 10927c82a1ecSDimitry Andric#endif 10937c82a1ecSDimitry Andric return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; 10947c82a1ecSDimitry Andric } 10957c82a1ecSDimitry Andric 10967c82a1ecSDimitry Andric#endif // _LIBCPP_CXX03_LANG 10977c82a1ecSDimitry Andric 1098854fa44bSDimitry Andric#if _LIBCPP_STD_VER > 14 1099854fa44bSDimitry Andric template <class... _Args> 1100854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1101854fa44bSDimitry Andric pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) 1102854fa44bSDimitry Andric { 11037c82a1ecSDimitry Andric return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct, 11047c82a1ecSDimitry Andric _VSTD::forward_as_tuple(__k), 11057c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1106854fa44bSDimitry Andric } 1107854fa44bSDimitry Andric 1108854fa44bSDimitry Andric template <class... _Args> 1109854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1110854fa44bSDimitry Andric pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) 1111854fa44bSDimitry Andric { 11127c82a1ecSDimitry Andric return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct, 11137c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::move(__k)), 11147c82a1ecSDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); 1115854fa44bSDimitry Andric } 1116854fa44bSDimitry Andric 1117854fa44bSDimitry Andric template <class... _Args> 1118854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1119854fa44bSDimitry Andric iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) 1120854fa44bSDimitry Andric { 11217c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 1122aed8d94eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, 11237c82a1ecSDimitry Andric "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" 11247c82a1ecSDimitry Andric " referring to this unordered_map"); 1125aed8d94eSDimitry Andric#else 1126aed8d94eSDimitry Andric ((void)__h); 11277c82a1ecSDimitry Andric#endif 11287c82a1ecSDimitry Andric return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first; 1129854fa44bSDimitry Andric } 1130854fa44bSDimitry Andric 1131854fa44bSDimitry Andric template <class... _Args> 1132854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1133854fa44bSDimitry Andric iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) 1134854fa44bSDimitry Andric { 11357c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 1136aed8d94eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, 11377c82a1ecSDimitry Andric "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" 11387c82a1ecSDimitry Andric " referring to this unordered_map"); 1139aed8d94eSDimitry Andric#else 1140aed8d94eSDimitry Andric ((void)__h); 11417c82a1ecSDimitry Andric#endif 11427c82a1ecSDimitry Andric return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first; 1143854fa44bSDimitry Andric } 1144854fa44bSDimitry Andric 1145854fa44bSDimitry Andric template <class _Vp> 1146854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1147854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) 1148854fa44bSDimitry Andric { 11497c82a1ecSDimitry Andric pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, 11507c82a1ecSDimitry Andric __k, _VSTD::forward<_Vp>(__v)); 11517c82a1ecSDimitry Andric if (!__res.second) { 11527c82a1ecSDimitry Andric __res.first->second = _VSTD::forward<_Vp>(__v); 1153854fa44bSDimitry Andric } 11547c82a1ecSDimitry Andric return __res; 1155854fa44bSDimitry Andric } 1156854fa44bSDimitry Andric 1157854fa44bSDimitry Andric template <class _Vp> 1158854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1159854fa44bSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) 1160854fa44bSDimitry Andric { 11617c82a1ecSDimitry Andric pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, 11627c82a1ecSDimitry Andric _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); 11637c82a1ecSDimitry Andric if (!__res.second) { 11647c82a1ecSDimitry Andric __res.first->second = _VSTD::forward<_Vp>(__v); 1165854fa44bSDimitry Andric } 11667c82a1ecSDimitry Andric return __res; 1167854fa44bSDimitry Andric } 1168854fa44bSDimitry Andric 1169854fa44bSDimitry Andric template <class _Vp> 1170854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1171aed8d94eSDimitry Andric iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v) 1172854fa44bSDimitry Andric { 1173aed8d94eSDimitry Andric // FIXME: Add debug mode checking for the iterator input 11747c82a1ecSDimitry Andric return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first; 1175854fa44bSDimitry Andric } 1176854fa44bSDimitry Andric 1177854fa44bSDimitry Andric template <class _Vp> 1178854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1179aed8d94eSDimitry Andric iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v) 1180854fa44bSDimitry Andric { 1181aed8d94eSDimitry Andric // FIXME: Add debug mode checking for the iterator input 11827c82a1ecSDimitry Andric return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first; 1183854fa44bSDimitry Andric } 1184540d2a8bSDimitry Andric#endif // _LIBCPP_STD_VER > 14 1185854fa44bSDimitry Andric 11867a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11877a984708SDavid Chisnall iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} 11887a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1189854fa44bSDimitry Andric iterator erase(iterator __p) {return __table_.erase(__p.__i_);} 1190854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 11917a984708SDavid Chisnall size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 11927a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11937a984708SDavid Chisnall iterator erase(const_iterator __first, const_iterator __last) 11947a984708SDavid Chisnall {return __table_.erase(__first.__i_, __last.__i_);} 11957a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11967a984708SDavid Chisnall void clear() _NOEXCEPT {__table_.clear();} 11977a984708SDavid Chisnall 11984ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 11994ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12004ba319b5SDimitry Andric insert_return_type insert(node_type&& __nh) 12014ba319b5SDimitry Andric { 12024ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 12034ba319b5SDimitry Andric "node_type with incompatible allocator passed to unordered_map::insert()"); 12044ba319b5SDimitry Andric return __table_.template __node_handle_insert_unique< 12054ba319b5SDimitry Andric node_type, insert_return_type>(_VSTD::move(__nh)); 12064ba319b5SDimitry Andric } 12074ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12084ba319b5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 12094ba319b5SDimitry Andric { 12104ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 12114ba319b5SDimitry Andric "node_type with incompatible allocator passed to unordered_map::insert()"); 12124ba319b5SDimitry Andric return __table_.template __node_handle_insert_unique<node_type>( 12134ba319b5SDimitry Andric __hint.__i_, _VSTD::move(__nh)); 12144ba319b5SDimitry Andric } 12154ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12164ba319b5SDimitry Andric node_type extract(key_type const& __key) 12174ba319b5SDimitry Andric { 12184ba319b5SDimitry Andric return __table_.template __node_handle_extract<node_type>(__key); 12194ba319b5SDimitry Andric } 12204ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12214ba319b5SDimitry Andric node_type extract(const_iterator __it) 12224ba319b5SDimitry Andric { 12234ba319b5SDimitry Andric return __table_.template __node_handle_extract<node_type>( 12244ba319b5SDimitry Andric __it.__i_); 12254ba319b5SDimitry Andric } 1226*b5893f02SDimitry Andric 1227*b5893f02SDimitry Andric template <class _H2, class _P2> 1228*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1229*b5893f02SDimitry Andric void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source) 1230*b5893f02SDimitry Andric { 1231*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1232*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1233*b5893f02SDimitry Andric return __table_.__node_handle_merge_unique(__source.__table_); 1234*b5893f02SDimitry Andric } 1235*b5893f02SDimitry Andric template <class _H2, class _P2> 1236*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1237*b5893f02SDimitry Andric void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) 1238*b5893f02SDimitry Andric { 1239*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1240*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1241*b5893f02SDimitry Andric return __table_.__node_handle_merge_unique(__source.__table_); 1242*b5893f02SDimitry Andric } 1243*b5893f02SDimitry Andric template <class _H2, class _P2> 1244*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1245*b5893f02SDimitry Andric void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source) 1246*b5893f02SDimitry Andric { 1247*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1248*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1249*b5893f02SDimitry Andric return __table_.__node_handle_merge_unique(__source.__table_); 1250*b5893f02SDimitry Andric } 1251*b5893f02SDimitry Andric template <class _H2, class _P2> 1252*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1253*b5893f02SDimitry Andric void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) 1254*b5893f02SDimitry Andric { 1255*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1256*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1257*b5893f02SDimitry Andric return __table_.__node_handle_merge_unique(__source.__table_); 1258*b5893f02SDimitry Andric } 12594ba319b5SDimitry Andric#endif 12604ba319b5SDimitry Andric 12617a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12627a984708SDavid Chisnall void swap(unordered_map& __u) 12637a984708SDavid Chisnall _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 12647a984708SDavid Chisnall { __table_.swap(__u.__table_);} 12657a984708SDavid Chisnall 12667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12677a984708SDavid Chisnall hasher hash_function() const 12687a984708SDavid Chisnall {return __table_.hash_function().hash_function();} 12697a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12707a984708SDavid Chisnall key_equal key_eq() const 12717a984708SDavid Chisnall {return __table_.key_eq().key_eq();} 12727a984708SDavid Chisnall 12737a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12747a984708SDavid Chisnall iterator find(const key_type& __k) {return __table_.find(__k);} 12757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12767a984708SDavid Chisnall const_iterator find(const key_type& __k) const {return __table_.find(__k);} 12777a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12787a984708SDavid Chisnall size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 12797a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12807a984708SDavid Chisnall pair<iterator, iterator> equal_range(const key_type& __k) 12817a984708SDavid Chisnall {return __table_.__equal_range_unique(__k);} 12827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12837a984708SDavid Chisnall pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 12847a984708SDavid Chisnall {return __table_.__equal_range_unique(__k);} 12857a984708SDavid Chisnall 12867a984708SDavid Chisnall mapped_type& operator[](const key_type& __k); 12877c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 12887a984708SDavid Chisnall mapped_type& operator[](key_type&& __k); 12897a984708SDavid Chisnall#endif 12907a984708SDavid Chisnall 12917a984708SDavid Chisnall mapped_type& at(const key_type& __k); 12927a984708SDavid Chisnall const mapped_type& at(const key_type& __k) const; 12937a984708SDavid Chisnall 12947a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12957a984708SDavid Chisnall size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 12967a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12977a984708SDavid Chisnall size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} 12987a984708SDavid Chisnall 12997a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13007a984708SDavid Chisnall size_type bucket_size(size_type __n) const 13017a984708SDavid Chisnall {return __table_.bucket_size(__n);} 13027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13037a984708SDavid Chisnall size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 13047a984708SDavid Chisnall 13057a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13067a984708SDavid Chisnall local_iterator begin(size_type __n) {return __table_.begin(__n);} 13077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13087a984708SDavid Chisnall local_iterator end(size_type __n) {return __table_.end(__n);} 13097a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13107a984708SDavid Chisnall const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 13117a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13127a984708SDavid Chisnall const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 13137a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13147a984708SDavid Chisnall const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 13157a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13167a984708SDavid Chisnall const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 13177a984708SDavid Chisnall 13187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13197a984708SDavid Chisnall float load_factor() const _NOEXCEPT {return __table_.load_factor();} 13207a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13217a984708SDavid Chisnall float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 13227a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13237a984708SDavid Chisnall void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 13247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13257a984708SDavid Chisnall void rehash(size_type __n) {__table_.rehash(__n);} 13267a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13277a984708SDavid Chisnall void reserve(size_type __n) {__table_.reserve(__n);} 13287a984708SDavid Chisnall 13294f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 13304f7ab58eSDimitry Andric 13314f7ab58eSDimitry Andric bool __dereferenceable(const const_iterator* __i) const 13324f7ab58eSDimitry Andric {return __table_.__dereferenceable(&__i->__i_);} 13334f7ab58eSDimitry Andric bool __decrementable(const const_iterator* __i) const 13344f7ab58eSDimitry Andric {return __table_.__decrementable(&__i->__i_);} 13354f7ab58eSDimitry Andric bool __addable(const const_iterator* __i, ptrdiff_t __n) const 13364f7ab58eSDimitry Andric {return __table_.__addable(&__i->__i_, __n);} 13374f7ab58eSDimitry Andric bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const 13384f7ab58eSDimitry Andric {return __table_.__addable(&__i->__i_, __n);} 13394f7ab58eSDimitry Andric 13404f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 13414f7ab58eSDimitry Andric 13427a984708SDavid Chisnallprivate: 13437c82a1ecSDimitry Andric 13447c82a1ecSDimitry Andric#ifdef _LIBCPP_CXX03_LANG 13454bab9fd9SDavid Chisnall __node_holder __construct_node_with_key(const key_type& __k); 13467c82a1ecSDimitry Andric#endif 13477a984708SDavid Chisnall}; 13487a984708SDavid Chisnall 13497a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 13507a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 13517a984708SDavid Chisnall size_type __n, const hasher& __hf, const key_equal& __eql) 13527a984708SDavid Chisnall : __table_(__hf, __eql) 13537a984708SDavid Chisnall{ 13544f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 13554f7ab58eSDimitry Andric __get_db()->__insert_c(this); 13564f7ab58eSDimitry Andric#endif 13577a984708SDavid Chisnall __table_.rehash(__n); 13587a984708SDavid Chisnall} 13597a984708SDavid Chisnall 13607a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 13617a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 13627a984708SDavid Chisnall size_type __n, const hasher& __hf, const key_equal& __eql, 13637a984708SDavid Chisnall const allocator_type& __a) 13647c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 13657a984708SDavid Chisnall{ 13664f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 13674f7ab58eSDimitry Andric __get_db()->__insert_c(this); 13684f7ab58eSDimitry Andric#endif 13697a984708SDavid Chisnall __table_.rehash(__n); 13707a984708SDavid Chisnall} 13717a984708SDavid Chisnall 13727a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 13737c82a1ecSDimitry Andricinline 13747a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 13757a984708SDavid Chisnall const allocator_type& __a) 13767c82a1ecSDimitry Andric : __table_(typename __table::allocator_type(__a)) 13777a984708SDavid Chisnall{ 13784f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 13794f7ab58eSDimitry Andric __get_db()->__insert_c(this); 13804f7ab58eSDimitry Andric#endif 13817a984708SDavid Chisnall} 13827a984708SDavid Chisnall 13837a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 13847a984708SDavid Chisnalltemplate <class _InputIterator> 13857a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 13867a984708SDavid Chisnall _InputIterator __first, _InputIterator __last) 13877a984708SDavid Chisnall{ 13884f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 13894f7ab58eSDimitry Andric __get_db()->__insert_c(this); 13904f7ab58eSDimitry Andric#endif 13917a984708SDavid Chisnall insert(__first, __last); 13927a984708SDavid Chisnall} 13937a984708SDavid Chisnall 13947a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 13957a984708SDavid Chisnalltemplate <class _InputIterator> 13967a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 13977a984708SDavid Chisnall _InputIterator __first, _InputIterator __last, size_type __n, 13987a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql) 13997a984708SDavid Chisnall : __table_(__hf, __eql) 14007a984708SDavid Chisnall{ 14014f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14024f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14034f7ab58eSDimitry Andric#endif 14047a984708SDavid Chisnall __table_.rehash(__n); 14057a984708SDavid Chisnall insert(__first, __last); 14067a984708SDavid Chisnall} 14077a984708SDavid Chisnall 14087a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14097a984708SDavid Chisnalltemplate <class _InputIterator> 14107a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14117a984708SDavid Chisnall _InputIterator __first, _InputIterator __last, size_type __n, 14127a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 14137c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 14147a984708SDavid Chisnall{ 14154f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14164f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14174f7ab58eSDimitry Andric#endif 14187a984708SDavid Chisnall __table_.rehash(__n); 14197a984708SDavid Chisnall insert(__first, __last); 14207a984708SDavid Chisnall} 14217a984708SDavid Chisnall 14227a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14237a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14247a984708SDavid Chisnall const unordered_map& __u) 14257a984708SDavid Chisnall : __table_(__u.__table_) 14267a984708SDavid Chisnall{ 14274f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14284f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14294f7ab58eSDimitry Andric#endif 14307a984708SDavid Chisnall __table_.rehash(__u.bucket_count()); 14317a984708SDavid Chisnall insert(__u.begin(), __u.end()); 14327a984708SDavid Chisnall} 14337a984708SDavid Chisnall 14347a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14357a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14367a984708SDavid Chisnall const unordered_map& __u, const allocator_type& __a) 14377c82a1ecSDimitry Andric : __table_(__u.__table_, typename __table::allocator_type(__a)) 14387a984708SDavid Chisnall{ 14394f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14404f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14414f7ab58eSDimitry Andric#endif 14427a984708SDavid Chisnall __table_.rehash(__u.bucket_count()); 14437a984708SDavid Chisnall insert(__u.begin(), __u.end()); 14447a984708SDavid Chisnall} 14457a984708SDavid Chisnall 1446540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14477a984708SDavid Chisnall 14487a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14497c82a1ecSDimitry Andricinline 14507a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14517a984708SDavid Chisnall unordered_map&& __u) 14527a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 14537a984708SDavid Chisnall : __table_(_VSTD::move(__u.__table_)) 14547a984708SDavid Chisnall{ 14554f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14564f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14574f7ab58eSDimitry Andric __get_db()->swap(this, &__u); 14584f7ab58eSDimitry Andric#endif 14597a984708SDavid Chisnall} 14607a984708SDavid Chisnall 14617a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14627a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14637a984708SDavid Chisnall unordered_map&& __u, const allocator_type& __a) 14647c82a1ecSDimitry Andric : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a)) 14657a984708SDavid Chisnall{ 14664f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14674f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14684f7ab58eSDimitry Andric#endif 14697a984708SDavid Chisnall if (__a != __u.get_allocator()) 14707a984708SDavid Chisnall { 14717a984708SDavid Chisnall iterator __i = __u.begin(); 14727c82a1ecSDimitry Andric while (__u.size() != 0) { 14734ba319b5SDimitry Andric __table_.__emplace_unique( 14744ba319b5SDimitry Andric __u.__table_.remove((__i++).__i_)->__value_.__move()); 14757c82a1ecSDimitry Andric } 14767a984708SDavid Chisnall } 14774f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14784f7ab58eSDimitry Andric else 14794f7ab58eSDimitry Andric __get_db()->swap(this, &__u); 14804f7ab58eSDimitry Andric#endif 14817a984708SDavid Chisnall} 14827a984708SDavid Chisnall 14837a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14847a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14857a984708SDavid Chisnall initializer_list<value_type> __il) 14867a984708SDavid Chisnall{ 14874f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14884f7ab58eSDimitry Andric __get_db()->__insert_c(this); 14894f7ab58eSDimitry Andric#endif 14907a984708SDavid Chisnall insert(__il.begin(), __il.end()); 14917a984708SDavid Chisnall} 14927a984708SDavid Chisnall 14937a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 14947a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 14957a984708SDavid Chisnall initializer_list<value_type> __il, size_type __n, const hasher& __hf, 14967a984708SDavid Chisnall const key_equal& __eql) 14977a984708SDavid Chisnall : __table_(__hf, __eql) 14987a984708SDavid Chisnall{ 14994f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 15004f7ab58eSDimitry Andric __get_db()->__insert_c(this); 15014f7ab58eSDimitry Andric#endif 15027a984708SDavid Chisnall __table_.rehash(__n); 15037a984708SDavid Chisnall insert(__il.begin(), __il.end()); 15047a984708SDavid Chisnall} 15057a984708SDavid Chisnall 15067a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15077a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 15087a984708SDavid Chisnall initializer_list<value_type> __il, size_type __n, const hasher& __hf, 15097a984708SDavid Chisnall const key_equal& __eql, const allocator_type& __a) 15107c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 15117a984708SDavid Chisnall{ 15124f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 15134f7ab58eSDimitry Andric __get_db()->__insert_c(this); 15144f7ab58eSDimitry Andric#endif 15157a984708SDavid Chisnall __table_.rehash(__n); 15167a984708SDavid Chisnall insert(__il.begin(), __il.end()); 15177a984708SDavid Chisnall} 15187a984708SDavid Chisnall 15197a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15207c82a1ecSDimitry Andricinline 15217a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& 15227a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u) 15237a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 15247a984708SDavid Chisnall{ 15257a984708SDavid Chisnall __table_ = _VSTD::move(__u.__table_); 15267a984708SDavid Chisnall return *this; 15277a984708SDavid Chisnall} 15287a984708SDavid Chisnall 15297a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15307c82a1ecSDimitry Andricinline 15317a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& 15327a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=( 15337a984708SDavid Chisnall initializer_list<value_type> __il) 15347a984708SDavid Chisnall{ 15357a984708SDavid Chisnall __table_.__assign_unique(__il.begin(), __il.end()); 15367a984708SDavid Chisnall return *this; 15377a984708SDavid Chisnall} 15387a984708SDavid Chisnall 1539540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 15407a984708SDavid Chisnall 15417a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15427a984708SDavid Chisnalltemplate <class _InputIterator> 15437c82a1ecSDimitry Andricinline 15447a984708SDavid Chisnallvoid 15457a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 15467a984708SDavid Chisnall _InputIterator __last) 15477a984708SDavid Chisnall{ 15487a984708SDavid Chisnall for (; __first != __last; ++__first) 15497a984708SDavid Chisnall __table_.__insert_unique(*__first); 15507a984708SDavid Chisnall} 15517a984708SDavid Chisnall 1552540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 15537a984708SDavid Chisnall 15547c82a1ecSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15557c82a1ecSDimitry Andric_Tp& 15567c82a1ecSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) 15577c82a1ecSDimitry Andric{ 15587c82a1ecSDimitry Andric return __table_.__emplace_unique_key_args(__k, 15597c82a1ecSDimitry Andric std::piecewise_construct, std::forward_as_tuple(__k), 15604ba319b5SDimitry Andric std::forward_as_tuple()).first->__get_value().second; 15617c82a1ecSDimitry Andric} 15627a984708SDavid Chisnall 15637a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 15647a984708SDavid Chisnall_Tp& 15657a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) 15667a984708SDavid Chisnall{ 15677c82a1ecSDimitry Andric return __table_.__emplace_unique_key_args(__k, 15687c82a1ecSDimitry Andric std::piecewise_construct, std::forward_as_tuple(std::move(__k)), 15694ba319b5SDimitry Andric std::forward_as_tuple()).first->__get_value().second; 15707a984708SDavid Chisnall} 1571540d2a8bSDimitry Andric#else // _LIBCPP_CXX03_LANG 15727a984708SDavid Chisnall 1573540d2a8bSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1574540d2a8bSDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder 1575540d2a8bSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) 1576540d2a8bSDimitry Andric{ 1577540d2a8bSDimitry Andric __node_allocator& __na = __table_.__node_alloc(); 1578540d2a8bSDimitry Andric __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 15794ba319b5SDimitry Andric __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k); 1580540d2a8bSDimitry Andric __h.get_deleter().__first_constructed = true; 15814ba319b5SDimitry Andric __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second)); 1582540d2a8bSDimitry Andric __h.get_deleter().__second_constructed = true; 1583540d2a8bSDimitry Andric return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 1584540d2a8bSDimitry Andric} 1585540d2a8bSDimitry Andric 1586540d2a8bSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1587540d2a8bSDimitry Andric_Tp& 1588540d2a8bSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) 1589540d2a8bSDimitry Andric{ 1590540d2a8bSDimitry Andric iterator __i = find(__k); 1591540d2a8bSDimitry Andric if (__i != end()) 1592540d2a8bSDimitry Andric return __i->second; 1593540d2a8bSDimitry Andric __node_holder __h = __construct_node_with_key(__k); 1594540d2a8bSDimitry Andric pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); 1595540d2a8bSDimitry Andric __h.release(); 1596540d2a8bSDimitry Andric return __r.first->second; 1597540d2a8bSDimitry Andric} 1598540d2a8bSDimitry Andric 1599540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_MODE 16007a984708SDavid Chisnall 16017a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 16027a984708SDavid Chisnall_Tp& 16037a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) 16047a984708SDavid Chisnall{ 16057a984708SDavid Chisnall iterator __i = find(__k); 16067a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 16077a984708SDavid Chisnall if (__i == end()) 16087a984708SDavid Chisnall throw out_of_range("unordered_map::at: key not found"); 16097a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 16107a984708SDavid Chisnall return __i->second; 16117a984708SDavid Chisnall} 16127a984708SDavid Chisnall 16137a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 16147a984708SDavid Chisnallconst _Tp& 16157a984708SDavid Chisnallunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const 16167a984708SDavid Chisnall{ 16177a984708SDavid Chisnall const_iterator __i = find(__k); 16187a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 16197a984708SDavid Chisnall if (__i == end()) 16207a984708SDavid Chisnall throw out_of_range("unordered_map::at: key not found"); 16217a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 16227a984708SDavid Chisnall return __i->second; 16237a984708SDavid Chisnall} 16247a984708SDavid Chisnall 16257a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 16267a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 16277a984708SDavid Chisnallvoid 16287a984708SDavid Chisnallswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 16297a984708SDavid Chisnall unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 16307a984708SDavid Chisnall _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 16317a984708SDavid Chisnall{ 16327a984708SDavid Chisnall __x.swap(__y); 16337a984708SDavid Chisnall} 16347a984708SDavid Chisnall 1635*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17 1636*b5893f02SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> 1637*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1638*b5893f02SDimitry Andricvoid erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) 1639*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); } 1640*b5893f02SDimitry Andric#endif 1641*b5893f02SDimitry Andric 16427a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 16437a984708SDavid Chisnallbool 16447a984708SDavid Chisnalloperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 16457a984708SDavid Chisnall const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 16467a984708SDavid Chisnall{ 16477a984708SDavid Chisnall if (__x.size() != __y.size()) 16487a984708SDavid Chisnall return false; 16497a984708SDavid Chisnall typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 16507a984708SDavid Chisnall const_iterator; 16517a984708SDavid Chisnall for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 16527a984708SDavid Chisnall __i != __ex; ++__i) 16537a984708SDavid Chisnall { 16547a984708SDavid Chisnall const_iterator __j = __y.find(__i->first); 16557a984708SDavid Chisnall if (__j == __ey || !(*__i == *__j)) 16567a984708SDavid Chisnall return false; 16577a984708SDavid Chisnall } 16587a984708SDavid Chisnall return true; 16597a984708SDavid Chisnall} 16607a984708SDavid Chisnall 16617a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 16627a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 16637a984708SDavid Chisnallbool 16647a984708SDavid Chisnalloperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 16657a984708SDavid Chisnall const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 16667a984708SDavid Chisnall{ 16677a984708SDavid Chisnall return !(__x == __y); 16687a984708SDavid Chisnall} 16697a984708SDavid Chisnall 16707a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 16717a984708SDavid Chisnall class _Alloc = allocator<pair<const _Key, _Tp> > > 1672aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap 16737a984708SDavid Chisnall{ 16747a984708SDavid Chisnallpublic: 16757a984708SDavid Chisnall // types 16767a984708SDavid Chisnall typedef _Key key_type; 16777a984708SDavid Chisnall typedef _Tp mapped_type; 16787a984708SDavid Chisnall typedef _Hash hasher; 16797a984708SDavid Chisnall typedef _Pred key_equal; 16807a984708SDavid Chisnall typedef _Alloc allocator_type; 16817a984708SDavid Chisnall typedef pair<const key_type, mapped_type> value_type; 16827a984708SDavid Chisnall typedef value_type& reference; 16837a984708SDavid Chisnall typedef const value_type& const_reference; 16844f7ab58eSDimitry Andric static_assert((is_same<value_type, typename allocator_type::value_type>::value), 16854f7ab58eSDimitry Andric "Invalid allocator::value_type"); 1686*b5893f02SDimitry Andric static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); 16877a984708SDavid Chisnall 16887a984708SDavid Chisnallprivate: 16894f7ab58eSDimitry Andric typedef __hash_value_type<key_type, mapped_type> __value_type; 16904bab9fd9SDavid Chisnall typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; 16914bab9fd9SDavid Chisnall typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; 1692854fa44bSDimitry Andric typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, 1693854fa44bSDimitry Andric __value_type>::type __allocator_type; 16947a984708SDavid Chisnall 16957a984708SDavid Chisnall typedef __hash_table<__value_type, __hasher, 16967a984708SDavid Chisnall __key_equal, __allocator_type> __table; 16977a984708SDavid Chisnall 16987a984708SDavid Chisnall __table __table_; 16997a984708SDavid Chisnall 17007c82a1ecSDimitry Andric typedef typename __table::_NodeTypes _NodeTypes; 17017a984708SDavid Chisnall typedef typename __table::__node_traits __node_traits; 17027a984708SDavid Chisnall typedef typename __table::__node_allocator __node_allocator; 17037a984708SDavid Chisnall typedef typename __table::__node __node; 170494e3ee44SDavid Chisnall typedef __hash_map_node_destructor<__node_allocator> _Dp; 170594e3ee44SDavid Chisnall typedef unique_ptr<__node, _Dp> __node_holder; 17067a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 17077c82a1ecSDimitry Andric static_assert((is_same<typename __node_traits::size_type, 17087c82a1ecSDimitry Andric typename __alloc_traits::size_type>::value), 17097c82a1ecSDimitry Andric "Allocator uses different size_type for different types"); 17107a984708SDavid Chisnallpublic: 17117a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 17127a984708SDavid Chisnall typedef typename __alloc_traits::const_pointer const_pointer; 17137c82a1ecSDimitry Andric typedef typename __table::size_type size_type; 17147c82a1ecSDimitry Andric typedef typename __table::difference_type difference_type; 17157a984708SDavid Chisnall 17167a984708SDavid Chisnall typedef __hash_map_iterator<typename __table::iterator> iterator; 17177a984708SDavid Chisnall typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 17187a984708SDavid Chisnall typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; 17197a984708SDavid Chisnall typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; 17207a984708SDavid Chisnall 17214ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 17224ba319b5SDimitry Andric typedef __map_node_handle<__node, allocator_type> node_type; 17234ba319b5SDimitry Andric#endif 17244ba319b5SDimitry Andric 1725*b5893f02SDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 1726*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 1727*b5893f02SDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 1728*b5893f02SDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 1729*b5893f02SDimitry Andric 17307a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17317a984708SDavid Chisnall unordered_multimap() 17327a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) 17334f7ab58eSDimitry Andric { 17344f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 17354f7ab58eSDimitry Andric __get_db()->__insert_c(this); 17364f7ab58eSDimitry Andric#endif 17374f7ab58eSDimitry Andric } 17387a984708SDavid Chisnall explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(), 17397a984708SDavid Chisnall const key_equal& __eql = key_equal()); 17407a984708SDavid Chisnall unordered_multimap(size_type __n, const hasher& __hf, 17417a984708SDavid Chisnall const key_equal& __eql, 17427a984708SDavid Chisnall const allocator_type& __a); 17437a984708SDavid Chisnall template <class _InputIterator> 17447a984708SDavid Chisnall unordered_multimap(_InputIterator __first, _InputIterator __last); 17457a984708SDavid Chisnall template <class _InputIterator> 17467a984708SDavid Chisnall unordered_multimap(_InputIterator __first, _InputIterator __last, 17477a984708SDavid Chisnall size_type __n, const hasher& __hf = hasher(), 17487a984708SDavid Chisnall const key_equal& __eql = key_equal()); 17497a984708SDavid Chisnall template <class _InputIterator> 17507a984708SDavid Chisnall unordered_multimap(_InputIterator __first, _InputIterator __last, 17517a984708SDavid Chisnall size_type __n, const hasher& __hf, 17527a984708SDavid Chisnall const key_equal& __eql, 17537a984708SDavid Chisnall const allocator_type& __a); 17547c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17557a984708SDavid Chisnall explicit unordered_multimap(const allocator_type& __a); 17567a984708SDavid Chisnall unordered_multimap(const unordered_multimap& __u); 17577a984708SDavid Chisnall unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); 1758540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 17597c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17607a984708SDavid Chisnall unordered_multimap(unordered_multimap&& __u) 17617a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); 17627a984708SDavid Chisnall unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); 17637a984708SDavid Chisnall unordered_multimap(initializer_list<value_type> __il); 17647a984708SDavid Chisnall unordered_multimap(initializer_list<value_type> __il, size_type __n, 17657a984708SDavid Chisnall const hasher& __hf = hasher(), 17667a984708SDavid Chisnall const key_equal& __eql = key_equal()); 17677a984708SDavid Chisnall unordered_multimap(initializer_list<value_type> __il, size_type __n, 17687a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql, 17697a984708SDavid Chisnall const allocator_type& __a); 1770540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 17714f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 17724f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17734f7ab58eSDimitry Andric unordered_multimap(size_type __n, const allocator_type& __a) 17744f7ab58eSDimitry Andric : unordered_multimap(__n, hasher(), key_equal(), __a) {} 17754f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17764f7ab58eSDimitry Andric unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) 17774f7ab58eSDimitry Andric : unordered_multimap(__n, __hf, key_equal(), __a) {} 17784f7ab58eSDimitry Andric template <class _InputIterator> 17794f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17804f7ab58eSDimitry Andric unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) 17814f7ab58eSDimitry Andric : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {} 17824f7ab58eSDimitry Andric template <class _InputIterator> 17834f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17844f7ab58eSDimitry Andric unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 17854f7ab58eSDimitry Andric const allocator_type& __a) 17864f7ab58eSDimitry Andric : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} 17874f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17884f7ab58eSDimitry Andric unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) 17894f7ab58eSDimitry Andric : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} 17904f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 17914f7ab58eSDimitry Andric unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 17924f7ab58eSDimitry Andric const allocator_type& __a) 17934f7ab58eSDimitry Andric : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} 17944f7ab58eSDimitry Andric#endif 17957a984708SDavid Chisnall // ~unordered_multimap() = default; 17967a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 17977a984708SDavid Chisnall unordered_multimap& operator=(const unordered_multimap& __u) 17987a984708SDavid Chisnall { 17997c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18007a984708SDavid Chisnall __table_ = __u.__table_; 18014bab9fd9SDavid Chisnall#else 1802a0492a11SDimitry Andric if (this != &__u) { 18034bab9fd9SDavid Chisnall __table_.clear(); 18044bab9fd9SDavid Chisnall __table_.hash_function() = __u.__table_.hash_function(); 18054bab9fd9SDavid Chisnall __table_.key_eq() = __u.__table_.key_eq(); 18064bab9fd9SDavid Chisnall __table_.max_load_factor() = __u.__table_.max_load_factor(); 18074bab9fd9SDavid Chisnall __table_.__copy_assign_alloc(__u.__table_); 18084bab9fd9SDavid Chisnall insert(__u.begin(), __u.end()); 1809a0492a11SDimitry Andric } 18104bab9fd9SDavid Chisnall#endif 18117a984708SDavid Chisnall return *this; 18127a984708SDavid Chisnall } 1813540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18147c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18157a984708SDavid Chisnall unordered_multimap& operator=(unordered_multimap&& __u) 18167a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); 18177c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18187a984708SDavid Chisnall unordered_multimap& operator=(initializer_list<value_type> __il); 1819540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 18207a984708SDavid Chisnall 18217a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18227a984708SDavid Chisnall allocator_type get_allocator() const _NOEXCEPT 18237a984708SDavid Chisnall {return allocator_type(__table_.__node_alloc());} 18247a984708SDavid Chisnall 1825b2c7081bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 18267a984708SDavid Chisnall bool empty() const _NOEXCEPT {return __table_.size() == 0;} 18277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18287a984708SDavid Chisnall size_type size() const _NOEXCEPT {return __table_.size();} 18297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18307a984708SDavid Chisnall size_type max_size() const _NOEXCEPT {return __table_.max_size();} 18317a984708SDavid Chisnall 18327a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18337a984708SDavid Chisnall iterator begin() _NOEXCEPT {return __table_.begin();} 18347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18357a984708SDavid Chisnall iterator end() _NOEXCEPT {return __table_.end();} 18367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18377a984708SDavid Chisnall const_iterator begin() const _NOEXCEPT {return __table_.begin();} 18387a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18397a984708SDavid Chisnall const_iterator end() const _NOEXCEPT {return __table_.end();} 18407a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18417a984708SDavid Chisnall const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} 18427a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18437a984708SDavid Chisnall const_iterator cend() const _NOEXCEPT {return __table_.end();} 18447a984708SDavid Chisnall 18457a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18467a984708SDavid Chisnall iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 18477c82a1ecSDimitry Andric 18487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18497a984708SDavid Chisnall iterator insert(const_iterator __p, const value_type& __x) 18507a984708SDavid Chisnall {return __table_.__insert_multi(__p.__i_, __x);} 18517c82a1ecSDimitry Andric 18527a984708SDavid Chisnall template <class _InputIterator> 18537c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18547a984708SDavid Chisnall void insert(_InputIterator __first, _InputIterator __last); 18557c82a1ecSDimitry Andric 1856540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18587a984708SDavid Chisnall void insert(initializer_list<value_type> __il) 18597a984708SDavid Chisnall {insert(__il.begin(), __il.end());} 18607c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18617c82a1ecSDimitry Andric iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));} 18627c82a1ecSDimitry Andric 18637c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18647c82a1ecSDimitry Andric iterator insert(const_iterator __p, value_type&& __x) 18657c82a1ecSDimitry Andric {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));} 18667c82a1ecSDimitry Andric 18677c82a1ecSDimitry Andric template <class _Pp, 18687c82a1ecSDimitry Andric class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 18697c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18707c82a1ecSDimitry Andric iterator insert(_Pp&& __x) 18717c82a1ecSDimitry Andric {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));} 18727c82a1ecSDimitry Andric 18737c82a1ecSDimitry Andric template <class _Pp, 18747c82a1ecSDimitry Andric class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> 18757c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18767c82a1ecSDimitry Andric iterator insert(const_iterator __p, _Pp&& __x) 18777c82a1ecSDimitry Andric {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));} 18787c82a1ecSDimitry Andric 18797c82a1ecSDimitry Andric template <class... _Args> 18807c82a1ecSDimitry Andric iterator emplace(_Args&&... __args) { 18817c82a1ecSDimitry Andric return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...); 18827c82a1ecSDimitry Andric } 18837c82a1ecSDimitry Andric 18847c82a1ecSDimitry Andric template <class... _Args> 18857c82a1ecSDimitry Andric iterator emplace_hint(const_iterator __p, _Args&&... __args) { 18867c82a1ecSDimitry Andric return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...); 18877c82a1ecSDimitry Andric } 18887c82a1ecSDimitry Andric#endif // _LIBCPP_CXX03_LANG 18897c82a1ecSDimitry Andric 18907c82a1ecSDimitry Andric 18917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18927a984708SDavid Chisnall iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} 18937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1894854fa44bSDimitry Andric iterator erase(iterator __p) {return __table_.erase(__p.__i_);} 1895854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 18967a984708SDavid Chisnall size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 18977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 18987a984708SDavid Chisnall iterator erase(const_iterator __first, const_iterator __last) 18997a984708SDavid Chisnall {return __table_.erase(__first.__i_, __last.__i_);} 19007a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19017a984708SDavid Chisnall void clear() _NOEXCEPT {__table_.clear();} 19027a984708SDavid Chisnall 19034ba319b5SDimitry Andric#if _LIBCPP_STD_VER > 14 19044ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19054ba319b5SDimitry Andric iterator insert(node_type&& __nh) 19064ba319b5SDimitry Andric { 19074ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 19084ba319b5SDimitry Andric "node_type with incompatible allocator passed to unordered_multimap::insert()"); 19094ba319b5SDimitry Andric return __table_.template __node_handle_insert_multi<node_type>( 19104ba319b5SDimitry Andric _VSTD::move(__nh)); 19114ba319b5SDimitry Andric } 19124ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19134ba319b5SDimitry Andric iterator insert(const_iterator __hint, node_type&& __nh) 19144ba319b5SDimitry Andric { 19154ba319b5SDimitry Andric _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), 19164ba319b5SDimitry Andric "node_type with incompatible allocator passed to unordered_multimap::insert()"); 19174ba319b5SDimitry Andric return __table_.template __node_handle_insert_multi<node_type>( 19184ba319b5SDimitry Andric __hint.__i_, _VSTD::move(__nh)); 19194ba319b5SDimitry Andric } 19204ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19214ba319b5SDimitry Andric node_type extract(key_type const& __key) 19224ba319b5SDimitry Andric { 19234ba319b5SDimitry Andric return __table_.template __node_handle_extract<node_type>(__key); 19244ba319b5SDimitry Andric } 19254ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 19264ba319b5SDimitry Andric node_type extract(const_iterator __it) 19274ba319b5SDimitry Andric { 19284ba319b5SDimitry Andric return __table_.template __node_handle_extract<node_type>( 19294ba319b5SDimitry Andric __it.__i_); 19304ba319b5SDimitry Andric } 1931*b5893f02SDimitry Andric 1932*b5893f02SDimitry Andric template <class _H2, class _P2> 1933*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1934*b5893f02SDimitry Andric void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source) 1935*b5893f02SDimitry Andric { 1936*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1937*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1938*b5893f02SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 1939*b5893f02SDimitry Andric } 1940*b5893f02SDimitry Andric template <class _H2, class _P2> 1941*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1942*b5893f02SDimitry Andric void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) 1943*b5893f02SDimitry Andric { 1944*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1945*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1946*b5893f02SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 1947*b5893f02SDimitry Andric } 1948*b5893f02SDimitry Andric template <class _H2, class _P2> 1949*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1950*b5893f02SDimitry Andric void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source) 1951*b5893f02SDimitry Andric { 1952*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1953*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1954*b5893f02SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 1955*b5893f02SDimitry Andric } 1956*b5893f02SDimitry Andric template <class _H2, class _P2> 1957*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1958*b5893f02SDimitry Andric void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) 1959*b5893f02SDimitry Andric { 1960*b5893f02SDimitry Andric _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), 1961*b5893f02SDimitry Andric "merging container with incompatible allocator"); 1962*b5893f02SDimitry Andric return __table_.__node_handle_merge_multi(__source.__table_); 1963*b5893f02SDimitry Andric } 19644ba319b5SDimitry Andric#endif 19654ba319b5SDimitry Andric 19667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19677a984708SDavid Chisnall void swap(unordered_multimap& __u) 19687a984708SDavid Chisnall _NOEXCEPT_(__is_nothrow_swappable<__table>::value) 19697a984708SDavid Chisnall {__table_.swap(__u.__table_);} 19707a984708SDavid Chisnall 19717a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19727a984708SDavid Chisnall hasher hash_function() const 19737a984708SDavid Chisnall {return __table_.hash_function().hash_function();} 19747a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19757a984708SDavid Chisnall key_equal key_eq() const 19767a984708SDavid Chisnall {return __table_.key_eq().key_eq();} 19777a984708SDavid Chisnall 19787a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19797a984708SDavid Chisnall iterator find(const key_type& __k) {return __table_.find(__k);} 19807a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19817a984708SDavid Chisnall const_iterator find(const key_type& __k) const {return __table_.find(__k);} 19827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19837a984708SDavid Chisnall size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 19847a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19857a984708SDavid Chisnall pair<iterator, iterator> equal_range(const key_type& __k) 19867a984708SDavid Chisnall {return __table_.__equal_range_multi(__k);} 19877a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19887a984708SDavid Chisnall pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 19897a984708SDavid Chisnall {return __table_.__equal_range_multi(__k);} 19907a984708SDavid Chisnall 19917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19927a984708SDavid Chisnall size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} 19937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19947a984708SDavid Chisnall size_type max_bucket_count() const _NOEXCEPT 19957a984708SDavid Chisnall {return __table_.max_bucket_count();} 19967a984708SDavid Chisnall 19977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 19987a984708SDavid Chisnall size_type bucket_size(size_type __n) const 19997a984708SDavid Chisnall {return __table_.bucket_size(__n);} 20007a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20017a984708SDavid Chisnall size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} 20027a984708SDavid Chisnall 20037a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20047a984708SDavid Chisnall local_iterator begin(size_type __n) {return __table_.begin(__n);} 20057a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20067a984708SDavid Chisnall local_iterator end(size_type __n) {return __table_.end(__n);} 20077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20087a984708SDavid Chisnall const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} 20097a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20107a984708SDavid Chisnall const_local_iterator end(size_type __n) const {return __table_.cend(__n);} 20117a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20127a984708SDavid Chisnall const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} 20137a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20147a984708SDavid Chisnall const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} 20157a984708SDavid Chisnall 20167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20177a984708SDavid Chisnall float load_factor() const _NOEXCEPT {return __table_.load_factor();} 20187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20197a984708SDavid Chisnall float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} 20207a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20217a984708SDavid Chisnall void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} 20227a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20237a984708SDavid Chisnall void rehash(size_type __n) {__table_.rehash(__n);} 20247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 20257a984708SDavid Chisnall void reserve(size_type __n) {__table_.reserve(__n);} 20267a984708SDavid Chisnall 20274f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20284f7ab58eSDimitry Andric 20294f7ab58eSDimitry Andric bool __dereferenceable(const const_iterator* __i) const 20304f7ab58eSDimitry Andric {return __table_.__dereferenceable(&__i->__i_);} 20314f7ab58eSDimitry Andric bool __decrementable(const const_iterator* __i) const 20324f7ab58eSDimitry Andric {return __table_.__decrementable(&__i->__i_);} 20334f7ab58eSDimitry Andric bool __addable(const const_iterator* __i, ptrdiff_t __n) const 20344f7ab58eSDimitry Andric {return __table_.__addable(&__i->__i_, __n);} 20354f7ab58eSDimitry Andric bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const 20364f7ab58eSDimitry Andric {return __table_.__addable(&__i->__i_, __n);} 20374f7ab58eSDimitry Andric 20384f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 20394f7ab58eSDimitry Andric 20407c82a1ecSDimitry Andric 20417a984708SDavid Chisnall}; 20427a984708SDavid Chisnall 20437a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 20447a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 20457a984708SDavid Chisnall size_type __n, const hasher& __hf, const key_equal& __eql) 20467a984708SDavid Chisnall : __table_(__hf, __eql) 20477a984708SDavid Chisnall{ 20484f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20494f7ab58eSDimitry Andric __get_db()->__insert_c(this); 20504f7ab58eSDimitry Andric#endif 20517a984708SDavid Chisnall __table_.rehash(__n); 20527a984708SDavid Chisnall} 20537a984708SDavid Chisnall 20547a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 20557a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 20567a984708SDavid Chisnall size_type __n, const hasher& __hf, const key_equal& __eql, 20577a984708SDavid Chisnall const allocator_type& __a) 20587c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 20597a984708SDavid Chisnall{ 20604f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20614f7ab58eSDimitry Andric __get_db()->__insert_c(this); 20624f7ab58eSDimitry Andric#endif 20637a984708SDavid Chisnall __table_.rehash(__n); 20647a984708SDavid Chisnall} 20657a984708SDavid Chisnall 20667a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 20677a984708SDavid Chisnalltemplate <class _InputIterator> 20687a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 20697a984708SDavid Chisnall _InputIterator __first, _InputIterator __last) 20707a984708SDavid Chisnall{ 20714f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20724f7ab58eSDimitry Andric __get_db()->__insert_c(this); 20734f7ab58eSDimitry Andric#endif 20747a984708SDavid Chisnall insert(__first, __last); 20757a984708SDavid Chisnall} 20767a984708SDavid Chisnall 20777a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 20787a984708SDavid Chisnalltemplate <class _InputIterator> 20797a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 20807a984708SDavid Chisnall _InputIterator __first, _InputIterator __last, size_type __n, 20817a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql) 20827a984708SDavid Chisnall : __table_(__hf, __eql) 20837a984708SDavid Chisnall{ 20844f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20854f7ab58eSDimitry Andric __get_db()->__insert_c(this); 20864f7ab58eSDimitry Andric#endif 20877a984708SDavid Chisnall __table_.rehash(__n); 20887a984708SDavid Chisnall insert(__first, __last); 20897a984708SDavid Chisnall} 20907a984708SDavid Chisnall 20917a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 20927a984708SDavid Chisnalltemplate <class _InputIterator> 20937a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 20947a984708SDavid Chisnall _InputIterator __first, _InputIterator __last, size_type __n, 20957a984708SDavid Chisnall const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 20967c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 20977a984708SDavid Chisnall{ 20984f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20994f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21004f7ab58eSDimitry Andric#endif 21017a984708SDavid Chisnall __table_.rehash(__n); 21027a984708SDavid Chisnall insert(__first, __last); 21037a984708SDavid Chisnall} 21047a984708SDavid Chisnall 21057a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21067c82a1ecSDimitry Andricinline 21077a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21087a984708SDavid Chisnall const allocator_type& __a) 21097c82a1ecSDimitry Andric : __table_(typename __table::allocator_type(__a)) 21107a984708SDavid Chisnall{ 21114f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21124f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21134f7ab58eSDimitry Andric#endif 21147a984708SDavid Chisnall} 21157a984708SDavid Chisnall 21167a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21177a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21187a984708SDavid Chisnall const unordered_multimap& __u) 21197a984708SDavid Chisnall : __table_(__u.__table_) 21207a984708SDavid Chisnall{ 21214f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21224f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21234f7ab58eSDimitry Andric#endif 21247a984708SDavid Chisnall __table_.rehash(__u.bucket_count()); 21257a984708SDavid Chisnall insert(__u.begin(), __u.end()); 21267a984708SDavid Chisnall} 21277a984708SDavid Chisnall 21287a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21297a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21307a984708SDavid Chisnall const unordered_multimap& __u, const allocator_type& __a) 21317c82a1ecSDimitry Andric : __table_(__u.__table_, typename __table::allocator_type(__a)) 21327a984708SDavid Chisnall{ 21334f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21344f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21354f7ab58eSDimitry Andric#endif 21367a984708SDavid Chisnall __table_.rehash(__u.bucket_count()); 21377a984708SDavid Chisnall insert(__u.begin(), __u.end()); 21387a984708SDavid Chisnall} 21397a984708SDavid Chisnall 2140540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 21417a984708SDavid Chisnall 21427a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21437c82a1ecSDimitry Andricinline 21447a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21457a984708SDavid Chisnall unordered_multimap&& __u) 21467a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) 21477a984708SDavid Chisnall : __table_(_VSTD::move(__u.__table_)) 21487a984708SDavid Chisnall{ 21494f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21504f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21514f7ab58eSDimitry Andric __get_db()->swap(this, &__u); 21524f7ab58eSDimitry Andric#endif 21537a984708SDavid Chisnall} 21547a984708SDavid Chisnall 21557a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21567a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21577a984708SDavid Chisnall unordered_multimap&& __u, const allocator_type& __a) 21587c82a1ecSDimitry Andric : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a)) 21597a984708SDavid Chisnall{ 21604f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21614f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21624f7ab58eSDimitry Andric#endif 21637a984708SDavid Chisnall if (__a != __u.get_allocator()) 21647a984708SDavid Chisnall { 21657a984708SDavid Chisnall iterator __i = __u.begin(); 21667a984708SDavid Chisnall while (__u.size() != 0) 21677a984708SDavid Chisnall { 21687a984708SDavid Chisnall __table_.__insert_multi( 21694ba319b5SDimitry Andric __u.__table_.remove((__i++).__i_)->__value_.__move()); 21707a984708SDavid Chisnall } 21717a984708SDavid Chisnall } 21724f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21734f7ab58eSDimitry Andric else 21744f7ab58eSDimitry Andric __get_db()->swap(this, &__u); 21754f7ab58eSDimitry Andric#endif 21767a984708SDavid Chisnall} 21777a984708SDavid Chisnall 21787a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21797a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21807a984708SDavid Chisnall initializer_list<value_type> __il) 21817a984708SDavid Chisnall{ 21824f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21834f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21844f7ab58eSDimitry Andric#endif 21857a984708SDavid Chisnall insert(__il.begin(), __il.end()); 21867a984708SDavid Chisnall} 21877a984708SDavid Chisnall 21887a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 21897a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 21907a984708SDavid Chisnall initializer_list<value_type> __il, size_type __n, const hasher& __hf, 21917a984708SDavid Chisnall const key_equal& __eql) 21927a984708SDavid Chisnall : __table_(__hf, __eql) 21937a984708SDavid Chisnall{ 21944f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21954f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21964f7ab58eSDimitry Andric#endif 21977a984708SDavid Chisnall __table_.rehash(__n); 21987a984708SDavid Chisnall insert(__il.begin(), __il.end()); 21997a984708SDavid Chisnall} 22007a984708SDavid Chisnall 22017a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22027a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 22037a984708SDavid Chisnall initializer_list<value_type> __il, size_type __n, const hasher& __hf, 22047a984708SDavid Chisnall const key_equal& __eql, const allocator_type& __a) 22057c82a1ecSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) 22067a984708SDavid Chisnall{ 22074f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 22084f7ab58eSDimitry Andric __get_db()->__insert_c(this); 22094f7ab58eSDimitry Andric#endif 22107a984708SDavid Chisnall __table_.rehash(__n); 22117a984708SDavid Chisnall insert(__il.begin(), __il.end()); 22127a984708SDavid Chisnall} 22137a984708SDavid Chisnall 22147a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22157c82a1ecSDimitry Andricinline 22167a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& 22177a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u) 22187a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) 22197a984708SDavid Chisnall{ 22207a984708SDavid Chisnall __table_ = _VSTD::move(__u.__table_); 22217a984708SDavid Chisnall return *this; 22227a984708SDavid Chisnall} 22237a984708SDavid Chisnall 22247a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22257c82a1ecSDimitry Andricinline 22267a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& 22277a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=( 22287a984708SDavid Chisnall initializer_list<value_type> __il) 22297a984708SDavid Chisnall{ 22307a984708SDavid Chisnall __table_.__assign_multi(__il.begin(), __il.end()); 22317a984708SDavid Chisnall return *this; 22327a984708SDavid Chisnall} 22337a984708SDavid Chisnall 2234540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 22357a984708SDavid Chisnall 22367a984708SDavid Chisnall 22377a984708SDavid Chisnall 22387a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22397a984708SDavid Chisnalltemplate <class _InputIterator> 22407c82a1ecSDimitry Andricinline 22417a984708SDavid Chisnallvoid 22427a984708SDavid Chisnallunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 22437a984708SDavid Chisnall _InputIterator __last) 22447a984708SDavid Chisnall{ 22457a984708SDavid Chisnall for (; __first != __last; ++__first) 22467a984708SDavid Chisnall __table_.__insert_multi(*__first); 22477a984708SDavid Chisnall} 22487a984708SDavid Chisnall 22497a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22507a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 22517a984708SDavid Chisnallvoid 22527a984708SDavid Chisnallswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 22537a984708SDavid Chisnall unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 22547a984708SDavid Chisnall _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 22557a984708SDavid Chisnall{ 22567a984708SDavid Chisnall __x.swap(__y); 22577a984708SDavid Chisnall} 22587a984708SDavid Chisnall 2259*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17 2260*b5893f02SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> 2261*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 2262*b5893f02SDimitry Andricvoid erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) 2263*b5893f02SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); } 2264*b5893f02SDimitry Andric#endif 2265*b5893f02SDimitry Andric 22667a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22677a984708SDavid Chisnallbool 22687a984708SDavid Chisnalloperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 22697a984708SDavid Chisnall const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 22707a984708SDavid Chisnall{ 22717a984708SDavid Chisnall if (__x.size() != __y.size()) 22727a984708SDavid Chisnall return false; 22737a984708SDavid Chisnall typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 22747a984708SDavid Chisnall const_iterator; 22757a984708SDavid Chisnall typedef pair<const_iterator, const_iterator> _EqRng; 22767a984708SDavid Chisnall for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 22777a984708SDavid Chisnall { 22787a984708SDavid Chisnall _EqRng __xeq = __x.equal_range(__i->first); 22797a984708SDavid Chisnall _EqRng __yeq = __y.equal_range(__i->first); 22807a984708SDavid Chisnall if (_VSTD::distance(__xeq.first, __xeq.second) != 22817a984708SDavid Chisnall _VSTD::distance(__yeq.first, __yeq.second) || 22827a984708SDavid Chisnall !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 22837a984708SDavid Chisnall return false; 22847a984708SDavid Chisnall __i = __xeq.second; 22857a984708SDavid Chisnall } 22867a984708SDavid Chisnall return true; 22877a984708SDavid Chisnall} 22887a984708SDavid Chisnall 22897a984708SDavid Chisnalltemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 22907a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 22917a984708SDavid Chisnallbool 22927a984708SDavid Chisnalloperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 22937a984708SDavid Chisnall const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 22947a984708SDavid Chisnall{ 22957a984708SDavid Chisnall return !(__x == __y); 22967a984708SDavid Chisnall} 22977a984708SDavid Chisnall 22987a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 22997a984708SDavid Chisnall 23007a984708SDavid Chisnall#endif // _LIBCPP_UNORDERED_MAP 2301