1 /*=========================================================================
3 Program: KWSys - Kitware System Library
4 Module: $RCSfile: hashtable.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 =========================================================================*/
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.
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@_hashtable_hxx
40 #define @KWSYS_NAMESPACE@_hashtable_hxx
42 #include <@KWSYS_NAMESPACE@/Configure.hxx>
44 #include <@KWSYS_NAMESPACE@/cstddef> // size_t
45 #include <@KWSYS_NAMESPACE@/stl/algorithm> // lower_bound
46 #include <@KWSYS_NAMESPACE@/stl/functional> // unary_function
47 #include <@KWSYS_NAMESPACE@/stl/iterator> // iterator_traits
48 #include <@KWSYS_NAMESPACE@/stl/memory> // allocator
49 #include <@KWSYS_NAMESPACE@/stl/utility> // pair
50 #include <@KWSYS_NAMESPACE@/stl/vector> // vector
53 # pragma warning (push)
54 # pragma warning (disable:4284)
55 # pragma warning (disable:4786)
56 # pragma warning (disable:4512) /* no assignment operator for class */
59 #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_TEMPLATE
60 # define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) @KWSYS_NAMESPACE@_stl::allocator< T >
61 #elif @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE
62 # define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) @KWSYS_NAMESPACE@_stl::allocator
64 # define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) @KWSYS_NAMESPACE@_stl::alloc
67 #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_OBJECTS
68 # define @KWSYS_NAMESPACE@_HASH_BUCKETS_INIT(__a) _M_buckets(__a)
69 # define @KWSYS_NAMESPACE@_HASH_BUCKETS_GET_ALLOCATOR(__b) , __b.get_allocator()
71 # define @KWSYS_NAMESPACE@_HASH_BUCKETS_INIT(__a) _M_buckets()
72 # define @KWSYS_NAMESPACE@_HASH_BUCKETS_GET_ALLOCATOR(__b)
75 namespace @KWSYS_NAMESPACE@
78 //----------------------------------------------------------------------------
79 // Define an allocator adaptor for platforms that do not provide an
80 // allocator with the rebind member.
81 #if !@KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND
83 // Utility functions to convert item counts.
84 inline size_t hash_sizeof(void*) { return sizeof(char); }
85 inline size_t hash_sizeof(const void*) { return sizeof(char); }
86 template <class TPtr
> inline size_t hash_sizeof(TPtr p
)
91 template <class POut
, class PIn
, class TSize
>
92 inline TSize
hash_allocator_n(POut out
, PIn in
, TSize n
)
94 return n
*(hash_sizeof(out
)/hash_sizeof(in
) +
95 (hash_sizeof(out
)%hash_sizeof(in
)>0));
98 // Define an allocation method to use the native allocator with
99 // the proper signature. The following signatures of the allocate
100 // method are used on various STL implementations:
101 // pointer allocate(size_type, const void* hint)
102 // pointer allocate(size_type)
103 // static pointer allocate(size_type, const void* hint)
104 // static pointer allocate(size_type)
105 // Where pointer might be a real type or void*.
106 // This set of overloads decodes the signature for a particular STL.
107 // The extra three int/long arguments will favor certain signatures
108 // over others in the case that multiple are present to avoid
110 template <class TAlloc
, class PIn
, class TSize
, class THint
, class POut
>
111 inline void hash_allocate(TAlloc
* a
, PIn (TAlloc::*allocate
)(TSize
, THint
),
112 TSize n_out
, const void* hint
, POut
& out
,
115 TSize n_in
= hash_allocator_n(POut(), PIn(), n_out
);
116 void* vout
= (a
->*allocate
)(n_in
, const_cast<THint
>(hint
));
117 out
= static_cast<POut
>(vout
);
120 template <class TAlloc
, class PIn
, class TSize
, class POut
>
121 inline void hash_allocate(TAlloc
* a
, PIn (TAlloc::*allocate
)(TSize
),
122 TSize n_out
, const void*, POut
& out
,
125 TSize n_in
= hash_allocator_n(POut(), PIn(), n_out
);
126 void* vout
= (a
->*allocate
)(n_in
);
127 out
= static_cast<POut
>(vout
);
130 template <class PIn
, class TSize
, class THint
, class POut
>
131 inline void hash_allocate(void*, PIn (*allocate
)(TSize
, THint
),
132 TSize n_out
, const void* hint
, POut
& out
,
135 TSize n_in
= hash_allocator_n(POut(), PIn(), n_out
);
136 void* vout
= allocate(n_in
, const_cast<THint
>(hint
));
137 out
= static_cast<POut
>(vout
);
140 template <class PIn
, class TSize
, class POut
>
141 inline void hash_allocate(void*, PIn (*allocate
)(TSize
),
142 TSize n_out
, const void*, POut
& out
,
145 TSize n_in
= hash_allocator_n(POut(), PIn(), n_out
);
146 void* vout
= allocate(n_in
);
147 out
= static_cast<POut
>(vout
);
150 // Define a deallocation method to use the native allocator with
151 // the proper signature. The following signatures of the deallocate
152 // method are used on various STL implementations:
153 // void deallocate(pointer, size_type)
154 // void deallocate(pointer)
155 // static void deallocate(pointer, size_type)
156 // static void deallocate(pointer)
157 // Where pointer might be a real type or void*.
158 // This set of overloads decodes the signature for a particular STL.
159 // The extra three int/long arguments will favor certain signatures
160 // over others in the case that multiple are present to avoid
162 template <class TAlloc
, class PIn
, class TSize
, class PInReal
, class POut
>
163 inline void hash_deallocate(TAlloc
* a
, void (TAlloc::*deallocate
)(PIn
, TSize
),
164 PInReal
, POut p
, TSize n_out
, int, int, int)
166 TSize n_in
= hash_allocator_n(POut(), PInReal(), n_out
);
168 (a
->*deallocate
)(static_cast<PIn
>(vout
), n_in
);
171 template <class TAlloc
, class PIn
, class TSize
, class PInReal
, class POut
>
172 inline void hash_deallocate(TAlloc
* a
, void (TAlloc::*deallocate
)(PIn
),
173 PInReal
, POut p
, TSize
, int, int, long)
176 (a
->*deallocate
)(static_cast<PIn
>(vout
));
179 template <class PIn
, class TSize
, class PInReal
, class POut
>
180 inline void hash_deallocate(void*, void (*deallocate
)(PIn
, TSize
),
181 PInReal
, POut p
, TSize n_out
, int, long, long)
183 TSize n_in
= hash_allocator_n(POut(), PInReal(), n_out
);
185 deallocate(static_cast<PIn
>(vout
), n_in
);
188 template <class PIn
, class TSize
, class PInReal
, class POut
>
189 inline void hash_deallocate(void*, void (*deallocate
)(PIn
),
190 PInReal
, POut p
, TSize
, long, long, long)
193 deallocate(static_cast<PIn
>(vout
));
196 // Use the same four overloads as hash_allocate to decode the type
197 // really used for allocation. This is passed as PInReal to the
198 // deallocate functions so that hash_allocator_n has the proper size.
199 template <class TAlloc
, class PIn
, class TSize
, class THint
>
200 inline PIn
hash_allocate_type(PIn (TAlloc::*)(TSize
, THint
),
201 int, int, int) { return 0; }
202 template <class TAlloc
, class PIn
, class TSize
>
203 inline PIn
hash_allocate_type(PIn (TAlloc::*)(TSize
),
204 int, int, long) { return 0; }
205 template <class PIn
, class TSize
, class THint
>
206 inline PIn
hash_allocate_type(PIn (*)(TSize
, THint
),
207 int, long, long) { return 0; }
208 template <class PIn
, class TSize
>
209 inline PIn
hash_allocate_type(PIn (*)(TSize
),
210 long, long, long) { return 0; }
212 // Define the comparison operators in terms of a base type to avoid
213 // needing templated versions.
214 class hash_allocator_base
{};
215 bool operator==(const hash_allocator_base
&,
216 const hash_allocator_base
&) throw() { return true; }
217 bool operator!=(const hash_allocator_base
&,
218 const hash_allocator_base
&) throw() { return false; }
220 // Define the allocator template.
221 template <class T
, class Alloc
>
222 class hash_allocator
: public hash_allocator_base
225 // Store the real allocator privately.
226 typedef Alloc alloc_type
;
230 // Standard allocator interface.
231 typedef size_t size_type
;
232 typedef ptrdiff_t difference_type
;
234 typedef const T
* const_pointer
;
235 typedef T
& reference
;
236 typedef const T
& const_reference
;
237 typedef T value_type
;
239 hash_allocator() throw(): alloc_() {}
240 hash_allocator(const hash_allocator_base
&) throw() : alloc_() {}
241 hash_allocator(const hash_allocator
& a
) throw() : alloc_(a
.alloc_
) {}
242 hash_allocator(const alloc_type
& a
) throw() : alloc_(a
) {}
243 ~hash_allocator() throw() {}
244 # if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES
246 struct rebind
{ typedef hash_allocator
<U
, alloc_type
> other
; };
248 pointer
address(reference x
) const { return &x
; }
249 const_pointer
address(const_reference x
) const { return &x
; }
250 typedef void* void_pointer
;
251 typedef const void* const_void_pointer
;
252 pointer
allocate(size_type n
=1, const_void_pointer hint
= 0)
257 hash_allocate(&alloc_
, &alloc_type::allocate
, n
, hint
, p
, 1, 1, 1);
265 void deallocate(pointer p
, size_type n
=1)
269 hash_deallocate(&alloc_
, &alloc_type::deallocate
,
270 hash_allocate_type(&alloc_type::allocate
, 1, 1, 1),
274 #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
275 size_type
max_size(size_type s
) const throw()
277 return alloc_
.max_size(s
);
280 size_type
max_size() const throw()
282 size_type n
= alloc_
.max_size() / sizeof(value_type
);
286 void construct(pointer p
, const value_type
& val
) { new (p
) value_type(val
); }
287 void destroy(pointer p
) { (void)p
; p
->~value_type(); }
291 template <class _Val
>
292 struct _Hashtable_node
294 _Hashtable_node
* _M_next
;
298 template <class _Val
, class _Key
, class _HashFcn
,
299 class _ExtractKey
, class _EqualKey
,
300 class _Alloc
= @KWSYS_NAMESPACE@
_HASH_DEFAULT_ALLOCATOR(char) >
303 template <class _Val
, class _Key
, class _HashFcn
,
304 class _ExtractKey
, class _EqualKey
, class _Alloc
>
305 struct _Hashtable_iterator
;
307 template <class _Val
, class _Key
, class _HashFcn
,
308 class _ExtractKey
, class _EqualKey
, class _Alloc
>
309 struct _Hashtable_const_iterator
;
311 template <class _Val
, class _Key
, class _HashFcn
,
312 class _ExtractKey
, class _EqualKey
, class _Alloc
>
313 struct _Hashtable_iterator
{
314 typedef hashtable
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,_Alloc
>
316 typedef _Hashtable_iterator
<_Val
, _Key
, _HashFcn
,
317 _ExtractKey
, _EqualKey
, _Alloc
>
319 typedef _Hashtable_const_iterator
<_Val
, _Key
, _HashFcn
,
320 _ExtractKey
, _EqualKey
, _Alloc
>
322 typedef _Hashtable_node
<_Val
> _Node
;
324 typedef @KWSYS_NAMESPACE@
_stl::forward_iterator_tag iterator_category
;
325 typedef _Val value_type
;
326 typedef ptrdiff_t difference_type
;
327 typedef size_t size_type
;
328 typedef _Val
& reference
;
329 typedef _Val
* pointer
;
334 _Hashtable_iterator(_Node
* __n
, _Hashtable
* __tab
)
335 : _M_cur(__n
), _M_ht(__tab
) {}
336 _Hashtable_iterator() {}
337 reference
operator*() const { return _M_cur
->_M_val
; }
338 pointer
operator->() const { return &(operator*()); }
339 iterator
& operator++();
340 iterator
operator++(int);
341 bool operator==(const iterator
& __it
) const
342 { return _M_cur
== __it
._M_cur
; }
343 bool operator!=(const iterator
& __it
) const
344 { return _M_cur
!= __it
._M_cur
; }
348 template <class _Val
, class _Key
, class _HashFcn
,
349 class _ExtractKey
, class _EqualKey
, class _Alloc
>
350 struct _Hashtable_const_iterator
{
351 typedef hashtable
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,_Alloc
>
353 typedef _Hashtable_iterator
<_Val
,_Key
,_HashFcn
,
354 _ExtractKey
,_EqualKey
,_Alloc
>
356 typedef _Hashtable_const_iterator
<_Val
, _Key
, _HashFcn
,
357 _ExtractKey
, _EqualKey
, _Alloc
>
359 typedef _Hashtable_node
<_Val
> _Node
;
361 typedef @KWSYS_NAMESPACE@
_stl::forward_iterator_tag iterator_category
;
362 typedef _Val value_type
;
363 typedef ptrdiff_t difference_type
;
364 typedef size_t size_type
;
365 typedef const _Val
& reference
;
366 typedef const _Val
* pointer
;
369 const _Hashtable
* _M_ht
;
371 _Hashtable_const_iterator(const _Node
* __n
, const _Hashtable
* __tab
)
372 : _M_cur(__n
), _M_ht(__tab
) {}
373 _Hashtable_const_iterator() {}
374 _Hashtable_const_iterator(const iterator
& __it
)
375 : _M_cur(__it
._M_cur
), _M_ht(__it
._M_ht
) {}
376 reference
operator*() const { return _M_cur
->_M_val
; }
377 pointer
operator->() const { return &(operator*()); }
378 const_iterator
& operator++();
379 const_iterator
operator++(int);
380 bool operator==(const const_iterator
& __it
) const
381 { return _M_cur
== __it
._M_cur
; }
382 bool operator!=(const const_iterator
& __it
) const
383 { return _M_cur
!= __it
._M_cur
; }
386 // Note: assumes long is at least 32 bits.
387 enum { _stl_num_primes
= 31 };
389 static const unsigned long _stl_prime_list
[_stl_num_primes
] =
392 53ul, 97ul, 193ul, 389ul, 769ul,
393 1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
394 49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
395 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
396 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
397 1610612741ul, 3221225473ul, 4294967291ul
400 inline size_t _stl_next_prime(size_t __n
)
402 const unsigned long* __first
= _stl_prime_list
;
403 const unsigned long* __last
= _stl_prime_list
+ (int)_stl_num_primes
;
404 const unsigned long* pos
= @KWSYS_NAMESPACE@
_stl::lower_bound(__first
, __last
, __n
);
405 return pos
== __last
? *(__last
- 1) : *pos
;
408 // Forward declaration of operator==.
410 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
413 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
414 bool operator==(const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht1
,
415 const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht2
);
417 // Hashtables handle allocators a bit differently than other containers
418 // do. If we're using standard-conforming allocators, then a hashtable
419 // unconditionally has a member variable to hold its allocator, even if
420 // it so happens that all instances of the allocator type are identical.
421 // This is because, for hashtables, this extra storage is negligible.
422 // Additionally, a base class wouldn't serve any other purposes; it
423 // wouldn't, for example, simplify the exception-handling code.
425 template <class _Val
, class _Key
, class _HashFcn
,
426 class _ExtractKey
, class _EqualKey
, class _Alloc
>
429 typedef _Key key_type
;
430 typedef _Val value_type
;
431 typedef _HashFcn hasher
;
432 typedef _EqualKey key_equal
;
434 typedef size_t size_type
;
435 typedef ptrdiff_t difference_type
;
436 typedef value_type
* pointer
;
437 typedef const value_type
* const_pointer
;
438 typedef value_type
& reference
;
439 typedef const value_type
& const_reference
;
441 hasher
hash_funct() const { return _M_hash
; }
442 key_equal
key_eq() const { return _M_equals
; }
445 typedef _Hashtable_node
<_Val
> _Node
;
447 #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND
449 typedef typename
_Alloc::template rebind
<_Val
>::other allocator_type
;
450 allocator_type
get_allocator() const { return _M_node_allocator
; }
452 typedef typename
_Alloc::template rebind
<_Node
>::other _M_node_allocator_type
;
453 typedef typename
_Alloc::template rebind
<_Node
*>::other _M_node_ptr_allocator_type
;
454 typedef @KWSYS_NAMESPACE@
_stl::vector
<_Node
*,_M_node_ptr_allocator_type
> _M_buckets_type
;
457 typedef hash_allocator
<_Val
, _Alloc
> allocator_type
;
458 allocator_type
get_allocator() const { return allocator_type(); }
460 typedef hash_allocator
<_Node
, _Alloc
> _M_node_allocator_type
;
461 # if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_OBJECTS
462 typedef hash_allocator
<_Node
*, _Alloc
> _M_node_ptr_allocator_type
;
464 typedef _Alloc _M_node_ptr_allocator_type
;
466 typedef @KWSYS_NAMESPACE@
_stl::vector
<_Node
*,_M_node_ptr_allocator_type
> _M_buckets_type
;
470 _M_node_allocator_type _M_node_allocator
;
473 _ExtractKey _M_get_key
;
474 _M_buckets_type _M_buckets
;
475 size_type _M_num_elements
;
477 _Node
* _M_get_node() { return _M_node_allocator
.allocate(1); }
478 void _M_put_node(_Node
* __p
) { _M_node_allocator
.deallocate(__p
, 1); }
481 typedef _Hashtable_iterator
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,_Alloc
>
483 typedef _Hashtable_const_iterator
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,
488 _Hashtable_iterator
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,_Alloc
>;
490 _Hashtable_const_iterator
<_Val
,_Key
,_HashFcn
,_ExtractKey
,_EqualKey
,_Alloc
>;
493 hashtable(size_type __n
,
494 const _HashFcn
& __hf
,
495 const _EqualKey
& __eql
,
496 const _ExtractKey
& __ext
,
497 const allocator_type
& __a
= allocator_type())
498 : _M_node_allocator(__a
),
502 @KWSYS_NAMESPACE@
_HASH_BUCKETS_INIT(__a
),
505 _M_initialize_buckets(__n
);
508 hashtable(size_type __n
,
509 const _HashFcn
& __hf
,
510 const _EqualKey
& __eql
,
511 const allocator_type
& __a
= allocator_type())
512 : _M_node_allocator(__a
),
515 _M_get_key(_ExtractKey()),
516 @KWSYS_NAMESPACE@
_HASH_BUCKETS_INIT(__a
),
519 _M_initialize_buckets(__n
);
522 hashtable(const hashtable
& __ht
)
523 : _M_node_allocator(__ht
.get_allocator()),
524 _M_hash(__ht
._M_hash
),
525 _M_equals(__ht
._M_equals
),
526 _M_get_key(__ht
._M_get_key
),
527 @KWSYS_NAMESPACE@
_HASH_BUCKETS_INIT(__ht
.get_allocator()),
533 hashtable
& operator= (const hashtable
& __ht
)
537 _M_hash
= __ht
._M_hash
;
538 _M_equals
= __ht
._M_equals
;
539 _M_get_key
= __ht
._M_get_key
;
545 ~hashtable() { clear(); }
547 size_type
size() const { return _M_num_elements
; }
548 size_type
max_size() const { return size_type(-1); }
549 bool empty() const { return size() == 0; }
551 void swap(hashtable
& __ht
)
553 @KWSYS_NAMESPACE@
_stl::swap(_M_hash
, __ht
._M_hash
);
554 @KWSYS_NAMESPACE@
_stl::swap(_M_equals
, __ht
._M_equals
);
555 @KWSYS_NAMESPACE@
_stl::swap(_M_get_key
, __ht
._M_get_key
);
556 _M_buckets
.swap(__ht
._M_buckets
);
557 @KWSYS_NAMESPACE@
_stl::swap(_M_num_elements
, __ht
._M_num_elements
);
562 for (size_type __n
= 0; __n
< _M_buckets
.size(); ++__n
)
564 return iterator(_M_buckets
[__n
], this);
568 iterator
end() { return iterator(0, this); }
570 const_iterator
begin() const
572 for (size_type __n
= 0; __n
< _M_buckets
.size(); ++__n
)
574 return const_iterator(_M_buckets
[__n
], this);
578 const_iterator
end() const { return const_iterator(0, this); }
580 friend bool operator==@KWSYS_NAMESPACE@
_CXX_NULL_TEMPLATE_ARGS(const hashtable
&,
585 size_type
bucket_count() const { return _M_buckets
.size(); }
587 size_type
max_bucket_count() const
588 { return _stl_prime_list
[(int)_stl_num_primes
- 1]; }
590 size_type
elems_in_bucket(size_type __bucket
) const
592 size_type __result
= 0;
593 for (_Node
* __cur
= _M_buckets
[__bucket
]; __cur
; __cur
= __cur
->_M_next
)
598 @KWSYS_NAMESPACE@
_stl::pair
<iterator
, bool> insert_unique(const value_type
& __obj
)
600 resize(_M_num_elements
+ 1);
601 return insert_unique_noresize(__obj
);
604 iterator
insert_equal(const value_type
& __obj
)
606 resize(_M_num_elements
+ 1);
607 return insert_equal_noresize(__obj
);
610 @KWSYS_NAMESPACE@
_stl::pair
<iterator
, bool> insert_unique_noresize(const value_type
& __obj
);
611 iterator
insert_equal_noresize(const value_type
& __obj
);
613 #if @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS
614 # define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \
615 typename @KWSYS_NAMESPACE@_stl::iterator_traits< T >::iterator_category()
616 #elif @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY
617 # define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \
618 @KWSYS_NAMESPACE@_stl::iterator_category( I )
619 #elif @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY
620 # define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \
621 @KWSYS_NAMESPACE@_stl::__iterator_category( I )
624 #if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES && defined(@KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY)
625 template <class _InputIterator
>
626 void insert_unique(_InputIterator __f
, _InputIterator __l
)
628 insert_unique(__f
, __l
,
629 @KWSYS_NAMESPACE@
_HASH_ITERATOR_CATEGORY(_InputIterator
, __f
));
632 template <class _InputIterator
>
633 void insert_equal(_InputIterator __f
, _InputIterator __l
)
635 insert_equal(__f
, __l
,
636 @KWSYS_NAMESPACE@
_HASH_ITERATOR_CATEGORY(_InputIterator
, __f
));
639 template <class _InputIterator
>
640 void insert_unique(_InputIterator __f
, _InputIterator __l
,
641 @KWSYS_NAMESPACE@
_stl::input_iterator_tag
)
643 for ( ; __f
!= __l
; ++__f
)
647 template <class _InputIterator
>
648 void insert_equal(_InputIterator __f
, _InputIterator __l
,
649 @KWSYS_NAMESPACE@
_stl::input_iterator_tag
)
651 for ( ; __f
!= __l
; ++__f
)
655 template <class _ForwardIterator
>
656 void insert_unique(_ForwardIterator __f
, _ForwardIterator __l
,
657 @KWSYS_NAMESPACE@
_stl::forward_iterator_tag
)
660 @KWSYS_NAMESPACE@
_stl::distance(__f
, __l
, __n
);
661 resize(_M_num_elements
+ __n
);
662 for ( ; __n
> 0; --__n
, ++__f
)
663 insert_unique_noresize(*__f
);
666 template <class _ForwardIterator
>
667 void insert_equal(_ForwardIterator __f
, _ForwardIterator __l
,
668 @KWSYS_NAMESPACE@
_stl::forward_iterator_tag
)
671 @KWSYS_NAMESPACE@
_stl::distance(__f
, __l
, __n
);
672 resize(_M_num_elements
+ __n
);
673 for ( ; __n
> 0; --__n
, ++__f
)
674 insert_equal_noresize(*__f
);
678 void insert_unique(const value_type
* __f
, const value_type
* __l
)
680 size_type __n
= __l
- __f
;
681 resize(_M_num_elements
+ __n
);
682 for ( ; __n
> 0; --__n
, ++__f
)
683 insert_unique_noresize(*__f
);
686 void insert_equal(const value_type
* __f
, const value_type
* __l
)
688 size_type __n
= __l
- __f
;
689 resize(_M_num_elements
+ __n
);
690 for ( ; __n
> 0; --__n
, ++__f
)
691 insert_equal_noresize(*__f
);
694 void insert_unique(const_iterator __f
, const_iterator __l
)
697 @KWSYS_NAMESPACE@
_stl::distance(__f
, __l
, __n
);
698 resize(_M_num_elements
+ __n
);
699 for ( ; __n
> 0; --__n
, ++__f
)
700 insert_unique_noresize(*__f
);
703 void insert_equal(const_iterator __f
, const_iterator __l
)
706 @KWSYS_NAMESPACE@
_stl::distance(__f
, __l
, __n
);
707 resize(_M_num_elements
+ __n
);
708 for ( ; __n
> 0; --__n
, ++__f
)
709 insert_equal_noresize(*__f
);
713 reference
find_or_insert(const value_type
& __obj
);
715 iterator
find(const key_type
& __key
)
717 size_type __n
= _M_bkt_num_key(__key
);
719 for ( __first
= _M_buckets
[__n
];
720 __first
&& !_M_equals(_M_get_key(__first
->_M_val
), __key
);
721 __first
= __first
->_M_next
)
723 return iterator(__first
, this);
726 const_iterator
find(const key_type
& __key
) const
728 size_type __n
= _M_bkt_num_key(__key
);
729 const _Node
* __first
;
730 for ( __first
= _M_buckets
[__n
];
731 __first
&& !_M_equals(_M_get_key(__first
->_M_val
), __key
);
732 __first
= __first
->_M_next
)
734 return const_iterator(__first
, this);
737 size_type
count(const key_type
& __key
) const
739 const size_type __n
= _M_bkt_num_key(__key
);
740 size_type __result
= 0;
742 for (const _Node
* __cur
= _M_buckets
[__n
]; __cur
; __cur
= __cur
->_M_next
)
743 if (_M_equals(_M_get_key(__cur
->_M_val
), __key
))
748 @KWSYS_NAMESPACE@
_stl::pair
<iterator
, iterator
>
749 equal_range(const key_type
& __key
);
751 @KWSYS_NAMESPACE@
_stl::pair
<const_iterator
, const_iterator
>
752 equal_range(const key_type
& __key
) const;
754 size_type
erase(const key_type
& __key
);
755 void erase(const iterator
& __it
);
756 void erase(iterator __first
, iterator __last
);
758 void erase(const const_iterator
& __it
);
759 void erase(const_iterator __first
, const_iterator __last
);
761 void resize(size_type __num_elements_hint
);
765 size_type
_M_next_size(size_type __n
) const
766 { return _stl_next_prime(__n
); }
768 void _M_initialize_buckets(size_type __n
)
770 const size_type __n_buckets
= _M_next_size(__n
);
771 _M_buckets
.reserve(__n_buckets
);
772 _M_buckets
.insert(_M_buckets
.end(), __n_buckets
, (_Node
*) 0);
776 size_type
_M_bkt_num_key(const key_type
& __key
) const
778 return _M_bkt_num_key(__key
, _M_buckets
.size());
781 size_type
_M_bkt_num(const value_type
& __obj
) const
783 return _M_bkt_num_key(_M_get_key(__obj
));
786 size_type
_M_bkt_num_key(const key_type
& __key
, size_t __n
) const
788 return _M_hash(__key
) % __n
;
791 size_type
_M_bkt_num(const value_type
& __obj
, size_t __n
) const
793 return _M_bkt_num_key(_M_get_key(__obj
), __n
);
796 void construct(_Val
* p
, const _Val
& v
)
800 void destroy(_Val
* p
)
806 _Node
* _M_new_node(const value_type
& __obj
)
808 _Node
* __n
= _M_get_node();
811 construct(&__n
->_M_val
, __obj
);
814 catch(...) {_M_put_node(__n
); throw;}
817 void _M_delete_node(_Node
* __n
)
819 destroy(&__n
->_M_val
);
823 void _M_erase_bucket(const size_type __n
, _Node
* __first
, _Node
* __last
);
824 void _M_erase_bucket(const size_type __n
, _Node
* __last
);
826 void _M_copy_from(const hashtable
& __ht
);
830 template <class _Val
, class _Key
, class _HF
, class _ExK
, class _EqK
,
832 _Hashtable_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>&
833 _Hashtable_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>::operator++()
835 const _Node
* __old
= _M_cur
;
836 _M_cur
= _M_cur
->_M_next
;
838 size_type __bucket
= _M_ht
->_M_bkt_num(__old
->_M_val
);
839 while (!_M_cur
&& ++__bucket
< _M_ht
->_M_buckets
.size())
840 _M_cur
= _M_ht
->_M_buckets
[__bucket
];
845 template <class _Val
, class _Key
, class _HF
, class _ExK
, class _EqK
,
847 inline _Hashtable_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>
848 _Hashtable_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>::operator++(int)
850 iterator __tmp
= *this;
855 template <class _Val
, class _Key
, class _HF
, class _ExK
, class _EqK
,
857 _Hashtable_const_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>&
858 _Hashtable_const_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>::operator++()
860 const _Node
* __old
= _M_cur
;
861 _M_cur
= _M_cur
->_M_next
;
863 size_type __bucket
= _M_ht
->_M_bkt_num(__old
->_M_val
);
864 while (!_M_cur
&& ++__bucket
< _M_ht
->_M_buckets
.size())
865 _M_cur
= _M_ht
->_M_buckets
[__bucket
];
870 template <class _Val
, class _Key
, class _HF
, class _ExK
, class _EqK
,
872 inline _Hashtable_const_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>
873 _Hashtable_const_iterator
<_Val
,_Key
,_HF
,_ExK
,_EqK
,_All
>::operator++(int)
875 const_iterator __tmp
= *this;
880 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
881 bool operator==(const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht1
,
882 const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht2
)
884 typedef typename hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::_Node _Node
;
885 if (__ht1
._M_buckets
.size() != __ht2
._M_buckets
.size())
887 for (int __n
= 0; __n
< __ht1
._M_buckets
.size(); ++__n
) {
888 _Node
* __cur1
= __ht1
._M_buckets
[__n
];
889 _Node
* __cur2
= __ht2
._M_buckets
[__n
];
890 for ( ; __cur1
&& __cur2
&& __cur1
->_M_val
== __cur2
->_M_val
;
891 __cur1
= __cur1
->_M_next
, __cur2
= __cur2
->_M_next
)
893 if (__cur1
|| __cur2
)
899 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
900 inline bool operator!=(const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht1
,
901 const hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>& __ht2
) {
902 return !(__ht1
== __ht2
);
905 template <class _Val
, class _Key
, class _HF
, class _Extract
, class _EqKey
,
907 inline void swap(hashtable
<_Val
, _Key
, _HF
, _Extract
, _EqKey
, _All
>& __ht1
,
908 hashtable
<_Val
, _Key
, _HF
, _Extract
, _EqKey
, _All
>& __ht2
) {
912 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
913 @KWSYS_NAMESPACE@
_stl::pair
<@KWSYS_NAMESPACE@_CXX_DECL_TYPENAME hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::iterator
, bool>
914 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
915 ::insert_unique_noresize(const value_type
& __obj
)
917 const size_type __n
= _M_bkt_num(__obj
);
918 _Node
* __first
= _M_buckets
[__n
];
920 for (_Node
* __cur
= __first
; __cur
; __cur
= __cur
->_M_next
)
921 if (_M_equals(_M_get_key(__cur
->_M_val
), _M_get_key(__obj
)))
922 return @KWSYS_NAMESPACE@
_stl::pair
<iterator
, bool>(iterator(__cur
, this), false);
924 _Node
* __tmp
= _M_new_node(__obj
);
925 __tmp
->_M_next
= __first
;
926 _M_buckets
[__n
] = __tmp
;
928 return @KWSYS_NAMESPACE@
_stl::pair
<iterator
, bool>(iterator(__tmp
, this), true);
931 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
932 typename hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::iterator
933 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
934 ::insert_equal_noresize(const value_type
& __obj
)
936 const size_type __n
= _M_bkt_num(__obj
);
937 _Node
* __first
= _M_buckets
[__n
];
939 for (_Node
* __cur
= __first
; __cur
; __cur
= __cur
->_M_next
)
940 if (_M_equals(_M_get_key(__cur
->_M_val
), _M_get_key(__obj
))) {
941 _Node
* __tmp
= _M_new_node(__obj
);
942 __tmp
->_M_next
= __cur
->_M_next
;
943 __cur
->_M_next
= __tmp
;
945 return iterator(__tmp
, this);
948 _Node
* __tmp
= _M_new_node(__obj
);
949 __tmp
->_M_next
= __first
;
950 _M_buckets
[__n
] = __tmp
;
952 return iterator(__tmp
, this);
955 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
956 typename hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::reference
957 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::find_or_insert(const value_type
& __obj
)
959 resize(_M_num_elements
+ 1);
961 size_type __n
= _M_bkt_num(__obj
);
962 _Node
* __first
= _M_buckets
[__n
];
964 for (_Node
* __cur
= __first
; __cur
; __cur
= __cur
->_M_next
)
965 if (_M_equals(_M_get_key(__cur
->_M_val
), _M_get_key(__obj
)))
966 return __cur
->_M_val
;
968 _Node
* __tmp
= _M_new_node(__obj
);
969 __tmp
->_M_next
= __first
;
970 _M_buckets
[__n
] = __tmp
;
972 return __tmp
->_M_val
;
975 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
976 @KWSYS_NAMESPACE@
_stl::pair
<@KWSYS_NAMESPACE@_CXX_DECL_TYPENAME hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::iterator
,
977 @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::iterator
>
978 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::equal_range(const key_type
& __key
)
980 typedef @KWSYS_NAMESPACE@
_stl::pair
<iterator
, iterator
> _Pii
;
981 const size_type __n
= _M_bkt_num_key(__key
);
983 for (_Node
* __first
= _M_buckets
[__n
]; __first
; __first
= __first
->_M_next
)
984 if (_M_equals(_M_get_key(__first
->_M_val
), __key
)) {
985 for (_Node
* __cur
= __first
->_M_next
; __cur
; __cur
= __cur
->_M_next
)
986 if (!_M_equals(_M_get_key(__cur
->_M_val
), __key
))
987 return _Pii(iterator(__first
, this), iterator(__cur
, this));
988 for (size_type __m
= __n
+ 1; __m
< _M_buckets
.size(); ++__m
)
990 return _Pii(iterator(__first
, this),
991 iterator(_M_buckets
[__m
], this));
992 return _Pii(iterator(__first
, this), end());
994 return _Pii(end(), end());
997 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
998 @KWSYS_NAMESPACE@
_stl::pair
<@KWSYS_NAMESPACE@_CXX_DECL_TYPENAME hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::const_iterator
,
999 @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::const_iterator
>
1000 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1001 ::equal_range(const key_type
& __key
) const
1003 typedef @KWSYS_NAMESPACE@
_stl::pair
<const_iterator
, const_iterator
> _Pii
;
1004 const size_type __n
= _M_bkt_num_key(__key
);
1006 for (const _Node
* __first
= _M_buckets
[__n
] ;
1008 __first
= __first
->_M_next
) {
1009 if (_M_equals(_M_get_key(__first
->_M_val
), __key
)) {
1010 for (const _Node
* __cur
= __first
->_M_next
;
1012 __cur
= __cur
->_M_next
)
1013 if (!_M_equals(_M_get_key(__cur
->_M_val
), __key
))
1014 return _Pii(const_iterator(__first
, this),
1015 const_iterator(__cur
, this));
1016 for (size_type __m
= __n
+ 1; __m
< _M_buckets
.size(); ++__m
)
1017 if (_M_buckets
[__m
])
1018 return _Pii(const_iterator(__first
, this),
1019 const_iterator(_M_buckets
[__m
], this));
1020 return _Pii(const_iterator(__first
, this), end());
1023 return _Pii(end(), end());
1026 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1027 typename hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::size_type
1028 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::erase(const key_type
& __key
)
1030 const size_type __n
= _M_bkt_num_key(__key
);
1031 _Node
* __first
= _M_buckets
[__n
];
1032 size_type __erased
= 0;
1035 _Node
* __cur
= __first
;
1036 _Node
* __next
= __cur
->_M_next
;
1038 if (_M_equals(_M_get_key(__next
->_M_val
), __key
)) {
1039 __cur
->_M_next
= __next
->_M_next
;
1040 _M_delete_node(__next
);
1041 __next
= __cur
->_M_next
;
1047 __next
= __cur
->_M_next
;
1050 if (_M_equals(_M_get_key(__first
->_M_val
), __key
)) {
1051 _M_buckets
[__n
] = __first
->_M_next
;
1052 _M_delete_node(__first
);
1060 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1061 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::erase(const iterator
& __it
)
1063 _Node
* __p
= __it
._M_cur
;
1065 const size_type __n
= _M_bkt_num(__p
->_M_val
);
1066 _Node
* __cur
= _M_buckets
[__n
];
1069 _M_buckets
[__n
] = __cur
->_M_next
;
1070 _M_delete_node(__cur
);
1074 _Node
* __next
= __cur
->_M_next
;
1076 if (__next
== __p
) {
1077 __cur
->_M_next
= __next
->_M_next
;
1078 _M_delete_node(__next
);
1084 __next
= __cur
->_M_next
;
1091 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1092 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1093 ::erase(iterator __first
, iterator __last
)
1095 size_type __f_bucket
= __first
._M_cur
?
1096 _M_bkt_num(__first
._M_cur
->_M_val
) : _M_buckets
.size();
1097 size_type __l_bucket
= __last
._M_cur
?
1098 _M_bkt_num(__last
._M_cur
->_M_val
) : _M_buckets
.size();
1100 if (__first
._M_cur
== __last
._M_cur
)
1102 else if (__f_bucket
== __l_bucket
)
1103 _M_erase_bucket(__f_bucket
, __first
._M_cur
, __last
._M_cur
);
1105 _M_erase_bucket(__f_bucket
, __first
._M_cur
, 0);
1106 for (size_type __n
= __f_bucket
+ 1; __n
< __l_bucket
; ++__n
)
1107 _M_erase_bucket(__n
, 0);
1108 if (__l_bucket
!= _M_buckets
.size())
1109 _M_erase_bucket(__l_bucket
, __last
._M_cur
);
1113 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1115 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::erase(const_iterator __first
,
1116 const_iterator __last
)
1118 erase(iterator(const_cast<_Node
*>(__first
._M_cur
),
1119 const_cast<hashtable
*>(__first
._M_ht
)),
1120 iterator(const_cast<_Node
*>(__last
._M_cur
),
1121 const_cast<hashtable
*>(__last
._M_ht
)));
1124 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1126 hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::erase(const const_iterator
& __it
)
1128 erase(iterator(const_cast<_Node
*>(__it
._M_cur
),
1129 const_cast<hashtable
*>(__it
._M_ht
)));
1132 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1133 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1134 ::resize(size_type __num_elements_hint
)
1136 const size_type __old_n
= _M_buckets
.size();
1137 if (__num_elements_hint
> __old_n
) {
1138 const size_type __n
= _M_next_size(__num_elements_hint
);
1139 if (__n
> __old_n
) {
1140 _M_buckets_type
__tmp(
1142 @KWSYS_NAMESPACE@
_HASH_BUCKETS_GET_ALLOCATOR(_M_buckets
));
1144 for (size_type __bucket
= 0; __bucket
< __old_n
; ++__bucket
) {
1145 _Node
* __first
= _M_buckets
[__bucket
];
1147 size_type __new_bucket
= _M_bkt_num(__first
->_M_val
, __n
);
1148 _M_buckets
[__bucket
] = __first
->_M_next
;
1149 __first
->_M_next
= __tmp
[__new_bucket
];
1150 __tmp
[__new_bucket
] = __first
;
1151 __first
= _M_buckets
[__bucket
];
1154 _M_buckets
.swap(__tmp
);
1157 for (size_type __bucket
= 0; __bucket
< __tmp
.size(); ++__bucket
) {
1158 while (__tmp
[__bucket
]) {
1159 _Node
* __next
= __tmp
[__bucket
]->_M_next
;
1160 _M_delete_node(__tmp
[__bucket
]);
1161 __tmp
[__bucket
] = __next
;
1170 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1171 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1172 ::_M_erase_bucket(const size_type __n
, _Node
* __first
, _Node
* __last
)
1174 _Node
* __cur
= _M_buckets
[__n
];
1175 if (__cur
== __first
)
1176 _M_erase_bucket(__n
, __last
);
1179 for (__next
= __cur
->_M_next
;
1181 __cur
= __next
, __next
= __cur
->_M_next
)
1183 while (__next
!= __last
) {
1184 __cur
->_M_next
= __next
->_M_next
;
1185 _M_delete_node(__next
);
1186 __next
= __cur
->_M_next
;
1192 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1193 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1194 ::_M_erase_bucket(const size_type __n
, _Node
* __last
)
1196 _Node
* __cur
= _M_buckets
[__n
];
1197 while (__cur
!= __last
) {
1198 _Node
* __next
= __cur
->_M_next
;
1199 _M_delete_node(__cur
);
1201 _M_buckets
[__n
] = __cur
;
1206 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1207 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>::clear()
1209 for (size_type __i
= 0; __i
< _M_buckets
.size(); ++__i
) {
1210 _Node
* __cur
= _M_buckets
[__i
];
1211 while (__cur
!= 0) {
1212 _Node
* __next
= __cur
->_M_next
;
1213 _M_delete_node(__cur
);
1216 _M_buckets
[__i
] = 0;
1218 _M_num_elements
= 0;
1222 template <class _Val
, class _Key
, class _HF
, class _Ex
, class _Eq
, class _All
>
1223 void hashtable
<_Val
,_Key
,_HF
,_Ex
,_Eq
,_All
>
1224 ::_M_copy_from(const hashtable
& __ht
)
1227 _M_buckets
.reserve(__ht
._M_buckets
.size());
1228 _M_buckets
.insert(_M_buckets
.end(), __ht
._M_buckets
.size(), (_Node
*) 0);
1230 for (size_type __i
= 0; __i
< __ht
._M_buckets
.size(); ++__i
) {
1231 const _Node
* __cur
= __ht
._M_buckets
[__i
];
1233 _Node
* __copy
= _M_new_node(__cur
->_M_val
);
1234 _M_buckets
[__i
] = __copy
;
1236 for (_Node
* __next
= __cur
->_M_next
;
1238 __cur
= __next
, __next
= __cur
->_M_next
) {
1239 __copy
->_M_next
= _M_new_node(__next
->_M_val
);
1240 __copy
= __copy
->_M_next
;
1244 _M_num_elements
= __ht
._M_num_elements
;
1246 catch(...) {clear(); throw;}
1249 } // namespace @KWSYS_NAMESPACE@
1251 // Normally the comparison operators should be found in the @KWSYS_NAMESPACE@
1252 // namespace by argument dependent lookup. For compilers that do not
1253 // support it we must bring them into the global namespace now.
1254 #if !@KWSYS_NAMESPACE@_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
1255 using @KWSYS_NAMESPACE@
::operator==;
1256 using @KWSYS_NAMESPACE@
::operator!=;
1259 #if defined(_MSC_VER)
1260 # pragma warning (pop)