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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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>
41 namespace std { namespace tr1 {
43 // XXX When we get typedef templates these class definitions will be unnecessary.
45 template <class Value,
46 class Hash = hash<Value>,
47 class Pred = std::equal_to<Value>,
48 class Alloc = std::allocator<Value>,
49 bool cache_hash_code = false>
51 : public hashtable <Value, Value, Alloc,
52 Internal::identity<Value>, Pred,
53 Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
54 Internal::prime_rehash_policy,
55 cache_hash_code, false, true>
57 typedef hashtable <Value, Value, Alloc,
58 Internal::identity<Value>, Pred,
59 Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
60 Internal::prime_rehash_policy,
61 cache_hash_code, false, true>
65 typedef typename Base::size_type size_type;
66 typedef typename Base::hasher hasher;
67 typedef typename Base::key_equal key_equal;
68 typedef typename Base::allocator_type allocator_type;
70 explicit unordered_set(size_type n = 10,
71 const hasher& hf = hasher(),
72 const key_equal& eql = key_equal(),
73 const allocator_type& a = allocator_type())
75 hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
76 eql, Internal::identity<Value>(),
80 template <typename InputIterator>
81 unordered_set(InputIterator f, InputIterator l,
83 const hasher& hf = hasher(),
84 const key_equal& eql = key_equal(),
85 const allocator_type& a = allocator_type())
88 hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
89 eql, Internal::identity<Value>(),
94 template <class Value,
95 class Hash = hash<Value>,
96 class Pred = std::equal_to<Value>,
97 class Alloc = std::allocator<Value>,
98 bool cache_hash_code = false>
99 class unordered_multiset
100 : public hashtable <Value, Value, Alloc,
101 Internal::identity<Value>, Pred,
102 Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
103 Internal::prime_rehash_policy,
104 cache_hash_code, false, false>
106 typedef hashtable <Value, Value, Alloc,
107 Internal::identity<Value>, Pred,
108 Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
109 Internal::prime_rehash_policy,
110 cache_hash_code, false, false>
114 typedef typename Base::size_type size_type;
115 typedef typename Base::hasher hasher;
116 typedef typename Base::key_equal key_equal;
117 typedef typename Base::allocator_type allocator_type;
119 explicit unordered_multiset(size_type n = 10,
120 const hasher& hf = hasher(),
121 const key_equal& eql = key_equal(),
122 const allocator_type& a = allocator_type())
124 hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
125 eql, Internal::identity<Value>(),
130 template <typename InputIterator>
131 unordered_multiset(InputIterator f, InputIterator l,
132 typename Base::size_type n = 0,
133 const hasher& hf = hasher(),
134 const key_equal& eql = key_equal(),
135 const allocator_type& a = allocator_type())
138 hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
139 eql, Internal::identity<Value>(),
144 template <class Value, class Hash, class Pred, class Alloc, bool cache_hash_code>
145 inline void swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
146 unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
151 template <class Value, class Hash, class Pred, class Alloc, bool cache_hash_code>
152 inline void swap (unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
153 unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
160 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_SET_ */