1// TR1 unordered_set -*- C++ -*- 2 3// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. 4// 5// This file is part of the GNU ISO C++ Library. This library is free 6// software; you can redistribute it and/or modify it under the 7// terms of the GNU General Public License as published by the 8// Free Software Foundation; either version 2, or (at your option) 9// any later version. 10 11// This library is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// You should have received a copy of the GNU General Public License along 17// with this library; see the file COPYING. If not, write to the Free 18// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19// USA. 20 21// As a special exception, you may use this file as part of a free software 22// library without restriction. Specifically, if other files instantiate 23// templates or use macros or inline functions from this file, or you compile 24// this file and link it with other files to produce an executable, this 25// file does not by itself cause the resulting executable to be covered by 26// the GNU General Public License. This exception does not however 27// invalidate any other reasons why the executable file might be covered by 28// the GNU General Public License. 29 30/** @file tr1/unordered_set 31 * This is a TR1 C++ Library header. 32 */ 33 34#ifndef _TR1_UNORDERED_SET 35#define _TR1_UNORDERED_SET 1 36 37#include <tr1/hashtable> 38#include <tr1/functional_hash.h> 39 40namespace std 41{ 42_GLIBCXX_BEGIN_NAMESPACE(tr1) 43 44 // XXX When we get typedef templates these class definitions 45 // will be unnecessary. 46 template<class _Value, 47 class _Hash = hash<_Value>, 48 class _Pred = std::equal_to<_Value>, 49 class _Alloc = std::allocator<_Value>, 50 bool __cache_hash_code = false> 51 class unordered_set 52 : public _Hashtable<_Value, _Value, _Alloc, 53 std::_Identity<_Value>, _Pred, 54 _Hash, __detail::_Mod_range_hashing, 55 __detail::_Default_ranged_hash, 56 __detail::_Prime_rehash_policy, 57 __cache_hash_code, true, true> 58 { 59 typedef _Hashtable<_Value, _Value, _Alloc, 60 std::_Identity<_Value>, _Pred, 61 _Hash, __detail::_Mod_range_hashing, 62 __detail::_Default_ranged_hash, 63 __detail::_Prime_rehash_policy, 64 __cache_hash_code, true, true> 65 _Base; 66 67 public: 68 typedef typename _Base::size_type size_type; 69 typedef typename _Base::hasher hasher; 70 typedef typename _Base::key_equal key_equal; 71 typedef typename _Base::allocator_type allocator_type; 72 73 explicit 74 unordered_set(size_type __n = 10, 75 const hasher& __hf = hasher(), 76 const key_equal& __eql = key_equal(), 77 const allocator_type& __a = allocator_type()) 78 : _Base(__n, __hf, __detail::_Mod_range_hashing(), 79 __detail::_Default_ranged_hash(), __eql, 80 std::_Identity<_Value>(), __a) 81 { } 82 83 template<typename _InputIterator> 84 unordered_set(_InputIterator __f, _InputIterator __l, 85 size_type __n = 10, 86 const hasher& __hf = hasher(), 87 const key_equal& __eql = key_equal(), 88 const allocator_type& __a = allocator_type()) 89 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), 90 __detail::_Default_ranged_hash(), __eql, 91 std::_Identity<_Value>(), __a) 92 { } 93 }; 94 95 template<class _Value, 96 class _Hash = hash<_Value>, 97 class _Pred = std::equal_to<_Value>, 98 class _Alloc = std::allocator<_Value>, 99 bool __cache_hash_code = false> 100 class unordered_multiset 101 : public _Hashtable<_Value, _Value, _Alloc, 102 std::_Identity<_Value>, _Pred, 103 _Hash, __detail::_Mod_range_hashing, 104 __detail::_Default_ranged_hash, 105 __detail::_Prime_rehash_policy, 106 __cache_hash_code, true, false> 107 { 108 typedef _Hashtable<_Value, _Value, _Alloc, 109 std::_Identity<_Value>, _Pred, 110 _Hash, __detail::_Mod_range_hashing, 111 __detail::_Default_ranged_hash, 112 __detail::_Prime_rehash_policy, 113 __cache_hash_code, true, false> 114 _Base; 115 116 public: 117 typedef typename _Base::size_type size_type; 118 typedef typename _Base::hasher hasher; 119 typedef typename _Base::key_equal key_equal; 120 typedef typename _Base::allocator_type allocator_type; 121 122 explicit 123 unordered_multiset(size_type __n = 10, 124 const hasher& __hf = hasher(), 125 const key_equal& __eql = key_equal(), 126 const allocator_type& __a = allocator_type()) 127 : _Base(__n, __hf, __detail::_Mod_range_hashing(), 128 __detail::_Default_ranged_hash(), __eql, 129 std::_Identity<_Value>(), __a) 130 { } 131 132 133 template<typename _InputIterator> 134 unordered_multiset(_InputIterator __f, _InputIterator __l, 135 typename _Base::size_type __n = 0, 136 const hasher& __hf = hasher(), 137 const key_equal& __eql = key_equal(), 138 const allocator_type& __a = allocator_type()) 139 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), 140 __detail::_Default_ranged_hash(), __eql, 141 std::_Identity<_Value>(), __a) 142 { } 143 }; 144 145 template<class _Value, class _Hash, class _Pred, class _Alloc, 146 bool __cache_hash_code> 147 inline void 148 swap (unordered_set<_Value, _Hash, _Pred, 149 _Alloc, __cache_hash_code>& __x, 150 unordered_set<_Value, _Hash, _Pred, 151 _Alloc, __cache_hash_code>& __y) 152 { __x.swap(__y); } 153 154 template<class _Value, class _Hash, class _Pred, class _Alloc, 155 bool __cache_hash_code> 156 inline void 157 swap(unordered_multiset<_Value, _Hash, _Pred, 158 _Alloc, __cache_hash_code>& __x, 159 unordered_multiset<_Value, _Hash, _Pred, 160 _Alloc, __cache_hash_code>& __y) 161 { __x.swap(__y); } 162 163_GLIBCXX_END_NAMESPACE 164} 165 166#endif // _TR1_UNORDERED_SET 167