Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / kwsys / hash_set.hxx.in
blob106e56de2b75ac61a344f97e1cd3d9b6f42968bd
1 /*=========================================================================
3 Program: KWSys - Kitware System Library
4 Module: $RCSfile: hash_set.hxx.in,v $
6 Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
13 =========================================================================*/
15 * Copyright (c) 1996
16 * Silicon Graphics Computer Systems, Inc.
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation. Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose. It is provided "as is" without express or implied warranty.
27 * Copyright (c) 1994
28 * Hewlett-Packard Company
30 * Permission to use, copy, modify, distribute and sell this software
31 * and its documentation for any purpose is hereby granted without fee,
32 * provided that the above copyright notice appear in all copies and
33 * that both that copyright notice and this permission notice appear
34 * in supporting documentation. Hewlett-Packard Company makes no
35 * representations about the suitability of this software for any
36 * purpose. It is provided "as is" without express or implied warranty.
39 #ifndef @KWSYS_NAMESPACE@_hash_set_hxx
40 #define @KWSYS_NAMESPACE@_hash_set_hxx
42 #include <@KWSYS_NAMESPACE@/hashtable.hxx>
43 #include <@KWSYS_NAMESPACE@/hash_fun.hxx>
44 #include <@KWSYS_NAMESPACE@/stl/functional> // equal_to
46 #if defined(_MSC_VER)
47 # pragma warning (push)
48 # pragma warning (disable:4284)
49 # pragma warning (disable:4786)
50 #endif
52 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
53 # pragma set woff 1174
54 # pragma set woff 1375
55 #endif
57 namespace @KWSYS_NAMESPACE@
60 // identity is an extension: it is not part of the standard.
61 template <class _Tp>
62 struct _Identity : public @KWSYS_NAMESPACE@_stl::unary_function<_Tp,_Tp>
64 const _Tp& operator()(const _Tp& __x) const { return __x; }
67 // Forward declaration of equality operator; needed for friend declaration.
69 template <class _Value,
70 class _HashFcn = hash<_Value>,
71 class _EqualKey = @KWSYS_NAMESPACE@_stl::equal_to<_Value>,
72 class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) >
73 class hash_set;
75 template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
76 bool
77 operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
78 const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2);
80 template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
81 class hash_set
83 private:
84 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
85 _EqualKey, _Alloc> _Ht;
86 _Ht _M_ht;
88 public:
89 typedef typename _Ht::key_type key_type;
90 typedef typename _Ht::value_type value_type;
91 typedef typename _Ht::hasher hasher;
92 typedef typename _Ht::key_equal key_equal;
94 typedef typename _Ht::size_type size_type;
95 typedef typename _Ht::difference_type difference_type;
96 typedef typename _Ht::const_pointer pointer;
97 typedef typename _Ht::const_pointer const_pointer;
98 typedef typename _Ht::const_reference reference;
99 typedef typename _Ht::const_reference const_reference;
101 typedef typename _Ht::const_iterator iterator;
102 typedef typename _Ht::const_iterator const_iterator;
104 typedef typename _Ht::allocator_type allocator_type;
106 hasher hash_funct() const { return _M_ht.hash_funct(); }
107 key_equal key_eq() const { return _M_ht.key_eq(); }
108 allocator_type get_allocator() const { return _M_ht.get_allocator(); }
110 public:
111 hash_set()
112 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
113 explicit hash_set(size_type __n)
114 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
115 hash_set(size_type __n, const hasher& __hf)
116 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
117 hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
118 const allocator_type& __a = allocator_type())
119 : _M_ht(__n, __hf, __eql, __a) {}
121 #if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES
122 template <class _InputIterator>
123 hash_set(_InputIterator __f, _InputIterator __l)
124 : _M_ht(100, hasher(), key_equal(), allocator_type())
125 { _M_ht.insert_unique(__f, __l); }
126 template <class _InputIterator>
127 hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
128 : _M_ht(__n, hasher(), key_equal(), allocator_type())
129 { _M_ht.insert_unique(__f, __l); }
130 template <class _InputIterator>
131 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
132 const hasher& __hf)
133 : _M_ht(__n, __hf, key_equal(), allocator_type())
134 { _M_ht.insert_unique(__f, __l); }
135 template <class _InputIterator>
136 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
137 const hasher& __hf, const key_equal& __eql,
138 const allocator_type& __a = allocator_type())
139 : _M_ht(__n, __hf, __eql, __a)
140 { _M_ht.insert_unique(__f, __l); }
141 #else
143 hash_set(const value_type* __f, const value_type* __l)
144 : _M_ht(100, hasher(), key_equal(), allocator_type())
145 { _M_ht.insert_unique(__f, __l); }
146 hash_set(const value_type* __f, const value_type* __l, size_type __n)
147 : _M_ht(__n, hasher(), key_equal(), allocator_type())
148 { _M_ht.insert_unique(__f, __l); }
149 hash_set(const value_type* __f, const value_type* __l, size_type __n,
150 const hasher& __hf)
151 : _M_ht(__n, __hf, key_equal(), allocator_type())
152 { _M_ht.insert_unique(__f, __l); }
153 hash_set(const value_type* __f, const value_type* __l, size_type __n,
154 const hasher& __hf, const key_equal& __eql,
155 const allocator_type& __a = allocator_type())
156 : _M_ht(__n, __hf, __eql, __a)
157 { _M_ht.insert_unique(__f, __l); }
159 hash_set(const_iterator __f, const_iterator __l)
160 : _M_ht(100, hasher(), key_equal(), allocator_type())
161 { _M_ht.insert_unique(__f, __l); }
162 hash_set(const_iterator __f, const_iterator __l, size_type __n)
163 : _M_ht(__n, hasher(), key_equal(), allocator_type())
164 { _M_ht.insert_unique(__f, __l); }
165 hash_set(const_iterator __f, const_iterator __l, size_type __n,
166 const hasher& __hf)
167 : _M_ht(__n, __hf, key_equal(), allocator_type())
168 { _M_ht.insert_unique(__f, __l); }
169 hash_set(const_iterator __f, const_iterator __l, size_type __n,
170 const hasher& __hf, const key_equal& __eql,
171 const allocator_type& __a = allocator_type())
172 : _M_ht(__n, __hf, __eql, __a)
173 { _M_ht.insert_unique(__f, __l); }
174 #endif
176 public:
177 size_type size() const { return _M_ht.size(); }
178 size_type max_size() const { return _M_ht.max_size(); }
179 bool empty() const { return _M_ht.empty(); }
180 void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }
182 friend bool operator==@KWSYS_NAMESPACE@_CXX_NULL_TEMPLATE_ARGS(const hash_set&,
183 const hash_set&);
185 iterator begin() const { return _M_ht.begin(); }
186 iterator end() const { return _M_ht.end(); }
188 public:
189 @KWSYS_NAMESPACE@_stl::pair<iterator, bool> insert(const value_type& __obj)
191 typedef typename _Ht::iterator _Ht_iterator;
192 @KWSYS_NAMESPACE@_stl::pair<_Ht_iterator, bool> __p = _M_ht.insert_unique(__obj);
193 return @KWSYS_NAMESPACE@_stl::pair<iterator,bool>(__p.first, __p.second);
195 #if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES
196 template <class _InputIterator>
197 void insert(_InputIterator __f, _InputIterator __l)
198 { _M_ht.insert_unique(__f,__l); }
199 #else
200 void insert(const value_type* __f, const value_type* __l) {
201 _M_ht.insert_unique(__f,__l);
203 void insert(const_iterator __f, const_iterator __l)
204 {_M_ht.insert_unique(__f, __l); }
205 #endif
206 @KWSYS_NAMESPACE@_stl::pair<iterator, bool> insert_noresize(const value_type& __obj)
208 typedef typename _Ht::iterator _Ht_iterator;
209 @KWSYS_NAMESPACE@_stl::pair<_Ht_iterator, bool> __p =
210 _M_ht.insert_unique_noresize(__obj);
211 return @KWSYS_NAMESPACE@_stl::pair<iterator, bool>(__p.first, __p.second);
214 iterator find(const key_type& __key) const { return _M_ht.find(__key); }
216 size_type count(const key_type& __key) const { return _M_ht.count(__key); }
218 @KWSYS_NAMESPACE@_stl::pair<iterator, iterator> equal_range(const key_type& __key) const
219 { return _M_ht.equal_range(__key); }
221 size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
222 void erase(iterator __it) { _M_ht.erase(__it); }
223 void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
224 void clear() { _M_ht.clear(); }
226 public:
227 void resize(size_type __hint) { _M_ht.resize(__hint); }
228 size_type bucket_count() const { return _M_ht.bucket_count(); }
229 size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
230 size_type elems_in_bucket(size_type __n) const
231 { return _M_ht.elems_in_bucket(__n); }
234 template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
235 bool
236 operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
237 const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2)
239 return __hs1._M_ht == __hs2._M_ht;
242 template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
243 inline bool
244 operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
245 const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) {
246 return !(__hs1 == __hs2);
249 template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
250 inline void
251 swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
252 hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
254 __hs1.swap(__hs2);
257 template <class _Value,
258 class _HashFcn = hash<_Value>,
259 class _EqualKey = @KWSYS_NAMESPACE@_stl::equal_to<_Value>,
260 class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) >
261 class hash_multiset;
263 template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
264 bool
265 operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
266 const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2);
269 template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
270 class hash_multiset
272 private:
273 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
274 _EqualKey, _Alloc> _Ht;
275 _Ht _M_ht;
277 public:
278 typedef typename _Ht::key_type key_type;
279 typedef typename _Ht::value_type value_type;
280 typedef typename _Ht::hasher hasher;
281 typedef typename _Ht::key_equal key_equal;
283 typedef typename _Ht::size_type size_type;
284 typedef typename _Ht::difference_type difference_type;
285 typedef typename _Ht::const_pointer pointer;
286 typedef typename _Ht::const_pointer const_pointer;
287 typedef typename _Ht::const_reference reference;
288 typedef typename _Ht::const_reference const_reference;
290 typedef typename _Ht::const_iterator iterator;
291 typedef typename _Ht::const_iterator const_iterator;
293 typedef typename _Ht::allocator_type allocator_type;
295 hasher hash_funct() const { return _M_ht.hash_funct(); }
296 key_equal key_eq() const { return _M_ht.key_eq(); }
297 allocator_type get_allocator() const { return _M_ht.get_allocator(); }
299 public:
300 hash_multiset()
301 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
302 explicit hash_multiset(size_type __n)
303 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
304 hash_multiset(size_type __n, const hasher& __hf)
305 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
306 hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
307 const allocator_type& __a = allocator_type())
308 : _M_ht(__n, __hf, __eql, __a) {}
310 #if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES
311 template <class _InputIterator>
312 hash_multiset(_InputIterator __f, _InputIterator __l)
313 : _M_ht(100, hasher(), key_equal(), allocator_type())
314 { _M_ht.insert_equal(__f, __l); }
315 template <class _InputIterator>
316 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
317 : _M_ht(__n, hasher(), key_equal(), allocator_type())
318 { _M_ht.insert_equal(__f, __l); }
319 template <class _InputIterator>
320 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
321 const hasher& __hf)
322 : _M_ht(__n, __hf, key_equal(), allocator_type())
323 { _M_ht.insert_equal(__f, __l); }
324 template <class _InputIterator>
325 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
326 const hasher& __hf, const key_equal& __eql,
327 const allocator_type& __a = allocator_type())
328 : _M_ht(__n, __hf, __eql, __a)
329 { _M_ht.insert_equal(__f, __l); }
330 #else
332 hash_multiset(const value_type* __f, const value_type* __l)
333 : _M_ht(100, hasher(), key_equal(), allocator_type())
334 { _M_ht.insert_equal(__f, __l); }
335 hash_multiset(const value_type* __f, const value_type* __l, size_type __n)
336 : _M_ht(__n, hasher(), key_equal(), allocator_type())
337 { _M_ht.insert_equal(__f, __l); }
338 hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
339 const hasher& __hf)
340 : _M_ht(__n, __hf, key_equal(), allocator_type())
341 { _M_ht.insert_equal(__f, __l); }
342 hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
343 const hasher& __hf, const key_equal& __eql,
344 const allocator_type& __a = allocator_type())
345 : _M_ht(__n, __hf, __eql, __a)
346 { _M_ht.insert_equal(__f, __l); }
348 hash_multiset(const_iterator __f, const_iterator __l)
349 : _M_ht(100, hasher(), key_equal(), allocator_type())
350 { _M_ht.insert_equal(__f, __l); }
351 hash_multiset(const_iterator __f, const_iterator __l, size_type __n)
352 : _M_ht(__n, hasher(), key_equal(), allocator_type())
353 { _M_ht.insert_equal(__f, __l); }
354 hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
355 const hasher& __hf)
356 : _M_ht(__n, __hf, key_equal(), allocator_type())
357 { _M_ht.insert_equal(__f, __l); }
358 hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
359 const hasher& __hf, const key_equal& __eql,
360 const allocator_type& __a = allocator_type())
361 : _M_ht(__n, __hf, __eql, __a)
362 { _M_ht.insert_equal(__f, __l); }
363 #endif
365 public:
366 size_type size() const { return _M_ht.size(); }
367 size_type max_size() const { return _M_ht.max_size(); }
368 bool empty() const { return _M_ht.empty(); }
369 void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }
371 friend bool operator==@KWSYS_NAMESPACE@_CXX_NULL_TEMPLATE_ARGS(const hash_multiset&,
372 const hash_multiset&);
374 iterator begin() const { return _M_ht.begin(); }
375 iterator end() const { return _M_ht.end(); }
377 public:
378 iterator insert(const value_type& __obj)
379 { return _M_ht.insert_equal(__obj); }
380 #if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES
381 template <class _InputIterator>
382 void insert(_InputIterator __f, _InputIterator __l)
383 { _M_ht.insert_equal(__f,__l); }
384 #else
385 void insert(const value_type* __f, const value_type* __l) {
386 _M_ht.insert_equal(__f,__l);
388 void insert(const_iterator __f, const_iterator __l)
389 { _M_ht.insert_equal(__f, __l); }
390 #endif
391 iterator insert_noresize(const value_type& __obj)
392 { return _M_ht.insert_equal_noresize(__obj); }
394 iterator find(const key_type& __key) const { return _M_ht.find(__key); }
396 size_type count(const key_type& __key) const { return _M_ht.count(__key); }
398 @KWSYS_NAMESPACE@_stl::pair<iterator, iterator> equal_range(const key_type& __key) const
399 { return _M_ht.equal_range(__key); }
401 size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
402 void erase(iterator __it) { _M_ht.erase(__it); }
403 void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
404 void clear() { _M_ht.clear(); }
406 public:
407 void resize(size_type __hint) { _M_ht.resize(__hint); }
408 size_type bucket_count() const { return _M_ht.bucket_count(); }
409 size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
410 size_type elems_in_bucket(size_type __n) const
411 { return _M_ht.elems_in_bucket(__n); }
414 template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
415 bool
416 operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
417 const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
419 return __hs1._M_ht == __hs2._M_ht;
422 template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
423 inline bool
424 operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
425 const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
426 return !(__hs1 == __hs2);
429 template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
430 inline void
431 swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
432 hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
433 __hs1.swap(__hs2);
436 } // namespace @KWSYS_NAMESPACE@
438 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
439 # pragma reset woff 1174
440 # pragma reset woff 1375
441 #endif
443 #if defined(_MSC_VER)
444 # pragma warning (pop)
445 #endif
447 #endif