56#ifndef _BACKWARD_HASHTABLE_H
57#define _BACKWARD_HASHTABLE_H 1
80 template<
class _Val,
class _Key,
class _HashFcn,
class _ExtractKey,
84 template<
class _Val,
class _Key,
class _HashFcn,
85 class _ExtractKey,
class _EqualKey,
class _Alloc>
88 template<
class _Val,
class _Key,
class _HashFcn,
89 class _ExtractKey,
class _EqualKey,
class _Alloc>
92 template<
class _Val,
class _Key,
class _HashFcn,
93 class _ExtractKey,
class _EqualKey,
class _Alloc>
99 _ExtractKey, _EqualKey, _Alloc>
102 _ExtractKey, _EqualKey, _Alloc>
122 {
return _M_cur->_M_val; }
143 template<
class _Val,
class _Key,
class _HashFcn,
144 class _ExtractKey,
class _EqualKey,
class _Alloc>
150 _ExtractKey,_EqualKey,_Alloc>
153 _ExtractKey, _EqualKey, _Alloc>
177 {
return _M_cur->_M_val; }
201 template<
typename _PrimeType>
206 static const _PrimeType*
210 template<
typename _PrimeType>
const _PrimeType
213 5ul, 53ul, 97ul, 193ul, 389ul,
214 769ul, 1543ul, 3079ul, 6151ul, 12289ul,
215 24593ul, 49157ul, 98317ul, 196613ul, 393241ul,
216 786433ul, 1572869ul, 3145739ul, 6291469ul, 12582917ul,
217 25165843ul, 50331653ul, 100663319ul, 201326611ul, 402653189ul,
218 805306457ul, 1610612741ul, 3221225473ul, 4294967291ul
221 template<
class _PrimeType>
inline const _PrimeType*
233 return pos == __last ? *(__last - 1) : *pos;
237 template<
class _Val,
class _Key,
class _HF,
class _Ex,
238 class _Eq,
class _All>
241 template<
class _Val,
class _Key,
class _HF,
class _Ex,
242 class _Eq,
class _All>
244 operator==(
const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1,
245 const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2);
255 template<
class _Val,
class _Key,
class _HashFcn,
256 class _ExtractKey,
class _EqualKey,
class _Alloc>
293 typedef typename _Alloc_traits::template rebind<_Node>::other
295 typedef typename _Alloc_traits::template rebind<_Node*>::other
333 const _EqualKey& __eql,
const _ExtractKey& __ext,
340 const _EqualKey& __eql,
379 {
return size() == 0; }
417 template<
class _Vl,
class _Ky,
class _HF,
class _Ex,
class _Eq,
463 template<
class _InputIterator>
468 template<
class _InputIterator>
473 template<
class _InputIterator>
478 for ( ; __f != __l; ++__f)
482 template<
class _InputIterator>
487 for ( ; __f != __l; ++__f)
491 template<
class _ForwardIterator>
498 for ( ; __n > 0; --__n, ++__f)
502 template<
class _ForwardIterator>
509 for ( ; __n > 0; --__n, ++__f)
532 const _Node* __first;
547 __cur = __cur->_M_next)
604 {
return _M_hash(__key) % __n; }
646 template<
class _Val,
class _Key,
class _HF,
class _ExK,
class _EqK,
657 while (!
_M_cur && ++__bucket < _M_ht->_M_buckets.
size())
663 template<
class _Val,
class _Key,
class _HF,
class _ExK,
class _EqK,
674 template<
class _Val,
class _Key,
class _HF,
class _ExK,
class _EqK,
685 while (!
_M_cur && ++__bucket < _M_ht->_M_buckets.
size())
691 template<
class _Val,
class _Key,
class _HF,
class _ExK,
class _EqK,
702 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
717 for (; __cur1 && __cur2;
718 __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next)
720 if (__cur1 || __cur2)
724 __cur1 = __cur1->_M_next)
726 bool _found__cur1 =
false;
728 __cur2; __cur2 = __cur2->_M_next)
730 if (__cur1->_M_val == __cur2->_M_val)
743 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
747 {
return !(__ht1 == __ht2); }
749 template<
class _Val,
class _Key,
class _HF,
class _Extract,
class _EqKey,
754 { __ht1.
swap(__ht2); }
756 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
765 for (
_Node* __cur = __first; __cur; __cur = __cur->
_M_next)
776 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
784 for (
_Node* __cur = __first; __cur; __cur = __cur->
_M_next)
801 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
811 for (
_Node* __cur = __first; __cur; __cur = __cur->
_M_next)
813 return __cur->_M_val;
822 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
832 __first = __first->_M_next)
835 for (
_Node* __cur = __first->_M_next; __cur;
836 __cur = __cur->_M_next)
841 return _Pii(
iterator(__first,
this),
845 return _Pii(
end(),
end());
848 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
859 __first = __first->_M_next)
863 for (
const _Node* __cur = __first->_M_next; __cur;
864 __cur = __cur->_M_next)
875 return _Pii(
end(),
end());
878 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
885 _Node* __saved_slot = 0;
890 _Node* __cur = __first;
906 __saved_slot = __cur;
920 __next = __saved_slot->
_M_next;
937 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
975 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
988 else if (__f_bucket == __l_bucket)
993 for (
size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
1000 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1011 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1018 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1024 if (__num_elements_hint > __old_n)
1032 for (
size_type __bucket = 0; __bucket < __old_n; ++__bucket)
1040 __first->
_M_next = __tmp[__new_bucket];
1041 __tmp[__new_bucket] = __first;
1052 while (__tmp[__bucket])
1054 _Node* __next = __tmp[__bucket]->_M_next;
1056 __tmp[__bucket] = __next;
1065 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1071 if (__cur == __first)
1078 __cur = __next, __next = __cur->
_M_next)
1080 while (__next != __last)
1090 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1096 while (__cur != __last)
1106 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1128 template<
class _Val,
class _Key,
class _HF,
class _Ex,
class _Eq,
class _All>
1147 __cur = __next, __next = __cur->
_M_next)
1150 __local_copy = __local_copy->
_M_next;
#define __throw_exception_again
#define _GLIBCXX_VISIBILITY(V)
#define _GLIBCXX_NODISCARD
#define _GLIBCXX_END_NAMESPACE_VERSION
#define _GLIBCXX_BEGIN_NAMESPACE_VERSION
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
__PTRDIFF_TYPE__ ptrdiff_t
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr _FIter lower_bound(_FIter, _FIter, const _Tp &)
constexpr __enable_if_t< __array_traits< _Tp, _Nm >::_Is_swappable::value > swap(array< _Tp, _Nm > &__one, array< _Tp, _Nm > &__two) noexcept(noexcept(__one.swap(__two)))
void swap(hashtable< _Val, _Key, _HF, _Extract, _EqKey, _All > &__ht1, hashtable< _Val, _Key, _HF, _Extract, _EqKey, _All > &__ht2)
unsigned long __stl_next_prime(unsigned long __n)
bool operator==(const hashtable< _Val, _Key, _HF, _Ex, _Eq, _All > &__ht1, const hashtable< _Val, _Key, _HF, _Ex, _Eq, _All > &__ht2)
bool operator!=(const hashtable< _Val, _Key, _HF, _Ex, _Eq, _All > &__ht1, const hashtable< _Val, _Key, _HF, _Ex, _Eq, _All > &__ht2)
GNU extensions for public use.
_Hashtable_node * _M_next
const_iterator end() const
iterator insert_equal_noresize(const value_type &__obj)
void insert_unique(_InputIterator __f, _InputIterator __l, std::input_iterator_tag)
void _M_erase_bucket(const size_type __n, _Node *__last)
const value_type * const_pointer
std::pair< iterator, bool > insert_unique_noresize(const value_type &__obj)
size_type _M_num_elements
hashtable & operator=(const hashtable &__ht)
void insert_equal(_InputIterator __f, _InputIterator __l, std::input_iterator_tag)
void _M_put_node(_Node *__p)
reference find_or_insert(const value_type &__obj)
size_type _M_next_size(size_type __n) const
_Select1st< pair< const _Key, _Tp > > _M_get_key
void _M_initialize_buckets(size_type __n)
size_type max_bucket_count() const
std::pair< const_iterator, const_iterator > equal_range(const key_type &__key) const
hashtable(size_type __n, const _HashFcn &__hf, const _EqualKey &__eql, const allocator_type &__a=allocator_type())
std::pair< iterator, bool > insert_unique(const value_type &__obj)
void erase(const iterator &__it)
hashtable(size_type __n, const _HashFcn &__hf, const _EqualKey &__eql, const _ExtractKey &__ext, const allocator_type &__a=allocator_type())
_Hashtable_node< _Val > _Node
void _M_copy_from(const hashtable &__ht)
_Alloc_traits::template rebind< _Node >::other _Node_Alloc
void _M_erase_bucket(const size_type __n, _Node *__first, _Node *__last)
__gnu_cxx::__alloc_traits< _Alloc >::template rebind< value_type >::other allocator_type
std::vector< _Node *, _Nodeptr_Alloc > _Vector_type
void insert_equal(_InputIterator __f, _InputIterator __l)
_Hashtable_const_iterator< pair< const _Key, _Tp >, _Key, _HashFn, _Select1st< pair< const _Key, _Tp > >, _EqualKey, _Alloc > const_iterator
void insert_equal(_ForwardIterator __f, _ForwardIterator __l, std::forward_iterator_tag)
hasher hash_funct() const
std::pair< iterator, iterator > equal_range(const key_type &__key)
void insert_unique(_InputIterator __f, _InputIterator __l)
const value_type & const_reference
std::ptrdiff_t difference_type
_Node_Alloc _M_node_allocator
size_type max_size() const
size_type _M_bkt_num(const value_type &__obj, std::size_t __n) const
void erase(const const_iterator &__it)
size_type _M_bkt_num_key(const key_type &__key, std::size_t __n) const
void insert_unique(_ForwardIterator __f, _ForwardIterator __l, std::forward_iterator_tag)
allocator_type get_allocator() const
void resize(size_type __num_elements_hint)
_Alloc_traits::template rebind< _Node * >::other _Nodeptr_Alloc
void erase(const_iterator __first, const_iterator __last)
size_type bucket_count() const
size_type elems_in_bucket(size_type __bucket) const
void _M_delete_node(_Node *__n)
size_type erase(const key_type &__key)
const_iterator begin() const
size_type _M_bkt_num(const value_type &__obj) const
friend bool operator==(const hashtable< _Vl, _Ky, _HF, _Ex, _Eq, _Al > &, const hashtable< _Vl, _Ky, _HF, _Ex, _Eq, _Al > &)
_Node * _M_new_node(const value_type &__obj)
iterator insert_equal(const value_type &__obj)
hashtable(const hashtable &__ht)
void swap(hashtable &__ht)
iterator find(const key_type &__key)
size_type count(const key_type &__key) const
size_type _M_bkt_num_key(const key_type &__key) const
void erase(iterator __first, iterator __last)
__gnu_cxx::__alloc_traits< allocator_type > _Alloc_traits
_Hashtable_iterator< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > iterator
const_iterator find(const key_type &__key) const
_Hashtable_iterator< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > iterator
std::ptrdiff_t difference_type
_Hashtable_node< _Val > _Node
bool operator==(const iterator &__it) const
std::forward_iterator_tag iterator_category
bool operator!=(const iterator &__it) const
_Hashtable_iterator(_Node *__n, _Hashtable *__tab)
_Hashtable_const_iterator< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > const_iterator
reference operator*() const
pointer operator->() const
hashtable< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > _Hashtable
_Hashtable_const_iterator()
_Hashtable_node< _Val > _Node
std::ptrdiff_t difference_type
_Hashtable_const_iterator< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > const_iterator
reference operator*() const
pointer operator->() const
_Hashtable_iterator< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > iterator
_Hashtable_const_iterator(const _Node *__n, const _Hashtable *__tab)
hashtable< _Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc > _Hashtable
bool operator==(const const_iterator &__it) const
const_iterator & operator++()
bool operator!=(const const_iterator &__it) const
std::forward_iterator_tag iterator_category
_Hashtable_const_iterator(const iterator &__it)
static const _PrimeType __stl_prime_list[_S_num_primes]
static const _PrimeType * _S_get_prime_list()
The standard allocator, as per C++03 [20.4.1].
Struct holding two objects of arbitrary type.
Forward iterators support a superset of input iterator operations.
constexpr size_type size() const noexcept
A standard container which offers fixed time access to individual elements in any order.
static constexpr std::__enable_if_t< __is_custom_pointer< _Ptr >::value > destroy(allocator_type &__a, _Ptr __p) noexcept(noexcept(_Base_type::destroy(__a, std::__to_address(__p))))
static constexpr std::__enable_if_t< __is_custom_pointer< _Ptr >::value > construct(allocator_type &__a, _Ptr __p, _Args &&... __args) noexcept(noexcept(_Base_type::construct(__a, std::__to_address(__p), std::forward< _Args >(__args)...)))