3 * Silicon Graphics Computer Systems, Inc.
5 * Permission to use, copy, modify, distribute and sell this software
6 * and its documentation for any purpose is hereby granted without fee,
7 * provided that the above copyright notice appear in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation. Silicon Graphics makes no
10 * representations about the suitability of this software for any
11 * purpose. It is provided "as is" without express or implied warranty.
15 * Hewlett-Packard Company
17 * Permission to use, copy, modify, distribute and sell this software
18 * and its documentation for any purpose is hereby granted without fee,
19 * provided that the above copyright notice appear in all copies and
20 * that both that copyright notice and this permission notice appear
21 * in supporting documentation. Hewlett-Packard Company makes no
22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef __SGI_STL_INTERNAL_HASH_SET_H
32 #define __SGI_STL_INTERNAL_HASH_SET_H
36 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
40 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
41 template <class Value, class HashFcn = hash<Value>,
42 class EqualKey = equal_to<Value>,
45 template <class Value, class HashFcn, class EqualKey, class Alloc = alloc>
50 typedef hashtable<Value, Value, HashFcn, identity<Value>,
55 typedef typename ht::key_type key_type;
56 typedef typename ht::value_type value_type;
57 typedef typename ht::hasher hasher;
58 typedef typename ht::key_equal key_equal;
60 typedef typename ht::size_type size_type;
61 typedef typename ht::difference_type difference_type;
62 typedef typename ht::const_pointer pointer;
63 typedef typename ht::const_pointer const_pointer;
64 typedef typename ht::const_reference reference;
65 typedef typename ht::const_reference const_reference;
67 typedef typename ht::const_iterator iterator;
68 typedef typename ht::const_iterator const_iterator;
70 hasher hash_funct() const { return rep.hash_funct(); }
71 key_equal key_eq() const { return rep.key_eq(); }
74 hash_set() : rep(100, hasher(), key_equal()) {}
75 explicit hash_set(size_type n) : rep(n, hasher(), key_equal()) {}
76 hash_set(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
77 hash_set(size_type n, const hasher& hf, const key_equal& eql)
80 #ifdef __STL_MEMBER_TEMPLATES
81 template <class InputIterator>
82 hash_set(InputIterator f, InputIterator l)
83 : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
84 template <class InputIterator>
85 hash_set(InputIterator f, InputIterator l, size_type n)
86 : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
87 template <class InputIterator>
88 hash_set(InputIterator f, InputIterator l, size_type n,
90 : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
91 template <class InputIterator>
92 hash_set(InputIterator f, InputIterator l, size_type n,
93 const hasher& hf, const key_equal& eql)
94 : rep(n, hf, eql) { rep.insert_unique(f, l); }
97 hash_set(const value_type* f, const value_type* l)
98 : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
99 hash_set(const value_type* f, const value_type* l, size_type n)
100 : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
101 hash_set(const value_type* f, const value_type* l, size_type n,
103 : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
104 hash_set(const value_type* f, const value_type* l, size_type n,
105 const hasher& hf, const key_equal& eql)
106 : rep(n, hf, eql) { rep.insert_unique(f, l); }
108 hash_set(const_iterator f, const_iterator l)
109 : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); }
110 hash_set(const_iterator f, const_iterator l, size_type n)
111 : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); }
112 hash_set(const_iterator f, const_iterator l, size_type n,
114 : rep(n, hf, key_equal()) { rep.insert_unique(f, l); }
115 hash_set(const_iterator f, const_iterator l, size_type n,
116 const hasher& hf, const key_equal& eql)
117 : rep(n, hf, eql) { rep.insert_unique(f, l); }
118 #endif /*__STL_MEMBER_TEMPLATES */
121 size_type size() const { return rep.size(); }
122 size_type max_size() const { return rep.max_size(); }
123 bool empty() const { return rep.empty(); }
124 void swap(hash_set& hs) { rep.swap(hs.rep); }
125 friend bool operator== __STL_NULL_TMPL_ARGS (const hash_set&,
128 iterator begin() const { return rep.begin(); }
129 iterator end() const { return rep.end(); }
132 pair<iterator, bool> insert(const value_type& obj)
134 pair<typename ht::iterator, bool> p = rep.insert_unique(obj);
135 return pair<iterator, bool>(p.first, p.second);
137 #ifdef __STL_MEMBER_TEMPLATES
138 template <class InputIterator>
139 void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); }
141 void insert(const value_type* f, const value_type* l) {
142 rep.insert_unique(f,l);
144 void insert(const_iterator f, const_iterator l) {rep.insert_unique(f, l); }
145 #endif /*__STL_MEMBER_TEMPLATES */
146 pair<iterator, bool> insert_noresize(const value_type& obj)
148 pair<typename ht::iterator, bool> p = rep.insert_unique_noresize(obj);
149 return pair<iterator, bool>(p.first, p.second);
152 iterator find(const key_type& key) const { return rep.find(key); }
154 size_type count(const key_type& key) const { return rep.count(key); }
156 pair<iterator, iterator> equal_range(const key_type& key) const
157 { return rep.equal_range(key); }
159 size_type erase(const key_type& key) {return rep.erase(key); }
160 void erase(iterator it) { rep.erase(it); }
161 void erase(iterator f, iterator l) { rep.erase(f, l); }
162 void clear() { rep.clear(); }
165 void resize(size_type hint) { rep.resize(hint); }
166 size_type bucket_count() const { return rep.bucket_count(); }
167 size_type max_bucket_count() const { return rep.max_bucket_count(); }
168 size_type elems_in_bucket(size_type n) const
169 { return rep.elems_in_bucket(n); }
172 template <class Value, class HashFcn, class EqualKey, class Alloc>
173 inline bool operator==(const hash_set<Value, HashFcn, EqualKey, Alloc>& hs1,
174 const hash_set<Value, HashFcn, EqualKey, Alloc>& hs2)
176 return hs1.rep == hs2.rep;
179 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
181 template <class Val, class HashFcn, class EqualKey, class Alloc>
182 inline void swap(hash_set<Val, HashFcn, EqualKey, Alloc>& hs1,
183 hash_set<Val, HashFcn, EqualKey, Alloc>& hs2) {
187 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
190 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
191 template <class Value, class HashFcn = hash<Value>,
192 class EqualKey = equal_to<Value>,
195 template <class Value, class HashFcn, class EqualKey, class Alloc = alloc>
200 typedef hashtable<Value, Value, HashFcn, identity<Value>,
205 typedef typename ht::key_type key_type;
206 typedef typename ht::value_type value_type;
207 typedef typename ht::hasher hasher;
208 typedef typename ht::key_equal key_equal;
210 typedef typename ht::size_type size_type;
211 typedef typename ht::difference_type difference_type;
212 typedef typename ht::const_pointer pointer;
213 typedef typename ht::const_pointer const_pointer;
214 typedef typename ht::const_reference reference;
215 typedef typename ht::const_reference const_reference;
217 typedef typename ht::const_iterator iterator;
218 typedef typename ht::const_iterator const_iterator;
220 hasher hash_funct() const { return rep.hash_funct(); }
221 key_equal key_eq() const { return rep.key_eq(); }
224 hash_multiset() : rep(100, hasher(), key_equal()) {}
225 explicit hash_multiset(size_type n) : rep(n, hasher(), key_equal()) {}
226 hash_multiset(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {}
227 hash_multiset(size_type n, const hasher& hf, const key_equal& eql)
230 #ifdef __STL_MEMBER_TEMPLATES
231 template <class InputIterator>
232 hash_multiset(InputIterator f, InputIterator l)
233 : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
234 template <class InputIterator>
235 hash_multiset(InputIterator f, InputIterator l, size_type n)
236 : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
237 template <class InputIterator>
238 hash_multiset(InputIterator f, InputIterator l, size_type n,
240 : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
241 template <class InputIterator>
242 hash_multiset(InputIterator f, InputIterator l, size_type n,
243 const hasher& hf, const key_equal& eql)
244 : rep(n, hf, eql) { rep.insert_equal(f, l); }
247 hash_multiset(const value_type* f, const value_type* l)
248 : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
249 hash_multiset(const value_type* f, const value_type* l, size_type n)
250 : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
251 hash_multiset(const value_type* f, const value_type* l, size_type n,
253 : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
254 hash_multiset(const value_type* f, const value_type* l, size_type n,
255 const hasher& hf, const key_equal& eql)
256 : rep(n, hf, eql) { rep.insert_equal(f, l); }
258 hash_multiset(const_iterator f, const_iterator l)
259 : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); }
260 hash_multiset(const_iterator f, const_iterator l, size_type n)
261 : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); }
262 hash_multiset(const_iterator f, const_iterator l, size_type n,
264 : rep(n, hf, key_equal()) { rep.insert_equal(f, l); }
265 hash_multiset(const_iterator f, const_iterator l, size_type n,
266 const hasher& hf, const key_equal& eql)
267 : rep(n, hf, eql) { rep.insert_equal(f, l); }
268 #endif /*__STL_MEMBER_TEMPLATES */
271 size_type size() const { return rep.size(); }
272 size_type max_size() const { return rep.max_size(); }
273 bool empty() const { return rep.empty(); }
274 void swap(hash_multiset& hs) { rep.swap(hs.rep); }
275 friend bool operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,
276 const hash_multiset&);
278 iterator begin() const { return rep.begin(); }
279 iterator end() const { return rep.end(); }
282 iterator insert(const value_type& obj) { return rep.insert_equal(obj); }
283 #ifdef __STL_MEMBER_TEMPLATES
284 template <class InputIterator>
285 void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); }
287 void insert(const value_type* f, const value_type* l) {
288 rep.insert_equal(f,l);
290 void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); }
291 #endif /*__STL_MEMBER_TEMPLATES */
292 iterator insert_noresize(const value_type& obj)
293 { return rep.insert_equal_noresize(obj); }
295 iterator find(const key_type& key) const { return rep.find(key); }
297 size_type count(const key_type& key) const { return rep.count(key); }
299 pair<iterator, iterator> equal_range(const key_type& key) const
300 { return rep.equal_range(key); }
302 size_type erase(const key_type& key) {return rep.erase(key); }
303 void erase(iterator it) { rep.erase(it); }
304 void erase(iterator f, iterator l) { rep.erase(f, l); }
305 void clear() { rep.clear(); }
308 void resize(size_type hint) { rep.resize(hint); }
309 size_type bucket_count() const { return rep.bucket_count(); }
310 size_type max_bucket_count() const { return rep.max_bucket_count(); }
311 size_type elems_in_bucket(size_type n) const
312 { return rep.elems_in_bucket(n); }
315 template <class Val, class HashFcn, class EqualKey, class Alloc>
316 inline bool operator==(const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,
317 const hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)
319 return hs1.rep == hs2.rep;
322 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
324 template <class Val, class HashFcn, class EqualKey, class Alloc>
325 inline void swap(hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs1,
326 hash_multiset<Val, HashFcn, EqualKey, Alloc>& hs2)
330 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
332 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
333 #pragma reset woff 1174
338 #endif /* __SGI_STL_INTERNAL_HASH_SET_H */