1169691Skan// TR1 unordered_map -*- C++ -*- 2169691Skan 3169691Skan// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. 4169691Skan// 5169691Skan// This file is part of the GNU ISO C++ Library. This library is free 6169691Skan// software; you can redistribute it and/or modify it under the 7169691Skan// terms of the GNU General Public License as published by the 8169691Skan// Free Software Foundation; either version 2, or (at your option) 9169691Skan// any later version. 10169691Skan 11169691Skan// This library is distributed in the hope that it will be useful, 12169691Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of 13169691Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14169691Skan// GNU General Public License for more details. 15169691Skan 16169691Skan// You should have received a copy of the GNU General Public License along 17169691Skan// with this library; see the file COPYING. If not, write to the Free 18169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19169691Skan// USA. 20169691Skan 21169691Skan// As a special exception, you may use this file as part of a free software 22169691Skan// library without restriction. Specifically, if other files instantiate 23169691Skan// templates or use macros or inline functions from this file, or you compile 24169691Skan// this file and link it with other files to produce an executable, this 25169691Skan// file does not by itself cause the resulting executable to be covered by 26169691Skan// the GNU General Public License. This exception does not however 27169691Skan// invalidate any other reasons why the executable file might be covered by 28169691Skan// the GNU General Public License. 29169691Skan 30169691Skan/** @file tr1/unordered_map 31169691Skan * This is a TR1 C++ Library header. 32169691Skan */ 33169691Skan 34169691Skan#ifndef _TR1_UNORDERED_MAP 35169691Skan#define _TR1_UNORDERED_MAP 1 36169691Skan 37169691Skan#include <tr1/hashtable> 38169691Skan#include <tr1/functional_hash.h> 39169691Skan 40169691Skannamespace std 41169691Skan{ 42169691Skan_GLIBCXX_BEGIN_NAMESPACE(tr1) 43169691Skan 44169691Skan // XXX When we get typedef templates these class definitions 45169691Skan // will be unnecessary. 46169691Skan template<class _Key, class _Tp, 47169691Skan class _Hash = hash<_Key>, 48169691Skan class _Pred = std::equal_to<_Key>, 49169691Skan class _Alloc = std::allocator<std::pair<const _Key, _Tp> >, 50169691Skan bool __cache_hash_code = false> 51169691Skan class unordered_map 52169691Skan : public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc, 53169691Skan std::_Select1st<std::pair<const _Key, _Tp> >, _Pred, 54169691Skan _Hash, __detail::_Mod_range_hashing, 55169691Skan __detail::_Default_ranged_hash, 56169691Skan __detail::_Prime_rehash_policy, 57169691Skan __cache_hash_code, false, true> 58169691Skan { 59169691Skan typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc, 60169691Skan std::_Select1st<std::pair<const _Key, _Tp> >, _Pred, 61169691Skan _Hash, __detail::_Mod_range_hashing, 62169691Skan __detail::_Default_ranged_hash, 63169691Skan __detail::_Prime_rehash_policy, 64169691Skan __cache_hash_code, false, true> 65169691Skan _Base; 66169691Skan 67169691Skan public: 68169691Skan typedef typename _Base::size_type size_type; 69169691Skan typedef typename _Base::hasher hasher; 70169691Skan typedef typename _Base::key_equal key_equal; 71169691Skan typedef typename _Base::allocator_type allocator_type; 72169691Skan 73169691Skan explicit 74169691Skan unordered_map(size_type __n = 10, 75169691Skan const hasher& __hf = hasher(), 76169691Skan const key_equal& __eql = key_equal(), 77169691Skan const allocator_type& __a = allocator_type()) 78169691Skan : _Base(__n, __hf, __detail::_Mod_range_hashing(), 79169691Skan __detail::_Default_ranged_hash(), 80169691Skan __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) 81169691Skan { } 82169691Skan 83169691Skan template<typename _InputIterator> 84169691Skan unordered_map(_InputIterator __f, _InputIterator __l, 85169691Skan size_type __n = 10, 86169691Skan const hasher& __hf = hasher(), 87169691Skan const key_equal& __eql = key_equal(), 88169691Skan const allocator_type& __a = allocator_type()) 89169691Skan : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), 90169691Skan __detail::_Default_ranged_hash(), 91169691Skan __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) 92169691Skan { } 93169691Skan }; 94169691Skan 95169691Skan template<class _Key, class _Tp, 96169691Skan class _Hash = hash<_Key>, 97169691Skan class _Pred = std::equal_to<_Key>, 98169691Skan class _Alloc = std::allocator<std::pair<const _Key, _Tp> >, 99169691Skan bool __cache_hash_code = false> 100169691Skan class unordered_multimap 101169691Skan : public _Hashtable<_Key, std::pair<const _Key, _Tp>, 102169691Skan _Alloc, 103169691Skan std::_Select1st<std::pair<const _Key, _Tp> >, _Pred, 104169691Skan _Hash, __detail::_Mod_range_hashing, 105169691Skan __detail::_Default_ranged_hash, 106169691Skan __detail::_Prime_rehash_policy, 107169691Skan __cache_hash_code, false, false> 108169691Skan { 109169691Skan typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, 110169691Skan _Alloc, 111169691Skan std::_Select1st<std::pair<const _Key, _Tp> >, _Pred, 112169691Skan _Hash, __detail::_Mod_range_hashing, 113169691Skan __detail::_Default_ranged_hash, 114169691Skan __detail::_Prime_rehash_policy, 115169691Skan __cache_hash_code, false, false> 116169691Skan _Base; 117169691Skan 118169691Skan public: 119169691Skan typedef typename _Base::size_type size_type; 120169691Skan typedef typename _Base::hasher hasher; 121169691Skan typedef typename _Base::key_equal key_equal; 122169691Skan typedef typename _Base::allocator_type allocator_type; 123169691Skan 124169691Skan explicit 125169691Skan unordered_multimap(size_type __n = 10, 126169691Skan const hasher& __hf = hasher(), 127169691Skan const key_equal& __eql = key_equal(), 128169691Skan const allocator_type& __a = allocator_type()) 129169691Skan : _Base(__n, __hf, __detail::_Mod_range_hashing(), 130169691Skan __detail::_Default_ranged_hash(), 131169691Skan __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) 132169691Skan { } 133169691Skan 134169691Skan 135169691Skan template<typename _InputIterator> 136169691Skan unordered_multimap(_InputIterator __f, _InputIterator __l, 137169691Skan typename _Base::size_type __n = 0, 138169691Skan const hasher& __hf = hasher(), 139169691Skan const key_equal& __eql = key_equal(), 140169691Skan const allocator_type& __a = allocator_type()) 141169691Skan : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), 142169691Skan __detail::_Default_ranged_hash(), 143169691Skan __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) 144169691Skan { } 145169691Skan }; 146169691Skan 147169691Skan template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, 148169691Skan bool __cache_hash_code> 149169691Skan inline void 150169691Skan swap(unordered_map<_Key, _Tp, _Hash, _Pred, 151169691Skan _Alloc, __cache_hash_code>& __x, 152169691Skan unordered_map<_Key, _Tp, _Hash, _Pred, 153169691Skan _Alloc, __cache_hash_code>& __y) 154169691Skan { __x.swap(__y); } 155169691Skan 156169691Skan template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, 157169691Skan bool __cache_hash_code> 158169691Skan inline void 159169691Skan swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, 160169691Skan _Alloc, __cache_hash_code>& __x, 161169691Skan unordered_multimap<_Key, _Tp, _Hash, _Pred, 162169691Skan _Alloc, __cache_hash_code>& __y) 163169691Skan { __x.swap(__y); } 164169691Skan 165169691Skan_GLIBCXX_END_NAMESPACE 166169691Skan} 167169691Skan 168169691Skan#endif // _TR1_UNORDERED_MAP 169