1 // TR1 unordered_set -*- C++ -*-
3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
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)
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.
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,
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.
31 * This is a TR1 C++ Library header.
34 #ifndef GNU_LIBSTDCXX_TR1_UNORDERED_SET_
35 #define GNU_LIBSTDCXX_TR1_UNORDERED_SET_
37 #include <tr1/hashtable>
38 #include <tr1/functional>
42 _GLIBCXX_BEGIN_NAMESPACE(tr1)
44 // XXX When we get typedef templates these class definitions
45 // will be unnecessary.
48 class Hash = hash<Value>,
49 class Pred = std::equal_to<Value>,
50 class Alloc = std::allocator<Value>,
51 bool cache_hash_code = false>
53 : public hashtable<Value, Value, Alloc,
54 Internal::identity<Value>, Pred,
55 Hash, Internal::mod_range_hashing,
56 Internal::default_ranged_hash,
57 Internal::prime_rehash_policy,
58 cache_hash_code, true, true>
60 typedef hashtable<Value, Value, Alloc,
61 Internal::identity<Value>, Pred,
62 Hash, Internal::mod_range_hashing,
63 Internal::default_ranged_hash,
64 Internal::prime_rehash_policy,
65 cache_hash_code, true, true>
69 typedef typename Base::size_type size_type;
70 typedef typename Base::hasher hasher;
71 typedef typename Base::key_equal key_equal;
72 typedef typename Base::allocator_type allocator_type;
75 unordered_set(size_type n = 10,
76 const hasher& hf = hasher(),
77 const key_equal& eql = key_equal(),
78 const allocator_type& a = allocator_type())
79 : Base (n, hf, Internal::mod_range_hashing(),
80 Internal::default_ranged_hash(),
81 eql, Internal::identity<Value>(), a)
84 template<typename InputIterator>
85 unordered_set(InputIterator f, InputIterator l,
87 const hasher& hf = hasher(),
88 const key_equal& eql = key_equal(),
89 const allocator_type& a = allocator_type())
90 : Base (f, l, n, hf, Internal::mod_range_hashing(),
91 Internal::default_ranged_hash(),
92 eql, Internal::identity<Value>(), a)
97 class Hash = hash<Value>,
98 class Pred = std::equal_to<Value>,
99 class Alloc = std::allocator<Value>,
100 bool cache_hash_code = false>
101 class unordered_multiset
102 : public hashtable <Value, Value, Alloc,
103 Internal::identity<Value>, Pred,
104 Hash, Internal::mod_range_hashing,
105 Internal::default_ranged_hash,
106 Internal::prime_rehash_policy,
107 cache_hash_code, true, false>
109 typedef hashtable<Value, Value, Alloc,
110 Internal::identity<Value>, Pred,
111 Hash, Internal::mod_range_hashing,
112 Internal::default_ranged_hash,
113 Internal::prime_rehash_policy,
114 cache_hash_code, true, false>
118 typedef typename Base::size_type size_type;
119 typedef typename Base::hasher hasher;
120 typedef typename Base::key_equal key_equal;
121 typedef typename Base::allocator_type allocator_type;
124 unordered_multiset(size_type n = 10,
125 const hasher& hf = hasher(),
126 const key_equal& eql = key_equal(),
127 const allocator_type& a = allocator_type())
128 : Base (n, hf, Internal::mod_range_hashing(),
129 Internal::default_ranged_hash(),
130 eql, Internal::identity<Value>(), a)
134 template<typename InputIterator>
135 unordered_multiset(InputIterator f, InputIterator l,
136 typename Base::size_type n = 0,
137 const hasher& hf = hasher(),
138 const key_equal& eql = key_equal(),
139 const allocator_type& a = allocator_type())
140 : Base (f, l, n, hf, Internal::mod_range_hashing(),
141 Internal::default_ranged_hash(), eql,
142 Internal::identity<Value>(), a)
146 template<class Value, class Hash, class Pred, class Alloc,
147 bool cache_hash_code>
149 swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
150 unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
153 template<class Value, class Hash, class Pred, class Alloc,
154 bool cache_hash_code>
156 swap(unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
157 unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
160 _GLIBCXX_END_NAMESPACE
163 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_SET_ */