1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_UNORDERED_MAP 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_UNORDERED_MAP 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric 15*700637cbSDimitry Andric unordered_map synopsis 16*700637cbSDimitry Andric 17*700637cbSDimitry Andric#include <__cxx03/initializer_list> 18*700637cbSDimitry Andric 19*700637cbSDimitry Andricnamespace std 20*700637cbSDimitry Andric{ 21*700637cbSDimitry Andric 22*700637cbSDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 23*700637cbSDimitry Andric class Alloc = allocator<pair<const Key, T>>> 24*700637cbSDimitry Andricclass unordered_map 25*700637cbSDimitry Andric{ 26*700637cbSDimitry Andricpublic: 27*700637cbSDimitry Andric // types 28*700637cbSDimitry Andric typedef Key key_type; 29*700637cbSDimitry Andric typedef T mapped_type; 30*700637cbSDimitry Andric typedef Hash hasher; 31*700637cbSDimitry Andric typedef Pred key_equal; 32*700637cbSDimitry Andric typedef Alloc allocator_type; 33*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 34*700637cbSDimitry Andric typedef value_type& reference; 35*700637cbSDimitry Andric typedef const value_type& const_reference; 36*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::pointer pointer; 37*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 38*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::size_type size_type; 39*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::difference_type difference_type; 40*700637cbSDimitry Andric 41*700637cbSDimitry Andric typedef /unspecified/ iterator; 42*700637cbSDimitry Andric typedef /unspecified/ const_iterator; 43*700637cbSDimitry Andric typedef /unspecified/ local_iterator; 44*700637cbSDimitry Andric typedef /unspecified/ const_local_iterator; 45*700637cbSDimitry Andric 46*700637cbSDimitry Andric typedef unspecified node_type; // C++17 47*700637cbSDimitry Andric typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 48*700637cbSDimitry Andric 49*700637cbSDimitry Andric unordered_map() 50*700637cbSDimitry Andric noexcept( 51*700637cbSDimitry Andric is_nothrow_default_constructible<hasher>::value && 52*700637cbSDimitry Andric is_nothrow_default_constructible<key_equal>::value && 53*700637cbSDimitry Andric is_nothrow_default_constructible<allocator_type>::value); 54*700637cbSDimitry Andric explicit unordered_map(size_type n, const hasher& hf = hasher(), 55*700637cbSDimitry Andric const key_equal& eql = key_equal(), 56*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 57*700637cbSDimitry Andric template <class InputIterator> 58*700637cbSDimitry Andric unordered_map(InputIterator f, InputIterator l, 59*700637cbSDimitry Andric size_type n = 0, const hasher& hf = hasher(), 60*700637cbSDimitry Andric const key_equal& eql = key_equal(), 61*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 62*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 63*700637cbSDimitry Andric unordered_map(from_range_t, R&& rg, size_type n = see below, 64*700637cbSDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 65*700637cbSDimitry Andric const allocator_type& a = allocator_type()); // C++23 66*700637cbSDimitry Andric 67*700637cbSDimitry Andric explicit unordered_map(const allocator_type&); 68*700637cbSDimitry Andric unordered_map(const unordered_map&); 69*700637cbSDimitry Andric unordered_map(const unordered_map&, const Allocator&); 70*700637cbSDimitry Andric unordered_map(unordered_map&&) 71*700637cbSDimitry Andric noexcept( 72*700637cbSDimitry Andric is_nothrow_move_constructible<hasher>::value && 73*700637cbSDimitry Andric is_nothrow_move_constructible<key_equal>::value && 74*700637cbSDimitry Andric is_nothrow_move_constructible<allocator_type>::value); 75*700637cbSDimitry Andric unordered_map(unordered_map&&, const Allocator&); 76*700637cbSDimitry Andric unordered_map(initializer_list<value_type>, size_type n = 0, 77*700637cbSDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 78*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 79*700637cbSDimitry Andric unordered_map(size_type n, const allocator_type& a) 80*700637cbSDimitry Andric : unordered_map(n, hasher(), key_equal(), a) {} // C++14 81*700637cbSDimitry Andric unordered_map(size_type n, const hasher& hf, const allocator_type& a) 82*700637cbSDimitry Andric : unordered_map(n, hf, key_equal(), a) {} // C++14 83*700637cbSDimitry Andric template <class InputIterator> 84*700637cbSDimitry Andric unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) 85*700637cbSDimitry Andric : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 86*700637cbSDimitry Andric template <class InputIterator> 87*700637cbSDimitry Andric unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, 88*700637cbSDimitry Andric const allocator_type& a) 89*700637cbSDimitry Andric : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 90*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 91*700637cbSDimitry Andric unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a) 92*700637cbSDimitry Andric : unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23 93*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 94*700637cbSDimitry Andric unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a) 95*700637cbSDimitry Andric : unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23 96*700637cbSDimitry Andric unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a) 97*700637cbSDimitry Andric : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 98*700637cbSDimitry Andric unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, 99*700637cbSDimitry Andric const allocator_type& a) 100*700637cbSDimitry Andric : unordered_map(il, n, hf, key_equal(), a) {} // C++14 101*700637cbSDimitry Andric ~unordered_map(); 102*700637cbSDimitry Andric unordered_map& operator=(const unordered_map&); 103*700637cbSDimitry Andric unordered_map& operator=(unordered_map&&) 104*700637cbSDimitry Andric noexcept( 105*700637cbSDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 106*700637cbSDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 107*700637cbSDimitry Andric is_nothrow_move_assignable<hasher>::value && 108*700637cbSDimitry Andric is_nothrow_move_assignable<key_equal>::value); 109*700637cbSDimitry Andric unordered_map& operator=(initializer_list<value_type>); 110*700637cbSDimitry Andric 111*700637cbSDimitry Andric allocator_type get_allocator() const noexcept; 112*700637cbSDimitry Andric 113*700637cbSDimitry Andric bool empty() const noexcept; 114*700637cbSDimitry Andric size_type size() const noexcept; 115*700637cbSDimitry Andric size_type max_size() const noexcept; 116*700637cbSDimitry Andric 117*700637cbSDimitry Andric iterator begin() noexcept; 118*700637cbSDimitry Andric iterator end() noexcept; 119*700637cbSDimitry Andric const_iterator begin() const noexcept; 120*700637cbSDimitry Andric const_iterator end() const noexcept; 121*700637cbSDimitry Andric const_iterator cbegin() const noexcept; 122*700637cbSDimitry Andric const_iterator cend() const noexcept; 123*700637cbSDimitry Andric 124*700637cbSDimitry Andric template <class... Args> 125*700637cbSDimitry Andric pair<iterator, bool> emplace(Args&&... args); 126*700637cbSDimitry Andric template <class... Args> 127*700637cbSDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 128*700637cbSDimitry Andric pair<iterator, bool> insert(const value_type& obj); 129*700637cbSDimitry Andric template <class P> 130*700637cbSDimitry Andric pair<iterator, bool> insert(P&& obj); 131*700637cbSDimitry Andric iterator insert(const_iterator hint, const value_type& obj); 132*700637cbSDimitry Andric template <class P> 133*700637cbSDimitry Andric iterator insert(const_iterator hint, P&& obj); 134*700637cbSDimitry Andric template <class InputIterator> 135*700637cbSDimitry Andric void insert(InputIterator first, InputIterator last); 136*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 137*700637cbSDimitry Andric void insert_range(R&& rg); // C++23 138*700637cbSDimitry Andric void insert(initializer_list<value_type>); 139*700637cbSDimitry Andric 140*700637cbSDimitry Andric node_type extract(const_iterator position); // C++17 141*700637cbSDimitry Andric node_type extract(const key_type& x); // C++17 142*700637cbSDimitry Andric insert_return_type insert(node_type&& nh); // C++17 143*700637cbSDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 144*700637cbSDimitry Andric 145*700637cbSDimitry Andric template <class... Args> 146*700637cbSDimitry Andric pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 147*700637cbSDimitry Andric template <class... Args> 148*700637cbSDimitry Andric pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 149*700637cbSDimitry Andric template <class... Args> 150*700637cbSDimitry Andric iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 151*700637cbSDimitry Andric template <class... Args> 152*700637cbSDimitry Andric iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 153*700637cbSDimitry Andric template <class M> 154*700637cbSDimitry Andric pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 155*700637cbSDimitry Andric template <class M> 156*700637cbSDimitry Andric pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 157*700637cbSDimitry Andric template <class M> 158*700637cbSDimitry Andric iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 159*700637cbSDimitry Andric template <class M> 160*700637cbSDimitry Andric iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 161*700637cbSDimitry Andric 162*700637cbSDimitry Andric iterator erase(const_iterator position); 163*700637cbSDimitry Andric iterator erase(iterator position); // C++14 164*700637cbSDimitry Andric size_type erase(const key_type& k); 165*700637cbSDimitry Andric iterator erase(const_iterator first, const_iterator last); 166*700637cbSDimitry Andric void clear() noexcept; 167*700637cbSDimitry Andric 168*700637cbSDimitry Andric template<class H2, class P2> 169*700637cbSDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17 170*700637cbSDimitry Andric template<class H2, class P2> 171*700637cbSDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17 172*700637cbSDimitry Andric template<class H2, class P2> 173*700637cbSDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17 174*700637cbSDimitry Andric template<class H2, class P2> 175*700637cbSDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17 176*700637cbSDimitry Andric 177*700637cbSDimitry Andric void swap(unordered_map&) 178*700637cbSDimitry Andric noexcept( 179*700637cbSDimitry Andric (!allocator_type::propagate_on_container_swap::value || 180*700637cbSDimitry Andric __is_nothrow_swappable<allocator_type>::value) && 181*700637cbSDimitry Andric __is_nothrow_swappable<hasher>::value && 182*700637cbSDimitry Andric __is_nothrow_swappable<key_equal>::value); 183*700637cbSDimitry Andric 184*700637cbSDimitry Andric hasher hash_function() const; 185*700637cbSDimitry Andric key_equal key_eq() const; 186*700637cbSDimitry Andric 187*700637cbSDimitry Andric iterator find(const key_type& k); 188*700637cbSDimitry Andric const_iterator find(const key_type& k) const; 189*700637cbSDimitry Andric template<typename K> 190*700637cbSDimitry Andric iterator find(const K& x); // C++20 191*700637cbSDimitry Andric template<typename K> 192*700637cbSDimitry Andric const_iterator find(const K& x) const; // C++20 193*700637cbSDimitry Andric size_type count(const key_type& k) const; 194*700637cbSDimitry Andric template<typename K> 195*700637cbSDimitry Andric size_type count(const K& k) const; // C++20 196*700637cbSDimitry Andric bool contains(const key_type& k) const; // C++20 197*700637cbSDimitry Andric template<typename K> 198*700637cbSDimitry Andric bool contains(const K& k) const; // C++20 199*700637cbSDimitry Andric pair<iterator, iterator> equal_range(const key_type& k); 200*700637cbSDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 201*700637cbSDimitry Andric template<typename K> 202*700637cbSDimitry Andric pair<iterator, iterator> equal_range(const K& k); // C++20 203*700637cbSDimitry Andric template<typename K> 204*700637cbSDimitry Andric pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 205*700637cbSDimitry Andric 206*700637cbSDimitry Andric mapped_type& operator[](const key_type& k); 207*700637cbSDimitry Andric mapped_type& operator[](key_type&& k); 208*700637cbSDimitry Andric 209*700637cbSDimitry Andric mapped_type& at(const key_type& k); 210*700637cbSDimitry Andric const mapped_type& at(const key_type& k) const; 211*700637cbSDimitry Andric 212*700637cbSDimitry Andric size_type bucket_count() const noexcept; 213*700637cbSDimitry Andric size_type max_bucket_count() const noexcept; 214*700637cbSDimitry Andric 215*700637cbSDimitry Andric size_type bucket_size(size_type n) const; 216*700637cbSDimitry Andric size_type bucket(const key_type& k) const; 217*700637cbSDimitry Andric 218*700637cbSDimitry Andric local_iterator begin(size_type n); 219*700637cbSDimitry Andric local_iterator end(size_type n); 220*700637cbSDimitry Andric const_local_iterator begin(size_type n) const; 221*700637cbSDimitry Andric const_local_iterator end(size_type n) const; 222*700637cbSDimitry Andric const_local_iterator cbegin(size_type n) const; 223*700637cbSDimitry Andric const_local_iterator cend(size_type n) const; 224*700637cbSDimitry Andric 225*700637cbSDimitry Andric float load_factor() const noexcept; 226*700637cbSDimitry Andric float max_load_factor() const noexcept; 227*700637cbSDimitry Andric void max_load_factor(float z); 228*700637cbSDimitry Andric void rehash(size_type n); 229*700637cbSDimitry Andric void reserve(size_type n); 230*700637cbSDimitry Andric}; 231*700637cbSDimitry Andric 232*700637cbSDimitry Andrictemplate<class InputIterator, 233*700637cbSDimitry Andric class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, 234*700637cbSDimitry Andric class Allocator = allocator<iter_to_alloc_t<InputIterator>>> 235*700637cbSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type = see below, 236*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 237*700637cbSDimitry Andric -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, 238*700637cbSDimitry Andric Allocator>; // C++17 239*700637cbSDimitry Andric 240*700637cbSDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>, 241*700637cbSDimitry Andric class Pred = equal_to<range-key-type<R>>, 242*700637cbSDimitry Andric class Allocator = allocator<range-to-alloc-type<R>>> 243*700637cbSDimitry Andric unordered_map(from_range_t, R&&, typename see below::size_type = see below, 244*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 245*700637cbSDimitry Andric -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23 246*700637cbSDimitry Andric 247*700637cbSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>, 248*700637cbSDimitry Andric class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> 249*700637cbSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, 250*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 251*700637cbSDimitry Andric -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17 252*700637cbSDimitry Andric 253*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator> 254*700637cbSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator) 255*700637cbSDimitry Andric -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, 256*700637cbSDimitry Andric hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 257*700637cbSDimitry Andric 258*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator> 259*700637cbSDimitry Andricunordered_map(InputIterator, InputIterator, Allocator) 260*700637cbSDimitry Andric -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, 261*700637cbSDimitry Andric hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 262*700637cbSDimitry Andric 263*700637cbSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator> 264*700637cbSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) 265*700637cbSDimitry Andric -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, 266*700637cbSDimitry Andric equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 267*700637cbSDimitry Andric 268*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 269*700637cbSDimitry Andric unordered_map(from_range_t, R&&, typename see below::size_type, Allocator) 270*700637cbSDimitry Andric -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>, 271*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 272*700637cbSDimitry Andric 273*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 274*700637cbSDimitry Andric unordered_map(from_range_t, R&&, Allocator) 275*700637cbSDimitry Andric -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>, 276*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 277*700637cbSDimitry Andric 278*700637cbSDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator> 279*700637cbSDimitry Andric unordered_map(from_range_t, R&&, typename see below::size_type, Hash, Allocator) 280*700637cbSDimitry Andric -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash, 281*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 282*700637cbSDimitry Andric 283*700637cbSDimitry Andrictemplate<class Key, class T, typename Allocator> 284*700637cbSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) 285*700637cbSDimitry Andric -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 286*700637cbSDimitry Andric 287*700637cbSDimitry Andrictemplate<class Key, class T, typename Allocator> 288*700637cbSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, Allocator) 289*700637cbSDimitry Andric -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 290*700637cbSDimitry Andric 291*700637cbSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator> 292*700637cbSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator) 293*700637cbSDimitry Andric -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 294*700637cbSDimitry Andric 295*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 296*700637cbSDimitry Andric void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, 297*700637cbSDimitry Andric unordered_map<Key, T, Hash, Pred, Alloc>& y) 298*700637cbSDimitry Andric noexcept(noexcept(x.swap(y))); 299*700637cbSDimitry Andric 300*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 301*700637cbSDimitry Andric bool 302*700637cbSDimitry Andric operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x, 303*700637cbSDimitry Andric const unordered_map<Key, T, Hash, Pred, Alloc>& y); 304*700637cbSDimitry Andric 305*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 306*700637cbSDimitry Andric bool 307*700637cbSDimitry Andric operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x, 308*700637cbSDimitry Andric const unordered_map<Key, T, Hash, Pred, Alloc>& y); // Removed in C++20 309*700637cbSDimitry Andric 310*700637cbSDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 311*700637cbSDimitry Andric class Alloc = allocator<pair<const Key, T>>> 312*700637cbSDimitry Andricclass unordered_multimap 313*700637cbSDimitry Andric{ 314*700637cbSDimitry Andricpublic: 315*700637cbSDimitry Andric // types 316*700637cbSDimitry Andric typedef Key key_type; 317*700637cbSDimitry Andric typedef T mapped_type; 318*700637cbSDimitry Andric typedef Hash hasher; 319*700637cbSDimitry Andric typedef Pred key_equal; 320*700637cbSDimitry Andric typedef Alloc allocator_type; 321*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 322*700637cbSDimitry Andric typedef value_type& reference; 323*700637cbSDimitry Andric typedef const value_type& const_reference; 324*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::pointer pointer; 325*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 326*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::size_type size_type; 327*700637cbSDimitry Andric typedef typename allocator_traits<allocator_type>::difference_type difference_type; 328*700637cbSDimitry Andric 329*700637cbSDimitry Andric typedef /unspecified/ iterator; 330*700637cbSDimitry Andric typedef /unspecified/ const_iterator; 331*700637cbSDimitry Andric typedef /unspecified/ local_iterator; 332*700637cbSDimitry Andric typedef /unspecified/ const_local_iterator; 333*700637cbSDimitry Andric 334*700637cbSDimitry Andric typedef unspecified node_type; // C++17 335*700637cbSDimitry Andric 336*700637cbSDimitry Andric unordered_multimap() 337*700637cbSDimitry Andric noexcept( 338*700637cbSDimitry Andric is_nothrow_default_constructible<hasher>::value && 339*700637cbSDimitry Andric is_nothrow_default_constructible<key_equal>::value && 340*700637cbSDimitry Andric is_nothrow_default_constructible<allocator_type>::value); 341*700637cbSDimitry Andric explicit unordered_multimap(size_type n, const hasher& hf = hasher(), 342*700637cbSDimitry Andric const key_equal& eql = key_equal(), 343*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 344*700637cbSDimitry Andric template <class InputIterator> 345*700637cbSDimitry Andric unordered_multimap(InputIterator f, InputIterator l, 346*700637cbSDimitry Andric size_type n = 0, const hasher& hf = hasher(), 347*700637cbSDimitry Andric const key_equal& eql = key_equal(), 348*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 349*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 350*700637cbSDimitry Andric unordered_multimap(from_range_t, R&& rg, size_type n = see below, 351*700637cbSDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 352*700637cbSDimitry Andric const allocator_type& a = allocator_type()); // C++23 353*700637cbSDimitry Andric explicit unordered_multimap(const allocator_type&); 354*700637cbSDimitry Andric unordered_multimap(const unordered_multimap&); 355*700637cbSDimitry Andric unordered_multimap(const unordered_multimap&, const Allocator&); 356*700637cbSDimitry Andric unordered_multimap(unordered_multimap&&) 357*700637cbSDimitry Andric noexcept( 358*700637cbSDimitry Andric is_nothrow_move_constructible<hasher>::value && 359*700637cbSDimitry Andric is_nothrow_move_constructible<key_equal>::value && 360*700637cbSDimitry Andric is_nothrow_move_constructible<allocator_type>::value); 361*700637cbSDimitry Andric unordered_multimap(unordered_multimap&&, const Allocator&); 362*700637cbSDimitry Andric unordered_multimap(initializer_list<value_type>, size_type n = 0, 363*700637cbSDimitry Andric const hasher& hf = hasher(), const key_equal& eql = key_equal(), 364*700637cbSDimitry Andric const allocator_type& a = allocator_type()); 365*700637cbSDimitry Andric unordered_multimap(size_type n, const allocator_type& a) 366*700637cbSDimitry Andric : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 367*700637cbSDimitry Andric unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) 368*700637cbSDimitry Andric : unordered_multimap(n, hf, key_equal(), a) {} // C++14 369*700637cbSDimitry Andric template <class InputIterator> 370*700637cbSDimitry Andric unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) 371*700637cbSDimitry Andric : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 372*700637cbSDimitry Andric template <class InputIterator> 373*700637cbSDimitry Andric unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, 374*700637cbSDimitry Andric const allocator_type& a) 375*700637cbSDimitry Andric : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 376*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 377*700637cbSDimitry Andric unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a) 378*700637cbSDimitry Andric : unordered_multimap(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23 379*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 380*700637cbSDimitry Andric unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a) 381*700637cbSDimitry Andric : unordered_multimap(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23 382*700637cbSDimitry Andric unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a) 383*700637cbSDimitry Andric : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 384*700637cbSDimitry Andric unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, 385*700637cbSDimitry Andric const allocator_type& a) 386*700637cbSDimitry Andric : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 387*700637cbSDimitry Andric ~unordered_multimap(); 388*700637cbSDimitry Andric unordered_multimap& operator=(const unordered_multimap&); 389*700637cbSDimitry Andric unordered_multimap& operator=(unordered_multimap&&) 390*700637cbSDimitry Andric noexcept( 391*700637cbSDimitry Andric allocator_type::propagate_on_container_move_assignment::value && 392*700637cbSDimitry Andric is_nothrow_move_assignable<allocator_type>::value && 393*700637cbSDimitry Andric is_nothrow_move_assignable<hasher>::value && 394*700637cbSDimitry Andric is_nothrow_move_assignable<key_equal>::value); 395*700637cbSDimitry Andric unordered_multimap& operator=(initializer_list<value_type>); 396*700637cbSDimitry Andric 397*700637cbSDimitry Andric allocator_type get_allocator() const noexcept; 398*700637cbSDimitry Andric 399*700637cbSDimitry Andric bool empty() const noexcept; 400*700637cbSDimitry Andric size_type size() const noexcept; 401*700637cbSDimitry Andric size_type max_size() const noexcept; 402*700637cbSDimitry Andric 403*700637cbSDimitry Andric iterator begin() noexcept; 404*700637cbSDimitry Andric iterator end() noexcept; 405*700637cbSDimitry Andric const_iterator begin() const noexcept; 406*700637cbSDimitry Andric const_iterator end() const noexcept; 407*700637cbSDimitry Andric const_iterator cbegin() const noexcept; 408*700637cbSDimitry Andric const_iterator cend() const noexcept; 409*700637cbSDimitry Andric 410*700637cbSDimitry Andric template <class... Args> 411*700637cbSDimitry Andric iterator emplace(Args&&... args); 412*700637cbSDimitry Andric template <class... Args> 413*700637cbSDimitry Andric iterator emplace_hint(const_iterator position, Args&&... args); 414*700637cbSDimitry Andric iterator insert(const value_type& obj); 415*700637cbSDimitry Andric template <class P> 416*700637cbSDimitry Andric iterator insert(P&& obj); 417*700637cbSDimitry Andric iterator insert(const_iterator hint, const value_type& obj); 418*700637cbSDimitry Andric template <class P> 419*700637cbSDimitry Andric iterator insert(const_iterator hint, P&& obj); 420*700637cbSDimitry Andric template <class InputIterator> 421*700637cbSDimitry Andric void insert(InputIterator first, InputIterator last); 422*700637cbSDimitry Andric template<container-compatible-range<value_type> R> 423*700637cbSDimitry Andric void insert_range(R&& rg); // C++23 424*700637cbSDimitry Andric void insert(initializer_list<value_type>); 425*700637cbSDimitry Andric 426*700637cbSDimitry Andric node_type extract(const_iterator position); // C++17 427*700637cbSDimitry Andric node_type extract(const key_type& x); // C++17 428*700637cbSDimitry Andric iterator insert(node_type&& nh); // C++17 429*700637cbSDimitry Andric iterator insert(const_iterator hint, node_type&& nh); // C++17 430*700637cbSDimitry Andric 431*700637cbSDimitry Andric iterator erase(const_iterator position); 432*700637cbSDimitry Andric iterator erase(iterator position); // C++14 433*700637cbSDimitry Andric size_type erase(const key_type& k); 434*700637cbSDimitry Andric iterator erase(const_iterator first, const_iterator last); 435*700637cbSDimitry Andric void clear() noexcept; 436*700637cbSDimitry Andric 437*700637cbSDimitry Andric template<class H2, class P2> 438*700637cbSDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); // C++17 439*700637cbSDimitry Andric template<class H2, class P2> 440*700637cbSDimitry Andric void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // C++17 441*700637cbSDimitry Andric template<class H2, class P2> 442*700637cbSDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>& source); // C++17 443*700637cbSDimitry Andric template<class H2, class P2> 444*700637cbSDimitry Andric void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // C++17 445*700637cbSDimitry Andric 446*700637cbSDimitry Andric void swap(unordered_multimap&) 447*700637cbSDimitry Andric noexcept( 448*700637cbSDimitry Andric (!allocator_type::propagate_on_container_swap::value || 449*700637cbSDimitry Andric __is_nothrow_swappable<allocator_type>::value) && 450*700637cbSDimitry Andric __is_nothrow_swappable<hasher>::value && 451*700637cbSDimitry Andric __is_nothrow_swappable<key_equal>::value); 452*700637cbSDimitry Andric 453*700637cbSDimitry Andric hasher hash_function() const; 454*700637cbSDimitry Andric key_equal key_eq() const; 455*700637cbSDimitry Andric 456*700637cbSDimitry Andric iterator find(const key_type& k); 457*700637cbSDimitry Andric const_iterator find(const key_type& k) const; 458*700637cbSDimitry Andric template<typename K> 459*700637cbSDimitry Andric iterator find(const K& x); // C++20 460*700637cbSDimitry Andric template<typename K> 461*700637cbSDimitry Andric const_iterator find(const K& x) const; // C++20 462*700637cbSDimitry Andric size_type count(const key_type& k) const; 463*700637cbSDimitry Andric template<typename K> 464*700637cbSDimitry Andric size_type count(const K& k) const; // C++20 465*700637cbSDimitry Andric bool contains(const key_type& k) const; // C++20 466*700637cbSDimitry Andric template<typename K> 467*700637cbSDimitry Andric bool contains(const K& k) const; // C++20 468*700637cbSDimitry Andric pair<iterator, iterator> equal_range(const key_type& k); 469*700637cbSDimitry Andric pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 470*700637cbSDimitry Andric template<typename K> 471*700637cbSDimitry Andric pair<iterator, iterator> equal_range(const K& k); // C++20 472*700637cbSDimitry Andric template<typename K> 473*700637cbSDimitry Andric pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20 474*700637cbSDimitry Andric 475*700637cbSDimitry Andric size_type bucket_count() const noexcept; 476*700637cbSDimitry Andric size_type max_bucket_count() const noexcept; 477*700637cbSDimitry Andric 478*700637cbSDimitry Andric size_type bucket_size(size_type n) const; 479*700637cbSDimitry Andric size_type bucket(const key_type& k) const; 480*700637cbSDimitry Andric 481*700637cbSDimitry Andric local_iterator begin(size_type n); 482*700637cbSDimitry Andric local_iterator end(size_type n); 483*700637cbSDimitry Andric const_local_iterator begin(size_type n) const; 484*700637cbSDimitry Andric const_local_iterator end(size_type n) const; 485*700637cbSDimitry Andric const_local_iterator cbegin(size_type n) const; 486*700637cbSDimitry Andric const_local_iterator cend(size_type n) const; 487*700637cbSDimitry Andric 488*700637cbSDimitry Andric float load_factor() const noexcept; 489*700637cbSDimitry Andric float max_load_factor() const noexcept; 490*700637cbSDimitry Andric void max_load_factor(float z); 491*700637cbSDimitry Andric void rehash(size_type n); 492*700637cbSDimitry Andric void reserve(size_type n); 493*700637cbSDimitry Andric}; 494*700637cbSDimitry Andric 495*700637cbSDimitry Andrictemplate<class InputIterator, 496*700637cbSDimitry Andric class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, 497*700637cbSDimitry Andric class Allocator = allocator<iter_to_alloc_t<InputIterator>>> 498*700637cbSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below, 499*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 500*700637cbSDimitry Andric -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, 501*700637cbSDimitry Andric Allocator>; // C++17 502*700637cbSDimitry Andric 503*700637cbSDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>, 504*700637cbSDimitry Andric class Pred = equal_to<range-key-type<R>>, 505*700637cbSDimitry Andric class Allocator = allocator<range-to-alloc-type<R>>> 506*700637cbSDimitry Andric unordered_multimap(from_range_t, R&&, typename see below::size_type = see below, 507*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 508*700637cbSDimitry Andric -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23 509*700637cbSDimitry Andric 510*700637cbSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>, 511*700637cbSDimitry Andric class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> 512*700637cbSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, 513*700637cbSDimitry Andric Hash = Hash(), Pred = Pred(), Allocator = Allocator()) 514*700637cbSDimitry Andric -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17 515*700637cbSDimitry Andric 516*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator> 517*700637cbSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator) 518*700637cbSDimitry Andric -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, 519*700637cbSDimitry Andric hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 520*700637cbSDimitry Andric 521*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator> 522*700637cbSDimitry Andricunordered_multimap(InputIterator, InputIterator, Allocator) 523*700637cbSDimitry Andric -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, 524*700637cbSDimitry Andric hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 525*700637cbSDimitry Andric 526*700637cbSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator> 527*700637cbSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) 528*700637cbSDimitry Andric -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, 529*700637cbSDimitry Andric equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 530*700637cbSDimitry Andric 531*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 532*700637cbSDimitry Andric unordered_multimap(from_range_t, R&&, typename see below::size_type, Allocator) 533*700637cbSDimitry Andric -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>, 534*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 535*700637cbSDimitry Andric 536*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator> 537*700637cbSDimitry Andric unordered_multimap(from_range_t, R&&, Allocator) 538*700637cbSDimitry Andric -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>, 539*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 540*700637cbSDimitry Andric 541*700637cbSDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator> 542*700637cbSDimitry Andric unordered_multimap(from_range_t, R&&, typename see below::size_type, Hash, Allocator) 543*700637cbSDimitry Andric -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash, 544*700637cbSDimitry Andric equal_to<range-key-type<R>>, Allocator>; // C++23 545*700637cbSDimitry Andric 546*700637cbSDimitry Andrictemplate<class Key, class T, typename Allocator> 547*700637cbSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) 548*700637cbSDimitry Andric -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 549*700637cbSDimitry Andric 550*700637cbSDimitry Andrictemplate<class Key, class T, typename Allocator> 551*700637cbSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, Allocator) 552*700637cbSDimitry Andric -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 553*700637cbSDimitry Andric 554*700637cbSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator> 555*700637cbSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, 556*700637cbSDimitry Andric Allocator) 557*700637cbSDimitry Andric -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 558*700637cbSDimitry Andric 559*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 560*700637cbSDimitry Andric void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 561*700637cbSDimitry Andric unordered_multimap<Key, T, Hash, Pred, Alloc>& y) 562*700637cbSDimitry Andric noexcept(noexcept(x.swap(y))); 563*700637cbSDimitry Andric 564*700637cbSDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 565*700637cbSDimitry Andric typename unordered_map<K, T, H, P, A>::size_type 566*700637cbSDimitry Andric erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred); // C++20 567*700637cbSDimitry Andric 568*700637cbSDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate> 569*700637cbSDimitry Andric typename unordered_multimap<K, T, H, P, A>::size_type 570*700637cbSDimitry Andric erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred); // C++20 571*700637cbSDimitry Andric 572*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 573*700637cbSDimitry Andric bool 574*700637cbSDimitry Andric operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 575*700637cbSDimitry Andric const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); 576*700637cbSDimitry Andric 577*700637cbSDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc> 578*700637cbSDimitry Andric bool 579*700637cbSDimitry Andric operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, 580*700637cbSDimitry Andric const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); // Removed in C++20 581*700637cbSDimitry Andric 582*700637cbSDimitry Andric} // std 583*700637cbSDimitry Andric 584*700637cbSDimitry Andric*/ 585*700637cbSDimitry Andric 586*700637cbSDimitry Andric#include <__cxx03/__algorithm/is_permutation.h> 587*700637cbSDimitry Andric#include <__cxx03/__assert> 588*700637cbSDimitry Andric#include <__cxx03/__config> 589*700637cbSDimitry Andric#include <__cxx03/__functional/operations.h> 590*700637cbSDimitry Andric#include <__cxx03/__hash_table> 591*700637cbSDimitry Andric#include <__cxx03/__iterator/distance.h> 592*700637cbSDimitry Andric#include <__cxx03/__iterator/erase_if_container.h> 593*700637cbSDimitry Andric#include <__cxx03/__iterator/iterator_traits.h> 594*700637cbSDimitry Andric#include <__cxx03/__memory/addressof.h> 595*700637cbSDimitry Andric#include <__cxx03/__memory/allocator.h> 596*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_allocator.h> 597*700637cbSDimitry Andric#include <__cxx03/__type_traits/type_identity.h> 598*700637cbSDimitry Andric#include <__cxx03/__utility/forward.h> 599*700637cbSDimitry Andric#include <__cxx03/stdexcept> 600*700637cbSDimitry Andric#include <__cxx03/version> 601*700637cbSDimitry Andric 602*700637cbSDimitry Andric// standard-mandated includes 603*700637cbSDimitry Andric 604*700637cbSDimitry Andric// [iterator.range] 605*700637cbSDimitry Andric#include <__cxx03/__iterator/access.h> 606*700637cbSDimitry Andric 607*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 608*700637cbSDimitry Andric# pragma GCC system_header 609*700637cbSDimitry Andric#endif 610*700637cbSDimitry Andric 611*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS 612*700637cbSDimitry Andric#include <__cxx03/__undef_macros> 613*700637cbSDimitry Andric 614*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 615*700637cbSDimitry Andric 616*700637cbSDimitry Andrictemplate <class _Key, 617*700637cbSDimitry Andric class _Cp, 618*700637cbSDimitry Andric class _Hash, 619*700637cbSDimitry Andric class _Pred, 620*700637cbSDimitry Andric bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value> 621*700637cbSDimitry Andricclass __unordered_map_hasher : private _Hash { 622*700637cbSDimitry Andricpublic: 623*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() : _Hash() {} 624*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) : _Hash(__h) {} 625*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; } 626*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { 627*700637cbSDimitry Andric return static_cast<const _Hash&>(*this)(__x.__get_value().first); 628*700637cbSDimitry Andric } 629*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); } 630*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) { 631*700637cbSDimitry Andric using std::swap; 632*700637cbSDimitry Andric swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); 633*700637cbSDimitry Andric } 634*700637cbSDimitry Andric}; 635*700637cbSDimitry Andric 636*700637cbSDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred> 637*700637cbSDimitry Andricclass __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false> { 638*700637cbSDimitry Andric _Hash __hash_; 639*700637cbSDimitry Andric 640*700637cbSDimitry Andricpublic: 641*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() : __hash_() {} 642*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) : __hash_(__h) {} 643*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; } 644*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); } 645*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); } 646*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) { 647*700637cbSDimitry Andric using std::swap; 648*700637cbSDimitry Andric swap(__hash_, __y.__hash_); 649*700637cbSDimitry Andric } 650*700637cbSDimitry Andric}; 651*700637cbSDimitry Andric 652*700637cbSDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred, bool __b> 653*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x, 654*700637cbSDimitry Andric __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y) { 655*700637cbSDimitry Andric __x.swap(__y); 656*700637cbSDimitry Andric} 657*700637cbSDimitry Andric 658*700637cbSDimitry Andrictemplate <class _Key, 659*700637cbSDimitry Andric class _Cp, 660*700637cbSDimitry Andric class _Pred, 661*700637cbSDimitry Andric class _Hash, 662*700637cbSDimitry Andric bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value> 663*700637cbSDimitry Andricclass __unordered_map_equal : private _Pred { 664*700637cbSDimitry Andricpublic: 665*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() : _Pred() {} 666*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) : _Pred(__p) {} 667*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; } 668*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { 669*700637cbSDimitry Andric return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first); 670*700637cbSDimitry Andric } 671*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { 672*700637cbSDimitry Andric return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y); 673*700637cbSDimitry Andric } 674*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { 675*700637cbSDimitry Andric return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); 676*700637cbSDimitry Andric } 677*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) { 678*700637cbSDimitry Andric using std::swap; 679*700637cbSDimitry Andric swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); 680*700637cbSDimitry Andric } 681*700637cbSDimitry Andric}; 682*700637cbSDimitry Andric 683*700637cbSDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash> 684*700637cbSDimitry Andricclass __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false> { 685*700637cbSDimitry Andric _Pred __pred_; 686*700637cbSDimitry Andric 687*700637cbSDimitry Andricpublic: 688*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() : __pred_() {} 689*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) : __pred_(__p) {} 690*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; } 691*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { 692*700637cbSDimitry Andric return __pred_(__x.__get_value().first, __y.__get_value().first); 693*700637cbSDimitry Andric } 694*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { 695*700637cbSDimitry Andric return __pred_(__x.__get_value().first, __y); 696*700637cbSDimitry Andric } 697*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { 698*700637cbSDimitry Andric return __pred_(__x, __y.__get_value().first); 699*700637cbSDimitry Andric } 700*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) { 701*700637cbSDimitry Andric using std::swap; 702*700637cbSDimitry Andric swap(__pred_, __y.__pred_); 703*700637cbSDimitry Andric } 704*700637cbSDimitry Andric}; 705*700637cbSDimitry Andric 706*700637cbSDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash, bool __b> 707*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x, 708*700637cbSDimitry Andric __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y) { 709*700637cbSDimitry Andric __x.swap(__y); 710*700637cbSDimitry Andric} 711*700637cbSDimitry Andric 712*700637cbSDimitry Andrictemplate <class _Alloc> 713*700637cbSDimitry Andricclass __hash_map_node_destructor { 714*700637cbSDimitry Andric typedef _Alloc allocator_type; 715*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 716*700637cbSDimitry Andric 717*700637cbSDimitry Andricpublic: 718*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 719*700637cbSDimitry Andric 720*700637cbSDimitry Andricprivate: 721*700637cbSDimitry Andric allocator_type& __na_; 722*700637cbSDimitry Andric 723*700637cbSDimitry Andricpublic: 724*700637cbSDimitry Andric bool __first_constructed; 725*700637cbSDimitry Andric bool __second_constructed; 726*700637cbSDimitry Andric 727*700637cbSDimitry Andric __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete; 728*700637cbSDimitry Andric 729*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT 730*700637cbSDimitry Andric : __na_(__na), 731*700637cbSDimitry Andric __first_constructed(false), 732*700637cbSDimitry Andric __second_constructed(false) {} 733*700637cbSDimitry Andric 734*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) 735*700637cbSDimitry Andric : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) { 736*700637cbSDimitry Andric const_cast<bool&>(__x.__value_constructed) = false; 737*700637cbSDimitry Andric } 738*700637cbSDimitry Andric 739*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { 740*700637cbSDimitry Andric if (__second_constructed) 741*700637cbSDimitry Andric __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().second)); 742*700637cbSDimitry Andric if (__first_constructed) 743*700637cbSDimitry Andric __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().first)); 744*700637cbSDimitry Andric if (__p) 745*700637cbSDimitry Andric __alloc_traits::deallocate(__na_, __p, 1); 746*700637cbSDimitry Andric } 747*700637cbSDimitry Andric}; 748*700637cbSDimitry Andric 749*700637cbSDimitry Andrictemplate <class _Key, class _Tp> 750*700637cbSDimitry Andricstruct __hash_value_type { 751*700637cbSDimitry Andric typedef _Key key_type; 752*700637cbSDimitry Andric typedef _Tp mapped_type; 753*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 754*700637cbSDimitry Andric 755*700637cbSDimitry Andricprivate: 756*700637cbSDimitry Andric value_type __cc_; 757*700637cbSDimitry Andric 758*700637cbSDimitry Andricpublic: 759*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } 760*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } 761*700637cbSDimitry Andric 762*700637cbSDimitry Andric ~__hash_value_type() = delete; 763*700637cbSDimitry Andric}; 764*700637cbSDimitry Andric 765*700637cbSDimitry Andrictemplate <class _HashIterator> 766*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator { 767*700637cbSDimitry Andric _HashIterator __i_; 768*700637cbSDimitry Andric 769*700637cbSDimitry Andric typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; 770*700637cbSDimitry Andric 771*700637cbSDimitry Andricpublic: 772*700637cbSDimitry Andric typedef forward_iterator_tag iterator_category; 773*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 774*700637cbSDimitry Andric typedef typename _NodeTypes::difference_type difference_type; 775*700637cbSDimitry Andric typedef value_type& reference; 776*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type_pointer pointer; 777*700637cbSDimitry Andric 778*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_iterator() _NOEXCEPT {} 779*700637cbSDimitry Andric 780*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} 781*700637cbSDimitry Andric 782*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } 783*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } 784*700637cbSDimitry Andric 785*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() { 786*700637cbSDimitry Andric ++__i_; 787*700637cbSDimitry Andric return *this; 788*700637cbSDimitry Andric } 789*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_iterator operator++(int) { 790*700637cbSDimitry Andric __hash_map_iterator __t(*this); 791*700637cbSDimitry Andric ++(*this); 792*700637cbSDimitry Andric return __t; 793*700637cbSDimitry Andric } 794*700637cbSDimitry Andric 795*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) { 796*700637cbSDimitry Andric return __x.__i_ == __y.__i_; 797*700637cbSDimitry Andric } 798*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) { 799*700637cbSDimitry Andric return __x.__i_ != __y.__i_; 800*700637cbSDimitry Andric } 801*700637cbSDimitry Andric 802*700637cbSDimitry Andric template <class, class, class, class, class> 803*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 804*700637cbSDimitry Andric template <class, class, class, class, class> 805*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 806*700637cbSDimitry Andric template <class> 807*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 808*700637cbSDimitry Andric template <class> 809*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 810*700637cbSDimitry Andric template <class> 811*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; 812*700637cbSDimitry Andric}; 813*700637cbSDimitry Andric 814*700637cbSDimitry Andrictemplate <class _HashIterator> 815*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator { 816*700637cbSDimitry Andric _HashIterator __i_; 817*700637cbSDimitry Andric 818*700637cbSDimitry Andric typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; 819*700637cbSDimitry Andric 820*700637cbSDimitry Andricpublic: 821*700637cbSDimitry Andric typedef forward_iterator_tag iterator_category; 822*700637cbSDimitry Andric typedef typename _NodeTypes::__map_value_type value_type; 823*700637cbSDimitry Andric typedef typename _NodeTypes::difference_type difference_type; 824*700637cbSDimitry Andric typedef const value_type& reference; 825*700637cbSDimitry Andric typedef typename _NodeTypes::__const_map_value_type_pointer pointer; 826*700637cbSDimitry Andric 827*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator() _NOEXCEPT {} 828*700637cbSDimitry Andric 829*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} 830*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 831*700637cbSDimitry Andric __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT 832*700637cbSDimitry Andric : __i_(__i.__i_) {} 833*700637cbSDimitry Andric 834*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } 835*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } 836*700637cbSDimitry Andric 837*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() { 838*700637cbSDimitry Andric ++__i_; 839*700637cbSDimitry Andric return *this; 840*700637cbSDimitry Andric } 841*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator operator++(int) { 842*700637cbSDimitry Andric __hash_map_const_iterator __t(*this); 843*700637cbSDimitry Andric ++(*this); 844*700637cbSDimitry Andric return __t; 845*700637cbSDimitry Andric } 846*700637cbSDimitry Andric 847*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 848*700637cbSDimitry Andric operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) { 849*700637cbSDimitry Andric return __x.__i_ == __y.__i_; 850*700637cbSDimitry Andric } 851*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 852*700637cbSDimitry Andric operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) { 853*700637cbSDimitry Andric return __x.__i_ != __y.__i_; 854*700637cbSDimitry Andric } 855*700637cbSDimitry Andric 856*700637cbSDimitry Andric template <class, class, class, class, class> 857*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 858*700637cbSDimitry Andric template <class, class, class, class, class> 859*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 860*700637cbSDimitry Andric template <class> 861*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 862*700637cbSDimitry Andric template <class> 863*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 864*700637cbSDimitry Andric}; 865*700637cbSDimitry Andric 866*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 867*700637cbSDimitry Andricclass unordered_multimap; 868*700637cbSDimitry Andric 869*700637cbSDimitry Andrictemplate <class _Key, 870*700637cbSDimitry Andric class _Tp, 871*700637cbSDimitry Andric class _Hash = hash<_Key>, 872*700637cbSDimitry Andric class _Pred = equal_to<_Key>, 873*700637cbSDimitry Andric class _Alloc = allocator<pair<const _Key, _Tp> > > 874*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map { 875*700637cbSDimitry Andricpublic: 876*700637cbSDimitry Andric // types 877*700637cbSDimitry Andric typedef _Key key_type; 878*700637cbSDimitry Andric typedef _Tp mapped_type; 879*700637cbSDimitry Andric typedef __type_identity_t<_Hash> hasher; 880*700637cbSDimitry Andric typedef __type_identity_t<_Pred> key_equal; 881*700637cbSDimitry Andric typedef __type_identity_t<_Alloc> allocator_type; 882*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 883*700637cbSDimitry Andric typedef value_type& reference; 884*700637cbSDimitry Andric typedef const value_type& const_reference; 885*700637cbSDimitry Andric static_assert(is_same<value_type, typename allocator_type::value_type>::value, 886*700637cbSDimitry Andric "Allocator::value_type must be same type as value_type"); 887*700637cbSDimitry Andric 888*700637cbSDimitry Andricprivate: 889*700637cbSDimitry Andric typedef __hash_value_type<key_type, mapped_type> __value_type; 890*700637cbSDimitry Andric typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher; 891*700637cbSDimitry Andric typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal; 892*700637cbSDimitry Andric typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; 893*700637cbSDimitry Andric 894*700637cbSDimitry Andric typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; 895*700637cbSDimitry Andric 896*700637cbSDimitry Andric __table __table_; 897*700637cbSDimitry Andric 898*700637cbSDimitry Andric typedef typename __table::_NodeTypes _NodeTypes; 899*700637cbSDimitry Andric typedef typename __table::__node_pointer __node_pointer; 900*700637cbSDimitry Andric typedef typename __table::__node_const_pointer __node_const_pointer; 901*700637cbSDimitry Andric typedef typename __table::__node_traits __node_traits; 902*700637cbSDimitry Andric typedef typename __table::__node_allocator __node_allocator; 903*700637cbSDimitry Andric typedef typename __table::__node __node; 904*700637cbSDimitry Andric typedef __hash_map_node_destructor<__node_allocator> _Dp; 905*700637cbSDimitry Andric typedef unique_ptr<__node, _Dp> __node_holder; 906*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 907*700637cbSDimitry Andric 908*700637cbSDimitry Andric static_assert(__check_valid_allocator<allocator_type>::value, ""); 909*700637cbSDimitry Andric 910*700637cbSDimitry Andric static_assert(is_same<typename __table::__container_value_type, value_type>::value, ""); 911*700637cbSDimitry Andric static_assert(is_same<typename __table::__node_value_type, __value_type>::value, ""); 912*700637cbSDimitry Andric 913*700637cbSDimitry Andricpublic: 914*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 915*700637cbSDimitry Andric typedef typename __alloc_traits::const_pointer const_pointer; 916*700637cbSDimitry Andric typedef typename __table::size_type size_type; 917*700637cbSDimitry Andric typedef typename __table::difference_type difference_type; 918*700637cbSDimitry Andric 919*700637cbSDimitry Andric typedef __hash_map_iterator<typename __table::iterator> iterator; 920*700637cbSDimitry Andric typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 921*700637cbSDimitry Andric typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; 922*700637cbSDimitry Andric typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; 923*700637cbSDimitry Andric 924*700637cbSDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 925*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 926*700637cbSDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 927*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 928*700637cbSDimitry Andric 929*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map() {} 930*700637cbSDimitry Andric explicit _LIBCPP_HIDE_FROM_ABI 931*700637cbSDimitry Andric unordered_map(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); 932*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 933*700637cbSDimitry Andric unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); 934*700637cbSDimitry Andric template <class _InputIterator> 935*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map(_InputIterator __first, _InputIterator __last); 936*700637cbSDimitry Andric template <class _InputIterator> 937*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 938*700637cbSDimitry Andric unordered_map(_InputIterator __first, 939*700637cbSDimitry Andric _InputIterator __last, 940*700637cbSDimitry Andric size_type __n, 941*700637cbSDimitry Andric const hasher& __hf = hasher(), 942*700637cbSDimitry Andric const key_equal& __eql = key_equal()); 943*700637cbSDimitry Andric template <class _InputIterator> 944*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map( 945*700637cbSDimitry Andric _InputIterator __first, 946*700637cbSDimitry Andric _InputIterator __last, 947*700637cbSDimitry Andric size_type __n, 948*700637cbSDimitry Andric const hasher& __hf, 949*700637cbSDimitry Andric const key_equal& __eql, 950*700637cbSDimitry Andric const allocator_type& __a); 951*700637cbSDimitry Andric 952*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a); 953*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u); 954*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a); 955*700637cbSDimitry Andric 956*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI ~unordered_map() { 957*700637cbSDimitry Andric static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); 958*700637cbSDimitry Andric } 959*700637cbSDimitry Andric 960*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) { 961*700637cbSDimitry Andric if (this != std::addressof(__u)) { 962*700637cbSDimitry Andric __table_.clear(); 963*700637cbSDimitry Andric __table_.hash_function() = __u.__table_.hash_function(); 964*700637cbSDimitry Andric __table_.key_eq() = __u.__table_.key_eq(); 965*700637cbSDimitry Andric __table_.max_load_factor() = __u.__table_.max_load_factor(); 966*700637cbSDimitry Andric __table_.__copy_assign_alloc(__u.__table_); 967*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 968*700637cbSDimitry Andric } 969*700637cbSDimitry Andric return *this; 970*700637cbSDimitry Andric } 971*700637cbSDimitry Andric 972*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { 973*700637cbSDimitry Andric return allocator_type(__table_.__node_alloc()); 974*700637cbSDimitry Andric } 975*700637cbSDimitry Andric 976*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } 977*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } 978*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } 979*700637cbSDimitry Andric 980*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } 981*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } 982*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } 983*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } 984*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } 985*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } 986*700637cbSDimitry Andric 987*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); } 988*700637cbSDimitry Andric 989*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } 990*700637cbSDimitry Andric 991*700637cbSDimitry Andric template <class _InputIterator> 992*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); 993*700637cbSDimitry Andric 994*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); } 995*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); } 996*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); } 997*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { 998*700637cbSDimitry Andric return __table_.erase(__first.__i_, __last.__i_); 999*700637cbSDimitry Andric } 1000*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } 1001*700637cbSDimitry Andric 1002*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) { __table_.swap(__u.__table_); } 1003*700637cbSDimitry Andric 1004*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); } 1005*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } 1006*700637cbSDimitry Andric 1007*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } 1008*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } 1009*700637cbSDimitry Andric 1010*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } 1011*700637cbSDimitry Andric 1012*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { 1013*700637cbSDimitry Andric return __table_.__equal_range_unique(__k); 1014*700637cbSDimitry Andric } 1015*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { 1016*700637cbSDimitry Andric return __table_.__equal_range_unique(__k); 1017*700637cbSDimitry Andric } 1018*700637cbSDimitry Andric 1019*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); 1020*700637cbSDimitry Andric 1021*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); 1022*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; 1023*700637cbSDimitry Andric 1024*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } 1025*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } 1026*700637cbSDimitry Andric 1027*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } 1028*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } 1029*700637cbSDimitry Andric 1030*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } 1031*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } 1032*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } 1033*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } 1034*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } 1035*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } 1036*700637cbSDimitry Andric 1037*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } 1038*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } 1039*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } 1040*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); } 1041*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } 1042*700637cbSDimitry Andric 1043*700637cbSDimitry Andricprivate: 1044*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); 1045*700637cbSDimitry Andric}; 1046*700637cbSDimitry Andric 1047*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1048*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql) 1049*700637cbSDimitry Andric : __table_(__hf, __eql) { 1050*700637cbSDimitry Andric __table_.__rehash_unique(__n); 1051*700637cbSDimitry Andric} 1052*700637cbSDimitry Andric 1053*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1054*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 1055*700637cbSDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 1056*700637cbSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) { 1057*700637cbSDimitry Andric __table_.__rehash_unique(__n); 1058*700637cbSDimitry Andric} 1059*700637cbSDimitry Andric 1060*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1061*700637cbSDimitry Andricinline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const allocator_type& __a) 1062*700637cbSDimitry Andric : __table_(typename __table::allocator_type(__a)) {} 1063*700637cbSDimitry Andric 1064*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1065*700637cbSDimitry Andrictemplate <class _InputIterator> 1066*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator __first, _InputIterator __last) { 1067*700637cbSDimitry Andric insert(__first, __last); 1068*700637cbSDimitry Andric} 1069*700637cbSDimitry Andric 1070*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1071*700637cbSDimitry Andrictemplate <class _InputIterator> 1072*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 1073*700637cbSDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql) 1074*700637cbSDimitry Andric : __table_(__hf, __eql) { 1075*700637cbSDimitry Andric __table_.__rehash_unique(__n); 1076*700637cbSDimitry Andric insert(__first, __last); 1077*700637cbSDimitry Andric} 1078*700637cbSDimitry Andric 1079*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1080*700637cbSDimitry Andrictemplate <class _InputIterator> 1081*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( 1082*700637cbSDimitry Andric _InputIterator __first, 1083*700637cbSDimitry Andric _InputIterator __last, 1084*700637cbSDimitry Andric size_type __n, 1085*700637cbSDimitry Andric const hasher& __hf, 1086*700637cbSDimitry Andric const key_equal& __eql, 1087*700637cbSDimitry Andric const allocator_type& __a) 1088*700637cbSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) { 1089*700637cbSDimitry Andric __table_.__rehash_unique(__n); 1090*700637cbSDimitry Andric insert(__first, __last); 1091*700637cbSDimitry Andric} 1092*700637cbSDimitry Andric 1093*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1094*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u) : __table_(__u.__table_) { 1095*700637cbSDimitry Andric __table_.__rehash_unique(__u.bucket_count()); 1096*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 1097*700637cbSDimitry Andric} 1098*700637cbSDimitry Andric 1099*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1100*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u, const allocator_type& __a) 1101*700637cbSDimitry Andric : __table_(__u.__table_, typename __table::allocator_type(__a)) { 1102*700637cbSDimitry Andric __table_.__rehash_unique(__u.bucket_count()); 1103*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 1104*700637cbSDimitry Andric} 1105*700637cbSDimitry Andric 1106*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1107*700637cbSDimitry Andrictemplate <class _InputIterator> 1108*700637cbSDimitry Andricinline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { 1109*700637cbSDimitry Andric for (; __first != __last; ++__first) 1110*700637cbSDimitry Andric __table_.__insert_unique(*__first); 1111*700637cbSDimitry Andric} 1112*700637cbSDimitry Andric 1113*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1114*700637cbSDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder 1115*700637cbSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) { 1116*700637cbSDimitry Andric __node_allocator& __na = __table_.__node_alloc(); 1117*700637cbSDimitry Andric __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 1118*700637cbSDimitry Andric __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().first), __k); 1119*700637cbSDimitry Andric __h.get_deleter().__first_constructed = true; 1120*700637cbSDimitry Andric __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().second)); 1121*700637cbSDimitry Andric __h.get_deleter().__second_constructed = true; 1122*700637cbSDimitry Andric return __h; 1123*700637cbSDimitry Andric} 1124*700637cbSDimitry Andric 1125*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1126*700637cbSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { 1127*700637cbSDimitry Andric iterator __i = find(__k); 1128*700637cbSDimitry Andric if (__i != end()) 1129*700637cbSDimitry Andric return __i->second; 1130*700637cbSDimitry Andric __node_holder __h = __construct_node_with_key(__k); 1131*700637cbSDimitry Andric pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); 1132*700637cbSDimitry Andric __h.release(); 1133*700637cbSDimitry Andric return __r.first->second; 1134*700637cbSDimitry Andric} 1135*700637cbSDimitry Andric 1136*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1137*700637cbSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) { 1138*700637cbSDimitry Andric iterator __i = find(__k); 1139*700637cbSDimitry Andric if (__i == end()) 1140*700637cbSDimitry Andric __throw_out_of_range("unordered_map::at: key not found"); 1141*700637cbSDimitry Andric return __i->second; 1142*700637cbSDimitry Andric} 1143*700637cbSDimitry Andric 1144*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1145*700637cbSDimitry Andricconst _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const { 1146*700637cbSDimitry Andric const_iterator __i = find(__k); 1147*700637cbSDimitry Andric if (__i == end()) 1148*700637cbSDimitry Andric __throw_out_of_range("unordered_map::at: key not found"); 1149*700637cbSDimitry Andric return __i->second; 1150*700637cbSDimitry Andric} 1151*700637cbSDimitry Andric 1152*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1153*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 1154*700637cbSDimitry Andricswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1155*700637cbSDimitry Andric __x.swap(__y); 1156*700637cbSDimitry Andric} 1157*700637cbSDimitry Andric 1158*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1159*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 1160*700637cbSDimitry Andric const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1161*700637cbSDimitry Andric if (__x.size() != __y.size()) 1162*700637cbSDimitry Andric return false; 1163*700637cbSDimitry Andric typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator const_iterator; 1164*700637cbSDimitry Andric for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); __i != __ex; ++__i) { 1165*700637cbSDimitry Andric const_iterator __j = __y.find(__i->first); 1166*700637cbSDimitry Andric if (__j == __ey || !(*__i == *__j)) 1167*700637cbSDimitry Andric return false; 1168*700637cbSDimitry Andric } 1169*700637cbSDimitry Andric return true; 1170*700637cbSDimitry Andric} 1171*700637cbSDimitry Andric 1172*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1173*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 1174*700637cbSDimitry Andric const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1175*700637cbSDimitry Andric return !(__x == __y); 1176*700637cbSDimitry Andric} 1177*700637cbSDimitry Andric 1178*700637cbSDimitry Andrictemplate <class _Key, 1179*700637cbSDimitry Andric class _Tp, 1180*700637cbSDimitry Andric class _Hash = hash<_Key>, 1181*700637cbSDimitry Andric class _Pred = equal_to<_Key>, 1182*700637cbSDimitry Andric class _Alloc = allocator<pair<const _Key, _Tp> > > 1183*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap { 1184*700637cbSDimitry Andricpublic: 1185*700637cbSDimitry Andric // types 1186*700637cbSDimitry Andric typedef _Key key_type; 1187*700637cbSDimitry Andric typedef _Tp mapped_type; 1188*700637cbSDimitry Andric typedef __type_identity_t<_Hash> hasher; 1189*700637cbSDimitry Andric typedef __type_identity_t<_Pred> key_equal; 1190*700637cbSDimitry Andric typedef __type_identity_t<_Alloc> allocator_type; 1191*700637cbSDimitry Andric typedef pair<const key_type, mapped_type> value_type; 1192*700637cbSDimitry Andric typedef value_type& reference; 1193*700637cbSDimitry Andric typedef const value_type& const_reference; 1194*700637cbSDimitry Andric static_assert(__check_valid_allocator<allocator_type>::value, ""); 1195*700637cbSDimitry Andric static_assert(is_same<value_type, typename allocator_type::value_type>::value, 1196*700637cbSDimitry Andric "Allocator::value_type must be same type as value_type"); 1197*700637cbSDimitry Andric 1198*700637cbSDimitry Andricprivate: 1199*700637cbSDimitry Andric typedef __hash_value_type<key_type, mapped_type> __value_type; 1200*700637cbSDimitry Andric typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher; 1201*700637cbSDimitry Andric typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal; 1202*700637cbSDimitry Andric typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; 1203*700637cbSDimitry Andric 1204*700637cbSDimitry Andric typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; 1205*700637cbSDimitry Andric 1206*700637cbSDimitry Andric __table __table_; 1207*700637cbSDimitry Andric 1208*700637cbSDimitry Andric typedef typename __table::_NodeTypes _NodeTypes; 1209*700637cbSDimitry Andric typedef typename __table::__node_traits __node_traits; 1210*700637cbSDimitry Andric typedef typename __table::__node_allocator __node_allocator; 1211*700637cbSDimitry Andric typedef typename __table::__node __node; 1212*700637cbSDimitry Andric typedef __hash_map_node_destructor<__node_allocator> _Dp; 1213*700637cbSDimitry Andric typedef unique_ptr<__node, _Dp> __node_holder; 1214*700637cbSDimitry Andric typedef allocator_traits<allocator_type> __alloc_traits; 1215*700637cbSDimitry Andric static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value, 1216*700637cbSDimitry Andric "Allocator uses different size_type for different types"); 1217*700637cbSDimitry Andric 1218*700637cbSDimitry Andricpublic: 1219*700637cbSDimitry Andric typedef typename __alloc_traits::pointer pointer; 1220*700637cbSDimitry Andric typedef typename __alloc_traits::const_pointer const_pointer; 1221*700637cbSDimitry Andric typedef typename __table::size_type size_type; 1222*700637cbSDimitry Andric typedef typename __table::difference_type difference_type; 1223*700637cbSDimitry Andric 1224*700637cbSDimitry Andric typedef __hash_map_iterator<typename __table::iterator> iterator; 1225*700637cbSDimitry Andric typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 1226*700637cbSDimitry Andric typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; 1227*700637cbSDimitry Andric typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; 1228*700637cbSDimitry Andric 1229*700637cbSDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 1230*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_map; 1231*700637cbSDimitry Andric template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> 1232*700637cbSDimitry Andric friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; 1233*700637cbSDimitry Andric 1234*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap() {} 1235*700637cbSDimitry Andric explicit _LIBCPP_HIDE_FROM_ABI 1236*700637cbSDimitry Andric unordered_multimap(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); 1237*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1238*700637cbSDimitry Andric unordered_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); 1239*700637cbSDimitry Andric template <class _InputIterator> 1240*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap(_InputIterator __first, _InputIterator __last); 1241*700637cbSDimitry Andric template <class _InputIterator> 1242*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap( 1243*700637cbSDimitry Andric _InputIterator __first, 1244*700637cbSDimitry Andric _InputIterator __last, 1245*700637cbSDimitry Andric size_type __n, 1246*700637cbSDimitry Andric const hasher& __hf = hasher(), 1247*700637cbSDimitry Andric const key_equal& __eql = key_equal()); 1248*700637cbSDimitry Andric template <class _InputIterator> 1249*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap( 1250*700637cbSDimitry Andric _InputIterator __first, 1251*700637cbSDimitry Andric _InputIterator __last, 1252*700637cbSDimitry Andric size_type __n, 1253*700637cbSDimitry Andric const hasher& __hf, 1254*700637cbSDimitry Andric const key_equal& __eql, 1255*700637cbSDimitry Andric const allocator_type& __a); 1256*700637cbSDimitry Andric 1257*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a); 1258*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u); 1259*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); 1260*700637cbSDimitry Andric 1261*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI ~unordered_multimap() { 1262*700637cbSDimitry Andric static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); 1263*700637cbSDimitry Andric } 1264*700637cbSDimitry Andric 1265*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) { 1266*700637cbSDimitry Andric if (this != std::addressof(__u)) { 1267*700637cbSDimitry Andric __table_.clear(); 1268*700637cbSDimitry Andric __table_.hash_function() = __u.__table_.hash_function(); 1269*700637cbSDimitry Andric __table_.key_eq() = __u.__table_.key_eq(); 1270*700637cbSDimitry Andric __table_.max_load_factor() = __u.__table_.max_load_factor(); 1271*700637cbSDimitry Andric __table_.__copy_assign_alloc(__u.__table_); 1272*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 1273*700637cbSDimitry Andric } 1274*700637cbSDimitry Andric return *this; 1275*700637cbSDimitry Andric } 1276*700637cbSDimitry Andric 1277*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { 1278*700637cbSDimitry Andric return allocator_type(__table_.__node_alloc()); 1279*700637cbSDimitry Andric } 1280*700637cbSDimitry Andric 1281*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } 1282*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } 1283*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } 1284*700637cbSDimitry Andric 1285*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } 1286*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } 1287*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } 1288*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } 1289*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } 1290*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } 1291*700637cbSDimitry Andric 1292*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } 1293*700637cbSDimitry Andric 1294*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) { 1295*700637cbSDimitry Andric return __table_.__insert_multi(__p.__i_, __x); 1296*700637cbSDimitry Andric } 1297*700637cbSDimitry Andric 1298*700637cbSDimitry Andric template <class _InputIterator> 1299*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); 1300*700637cbSDimitry Andric 1301*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); } 1302*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); } 1303*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); } 1304*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { 1305*700637cbSDimitry Andric return __table_.erase(__first.__i_, __last.__i_); 1306*700637cbSDimitry Andric } 1307*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } 1308*700637cbSDimitry Andric 1309*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) { __table_.swap(__u.__table_); } 1310*700637cbSDimitry Andric 1311*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); } 1312*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } 1313*700637cbSDimitry Andric 1314*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } 1315*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } 1316*700637cbSDimitry Andric 1317*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } 1318*700637cbSDimitry Andric 1319*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { 1320*700637cbSDimitry Andric return __table_.__equal_range_multi(__k); 1321*700637cbSDimitry Andric } 1322*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { 1323*700637cbSDimitry Andric return __table_.__equal_range_multi(__k); 1324*700637cbSDimitry Andric } 1325*700637cbSDimitry Andric 1326*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } 1327*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } 1328*700637cbSDimitry Andric 1329*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } 1330*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } 1331*700637cbSDimitry Andric 1332*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } 1333*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } 1334*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } 1335*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } 1336*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } 1337*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } 1338*700637cbSDimitry Andric 1339*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } 1340*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } 1341*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } 1342*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); } 1343*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } 1344*700637cbSDimitry Andric}; 1345*700637cbSDimitry Andric 1346*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1347*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 1348*700637cbSDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql) 1349*700637cbSDimitry Andric : __table_(__hf, __eql) { 1350*700637cbSDimitry Andric __table_.__rehash_multi(__n); 1351*700637cbSDimitry Andric} 1352*700637cbSDimitry Andric 1353*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1354*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 1355*700637cbSDimitry Andric size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 1356*700637cbSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) { 1357*700637cbSDimitry Andric __table_.__rehash_multi(__n); 1358*700637cbSDimitry Andric} 1359*700637cbSDimitry Andric 1360*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1361*700637cbSDimitry Andrictemplate <class _InputIterator> 1362*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(_InputIterator __first, _InputIterator __last) { 1363*700637cbSDimitry Andric insert(__first, __last); 1364*700637cbSDimitry Andric} 1365*700637cbSDimitry Andric 1366*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1367*700637cbSDimitry Andrictemplate <class _InputIterator> 1368*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 1369*700637cbSDimitry Andric _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql) 1370*700637cbSDimitry Andric : __table_(__hf, __eql) { 1371*700637cbSDimitry Andric __table_.__rehash_multi(__n); 1372*700637cbSDimitry Andric insert(__first, __last); 1373*700637cbSDimitry Andric} 1374*700637cbSDimitry Andric 1375*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1376*700637cbSDimitry Andrictemplate <class _InputIterator> 1377*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 1378*700637cbSDimitry Andric _InputIterator __first, 1379*700637cbSDimitry Andric _InputIterator __last, 1380*700637cbSDimitry Andric size_type __n, 1381*700637cbSDimitry Andric const hasher& __hf, 1382*700637cbSDimitry Andric const key_equal& __eql, 1383*700637cbSDimitry Andric const allocator_type& __a) 1384*700637cbSDimitry Andric : __table_(__hf, __eql, typename __table::allocator_type(__a)) { 1385*700637cbSDimitry Andric __table_.__rehash_multi(__n); 1386*700637cbSDimitry Andric insert(__first, __last); 1387*700637cbSDimitry Andric} 1388*700637cbSDimitry Andric 1389*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1390*700637cbSDimitry Andricinline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const allocator_type& __a) 1391*700637cbSDimitry Andric : __table_(typename __table::allocator_type(__a)) {} 1392*700637cbSDimitry Andric 1393*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1394*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const unordered_multimap& __u) 1395*700637cbSDimitry Andric : __table_(__u.__table_) { 1396*700637cbSDimitry Andric __table_.__rehash_multi(__u.bucket_count()); 1397*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 1398*700637cbSDimitry Andric} 1399*700637cbSDimitry Andric 1400*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1401*700637cbSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( 1402*700637cbSDimitry Andric const unordered_multimap& __u, const allocator_type& __a) 1403*700637cbSDimitry Andric : __table_(__u.__table_, typename __table::allocator_type(__a)) { 1404*700637cbSDimitry Andric __table_.__rehash_multi(__u.bucket_count()); 1405*700637cbSDimitry Andric insert(__u.begin(), __u.end()); 1406*700637cbSDimitry Andric} 1407*700637cbSDimitry Andric 1408*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1409*700637cbSDimitry Andrictemplate <class _InputIterator> 1410*700637cbSDimitry Andricinline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { 1411*700637cbSDimitry Andric for (; __first != __last; ++__first) 1412*700637cbSDimitry Andric __table_.__insert_multi(*__first); 1413*700637cbSDimitry Andric} 1414*700637cbSDimitry Andric 1415*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1416*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 1417*700637cbSDimitry Andric unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1418*700637cbSDimitry Andric __x.swap(__y); 1419*700637cbSDimitry Andric} 1420*700637cbSDimitry Andric 1421*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1422*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 1423*700637cbSDimitry Andric const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1424*700637cbSDimitry Andric if (__x.size() != __y.size()) 1425*700637cbSDimitry Andric return false; 1426*700637cbSDimitry Andric typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator const_iterator; 1427*700637cbSDimitry Andric typedef pair<const_iterator, const_iterator> _EqRng; 1428*700637cbSDimitry Andric for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) { 1429*700637cbSDimitry Andric _EqRng __xeq = __x.equal_range(__i->first); 1430*700637cbSDimitry Andric _EqRng __yeq = __y.equal_range(__i->first); 1431*700637cbSDimitry Andric if (std::distance(__xeq.first, __xeq.second) != std::distance(__yeq.first, __yeq.second) || 1432*700637cbSDimitry Andric !std::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 1433*700637cbSDimitry Andric return false; 1434*700637cbSDimitry Andric __i = __xeq.second; 1435*700637cbSDimitry Andric } 1436*700637cbSDimitry Andric return true; 1437*700637cbSDimitry Andric} 1438*700637cbSDimitry Andric 1439*700637cbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 1440*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 1441*700637cbSDimitry Andric const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { 1442*700637cbSDimitry Andric return !(__x == __y); 1443*700637cbSDimitry Andric} 1444*700637cbSDimitry Andric 1445*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD 1446*700637cbSDimitry Andric 1447*700637cbSDimitry Andric_LIBCPP_POP_MACROS 1448*700637cbSDimitry Andric 1449*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 1450*700637cbSDimitry Andric# include <__cxx03/algorithm> 1451*700637cbSDimitry Andric# include <__cxx03/cstdlib> 1452*700637cbSDimitry Andric# include <__cxx03/iterator> 1453*700637cbSDimitry Andric# include <__cxx03/type_traits> 1454*700637cbSDimitry Andric#endif 1455*700637cbSDimitry Andric 1456*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_UNORDERED_MAP 1457