diff options
author | mikhnenko <[email protected]> | 2023-11-02 19:27:12 +0300 |
---|---|---|
committer | mikhnenko <[email protected]> | 2023-11-02 20:14:23 +0300 |
commit | ea7266e3afdfe76274c756747fbd24626e1c205a (patch) | |
tree | 9b8370f3cf8d4399fc960a2c50aa9759f5acf554 /contrib/libs/cxxsupp/libcxx/include/__hash_table | |
parent | a528d5d25d42706fe385120b27e1df3a257823fb (diff) |
Upd libc++ to 14 Jun 2022 1cf4113952ae3e4cc75decdf6feb3ce5dd8ca4a1
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__hash_table')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__hash_table | 150 |
1 files changed, 29 insertions, 121 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__hash_table b/contrib/libs/cxxsupp/libcxx/include/__hash_table index 14f53429dee..990f5efc740 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__hash_table +++ b/contrib/libs/cxxsupp/libcxx/include/__hash_table @@ -17,10 +17,10 @@ #include <__config> #include <__debug> #include <__functional/hash.h> +#include <__iterator/iterator_traits.h> #include <__utility/swap.h> #include <cmath> #include <initializer_list> -#include <iterator> #include <memory> #include <type_traits> @@ -301,7 +301,7 @@ public: _VSTD::__debug_db_insert_i(this); } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY __hash_iterator(const __hash_iterator& __i) : __node_(__i.__node_) @@ -325,7 +325,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -367,19 +367,15 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY explicit __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) { + (void)__c; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - explicit __hash_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} #endif + } template <class, class, class, class> friend class __hash_table; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; @@ -415,12 +411,12 @@ public: __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) { -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); #endif } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __hash_const_iterator& __i) : __node_(__i.__node_) @@ -444,7 +440,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -485,19 +481,15 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY explicit __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) { + (void)__c; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - explicit __hash_const_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} #endif + } template <class, class, class, class> friend class __hash_table; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map; @@ -526,7 +518,7 @@ public: _VSTD::__debug_db_insert_i(this); } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(const __hash_local_iterator& __i) : __node_(__i.__node_), @@ -554,7 +546,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -598,7 +590,6 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY explicit __hash_local_iterator(__next_pointer __node, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT @@ -606,22 +597,13 @@ private: __bucket_(__bucket), __bucket_count_(__bucket_count) { + (void)__c; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__insert_ic(this, __c); +#endif if (__node_ != nullptr) __node_ = __node_->__next_; } -#else - _LIBCPP_INLINE_VISIBILITY - explicit __hash_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif template <class, class, class, class> friend class __hash_table; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; @@ -664,12 +646,12 @@ public: __bucket_(__x.__bucket_), __bucket_count_(__x.__bucket_count_) { -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); #endif } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(const __hash_const_local_iterator& __i) : __node_(__i.__node_), @@ -697,7 +679,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -741,7 +723,6 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY explicit __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT @@ -749,22 +730,13 @@ private: __bucket_(__bucket), __bucket_count_(__bucket_count) { + (void)__c; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __get_db()->__insert_ic(this, __c); +#endif if (__node_ != nullptr) __node_ = __node_->__next_; } -#else - _LIBCPP_INLINE_VISIBILITY - explicit __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node_ptr), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif template <class, class, class, class> friend class __hash_table; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; }; @@ -1286,11 +1258,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::begin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL == 2 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif } _LIBCPP_INLINE_VISIBILITY @@ -1299,11 +1267,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::end(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL == 2 return local_iterator(nullptr, __n, bucket_count(), this); -#else - return local_iterator(nullptr, __n, bucket_count()); -#endif } _LIBCPP_INLINE_VISIBILITY @@ -1312,11 +1276,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cbegin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL == 2 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif } _LIBCPP_INLINE_VISIBILITY @@ -1325,21 +1285,17 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cend(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL == 2 return const_local_iterator(nullptr, __n, bucket_count(), this); -#else - return const_local_iterator(nullptr, __n, bucket_count()); -#endif } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE private: void __rehash(size_type __n); @@ -1561,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) while (__np != nullptr) { __next_pointer __next = __np->__next_; -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __p = __c->end_; __p != __c->beg_; ) { @@ -1772,11 +1728,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__p1_.first().__next_, this); -#else - return iterator(__p1_.first().__next_); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1784,11 +1736,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(nullptr, this); -#else - return iterator(nullptr); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1796,11 +1744,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(__p1_.first().__next_, this); -#else - return const_iterator(__p1_.first().__next_); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1808,11 +1752,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(nullptr, this); -#else - return const_iterator(nullptr); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1917,11 +1857,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ __existing_node = __nd->__ptr(); __inserted = true; } -#if _LIBCPP_DEBUG_LEVEL == 2 return pair<iterator, bool>(iterator(__existing_node, this), __inserted); -#else - return pair<iterator, bool>(iterator(__existing_node), __inserted); -#endif } // Prepare the container for an insertion of the value __cp_val with the hash @@ -2015,11 +1951,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_); __node_insert_multi_perform(__cp, __pn); -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__cp->__ptr(), this); -#else - return iterator(__cp->__ptr()); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -2048,11 +1980,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( __cp->__next_ = __np; __pp->__next_ = static_cast<__next_pointer>(__cp); ++size(); -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(static_cast<__next_pointer>(__cp), this); -#else - return iterator(static_cast<__next_pointer>(__cp)); -#endif } return __node_insert_multi(__cp); } @@ -2118,11 +2046,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __inserted = true; } __done: -#if _LIBCPP_DEBUG_LEVEL == 2 return pair<iterator, bool>(iterator(__nd, this), __inserted); -#else - return pair<iterator, bool>(iterator(__nd), __inserted); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -2393,11 +2317,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) { if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__nd, this); -#else - return iterator(__nd); -#endif } } } @@ -2424,11 +2344,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const { if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(__nd, this); -#else - return const_iterator(__nd); -#endif } } @@ -2481,11 +2397,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) " referring to this container"); _LIBCPP_ASSERT(__p != end(), "unordered container erase(iterator) called with a non-dereferenceable iterator"); -#if _LIBCPP_DEBUG_LEVEL == 2 iterator __r(__np, this); -#else - iterator __r(__np); -#endif ++__r; remove(__p); return __r; @@ -2508,11 +2420,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, erase(__p); } __next_pointer __np = __last.__node_; -#if _LIBCPP_DEBUG_LEVEL == 2 return iterator (__np, this); -#else - return iterator (__np); -#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -2579,7 +2487,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT __pn->__next_ = __cn->__next_; __cn->__next_ = nullptr; --size(); -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __dp = __c->end_; __dp != __c->beg_; ) { @@ -2762,7 +2670,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, __x.swap(__y); } -#if _LIBCPP_DEBUG_LEVEL == 2 +#ifdef _LIBCPP_ENABLE_DEBUG_MODE template <class _Tp, class _Hash, class _Equal, class _Alloc> bool @@ -2792,7 +2700,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, return false; } -#endif // _LIBCPP_DEBUG_LEVEL == 2 +#endif // _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_END_NAMESPACE_STD |