1 // TR1 unordered_set -*- C++ -*-
3 // Copyright (C) 2005 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>
46 // XXX When we get typedef templates these class definitions
47 // will be unnecessary.
50 class Hash = hash<Value>,
51 class Pred = std::equal_to<Value>,
52 class Alloc = std::allocator<Value>,
53 bool cache_hash_code = false>
55 : public hashtable<Value, Value, Alloc,
56 Internal::identity<Value>, Pred,
57 Hash, Internal::mod_range_hashing,
58 Internal::default_ranged_hash,
59 Internal::prime_rehash_policy,
60 cache_hash_code, true, true>
62 typedef hashtable<Value, Value, Alloc,
63 Internal::identity<Value>, Pred,
64 Hash, Internal::mod_range_hashing,
65 Internal::default_ranged_hash,
66 Internal::prime_rehash_policy,
67 cache_hash_code, true, true>
71 typedef typename Base::size_type size_type;
72 typedef typename Base::hasher hasher;
73 typedef typename Base::key_equal key_equal;
74 typedef typename Base::allocator_type allocator_type;
77 unordered_set(size_type n = 10,
78 const hasher& hf = hasher(),
79 const key_equal& eql = key_equal(),
80 const allocator_type& a = allocator_type())
81 : Base (n, hf, Internal::mod_range_hashing(),
82 Internal::default_ranged_hash(),
83 eql, Internal::identity<Value>(), a)
86 template<typename InputIterator>
87 unordered_set(InputIterator f, InputIterator l,
89 const hasher& hf = hasher(),
90 const key_equal& eql = key_equal(),
91 const allocator_type& a = allocator_type())
92 : Base (f, l, n, hf, Internal::mod_range_hashing(),
93 Internal::default_ranged_hash(),
94 eql, Internal::identity<Value>(), a)
99 class Hash = hash<Value>,
100 class Pred = std::equal_to<Value>,
101 class Alloc = std::allocator<Value>,
102 bool cache_hash_code = false>
103 class unordered_multiset
104 : public hashtable <Value, Value, Alloc,
105 Internal::identity<Value>, Pred,
106 Hash, Internal::mod_range_hashing,
107 Internal::default_ranged_hash,
108 Internal::prime_rehash_policy,
109 cache_hash_code, true, false>
111 typedef hashtable<Value, Value, Alloc,
112 Internal::identity<Value>, Pred,
113 Hash, Internal::mod_range_hashing,
114 Internal::default_ranged_hash,
115 Internal::prime_rehash_policy,
116 cache_hash_code, true, false>
120 typedef typename Base::size_type size_type;
121 typedef typename Base::hasher hasher;
122 typedef typename Base::key_equal key_equal;
123 typedef typename Base::allocator_type allocator_type;
126 unordered_multiset(size_type n = 10,
127 const hasher& hf = hasher(),
128 const key_equal& eql = key_equal(),
129 const allocator_type& a = allocator_type())
130 : Base (n, hf, Internal::mod_range_hashing(),
131 Internal::default_ranged_hash(),
132 eql, Internal::identity<Value>(), a)
136 template<typename InputIterator>
137 unordered_multiset(InputIterator f, InputIterator l,
138 typename Base::size_type n = 0,
139 const hasher& hf = hasher(),
140 const key_equal& eql = key_equal(),
141 const allocator_type& a = allocator_type())
142 : Base (f, l, n, hf, Internal::mod_range_hashing(),
143 Internal::default_ranged_hash(), eql,
144 Internal::identity<Value>(), a)
148 template<class Value, class Hash, class Pred, class Alloc,
149 bool cache_hash_code>
151 swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
152 unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
155 template<class Value, class Hash, class Pred, class Alloc,
156 bool cache_hash_code>
158 swap(unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
159 unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
165 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_SET_ */