1169691Skan// TR1 unordered_set -*- 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_set 31169691Skan * This is a TR1 C++ Library header. 32169691Skan */ 33169691Skan 34169691Skan#ifndef _TR1_UNORDERED_SET 35169691Skan#define _TR1_UNORDERED_SET 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 _Value, 47169691Skan class _Hash = hash<_Value>, 48169691Skan class _Pred = std::equal_to<_Value>, 49169691Skan class _Alloc = std::allocator<_Value>, 50169691Skan bool __cache_hash_code = false> 51169691Skan class unordered_set 52169691Skan : public _Hashtable<_Value, _Value, _Alloc, 53169691Skan std::_Identity<_Value>, _Pred, 54169691Skan _Hash, __detail::_Mod_range_hashing, 55169691Skan __detail::_Default_ranged_hash, 56169691Skan __detail::_Prime_rehash_policy, 57169691Skan __cache_hash_code, true, true> 58169691Skan { 59169691Skan typedef _Hashtable<_Value, _Value, _Alloc, 60169691Skan std::_Identity<_Value>, _Pred, 61169691Skan _Hash, __detail::_Mod_range_hashing, 62169691Skan __detail::_Default_ranged_hash, 63169691Skan __detail::_Prime_rehash_policy, 64169691Skan __cache_hash_code, true, 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_set(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(), __eql, 80169691Skan std::_Identity<_Value>(), __a) 81169691Skan { } 82169691Skan 83169691Skan template<typename _InputIterator> 84169691Skan unordered_set(_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(), __eql, 91169691Skan std::_Identity<_Value>(), __a) 92169691Skan { } 93169691Skan }; 94169691Skan 95169691Skan template<class _Value, 96169691Skan class _Hash = hash<_Value>, 97169691Skan class _Pred = std::equal_to<_Value>, 98169691Skan class _Alloc = std::allocator<_Value>, 99169691Skan bool __cache_hash_code = false> 100169691Skan class unordered_multiset 101169691Skan : public _Hashtable<_Value, _Value, _Alloc, 102169691Skan std::_Identity<_Value>, _Pred, 103169691Skan _Hash, __detail::_Mod_range_hashing, 104169691Skan __detail::_Default_ranged_hash, 105169691Skan __detail::_Prime_rehash_policy, 106169691Skan __cache_hash_code, true, false> 107169691Skan { 108169691Skan typedef _Hashtable<_Value, _Value, _Alloc, 109169691Skan std::_Identity<_Value>, _Pred, 110169691Skan _Hash, __detail::_Mod_range_hashing, 111169691Skan __detail::_Default_ranged_hash, 112169691Skan __detail::_Prime_rehash_policy, 113169691Skan __cache_hash_code, true, false> 114169691Skan _Base; 115169691Skan 116169691Skan public: 117169691Skan typedef typename _Base::size_type size_type; 118169691Skan typedef typename _Base::hasher hasher; 119169691Skan typedef typename _Base::key_equal key_equal; 120169691Skan typedef typename _Base::allocator_type allocator_type; 121169691Skan 122169691Skan explicit 123169691Skan unordered_multiset(size_type __n = 10, 124169691Skan const hasher& __hf = hasher(), 125169691Skan const key_equal& __eql = key_equal(), 126169691Skan const allocator_type& __a = allocator_type()) 127169691Skan : _Base(__n, __hf, __detail::_Mod_range_hashing(), 128169691Skan __detail::_Default_ranged_hash(), __eql, 129169691Skan std::_Identity<_Value>(), __a) 130169691Skan { } 131169691Skan 132169691Skan 133169691Skan template<typename _InputIterator> 134169691Skan unordered_multiset(_InputIterator __f, _InputIterator __l, 135169691Skan typename _Base::size_type __n = 0, 136169691Skan const hasher& __hf = hasher(), 137169691Skan const key_equal& __eql = key_equal(), 138169691Skan const allocator_type& __a = allocator_type()) 139169691Skan : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), 140169691Skan __detail::_Default_ranged_hash(), __eql, 141169691Skan std::_Identity<_Value>(), __a) 142169691Skan { } 143169691Skan }; 144169691Skan 145169691Skan template<class _Value, class _Hash, class _Pred, class _Alloc, 146169691Skan bool __cache_hash_code> 147169691Skan inline void 148169691Skan swap (unordered_set<_Value, _Hash, _Pred, 149169691Skan _Alloc, __cache_hash_code>& __x, 150169691Skan unordered_set<_Value, _Hash, _Pred, 151169691Skan _Alloc, __cache_hash_code>& __y) 152169691Skan { __x.swap(__y); } 153169691Skan 154169691Skan template<class _Value, class _Hash, class _Pred, class _Alloc, 155169691Skan bool __cache_hash_code> 156169691Skan inline void 157169691Skan swap(unordered_multiset<_Value, _Hash, _Pred, 158169691Skan _Alloc, __cache_hash_code>& __x, 159169691Skan unordered_multiset<_Value, _Hash, _Pred, 160169691Skan _Alloc, __cache_hash_code>& __y) 161169691Skan { __x.swap(__y); } 162169691Skan 163169691Skan_GLIBCXX_END_NAMESPACE 164169691Skan} 165169691Skan 166169691Skan#endif // _TR1_UNORDERED_SET 167