diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5250cccdcf0..103f75d50e6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,216 @@ +2006-09-08 Benjamin Kosnik + + * include/debug/debug.h (_GLIBCXX_DEBUG_ONLY): New. + * include/ext/bitmap_allocator.h (_BALLOC_SANITY_CHECK, + _BALLOC_ASSERT): Remove. Use _GLIBCXX_DEBUG, + _GLIBCXX_DEBUG_ASSERT. + * include/ext/pb_ds/hash_policy.hpp (PB_DS_DBG_ASSERT): Convert to + _GLIBCXX_DEBUG_ASSERT. Formatting corrections. + (PB_DS_DBG_VERIFY): Remove, unused. + (PB_DS_DBG_ONLY): Convert to _GLIBCXX_DEBUG blocks. + * include/ext/pb_ds/detail/resize_policy/ + hash_load_check_resize_trigger_imp.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/ + insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/ + binomial_heap_base_.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_base_/ + split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + constructor_destructor_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + erase_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + insert_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + constructor_destructor_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + insert_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + debug_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + constructor_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + debug_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + erase_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/unordered_iterator/iterator.hpp: Same. + * include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp: Same. + * include/ext/pb_ds/detail/unordered_iterator/ + const_point_iterator.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/head.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/leaf.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/node_base.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/internal_node.hpp: Same. + * include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/ + split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + constructor_destructor_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + erase_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + insert_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + resize_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + constructor_destructor_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + insert_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + debug_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + constructor_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + debug_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + erase_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + resize_no_store_hash_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/types_traits.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp: Same. + * include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp: Same. + * include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + left_child_next_sibling_heap_.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + const_iterator.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + const_point_iterator.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/map_debug_base.hpp: Same. + * include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Same. + * include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp: Same. + * include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/ + constructor_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/list_update_map_/ + iterators_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/ + rc_binomial_heap_.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp: Same. + * include/ext/pb_ds/detail/rc_binomial_heap_/ + split_join_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/ + constructors_destructor_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp: Same. + * include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp: Same. + * testsuite/util/regression/res_mng/forced_exception.hpp: Same. + * testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp: Same. + * testsuite/util/regression/res_mng/dbg_ex_allocator.hpp: Same. + * testsuite/util/rng/twister_rand_gen.cc + * testsuite/util/native_type/assoc/native_multimap.hpp: Same. + * testsuite/util/native_type/assoc/native_hash_multimap.hpp: Same. + 2006-09-05 Paolo Carlini * include/bits/basic_string.tcc (find(const _CharT*, size_type, diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index 81f586cf1ae..72aefd7a64a 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -60,6 +60,7 @@ namespace __gnu_debug # define _GLIBCXX_DEBUG_ASSERT(_Condition) # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) ; # define __glibcxx_requires_cond(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) # define __glibcxx_requires_sorted(_First,_Last) @@ -109,6 +110,7 @@ namespace std #else # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) #endif +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) \ diff --git a/libstdc++-v3/include/ext/bitmap_allocator.h b/libstdc++-v3/include/ext/bitmap_allocator.h index 0f903077c2c..6452cb8f69c 100644 --- a/libstdc++-v3/include/ext/bitmap_allocator.h +++ b/libstdc++-v3/include/ext/bitmap_allocator.h @@ -1,6 +1,6 @@ // Bitmap Allocator. -*- C++ -*- -// Copyright (C) 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -52,23 +52,14 @@ // For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock. #include -// Define this to enable error checking withing the allocator -// itself(to debug the allocator itself). -//#define _BALLOC_SANITY_CHECK +#include // _GLIBCXX_DEBUG_ASSERT + /** @brief The constant in the expression below is the alignment * required in bytes. */ #define _BALLOC_ALIGN_BYTES 8 -#if defined _BALLOC_SANITY_CHECK -#include -#define _BALLOC_ASSERT(_EXPR) assert(_EXPR) -#else -#define _BALLOC_ASSERT(_EXPR) -#endif - - _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) using std::size_t; @@ -618,7 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _M_curr_bmap = reinterpret_cast (_M_vbp[_M_curr_index].first) - 1; - _BALLOC_ASSERT(__index <= (long)_M_vbp.size() - 1); + _GLIBCXX_DEBUG_ASSERT(__index <= (long)_M_vbp.size() - 1); _M_last_bmap_in_block = _M_curr_bmap - ((_M_vbp[_M_curr_index].second @@ -904,7 +895,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) typedef typename balloc::__mini_vector<_Block_pair> _BPVector; -#if defined _BALLOC_SANITY_CHECK +#if defined _GLIBCXX_DEBUG // Complexity: O(lg(N)). Where, N is the number of block of size // sizeof(value_type). void @@ -919,7 +910,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) (_S_mem_blocks.begin(), _S_mem_blocks.end(), __gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff)); - _BALLOC_ASSERT(__bpi == _S_mem_blocks.end()); + _GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end()); } #endif @@ -937,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) void _S_refill_pool() throw(std::bad_alloc) { -#if defined _BALLOC_SANITY_CHECK +#if defined _GLIBCXX_DEBUG _S_check_for_free_blocks(); #endif @@ -1110,14 +1101,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _Difference_type __diff; long __displacement; - _BALLOC_ASSERT(_S_last_dealloc_index >= 0); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0); if (__gnu_cxx::balloc::_Inclusive_between<_Alloc_block*> (__real_p) (_S_mem_blocks[_S_last_dealloc_index])) { - _BALLOC_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1); // Initial Assumption was correct! __diff = _S_last_dealloc_index; @@ -1132,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __gnu_cxx::balloc:: _Inclusive_between<_Alloc_block*>(__real_p)); - _BALLOC_ASSERT(_iter != _S_mem_blocks.end()); + _GLIBCXX_DEBUG_ASSERT(_iter != _S_mem_blocks.end()); __diff = _iter - _S_mem_blocks.begin(); __displacement = __real_p - _S_mem_blocks[__diff].first; @@ -1152,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) (_S_mem_blocks[__diff].first) - (__gnu_cxx::balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1); - _BALLOC_ASSERT(*__puse_count != 0); + _GLIBCXX_DEBUG_ASSERT(*__puse_count != 0); --(*__puse_count); @@ -1182,7 +1173,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) if (_S_last_dealloc_index >= _S_mem_blocks.size()) { _S_last_dealloc_index =(__diff != -1 ? __diff : 0); - _BALLOC_ASSERT(_S_last_dealloc_index >= 0); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0); } } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp index 8f325538f29..fa0ff416b42 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp @@ -58,40 +58,26 @@ #include #include #include -#include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ - #define PB_DS_CLASS_T_DEC \ - template< \ - typename Key, \ - typename Mapped, \ - class Cmp_Fn, \ - class Node_And_It_Traits, \ - class Allocator> + template #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CLASS_NAME \ bin_search_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_CLASS_NAME \ bin_search_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_CLASS_C_DEC \ PB_DS_CLASS_NAME< \ @@ -108,26 +94,23 @@ namespace pb_ds Allocator, \ false> -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG #define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - eq_by_less, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE + map_debug_base, \ + typename Allocator::template rebind::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #ifdef PB_DS_TREE_TRACE #define PB_DS_TREE_TRACE_BASE_C_DEC \ @@ -137,7 +120,7 @@ namespace pb_ds Cmp_Fn, \ true, \ Allocator> -#endif // #ifdef PB_DS_TREE_TRACE +#endif /** * class description = "8i|\|4ree $34rc|-| 7r33 74813."> @@ -148,12 +131,12 @@ namespace pb_ds class Node_And_It_Traits, class Allocator> class PB_DS_CLASS_NAME : -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG public PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif #ifdef PB_DS_TREE_TRACE public PB_DS_TREE_TRACE_BASE_C_DEC, -#endif // #ifdef PB_DS_TREE_TRACE +#endif public Cmp_Fn, public PB_DS_TYPES_TRAITS_C_DEC, public Node_And_It_Traits::node_update @@ -178,9 +161,9 @@ namespace pb_ds private: typedef cond_dealtor< node, Allocator> cond_dealtor_t; -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif public: @@ -203,7 +186,6 @@ namespace pb_ds const_key_reference; #ifdef PB_DS_DATA_TRUE_INDICATOR - typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type; typedef @@ -221,8 +203,7 @@ namespace pb_ds typedef typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference const_mapped_reference; - -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type; @@ -426,8 +407,7 @@ namespace pb_ds size_type recursive_count(node_pointer p_nd) const; -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; @@ -436,12 +416,10 @@ namespace pb_ds void assert_node_consistent(const node_pointer p_nd) const; - -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif private: -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_iterators() const; @@ -476,8 +454,7 @@ namespace pb_ds node_consistent_t assert_node_consistent_(const node_pointer p_nd) const; - -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif void initialize(); @@ -516,15 +493,11 @@ namespace pb_ds #ifdef PB_DS_TREE_TRACE #undef PB_DS_TREE_TRACE_BASE_C_DEC -#endif // #ifdef PB_DS_TREE_TRACE +#endif #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp index aa758a01da7..454d46b6f5c 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp @@ -50,26 +50,20 @@ PB_DS_CLASS_C_DEC::s_node_allocator; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: -PB_DS_CLASS_NAME() : - m_p_head(s_node_allocator.allocate(1)), - m_size(0) +PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); - - PB_DS_DBG_ONLY(structure_only_assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : - Cmp_Fn(r_cmp_fn), - m_p_head(s_node_allocator.allocate(1)), - m_size(0) + Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); - - PB_DS_DBG_ONLY(structure_only_assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -80,79 +74,64 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : m_size(0) { initialize(); - - PB_DS_DBG_ONLY(structure_only_assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG map_debug_base(other), -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif #ifdef PB_DS_TREE_TRACE PB_DS_TREE_TRACE_BASE_C_DEC(other), -#endif // #ifdef PB_DS_TREE_TRACE +#endif Cmp_Fn(other), node_update(other), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); - m_size = other.m_size; - - PB_DS_DBG_ONLY(other.structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) try { - m_p_head->m_p_parent = - recursive_copy_node(other.m_p_head->m_p_parent); - + m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent); if (m_p_head->m_p_parent != NULL) m_p_head->m_p_parent->m_p_parent = m_p_head; - m_size = other.m_size; - initialize_min_max(); } catch(...) { - PB_DS_DBG_ONLY(map_debug_base::clear();) - - s_node_allocator.deallocate(m_p_head, 1); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) + s_node_allocator.deallocate(m_p_head, 1); throw; } - - PB_DS_DBG_ONLY(structure_only_assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(structure_only_assert_valid();) - PB_DS_DBG_ONLY(other.structure_only_assert_valid();) - - value_swap(other); - + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) + value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - - PB_DS_DBG_ONLY(structure_only_assert_valid();) - PB_DS_DBG_ONLY(other.structure_only_assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(map_debug_base::swap(other);) - - std::swap(m_p_head, other.m_p_head); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);) + std::swap(m_p_head, other.m_p_head); std::swap(m_size, other.m_size); } @@ -161,7 +140,6 @@ PB_DS_CLASS_C_DEC:: ~PB_DS_CLASS_NAME() { clear(); - s_node_allocator.deallocate(m_p_head, 1); } @@ -173,7 +151,6 @@ initialize() m_p_head->m_p_parent = NULL; m_p_head->m_p_left = m_p_head; m_p_head->m_p_right = m_p_head; - m_size = 0; } @@ -186,7 +163,6 @@ recursive_copy_node(const node_pointer p_nd) return (NULL); node_pointer p_ret = s_node_allocator.allocate(1); - try { new (p_ret) node(*p_nd); @@ -194,7 +170,6 @@ recursive_copy_node(const node_pointer p_nd) catch(...) { s_node_allocator.deallocate(p_ret, 1); - throw; } @@ -203,13 +178,11 @@ recursive_copy_node(const node_pointer p_nd) try { p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left); - p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right); } catch(...) { clear_imp(p_ret); - throw; } @@ -219,9 +192,8 @@ recursive_copy_node(const node_pointer p_nd) if (p_ret->m_p_right != NULL) p_ret->m_p_right->m_p_parent = p_ret; - PB_DS_DBG_ONLY(assert_node_consistent(p_ret);) - - return (p_ret); + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret);) + return p_ret; } PB_DS_CLASS_T_DEC @@ -232,25 +204,20 @@ initialize_min_max() if (m_p_head->m_p_parent == NULL) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; - return; } { node_pointer p_min = m_p_head->m_p_parent; - while (p_min->m_p_left != NULL) p_min = p_min->m_p_left; - m_p_head->m_p_left = p_min; } { node_pointer p_max = m_p_head->m_p_parent; - while (p_max->m_p_right != NULL) p_max = p_max->m_p_right; - m_p_head->m_p_right = p_max; } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp index e6a7d2b33d5..eff970a3695 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for bin_search_tree_. */ -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,20 +52,16 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { structure_only_assert_valid(); - assert_consistent_with_debug_base(); - assert_size(); - assert_iterators(); - if (m_p_head->m_p_parent == NULL) { - PB_DS_DBG_ASSERT(m_size == 0); + _GLIBCXX_DEBUG_ASSERT(m_size == 0); } else { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); } } @@ -74,24 +70,21 @@ void PB_DS_CLASS_C_DEC:: structure_only_assert_valid() const { - PB_DS_DBG_ASSERT(m_p_head != NULL); - + _GLIBCXX_DEBUG_ASSERT(m_p_head != NULL); if (m_p_head->m_p_parent == NULL) { - PB_DS_DBG_ASSERT(m_p_head->m_p_left == m_p_head); - PB_DS_DBG_ASSERT(m_p_head->m_p_right == m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); } else { - PB_DS_DBG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head); - - PB_DS_DBG_ASSERT(m_p_head->m_p_left != m_p_head); - PB_DS_DBG_ASSERT(m_p_head->m_p_right != m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left != m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head); } if (m_p_head->m_p_parent != NULL) assert_node_consistent(m_p_head->m_p_parent); - assert_min(); assert_max(); } @@ -116,22 +109,18 @@ assert_node_consistent_(const node_pointer p_nd) const assert_node_consistent_with_right(p_nd); const std::pair - l_range = - assert_node_consistent_(p_nd->m_p_left); + l_range = assert_node_consistent_(p_nd->m_p_left); if (l_range.second != NULL) - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( - PB_DS_V2F(*l_range.second), - PB_DS_V2F(p_nd->m_value))); + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second), + PB_DS_V2F(p_nd->m_value))); const std::pair - r_range = - assert_node_consistent_(p_nd->m_p_right); + r_range = assert_node_consistent_(p_nd->m_p_right); if (r_range.first != NULL) - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( - PB_DS_V2F(p_nd->m_value), - PB_DS_V2F(*r_range.first))); + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), + PB_DS_V2F(*r_range.first))); return (std::make_pair((l_range.first != NULL)? l_range.first :& p_nd->m_value,(r_range.second != NULL)? r_range.second :& p_nd->m_value)); } @@ -143,12 +132,9 @@ assert_node_consistent_with_left(const node_pointer p_nd) const { if (p_nd->m_p_left == NULL) return; - - PB_DS_DBG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd); - - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()( - PB_DS_V2F(p_nd->m_value), - PB_DS_V2F(p_nd->m_p_left->m_value))); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd); + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), + PB_DS_V2F(p_nd->m_p_left->m_value))); } PB_DS_CLASS_T_DEC @@ -158,11 +144,8 @@ assert_node_consistent_with_right(const node_pointer p_nd) const { if (p_nd->m_p_right == NULL) return; - - PB_DS_DBG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd); - - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()( - PB_DS_V2F(p_nd->m_p_right->m_value), + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd); + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value), PB_DS_V2F(p_nd->m_value))); } @@ -181,18 +164,15 @@ assert_min_imp(const node_pointer p_nd) const { if (p_nd == NULL) { - PB_DS_DBG_ASSERT(m_p_head->m_p_left == m_p_head); - + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); return; } if (p_nd->m_p_left == NULL) { - PB_DS_DBG_ASSERT(p_nd == m_p_head->m_p_left); - + _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_left); return; } - assert_min_imp(p_nd->m_p_left); } @@ -211,15 +191,13 @@ assert_max_imp(const node_pointer p_nd) const { if (p_nd == NULL) { - PB_DS_DBG_ASSERT(m_p_head->m_p_right == m_p_head); - + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); return; } if (p_nd->m_p_right == NULL) { - PB_DS_DBG_ASSERT(p_nd == m_p_head->m_p_right); - + _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_right); return; } @@ -232,61 +210,40 @@ PB_DS_CLASS_C_DEC:: assert_iterators() const { size_type iterated_num = 0; - const_iterator prev_it = end(); - for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; - - PB_DS_DBG_ASSERT(lower_bound( - PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); - - const_iterator upper_bound_it = upper_bound( - PB_DS_V2F(*it)); - + _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); + const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; - - PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd); + _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd); if (prev_it != end()) - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( - PB_DS_V2F(*prev_it), - PB_DS_V2F(*it))); - + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), + PB_DS_V2F(*it))); prev_it = it; } - PB_DS_DBG_ASSERT(iterated_num == m_size); - + _GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); size_type reverse_iterated_num = 0; - const_reverse_iterator reverse_prev_it = rend(); - for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); ++reverse_it) { ++reverse_iterated_num; - - PB_DS_DBG_ASSERT(lower_bound( + _GLIBCXX_DEBUG_ASSERT(lower_bound( PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); - const_iterator upper_bound_it = upper_bound( - PB_DS_V2F(*reverse_it)); - + const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it)); --upper_bound_it; - - PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd); - + _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd); if (reverse_prev_it != rend()) - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()( - PB_DS_V2F(*reverse_prev_it), - PB_DS_V2F(*reverse_it))); - + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it), + PB_DS_V2F(*reverse_it))); reverse_prev_it = reverse_it; } - - PB_DS_DBG_ASSERT(reverse_iterated_num == m_size); + _GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size); } PB_DS_CLASS_T_DEC @@ -295,7 +252,6 @@ PB_DS_CLASS_C_DEC:: assert_consistent_with_debug_base() const { map_debug_base::check_size(m_size); - assert_consistent_with_debug_base(m_p_head->m_p_parent); } @@ -306,10 +262,7 @@ assert_consistent_with_debug_base(const node_pointer p_nd) const { if (p_nd == NULL) return; - - map_debug_base::check_key_exists( - PB_DS_V2F(p_nd->m_value)); - + map_debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value)); assert_consistent_with_debug_base(p_nd->m_p_left); assert_consistent_with_debug_base(p_nd->m_p_right); } @@ -319,7 +272,7 @@ void PB_DS_CLASS_C_DEC:: assert_size() const { - PB_DS_DBG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size); + _GLIBCXX_DEBUG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size); } -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp index d34368bbb52..2006a82b680 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp @@ -49,10 +49,10 @@ inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); p_z->~node(); @@ -94,7 +94,7 @@ void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) clear_imp(m_p_head->m_p_parent); @@ -102,9 +102,9 @@ clear() initialize(); - PB_DS_DBG_ONLY(map_debug_base::clear();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp index 0e79040280b..5f534d1c753 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp @@ -139,7 +139,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; @@ -165,7 +165,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp index 2bad1d0ef91..91fe41ab9d2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp @@ -49,7 +49,7 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf(const_reference r_value) { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) if (m_size == 0) return (std::make_pair( @@ -80,15 +80,15 @@ insert_leaf(const_reference r_value) PB_DS_V2F(r_value), PB_DS_V2F(p_pot->m_value))) { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists( PB_DS_V2F(r_value))); return (std::make_pair(p_pot, false)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( PB_DS_V2F(r_value))); p_nd = p_pot->m_p_left; @@ -115,8 +115,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) if (left_nd) { - PB_DS_DBG_ASSERT(p_nd->m_p_left == NULL); - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == NULL); + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()( PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value))); @@ -127,8 +127,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) } else { - PB_DS_DBG_ASSERT(p_nd->m_p_right == NULL); - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == NULL); + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()( PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))); @@ -142,11 +142,11 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) p_new_nd->m_p_left = p_new_nd->m_p_right = NULL; - PB_DS_DBG_ONLY(assert_node_consistent(p_nd)); + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_nd)); update_to_top(p_new_nd, (node_update* )this); - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(r_value))); return (iterator(p_new_nd)); @@ -167,7 +167,7 @@ insert_imp_empty(const_reference r_value) p_new_node->m_p_left = p_new_node->m_p_right = NULL; - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(r_value))); update_to_top(m_p_head->m_p_parent, (node_update* )this); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp index bf320241b1d..275177e10e0 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp @@ -47,10 +47,8 @@ #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP #define PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ -#include -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #include +#include namespace pb_ds { @@ -101,16 +99,6 @@ namespace pb_ds !Is_Forward_Iterator, \ Allocator> -#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ - // Const iterator. template(p_nd)) + bin_search_tree_const_it_(const Node_Pointer p_nd = NULL) + : m_p_nd(const_cast(p_nd)) { } inline - bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& - other) : m_p_nd(other.m_p_nd) + bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) + : m_p_nd(other.m_p_nd) { } inline PB_DS_TREE_CONST_IT_C_DEC& - operator=(const PB_DS_TREE_CONST_IT_C_DEC& - other) + operator=(const PB_DS_TREE_CONST_IT_C_DEC& other) { m_p_nd = other.m_p_nd; - - return (*this); + return *this; } inline PB_DS_TREE_CONST_IT_C_DEC& - operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& - other) + operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) { m_p_nd = other.m_p_nd; - - return (*this); + return *this; } inline const_pointer operator->() const { - PB_DS_DBG_ASSERT(m_p_nd != NULL); - - return (&m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL); + return &m_p_nd->m_value; } inline const_reference operator*() const { - PB_DS_DBG_ASSERT(m_p_nd != NULL); - - return (m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL); + return m_p_nd->m_value; } inline bool - operator==(const PB_DS_TREE_CONST_IT_C_DEC - & other) const - { - return (m_p_nd == other.m_p_nd); - } + operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const + { return m_p_nd == other.m_p_nd; } inline bool - operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC - & other) const - { - return (m_p_nd == other.m_p_nd); - } + operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const + { return m_p_nd == other.m_p_nd; } inline bool - operator!=(const PB_DS_TREE_CONST_IT_C_DEC& - other) const - { - return (m_p_nd != other.m_p_nd); - } + operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const + { return m_p_nd != other.m_p_nd; } inline bool - operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& - other) const - { - return (m_p_nd != other.m_p_nd); - } + operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const + { return m_p_nd != other.m_p_nd; } inline PB_DS_TREE_CONST_IT_C_DEC& operator++() { - PB_DS_DBG_ASSERT(m_p_nd != NULL); - + _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL); inc(integral_constant()); - - return (*this); + return *this; } inline PB_DS_TREE_CONST_IT_C_DEC operator++(int) { - PB_DS_TREE_CONST_IT_C_DEC - ret_it(m_p_nd); - + PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd); operator++(); - - return (ret_it); + return ret_it; } inline PB_DS_TREE_CONST_IT_C_DEC& operator--() { dec(integral_constant()); - - return (*this); + return *this; } inline PB_DS_TREE_CONST_IT_C_DEC operator--(int) { - PB_DS_TREE_CONST_IT_C_DEC - ret_it(m_p_nd); - + PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd); operator--(); - - return (ret_it); + return ret_it; } protected: inline void inc(false_type) - { - dec(true_type()); - } + { dec(true_type()); } void inc(true_type) @@ -268,26 +228,21 @@ namespace pb_ds m_p_nd->m_p_parent->m_p_parent == m_p_nd) { m_p_nd = m_p_nd->m_p_left; - return; } if (m_p_nd->m_p_right != NULL) { m_p_nd = m_p_nd->m_p_right; - while (m_p_nd->m_p_left != NULL) m_p_nd = m_p_nd->m_p_left; - return; } Node_Pointer p_y = m_p_nd->m_p_parent; - while (m_p_nd == p_y->m_p_right) { m_p_nd = p_y; - p_y = p_y->m_p_parent; } @@ -297,42 +252,32 @@ namespace pb_ds inline void dec(false_type) - { - inc(true_type()); - } + { inc(true_type()); } void dec(true_type) { - if (m_p_nd->special()&& - m_p_nd->m_p_parent->m_p_parent == m_p_nd) + if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd) { m_p_nd = m_p_nd->m_p_right; - return; } if (m_p_nd->m_p_left != NULL) { Node_Pointer p_y = m_p_nd->m_p_left; - while (p_y->m_p_right != NULL) p_y = p_y->m_p_right; - m_p_nd = p_y; - return; } Node_Pointer p_y = m_p_nd->m_p_parent; - while (m_p_nd == p_y->m_p_left) { m_p_nd = p_y; - p_y = p_y->m_p_parent; } - if (m_p_nd->m_p_left != p_y) m_p_nd = p_y; } @@ -358,11 +303,13 @@ namespace pb_ds public: inline - bin_search_tree_it_(const Node_Pointer p_nd = NULL) : PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd) + bin_search_tree_it_(const Node_Pointer p_nd = NULL) + : PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd) { } inline - bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other) : PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd) + bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other) + : PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd) { } inline @@ -370,8 +317,7 @@ namespace pb_ds operator=(const PB_DS_TREE_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; - - return (*this); + return *this; } inline @@ -379,64 +325,51 @@ namespace pb_ds operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; - - return (*this); + return *this; } inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer operator->() const { - PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL); - - return (&base_it_type::m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL); + return &base_it_type::m_p_nd->m_value; } inline typename PB_DS_TREE_CONST_IT_C_DEC::reference operator*() const { - PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL); - - return (base_it_type::m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL); + return base_it_type::m_p_nd->m_value; } inline PB_DS_TREE_IT_C_DEC& operator++() { - PB_DS_TREE_CONST_IT_C_DEC:: - operator++(); - - return (*this); + PB_DS_TREE_CONST_IT_C_DEC:: operator++(); + return *this; } inline PB_DS_TREE_IT_C_DEC operator++(int) { - PB_DS_TREE_IT_C_DEC - ret_it(base_it_type::m_p_nd); - + PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd); operator++(); - - return (ret_it); + return ret_it; } inline PB_DS_TREE_IT_C_DEC& operator--() { - PB_DS_TREE_CONST_IT_C_DEC:: - operator--(); - - return (*this); + PB_DS_TREE_CONST_IT_C_DEC:: operator--(); + return *this; } inline PB_DS_TREE_IT_C_DEC operator--(int) { - PB_DS_TREE_IT_C_DEC - ret_it(base_it_type::m_p_nd); - + PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd); operator--(); - - return (ret_it); + return ret_it; } protected: @@ -444,18 +377,11 @@ namespace pb_ds }; #undef PB_DS_TREE_CONST_IT_C_DEC - #undef PB_DS_TREE_CONST_ODIR_IT_C_DEC - #undef PB_DS_TREE_IT_C_DEC - #undef PB_DS_TREE_ODIR_IT_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp index 772255aba6a..2bad9795b2b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp @@ -49,10 +49,10 @@ inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); p_z->~node(); @@ -94,7 +94,7 @@ void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) clear_imp(m_p_head->m_p_parent); @@ -102,9 +102,9 @@ clear() initialize(); - PB_DS_DBG_ONLY(map_debug_base::clear();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) - PB_DS_DBG_ONLY(structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp index 795aecfa5bb..4e32aae637f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp @@ -68,8 +68,8 @@ rotate_left(node_pointer p_x) p_y->m_p_left = p_x; p_x->m_p_parent = p_y; - PB_DS_DBG_ONLY(assert_node_consistent(p_x);) - PB_DS_DBG_ONLY(assert_node_consistent(p_y);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); @@ -99,8 +99,8 @@ rotate_right(node_pointer p_x) p_y->m_p_right = p_x; p_x->m_p_parent = p_y; - PB_DS_DBG_ONLY(assert_node_consistent(p_x);) - PB_DS_DBG_ONLY(assert_node_consistent(p_y);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); @@ -118,8 +118,8 @@ rotate_parent(node_pointer p_nd) else rotate_left(p_parent); - PB_DS_DBG_ASSERT(p_parent->m_p_parent = p_nd); - PB_DS_DBG_ASSERT(p_nd->m_p_left == p_parent || + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp index 103f636d6a5..ee7e2e8a3c3 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp @@ -49,8 +49,8 @@ bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (other.m_size == 0) return (false); @@ -78,7 +78,7 @@ join_prep(PB_DS_CLASS_C_DEC& other) m_size += other.m_size; - PB_DS_DBG_ONLY(map_debug_base::join(other);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) return (true); } @@ -98,15 +98,15 @@ bool PB_DS_CLASS_C_DEC:: split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) other.clear(); if (m_size == 0) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return (false); } @@ -115,8 +115,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { value_swap(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return (false); } @@ -125,8 +125,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) r_key, PB_DS_V2F(m_p_head->m_p_right->m_value))) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return (false); } @@ -135,13 +135,13 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { value_swap(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return (false); } - PB_DS_DBG_ONLY(map_debug_base::split( + _GLIBCXX_DEBUG_ONLY(map_debug_base::split( r_key,(Cmp_Fn& )(*this), other);) @@ -162,8 +162,8 @@ split_finish(PB_DS_CLASS_C_DEC& other) initialize_min_max(); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp index bcc81deb770..a47033a64af 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp @@ -63,44 +63,25 @@ #include #ifdef PB_DS_BINARY_HEAP_TRACE_ #include -#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ +#endif #include +#include namespace pb_ds { namespace detail { - -#ifdef PB_DS_BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - binary_heap_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + binary_heap_ -#define PB_DS_ENTRY_CMP_DEC \ - entry_cmp< \ - Value_Type, \ - Cmp_Fn, \ - is_simple< \ - Value_Type>::value, \ - Allocator>::type +#define PB_DS_ENTRY_CMP_DEC \ + entry_cmp::value, Allocator>::type -#define PB_DS_RESIZE_POLICY_DEC \ - resize_policy< \ - typename Allocator::size_type> +#define PB_DS_RESIZE_POLICY_DEC \ + resize_policy /** * class description = "Base class for some types of h3ap$"> @@ -113,8 +94,7 @@ namespace pb_ds private: enum { - simple_value = is_simple< - Value_Type>::value + simple_value = is_simple::value }; typedef integral_constant no_throw_copies_t; @@ -276,11 +256,9 @@ namespace pb_ds join(PB_DS_CLASS_C_DEC& other); #ifdef PB_DS_BINARY_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ +#endif protected: @@ -336,22 +314,18 @@ namespace pb_ds size_type partition(Pred pred); -#ifdef PB_DS_BINARY_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ +#endif #ifdef PB_DS_BINARY_HEAP_TRACE_ - void trace_entry(const entry& r_e, false_type) const; void trace_entry(const entry& r_e, true_type) const; - -#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ +#endif private: static entry_allocator s_entry_allocator; @@ -379,18 +353,11 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_ENTRY_CMP_DEC - #undef PB_DS_RESIZE_POLICY_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BINARY_HEAP_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp index c739317e00a..12b96e766ba 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp @@ -49,35 +49,18 @@ #define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP #include +#include namespace pb_ds { namespace detail { -#ifdef BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef BINARY_HEAP_DEBUG_ +#define PB_DS_CLASS_C_DEC \ + binary_heap_const_iterator_ -#define PB_DS_CLASS_C_DEC \ - binary_heap_const_iterator_< \ - Value_Type, \ - Entry, \ - Simple, \ - Allocator> - -#define PB_DS_BASE_C_DEC \ - binary_heap_const_point_iterator_< \ - Value_Type, \ - Entry, \ - Simple, \ - Allocator> +#define PB_DS_BASE_C_DEC \ + binary_heap_const_point_iterator_ // Const point-type iterator. template +#include namespace pb_ds { namespace detail { -#ifdef BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ;m_p_prev_or_parent -#endif // #ifdef BINARY_HEAP_DEBUG_ +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_T_DEC \ - template< \ - typename Value_Type, \ - typename Entry, \ - bool Simple, \ - class Allocator> - -#define PB_DS_CLASS_C_DEC \ - binary_heap_const_point_iterator_< \ - Value_Type, \ - Entry, \ - Simple, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + binary_heap_const_point_iterator_ // Const point-type iterator. template() const { - PB_DS_DBG_ASSERT(m_p_e != NULL); - - return (to_ptr(integral_constant())); + _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); + return to_ptr(integral_constant()); } // Access. inline const_reference operator*() const { - PB_DS_DBG_ASSERT(m_p_e != NULL); - - return (*to_ptr(integral_constant())); + _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); + return *to_ptr(integral_constant()); } // Compares content to a different iterator object. inline bool operator==(const PB_DS_CLASS_C_DEC& other) const - { - return (m_p_e == other.m_p_e); - } + { return m_p_e == other.m_p_e; } // Compares content (negatively) to a different iterator object. inline bool operator!=(const PB_DS_CLASS_C_DEC& other) const - { - return (m_p_e != other.m_p_e); - } + { return m_p_e != other.m_p_e; } private: inline const_pointer to_ptr(true_type) const - { - return m_p_e; - } + { return m_p_e; } inline const_pointer to_ptr(false_type) const - { - return* m_p_e; - } + { return *m_p_e; } public: entry_pointer m_p_e; @@ -200,11 +169,7 @@ namespace pb_ds #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp index c568aaa3832..ada9c2af083 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp @@ -71,7 +71,7 @@ copy_from_range(It first_it, It last_it) std::make_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -81,7 +81,7 @@ binary_heap_() : m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -92,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) : m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -104,8 +104,8 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : m_actual_size(other.m_actual_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - PB_DS_DBG_ONLY(other.assert_valid();) - PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); const_iterator first_it = other.begin(); const_iterator last_it = other.end(); @@ -129,7 +129,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : throw; } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -137,16 +137,16 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); value_swap(other); std::swap((entry_cmp& )(*this), (entry_cmp& )other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp index e24835cfe2f..198d6608e37 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for a binary_heap. */ -#ifdef PB_DS_BINARY_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -53,28 +53,26 @@ assert_valid() const { #ifdef PB_DS_REGRESSION s_entry_allocator.check_allocated(m_a_entries, m_actual_size); -#endif // #ifdef PB_DS_REGRESSION +#endif resize_policy::assert_valid(); - - PB_DS_DBG_ASSERT(m_size <= m_actual_size); - + _GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size); for (size_type i = 0; i < m_size; ++i) { #ifdef PB_DS_REGRESSION s_value_allocator.check_allocated(m_a_entries[i], 1); -#endif // #ifdef PB_DS_REGRESSION +#endif if (left_child(i) < m_size) - PB_DS_DBG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); + _GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); - PB_DS_DBG_ASSERT(parent(left_child(i)) == i); + _GLIBCXX_DEBUG_ASSERT(parent(left_child(i)) == i); if (right_child(i) < m_size) - PB_DS_DBG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); + _GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); - PB_DS_DBG_ASSERT(parent(right_child(i)) == i); + _GLIBCXX_DEBUG_ASSERT(parent(right_child(i)) == i); } } -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp index 08a42467669..72686d12974 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp @@ -71,7 +71,7 @@ clear() m_size = 0; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -95,8 +95,8 @@ inline void PB_DS_CLASS_C_DEC:: pop() { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!empty()); erase_at(m_a_entries, 0, s_no_throw_copies_ind); @@ -104,10 +104,10 @@ pop() resize_for_erase_if_needed(); - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -116,7 +116,7 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) typedef typename entry_pred< @@ -128,7 +128,7 @@ erase_if(Pred pred) const size_type left = partition(pred_t(pred)); - PB_DS_DBG_ASSERT(m_size >= left); + _GLIBCXX_DEBUG_ASSERT(m_size >= left); const size_type ersd = m_size - left; @@ -157,7 +157,7 @@ erase_if(Pred pred) std::make_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return ersd; } @@ -167,8 +167,8 @@ inline void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!empty()); const size_type fix_pos = it.m_p_e - m_a_entries; @@ -178,15 +178,15 @@ erase(point_iterator it) resize_for_erase_if_needed(); - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - PB_DS_DBG_ASSERT(fix_pos <= m_size); + _GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size); if (fix_pos != m_size) fix(m_a_entries + fix_pos); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -206,7 +206,7 @@ resize_for_erase_if_needed() resize_policy::notify_shrink_resize(); - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); std::copy(m_a_entries, m_a_entries + m_size - 1, a_new_entries); s_entry_allocator.deallocate(m_a_entries, m_actual_size); @@ -230,7 +230,7 @@ partition(Pred pred) while (right + 1 != left) { - PB_DS_DBG_ASSERT(left <= m_size); + _GLIBCXX_DEBUG_ASSERT(left <= m_size); if (!pred(m_a_entries[left])) ++left; @@ -238,7 +238,7 @@ partition(Pred pred) --right; else { - PB_DS_DBG_ASSERT(left < right); + _GLIBCXX_DEBUG_ASSERT(left < right); std::swap(m_a_entries[left], m_a_entries[right]); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp index 92fc949da2b..b7606b673d8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp @@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!empty()); return top_imp(s_no_throw_copies_ind); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp index 543285835b8..489ccc12465 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp @@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) insert_value(r_val, s_no_throw_copies_ind); std::push_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return point_iterator(m_a_entries); } @@ -105,7 +105,7 @@ resize_for_insert_if_needed() { if (!resize_policy::resize_needed_for_grow(m_size)) { - PB_DS_DBG_ASSERT(m_size < m_actual_size); + _GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size); return; } @@ -131,13 +131,13 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); fix(it.m_p_e); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -160,7 +160,7 @@ fix(entry_pointer p_e) parent_i = parent(i); } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } @@ -170,7 +170,7 @@ fix(entry_pointer p_e) const size_type left_child_i = left_child(i); const size_type right_child_i = right_child(i); - PB_DS_DBG_ASSERT(right_child_i > left_child_i); + _GLIBCXX_DEBUG_ASSERT(right_child_i > left_child_i); const bool smaller_than_left_child = left_child_i < m_size&& diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp index 1982e07ae74..c6021a99804 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp @@ -47,27 +47,16 @@ #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP +#include + namespace pb_ds { namespace detail { -#ifdef PB_DS_BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BINARY_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ +#define PB_DS_CLASS_T_DEC template -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - resize_policy< \ - Size_Type> +#define PB_DS_CLASS_C_DEC resize_policy template class resize_policy @@ -117,17 +106,15 @@ namespace pb_ds void notify_arbitrary(size_type actual_size); -#ifdef PB_DS_BINARY_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG void assert_valid() const; -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ +#endif #ifdef PB_DS_BINARY_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ +#endif private: enum @@ -138,7 +125,6 @@ namespace pb_ds private: size_type m_next_shrink_size; - size_type m_next_grow_size; }; @@ -148,9 +134,7 @@ namespace pb_ds resize_policy() : m_next_shrink_size(0), m_next_grow_size(min_size) - { - PB_DS_DBG_ONLY(assert_valid();) - } + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void @@ -166,8 +150,7 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: resize_needed_for_grow(size_type size) const { - PB_DS_DBG_ASSERT(size <= m_next_grow_size); - + _GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size); return size == m_next_grow_size; } @@ -176,8 +159,7 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: resize_needed_for_shrink(size_type size) const { - PB_DS_DBG_ASSERT(size <= m_next_grow_size); - + _GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size); return size == m_next_shrink_size; } @@ -185,9 +167,7 @@ namespace pb_ds inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: get_new_size_for_grow() const - { - return m_next_grow_size* factor; - } + { return m_next_grow_size* factor; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type @@ -195,7 +175,6 @@ namespace pb_ds get_new_size_for_shrink() const { const size_type half_size = m_next_grow_size / factor; - return std::max(static_cast(min_size), half_size); } @@ -205,10 +184,8 @@ namespace pb_ds get_new_size_for_arbitrary(size_type size) const { size_type ret = min_size; - while (ret < size) ret *= factor; - return ret; } @@ -217,33 +194,27 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: notify_grow_resize() { - PB_DS_DBG_ONLY(assert_valid();) - - PB_DS_DBG_ASSERT(m_next_grow_size >= min_size); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); m_next_grow_size *= factor; - m_next_shrink_size = m_next_grow_size / ratio; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_shrink_resize() { - PB_DS_DBG_ONLY(assert_valid();) - - m_next_shrink_size /= factor; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + m_next_shrink_size /= factor; if (m_next_shrink_size == 1) m_next_shrink_size = 0; m_next_grow_size = std::max(m_next_grow_size / factor, static_cast(min_size)); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void @@ -251,24 +222,22 @@ namespace pb_ds notify_arbitrary(size_type actual_size) { m_next_grow_size = actual_size; - m_next_shrink_size = m_next_grow_size / ratio; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } - PB_DS_DBG_ONLY(assert_valid();) - } - -#ifdef PB_DS_BINARY_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { - PB_DS_DBG_ASSERT(m_next_shrink_size == 0 || + _GLIBCXX_DEBUG_ASSERT(m_next_shrink_size == 0 || m_next_shrink_size* ratio == m_next_grow_size); - PB_DS_DBG_ASSERT(m_next_grow_size >= min_size); + _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); } -#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ +#endif #ifdef PB_DS_BINARY_HEAP_TRACE_ PB_DS_CLASS_T_DEC @@ -279,17 +248,12 @@ namespace pb_ds std::cerr << "shrink = " << m_next_shrink_size << " grow = " << m_next_grow_size << std::endl; } -#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ +#endif #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace detail +} // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp index 20913c47d59..1cca3818139 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp @@ -50,7 +50,7 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) typedef typename entry_pred< @@ -62,11 +62,11 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) const size_type left = partition(pred_t(pred)); - PB_DS_DBG_ASSERT(m_size >= left); + _GLIBCXX_DEBUG_ASSERT(m_size >= left); const size_type ersd = m_size - left; - PB_DS_DBG_ASSERT(m_size >= ersd); + _GLIBCXX_DEBUG_ASSERT(m_size >= ersd); const size_type actual_size = resize_policy::get_new_size_for_arbitrary(left); @@ -97,7 +97,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) for (size_type i = 0; i < other.m_size; ++i) erase_at(other.m_a_entries, i, s_no_throw_copies_ind); - PB_DS_DBG_ASSERT(actual_size >= left); + _GLIBCXX_DEBUG_ASSERT(actual_size >= left); std::copy(m_a_entries, m_a_entries + left, a_entries); std::copy(m_a_entries + left, m_a_entries + m_size, a_other_entries); @@ -119,8 +119,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) resize_policy::notify_arbitrary(m_actual_size); other.notify_arbitrary(other.m_actual_size); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -128,8 +128,8 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) const size_type size = m_size + other.m_size; const size_type actual_size = resize_policy::get_new_size_for_arbitrary(size); @@ -173,7 +173,7 @@ join(PB_DS_CLASS_C_DEC& other) other.notify_arbitrary(resize_policy::min_size); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp index 2689bdb91e6..8fdc97d4f74 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp @@ -50,9 +50,7 @@ * Modified from CLRS. */ -#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ -#include -#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ +#include #include #include #include @@ -62,30 +60,14 @@ namespace pb_ds namespace detail { -#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - binomial_heap_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + binomial_heap_ -#define PB_DS_BASE_C_DEC \ - binomial_heap_base_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_BASE_C_DEC \ + binomial_heap_base_ /** * class description = "8y|\|0|\/|i41 h34p 74813"> @@ -140,12 +122,10 @@ namespace pb_ds ~binomial_heap_(); protected: -#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ +#endif }; #include @@ -156,10 +136,5 @@ namespace pb_ds #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_C_DEC - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp index ab7bec6bf94..2e63cf8e923 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp @@ -47,28 +47,21 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_() -{ - PB_DS_DBG_ONLY(assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) -{ - PB_DS_DBG_ONLY(assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other) -{ - PB_DS_DBG_ONLY(assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: -~binomial_heap_() -{ } +~binomial_heap_() { } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp index 39208a8c6e8..540bd7cd846 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp @@ -44,14 +44,12 @@ * Contains an implementation for binomial_heap_. */ -#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const -{ - base_type::assert_valid(true); -} +{ base_type::assert_valid(true); } -#endif // #ifdef PB_DS_BINOMIAL_HEAP__DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp index 5ad1ad5dea9..09af8cfffd7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp @@ -53,9 +53,7 @@ * Modified from CLRS. */ -#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ -#include -#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ +#include #include #include #include @@ -66,41 +64,22 @@ namespace pb_ds namespace detail { -#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - binomial_heap_base_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + binomial_heap_base_ -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - typename Allocator::size_type, \ - Allocator, \ - false> -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - typename Allocator::size_type, \ - Allocator> -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG +#define PB_DS_BASE_C_DEC \ + left_child_next_sibling_heap_ +#else +#define PB_DS_BASE_C_DEC \ + left_child_next_sibling_heap_ +#endif /** * class description = "8y|\|0|\/|i41 h34p 74813"> @@ -212,15 +191,13 @@ namespace pb_ds inline void find_max(); -#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid(bool strictly_binomial) const; void assert_max() const; - -#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ +#endif private: @@ -236,12 +213,10 @@ namespace pb_ds inline node_pointer join(node_pointer p_lhs, node_pointer p_rhs) const; -#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void - assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const; - -#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ + assert_node_consistent(const_node_pointer, bool, bool) const; +#endif protected: node_pointer m_p_max; @@ -255,16 +230,11 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp index dd3d090e60e..24ea2955917 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp @@ -53,7 +53,7 @@ copy_from_range(It first_it, It last_it) while (first_it != last_it) push(*(first_it++)); - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) } PB_DS_CLASS_T_DEC @@ -61,7 +61,7 @@ PB_DS_CLASS_C_DEC:: binomial_heap_base_() : m_p_max(NULL) { - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) } PB_DS_CLASS_T_DEC @@ -70,7 +70,7 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn), m_p_max(NULL) { - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) } PB_DS_CLASS_T_DEC @@ -79,7 +79,7 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other), m_p_max(NULL) { - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) } PB_DS_CLASS_T_DEC @@ -87,13 +87,13 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) base_type::swap(other); std::swap(m_p_max, other.m_p_max); - PB_DS_DBG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp index f50524d9c2c..200249d8d98 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for a base of binomial heaps. */ -#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,9 +52,7 @@ PB_DS_CLASS_C_DEC:: assert_valid(bool strictly_binomial) const { base_type::assert_valid(); - assert_node_consistent(base_type::m_p_root, strictly_binomial, true); - assert_max(); } @@ -65,11 +63,9 @@ assert_max() const { if (m_p_max == NULL) return; - - PB_DS_DBG_ASSERT(base_type::parent(m_p_max) == NULL); - + _GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == NULL); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC @@ -77,32 +73,25 @@ void PB_DS_CLASS_C_DEC:: assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const { - PB_DS_DBG_ASSERT(increasing || strictly_binomial); - + _GLIBCXX_DEBUG_ASSERT(increasing || strictly_binomial); base_type::assert_node_consistent(p_nd, false); - if (p_nd == NULL) return; - - PB_DS_DBG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd)); - - PB_DS_DBG_ASSERT(base_type::size_under_node(p_nd) == + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd)); + _GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) == static_cast(1 << p_nd->m_metadata)); - assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing); - assert_node_consistent(p_nd->m_p_l_child, true, false); - if (p_nd->m_p_next_sibling != NULL) if (increasing) { if (strictly_binomial) - PB_DS_DBG_ASSERT(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata); else - PB_DS_DBG_ASSERT(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata); } else - PB_DS_DBG_ASSERT(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata); } -#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp index bb373101a5f..8109b53ec01 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp @@ -49,13 +49,13 @@ void PB_DS_CLASS_C_DEC:: pop() { - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == NULL) find_max(); - PB_DS_DBG_ASSERT(m_p_max != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL); node_pointer p_nd = m_p_max; @@ -65,7 +65,7 @@ pop() m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) } PB_DS_CLASS_T_DEC @@ -73,8 +73,8 @@ void PB_DS_CLASS_C_DEC:: remove_parentless_node(node_pointer p_nd) { - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(base_type::parent(p_nd) == NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == NULL); node_pointer p_cur_root = p_nd == base_type::m_p_root? p_nd->m_p_next_sibling : @@ -119,8 +119,8 @@ void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); base_type::bubble_to_top(it.m_p_nd); @@ -130,7 +130,7 @@ erase(point_iterator it) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) } PB_DS_CLASS_T_DEC @@ -139,11 +139,11 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) return 0; } @@ -191,7 +191,7 @@ erase_if(Pred pred) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp index 7b26b352a08..6014c072526 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp @@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - PB_DS_DBG_ONLY(assert_valid(false);) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid(false);) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == NULL) const_cast(this)->find_max(); - PB_DS_DBG_ASSERT(m_p_max != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL); return m_p_max->m_value; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp index 56c99c43029..91b04e165fd 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp @@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); @@ -57,7 +57,7 @@ push(const_reference r_val) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) return point_iterator(p_nd); } @@ -120,7 +120,7 @@ insert_node(node_pointer p_nd) p_nd->m_metadata = 0; - PB_DS_DBG_ASSERT(base_type::m_p_root->m_p_l_child == 0); + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0); base_type::m_p_root->m_p_l_child = p_nd; base_type::m_p_root->m_metadata = 1; @@ -177,11 +177,11 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) node_pointer p_nd = it.m_p_nd; - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false);) + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false);) const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val); @@ -204,7 +204,7 @@ modify(point_iterator it, const_reference r_new_val) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) return; } @@ -217,6 +217,6 @@ modify(point_iterator it, const_reference r_new_val) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp index 2823269b60b..05f9f1278bc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp @@ -50,15 +50,15 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) other.clear(); if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) return; } @@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) while (p_out != NULL) { - PB_DS_DBG_ASSERT(base_type::m_size > 0); + _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; @@ -92,7 +92,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) node_pointer p_cur = base_type::m_p_root; @@ -120,8 +120,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) } PB_DS_CLASS_T_DEC @@ -129,8 +129,8 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) node_pointer p_other = other.m_p_root; @@ -153,8 +153,8 @@ join(PB_DS_CLASS_C_DEC& other) other.m_size = 0; other.m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid(true);) - PB_DS_DBG_ONLY(other.assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp index 89cea3fa8fb..2659a0bb347 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp @@ -52,105 +52,62 @@ #include #include #include -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG #include -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif #ifdef PB_DS_HT_MAP_TRACE_ #include -#endif // PB_DS_HT_MAP_TRACE_ +#endif +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_CC_HT_MAP_DEBUG__ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_CC_HT_MAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ - template< \ - typename Key, \ - typename Mapped, \ - class Hash_Fn, \ - class Eq_Fn, \ - class Allocator, \ - bool Store_Hash, \ - class Comb_Hash_Fn, \ - class Resize_Policy> +#define PB_DS_CLASS_T_DEC \ + template #ifdef PB_DS_DATA_TRUE_INDICATOR -#define PB_DS_CLASS_NAME \ - cc_ht_map_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#define PB_DS_CLASS_NAME cc_ht_map_data_ +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR -#define PB_DS_CLASS_NAME \ - cc_ht_map_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#define PB_DS_CLASS_NAME cc_ht_map_no_data_ +#endif -#define PB_DS_CLASS_C_DEC \ - PB_DS_CLASS_NAME< \ - Key, \ - Mapped, \ - Hash_Fn, \ - Eq_Fn, \ - Allocator, \ - Store_Hash, \ - Comb_Hash_Fn, \ - Resize_Policy > +#define PB_DS_CLASS_C_DEC \ + PB_DS_CLASS_NAME -#define PB_DS_HASH_EQ_FN_C_DEC \ - hash_eq_fn< \ - Key, \ - Eq_Fn, \ - Allocator, \ - Store_Hash> +#define PB_DS_HASH_EQ_FN_C_DEC \ + hash_eq_fn -#define PB_DS_RANGED_HASH_FN_C_DEC \ - ranged_hash_fn< \ - Key, \ - Hash_Fn, \ - Allocator, \ - Comb_Hash_Fn, \ - Store_Hash> +#define PB_DS_RANGED_HASH_FN_C_DEC \ + ranged_hash_fn -#define PB_DS_TYPES_TRAITS_C_DEC \ - types_traits< \ - Key, \ - Mapped, \ - Allocator, \ - Store_Hash> +#define PB_DS_TYPES_TRAITS_C_DEC \ + types_traits -#ifdef PB_DS_USE_MAP_DEBUG_BASE -#define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - Eq_Fn, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG +#define PB_DS_MAP_DEBUG_BASE_C_DEC \ + map_debug_base::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif -#define PB_DS_STATIC_ASSERT(UNIQUE, E) \ - typedef \ - static_assert_dumclass< \ - sizeof(static_assert<(bool)(E)>)> \ +#define PB_DS_STATIC_ASSERT(UNIQUE, E) \ + typedef static_assert_dumclass)> \ UNIQUE##static_assert_type // <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813. @@ -163,9 +120,9 @@ namespace pb_ds class Comb_Hash_Fn, class Resize_Policy > class PB_DS_CLASS_NAME: -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG protected PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif public PB_DS_HASH_EQ_FN_C_DEC, public Resize_Policy, public PB_DS_RANGED_HASH_FN_C_DEC, @@ -214,10 +171,7 @@ namespace pb_ds typename PB_DS_TYPES_TRAITS_C_DEC::const_reference const_reference_; -#define PB_DS_GEN_POS \ - std::pair< \ - entry_pointer, \ - typename Allocator::size_type> +#define PB_DS_GEN_POS std::pair #include #include @@ -293,21 +247,21 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR typedef point_iterator_ point_iterator; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_point_iterator_ point_iterator; -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif typedef const_point_iterator_ const_point_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef iterator_ iterator; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_iterator_ iterator; -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif typedef const_iterator_ const_iterator; @@ -374,7 +328,7 @@ namespace pb_ds inline std::pair insert(const_reference r_val) { - return (insert_imp(r_val, traits_base::m_store_extra_indicator)); + return insert_imp(r_val, traits_base::m_store_extra_indicator); } inline mapped_reference @@ -382,11 +336,10 @@ namespace pb_ds { #ifdef PB_DS_DATA_TRUE_INDICATOR return (subscript_imp(r_key, traits_base::m_store_extra_indicator)); -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR +#else insert(r_key); - - return (traits_base::s_null_mapped); -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR + return traits_base::s_null_mapped; +#endif } inline point_iterator @@ -423,19 +376,15 @@ namespace pb_ds inline const_iterator end() const; -#ifdef PB_DS_CC_HT_MAP_DEBUG__ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif #ifdef PB_DS_HT_MAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_HT_MAP_TRACE_ +#endif private: typedef PB_DS_TYPES_TRAITS_C_DEC traits_base; @@ -446,9 +395,9 @@ namespace pb_ds typedef Resize_Policy resize_base; -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif typedef typename PB_DS_TYPES_TRAITS_C_DEC::store_extra_false_type @@ -486,10 +435,10 @@ namespace pb_ds do_resize(size_type new_size); void - resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size); + resize_imp_no_exceptions(size_type, entry_pointer_array, size_type); inline entry_pointer - resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, store_hash_false_type); + resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, store_hash_false_type); inline entry_pointer resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, store_hash_true_type); @@ -510,86 +459,59 @@ namespace pb_ds inline mapped_reference subscript_imp(const_key_reference r_key, store_hash_false_type) { - PB_DS_DBG_ONLY(assert_valid();) - - const size_type pos = ranged_hash_fn_base::operator()(r_key); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + const size_type pos = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_a_p_entries[pos]; - resize_base::notify_insert_search_start(); - while (p_e != NULL&& - !hash_eq_fn_base::operator()(p_e->m_value.first, r_key)) + while (p_e != NULL + && !hash_eq_fn_base::operator()(p_e->m_value.first, r_key)) { resize_base::notify_insert_search_collision(); - p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); - if (p_e != NULL) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) - - return (p_e->m_value.second); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) + return (p_e->m_value.second); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) - - return (insert_new_imp( - value_type( - r_key, - mapped_type()), - pos)->second); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + return insert_new_imp(value_type(r_key, mapped_type()), pos)->second; } inline mapped_reference subscript_imp(const_key_reference r_key, store_hash_true_type) { - PB_DS_DBG_ONLY(assert_valid();) - - comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_a_p_entries[pos_hash_pair.first]; - resize_base::notify_insert_search_start(); - - while (p_e != NULL&& + while (p_e != NULL && !hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_insert_search_collision(); - p_e = p_e->m_p_next; } resize_base::notify_insert_search_end(); - if (p_e != NULL) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) - - return (p_e->m_value.second); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) + return p_e->m_value.second; } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) - - return (insert_new_imp( - value_type( - r_key, - mapped_type()), - pos_hash_pair)->second); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + return insert_new_imp(value_type(r_key, mapped_type()), pos_hash_pair)->second; } -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif - inline std::pair< - point_iterator, - bool> + inline std::pair insert_imp(const_reference r_val, store_hash_false_type); - inline std::pair< - point_iterator, - bool> + inline std::pair insert_imp(const_reference r_val, store_hash_true_type); inline pointer @@ -599,111 +521,84 @@ namespace pb_ds pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val)); // Following lines might throw an exception. - entry_pointer p_e = get_entry( r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); + entry_pointer p_e = get_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); // At this point no exceptions can be thrown. - p_e->m_p_next = m_a_p_entries[pos]; - m_a_p_entries[pos] = p_e; - resize_base::notify_inserted(++m_num_used_e); - PB_DS_DBG_ONLY(map_debug_base::insert_new( - PB_DS_V2F(r_val));) - - PB_DS_DBG_ONLY(assert_valid();) - - return (&p_e->m_value); + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return &p_e->m_value; } inline pointer insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) { // Following lines might throw an exception. - if (do_resize_if_needed()) - r_pos_hash_pair = ranged_hash_fn_base::operator()( - PB_DS_V2F(r_val)); + r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val)); - entry_pointer p_e = get_entry( r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); + entry_pointer p_e = get_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); // At this point no exceptions can be thrown. - p_e->m_hash = r_pos_hash_pair.second; - p_e->m_p_next = m_a_p_entries[r_pos_hash_pair.first]; - m_a_p_entries[r_pos_hash_pair.first] = p_e; - resize_base::notify_inserted(++m_num_used_e); - - PB_DS_DBG_ONLY(map_debug_base::insert_new( - PB_DS_V2F(r_val));) - - PB_DS_DBG_ONLY(assert_valid();) - - return (&p_e->m_value); + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return &p_e->m_value; } inline pointer find_key_pointer(const_key_reference r_key, store_hash_false_type) { - entry_pointer p_e = - m_a_p_entries[ranged_hash_fn_base::operator()(r_key)]; - + entry_pointer p_e = m_a_p_entries[ranged_hash_fn_base::operator()(r_key)]; resize_base::notify_find_search_start(); - - while (p_e != NULL&& + while (p_e != NULL && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_find_search_collision(); - p_e = p_e->m_p_next; } resize_base::notify_find_search_end(); -#ifdef PB_DS_CC_HT_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG if (p_e == NULL) map_debug_base::check_key_does_not_exist(r_key); else map_debug_base::check_key_exists(r_key); -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_ - - return (&p_e->m_value); +#endif + return &p_e->m_value; } inline pointer find_key_pointer(const_key_reference r_key, store_hash_true_type) { comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); - entry_pointer p_e = m_a_p_entries[pos_hash_pair.first]; - resize_base::notify_find_search_start(); - - while (p_e != NULL&& - !hash_eq_fn_base::operator()( - PB_DS_V2F(p_e->m_value), + while (p_e != NULL && + !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash, r_key, pos_hash_pair.second)) { resize_base::notify_find_search_collision(); - p_e = p_e->m_p_next; } resize_base::notify_find_search_end(); -#ifdef PB_DS_CC_HT_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG if (p_e == NULL) map_debug_base::check_key_does_not_exist(r_key); else map_debug_base::check_key_exists(r_key); -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_ - - return (&p_e->m_value); +#endif + return &p_e->m_value; } inline bool @@ -721,19 +616,17 @@ namespace pb_ds { inc_it_state((const_mapped_pointer& )r_p_value, r_pos); } -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif void - inc_it_state(const_pointer& r_p_value, std::pair& r_pos) const + inc_it_state(const_pointer& r_p_value, + std::pair& r_pos) const { - PB_DS_DBG_ASSERT(r_p_value != NULL); - + _GLIBCXX_DEBUG_ASSERT(r_p_value != NULL); r_pos.first = r_pos.first->m_p_next; - if (r_pos.first != NULL) { r_p_value =& r_pos.first->m_value; - return; } @@ -741,50 +634,43 @@ namespace pb_ds if (m_a_p_entries[r_pos.second] != NULL) { r_pos.first = m_a_p_entries[r_pos.second]; - r_p_value =& r_pos.first->m_value; - return; } - r_p_value = NULL; } void - get_start_it_state(pointer& r_p_value, std::pair& r_pos) const + get_start_it_state(pointer& r_p_value, + std::pair& r_pos) const { for (r_pos.second = 0; r_pos.second < m_num_e_p; ++r_pos.second) if (m_a_p_entries[r_pos.second] != NULL) { r_pos.first = m_a_p_entries[r_pos.second]; - r_p_value =& r_pos.first->m_value; - return; } - r_p_value = NULL; } -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG + void + assert_entry_pointer_array_valid(const entry_pointer_array) const; void - assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const; + assert_entry_pointer_valid(const entry_pointer, + store_hash_true_type) const; void - assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const; - - void - assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_type) const; - -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ + assert_entry_pointer_valid(const entry_pointer, + store_hash_false_type) const; +#endif #ifdef PB_DS_HT_MAP_TRACE_ - void trace_list(const_entry_pointer p_l) const; - -#endif // #ifdef PB_DS_HT_MAP_TRACE_ +#endif private: static entry_allocator s_entry_allocator; @@ -801,7 +687,7 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif friend class const_iterator_; @@ -815,11 +701,8 @@ namespace pb_ds enum { - store_hash_ok = - !Store_Hash || - !is_same< - Hash_Fn, - pb_ds::null_hash_fn>::value + store_hash_ok = !Store_Hash + || !is_same::value }; PB_DS_STATIC_ASSERT(sth, store_hash_ok); @@ -838,26 +721,16 @@ namespace pb_ds #include #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_HASH_EQ_FN_C_DEC - #undef PB_DS_RANGED_HASH_FN_C_DEC - #undef PB_DS_TYPES_TRAITS_C_DEC - #undef PB_DS_MAP_DEBUG_BASE_C_DEC - #undef PB_DS_CLASS_NAME #undef PB_DS_V2F #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - #undef PB_DS_STATIC_ASSERT } // namespace detail diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp index 6b398b0450c..94c1fc669a8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp @@ -78,7 +78,7 @@ cmp_with_other(const Other_Map_Type& other) const #ifdef PB_DS_DATA_TRUE_INDICATOR if (p_mapped_value->second != it->second) return (false); -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif } return (true); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp index 1fe673fd3de..9d6ee01efff 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp @@ -67,106 +67,87 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() : ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)), - m_a_p_entries(s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : - ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), - r_hash_fn), - m_a_p_entries(s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), - ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), - r_hash_fn), - m_a_p_entries(s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); - Resize_Policy::notify_cleared(); - ranged_hash_fn_base::notify_resized(m_num_e_p); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), - ranged_hash_fn_base( - resize_base::get_nearest_larger_size(1), + ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), - m_a_p_entries(s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn, const Resize_Policy& r_resize_policy) : PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn), Resize_Policy(r_resize_policy), - ranged_hash_fn_base( - resize_base::get_nearest_larger_size(1), + ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), - m_a_p_entries(s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_CC_HT_MAP_DEBUG_ - PB_DS_MAP_DEBUG_BASE_C_DEC(other), -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG + map_debug_base(other), +#endif PB_DS_HASH_EQ_FN_C_DEC(other), resize_base(other), ranged_hash_fn_base(other), - m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) try { copy_from_range(other.begin(), other.end()); @@ -174,44 +155,34 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : catch(...) { deallocate_all(); - throw; } - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_CLASS_NAME() -{ - deallocate_all(); -} +{ deallocate_all(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); std::swap(m_a_p_entries, other.m_a_p_entries); - std::swap(m_num_e_p, other.m_num_e_p); - std::swap(m_num_used_e, other.m_num_used_e); - ranged_hash_fn_base::swap(other); - hash_eq_fn_base::swap(other); - resize_base::swap(other); - PB_DS_DBG_ONLY(map_debug_base::swap(other)); - - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other)); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); } PB_DS_CLASS_T_DEC @@ -220,7 +191,6 @@ PB_DS_CLASS_C_DEC:: deallocate_all() { clear(); - s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p); } @@ -229,11 +199,8 @@ void PB_DS_CLASS_C_DEC:: initialize() { - std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); - + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, entry_pointer(NULL)); Resize_Policy::notify_resized(m_num_e_p); - Resize_Policy::notify_cleared(); - ranged_hash_fn_base::notify_resized(m_num_e_p); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp index db1eac3b7e5..3bf820f94e6 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp @@ -56,8 +56,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral // At this point no exceptions can be thrown. p_e->m_p_next = m_a_p_entries[pos]; - m_a_p_entries[pos] = p_e; - - PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);) - } + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp index 9771d093306..8dbbe5cbf99 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp @@ -51,15 +51,13 @@ PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(const_reference r_val, size_type pos, true_type) { // Following lines might throw an exception. - entry_pointer p_e = get_entry(r_val, traits_base::s_no_throw_copies_indicator); + entry_pointer p_e = get_entry(r_val, + traits_base::s_no_throw_copies_indicator); // At this point no exceptions can be thrown. - p_e->m_p_next = m_a_p_entries[pos]; - p_e->m_hash = ranged_hash_fn_base::operator()((const_key_reference)(PB_DS_V2F(p_e->m_value))).second; m_a_p_entries[pos] = p_e; - - PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);) - } + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp index 73f747c898a..9de8696c422 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of cc_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,7 +52,6 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { map_debug_base::check_size(m_num_used_e); - assert_entry_pointer_array_valid(m_a_p_entries); } @@ -62,25 +61,20 @@ PB_DS_CLASS_C_DEC:: assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const { size_type iterated_num_used_e = 0; - for (size_type pos = 0; pos < m_num_e_p; ++pos) { entry_pointer p_e = a_p_entries[pos]; - while (p_e != NULL) { ++iterated_num_used_e; - - assert_entry_pointer_valid(p_e, traits_base::m_store_hash_indicator); - + assert_entry_pointer_valid(p_e, traits_base::m_store_hash_indicator); p_e = p_e->m_p_next; } } - - PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e); + _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); } #include #include -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp index 205c6c6d553..42503edd18f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp @@ -44,14 +44,13 @@ * Contains implementations of cc_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_type) const -{ - map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); -} +assert_entry_pointer_valid(const entry_pointer p_e, + store_hash_false_type) const +{ map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); } -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp index 17dbca20d20..cfa2af6434b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of cc_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_CC_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC:: assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const { map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); + comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value)); - comp_hash pos_hash_pair = - ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value)); - - PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second); + _GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); } -#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp index 1b4148d4cc0..be92f2f9c8d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp @@ -49,7 +49,7 @@ inline void PB_DS_CLASS_C_DEC:: erase_entry_pointer(entry_pointer& r_p_e) { - PB_DS_DBG_ONLY(map_debug_base::erase_existing( + _GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing( PB_DS_V2F(r_p_e->m_value))); entry_pointer p_e = r_p_e; @@ -58,7 +58,7 @@ erase_entry_pointer(entry_pointer& r_p_e) rels_entry(p_e); - PB_DS_DBG_ASSERT(m_num_used_e > 0); + _GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0); resize_base::notify_erased(--m_num_used_e); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp index 5441555ab90..3d3dd9d1f81 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key))); @@ -61,7 +61,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(const_key_reference r_key, size_type pos) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) entry_pointer p_e = m_a_p_entries[pos]; @@ -71,10 +71,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( r_key);) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (false); } @@ -85,14 +85,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_exists(r_key);) erase_entry_pointer(m_a_p_entries[pos]); do_resize_if_needed_no_throw(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (true); } @@ -105,10 +105,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (false); } @@ -119,14 +119,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_exists(r_key);) erase_entry_pointer(p_e->m_p_next); do_resize_if_needed_no_throw(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp index fbc2dd5f2e5..490c365c9fd 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) entry_pointer p_e = m_a_p_entries[r_pos_hash_pair.first]; @@ -60,11 +60,11 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist( r_key);) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (false); } @@ -77,14 +77,14 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists( r_key);) erase_entry_pointer(m_a_p_entries[r_pos_hash_pair.first]); do_resize_if_needed_no_throw(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (true); } @@ -97,10 +97,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (false); } @@ -113,7 +113,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_exists( r_key);) @@ -121,7 +121,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) do_resize_if_needed_no_throw(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp index f1d68aa1dd0..942879f4e20 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp @@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (find_key_pointer(r_key, traits_base::m_store_extra_indicator)); } @@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (const_cast(*this).find_key_pointer( r_key, traits_base::m_store_extra_indicator)); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp index 6c5fa3cb54a..64ce3928f6a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp @@ -52,7 +52,7 @@ inline std::pair< PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, store_hash_false_type) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) const_key_reference r_key = PB_DS_V2F(r_val); @@ -74,13 +74,13 @@ insert_imp(const_reference r_val, store_hash_false_type) if (p_e != NULL) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return ( std::make_pair( & p_e->m_value, false)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (std::make_pair( insert_new_imp(r_val, pos), diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp index 480800a228d..b3841391d89 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp @@ -52,7 +52,7 @@ inline std::pair< PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, store_hash_true_type) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) const_key_reference r_key = PB_DS_V2F(r_val); @@ -77,12 +77,12 @@ insert_imp(const_reference r_val, store_hash_true_type) if (p_e != NULL) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return (std::make_pair( & p_e->m_value, false)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (std::make_pair( insert_new_imp(r_val, pos_hash_pair), diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp index ea15143a71a..b508d4da138 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp @@ -81,7 +81,7 @@ do_resize_if_needed_no_throw() catch(...) { } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -89,7 +89,7 @@ void PB_DS_CLASS_C_DEC:: resize_imp(size_type new_size) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (new_size == m_num_e_p) return; @@ -123,7 +123,7 @@ resize_imp(size_type new_size) Resize_Policy::notify_resized(new_size); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -143,13 +143,13 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res m_num_e_p = new_size; - PB_DS_DBG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);) + _GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);) s_entry_pointer_allocator.deallocate(m_a_p_entries, old_size); m_a_p_entries = a_p_entries_resized; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } #include diff --git a/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp b/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp index b143751b563..8218ea47ab5 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp @@ -49,34 +49,20 @@ #define PB_DS_HASH_EQ_FN_HPP #include +#include namespace pb_ds { namespace detail { - -#ifdef PB_DS_HASH_EQ_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_HASH_EQ_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_HASH_EQ_FN_DEBUG - template struct hash_eq_fn; -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - hash_eq_fn< \ - Key, \ - Eq_Fn, \ - Allocator, \ - false> +#define PB_DS_CLASS_C_DEC \ + hash_eq_fn /** * Specialization 1- The client requests that hash values not be stored. @@ -110,9 +96,7 @@ namespace pb_ds inline void PB_DS_CLASS_C_DEC:: swap(const PB_DS_CLASS_C_DEC& other) - { - std::swap((Eq_Fn& )(*this), (Eq_Fn& )other); - } + { std::swap((Eq_Fn& )(*this), (Eq_Fn& )other); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -124,22 +108,16 @@ namespace pb_ds inline bool PB_DS_CLASS_C_DEC:: operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const - { - return (eq_fn_base::operator()(r_lhs_key, r_rhs_key)); - } + { return (eq_fn_base::operator()(r_lhs_key, r_rhs_key)); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - hash_eq_fn< \ - Key, \ - Eq_Fn, \ - Allocator, \ - true> +#define PB_DS_CLASS_C_DEC \ + hash_eq_fn /** * Specialization 2- The client requests that hash values be stored. @@ -161,7 +139,8 @@ namespace pb_ds hash_eq_fn(const Eq_Fn& r_eq_fn); inline bool - operator()(const_key_reference r_lhs_key, size_type lhs_hash, const_key_reference r_rhs_key, size_type rhs_hash) const; + operator()(const_key_reference r_lhs_key, size_type lhs_hash, + const_key_reference r_rhs_key, size_type rhs_hash) const; inline void swap(const PB_DS_CLASS_C_DEC& other); @@ -181,12 +160,13 @@ namespace pb_ds PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: - operator()(const_key_reference r_lhs_key, size_type lhs_hash, const_key_reference r_rhs_key, size_type rhs_hash) const + operator()(const_key_reference r_lhs_key, size_type lhs_hash, + const_key_reference r_rhs_key, size_type rhs_hash) const { - PB_DS_DBG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key) || - lhs_hash == rhs_hash); + _GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key) + || lhs_hash == rhs_hash); - return (lhs_hash == rhs_hash&& + return (lhs_hash == rhs_hash && eq_fn_base::operator()(r_lhs_key, r_rhs_key)); } @@ -194,18 +174,12 @@ namespace pb_ds inline void PB_DS_CLASS_C_DEC:: swap(const PB_DS_CLASS_C_DEC& other) - { - std::swap((Eq_Fn& )(*this), (Eq_Fn& )(other)); - } + { std::swap((Eq_Fn& )(*this), (Eq_Fn& )(other)); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_HASH_EQ_FN_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp index 6ab4b265dc6..817bcd0ca70 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp @@ -63,44 +63,38 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() : ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -108,15 +102,13 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -124,15 +116,13 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob hash_eq_fn_base(r_eq_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn, r_probe_fn), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -141,22 +131,20 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob resize_base(r_resize_policy), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn, r_comb_hash_fn, r_probe_fn), - m_a_entries(s_entry_allocator.allocate( - resize_base::get_nearest_larger_size(1))), + m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0) { initialize(); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_GP_HT_MAP_DEBUG__ - PB_DS_MAP_DEBUG_BASE_C_DEC(other), -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG + map_debug_base(other), +#endif hash_eq_fn_base(other), resize_base(other), ranged_probe_fn_base(other), @@ -172,7 +160,6 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : for (size_type i = 0; i < m_num_e; ++i) { m_a_entries[i].m_stat = other.m_a_entries[i].m_stat; - if (m_a_entries[i].m_stat == valid_entry_status) new (m_a_entries + i) entry(other.m_a_entries[i]); } @@ -180,11 +167,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : catch(...) { deallocate_all(); - throw; } - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } PB_DS_CLASS_T_DEC @@ -199,25 +185,17 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); - + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); std::swap(m_a_entries, other.m_a_entries); - std::swap(m_num_e, other.m_num_e); - std::swap(m_num_used_e, other.m_num_used_e); - ranged_probe_fn_base::swap(other); - hash_eq_fn_base::swap(other); - resize_base::swap(other); - - PB_DS_DBG_ONLY(map_debug_base::swap(other)); - - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other)); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); } PB_DS_CLASS_T_DEC @@ -226,9 +204,7 @@ PB_DS_CLASS_C_DEC:: deallocate_all() { clear(); - erase_all_valid_entries(m_a_entries, m_num_e); - s_entry_allocator.deallocate(m_a_entries, m_num_e); } @@ -240,7 +216,6 @@ erase_all_valid_entries(entry_array a_entries_resized, size_type size) for (size_type pos = 0; pos < size; ++pos) { entry_pointer p_e =& a_entries_resized[pos]; - if (p_e->m_stat == valid_entry_status) p_e->m_value.~value_type(); } @@ -252,11 +227,8 @@ PB_DS_CLASS_C_DEC:: initialize() { Resize_Policy::notify_resized(m_num_e); - Resize_Policy::notify_cleared(); - ranged_probe_fn_base::notify_resized(m_num_e); - for (size_type i = 0; i < m_num_e; ++i) m_a_entries[i].m_stat = (entry_status)empty_entry_status; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp index 960a79045a9..c7a3d403ff4 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant) { - PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); + _GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); entry* const p_e = m_a_entries + pos; @@ -58,6 +58,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral p_e->m_stat = valid_entry_status; - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: insert_new(p_e->m_value.first);) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp index 95389795e77..74e5429b420 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline void PB_DS_CLASS_C_DEC:: constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_type) { - PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); + _GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); entry* const p_e = m_a_entries + pos; @@ -61,6 +61,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_typ p_e->m_stat = valid_entry_status; - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: insert_new(p_e->m_value.first);) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp index aaac10f76b2..1efdd183b80 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of gp_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,11 +52,10 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { map_debug_base::check_size(m_num_used_e); - assert_entry_array_valid(m_a_entries, traits_base::m_store_extra_indicator); } #include #include -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp index c55069ed18f..5669f60282b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of gp_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -74,11 +74,11 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) con break; } default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; } - PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e); + _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); } -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp index dc92deff77e..eef17cdd931 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of gp_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -56,7 +56,6 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons for (size_type pos = 0; pos < m_num_e; ++pos) { const_entry_pointer p_e =& a_entries[pos]; - switch(p_e->m_stat) { case empty_entry_status: @@ -64,26 +63,21 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons break; case valid_entry_status: { - const_key_reference r_key = - PB_DS_V2F(p_e->m_value); - + const_key_reference r_key = PB_DS_V2F(p_e->m_value); map_debug_base::check_key_exists(r_key); - const comp_hash pos_hash_pair = - ranged_probe_fn_base::operator()(r_key); - - PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second); + const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); + _GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); ++iterated_num_used_e; - break; } default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; } - PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e); + _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); } -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp index 92422873b40..df4f673bb5f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp @@ -49,9 +49,9 @@ inline void PB_DS_CLASS_C_DEC:: erase_entry(entry_pointer p_e) { - PB_DS_DBG_ASSERT(p_e->m_stat = valid_entry_status); + _GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status); - PB_DS_DBG_ONLY(map_debug_base::erase_existing( + _GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing( PB_DS_V2F(p_e->m_value));) typedef @@ -62,7 +62,7 @@ erase_entry(entry_pointer p_e) p_e->m_stat = erased_entry_status; - PB_DS_DBG_ASSERT(m_num_used_e > 0); + _GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0); resize_base::notify_erased(--m_num_used_e); } @@ -90,7 +90,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) size_type num_ersd = 0; @@ -109,7 +109,7 @@ erase_if(Pred pred) do_resize_if_needed_no_throw(); - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) return (num_ersd); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp index eb2bf9899fd..0f6949a912d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase_imp(const_key_reference r_key, false_type) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) size_type hash = ranged_probe_fn_base::operator()(r_key); @@ -71,7 +71,7 @@ erase_imp(const_key_reference r_key, false_type) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( r_key)); return (false); @@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, false_type) case erased_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_erase_search_collision(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp index a6f683160ce..d4eda6bda58 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp @@ -69,7 +69,7 @@ erase_imp(const_key_reference r_key, true_type) { resize_base::notify_erase_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( r_key)); return (false); @@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, true_type) case erased_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_erase_search_collision(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp index eb231d8b056..2f89522744e 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp @@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return ((find_key_pointer(r_key, traits_base::m_store_extra_indicator))); } @@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (const_cast(*this). find_key_pointer(r_key, traits_base::m_store_extra_indicator)); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp index 3f0c6c22d88..0497fbc8619 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp @@ -52,26 +52,17 @@ #include #ifdef PB_DS_HT_MAP_TRACE_ #include -#endif // PB_DS_HT_MAP_TRACE_ -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#endif +#ifdef _GLIBCXX_DEBUG #include -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#endif +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_GP_HT_MAP_DEBUG__ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_GP_HT_MAP_DEBUG__ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ - #define PB_DS_CLASS_T_DEC \ template< \ typename Key, \ @@ -85,14 +76,12 @@ namespace pb_ds class Resize_Policy> #ifdef PB_DS_DATA_TRUE_INDICATOR -#define PB_DS_CLASS_NAME \ - gp_ht_map_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#define PB_DS_CLASS_NAME gp_ht_map_data_ +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR -#define PB_DS_CLASS_NAME \ - gp_ht_map_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#define PB_DS_CLASS_NAME gp_ht_map_no_data_ +#endif #define PB_DS_CLASS_C_DEC \ PB_DS_CLASS_NAME< \ @@ -129,24 +118,20 @@ namespace pb_ds Allocator, \ Store_Hash> -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG #define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - Eq_Fn, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE + map_debug_base::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped() -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_STATIC_ASSERT(UNIQUE, E) \ typedef \ @@ -164,9 +149,9 @@ namespace pb_ds class Probe_Fn, class Resize_Policy> class PB_DS_CLASS_NAME : -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG protected PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif public PB_DS_HASH_EQ_FN_C_DEC, public Resize_Policy, public PB_DS_RANGED_PROBE_FN_C_DEC, @@ -362,7 +347,7 @@ namespace pb_ds inline std::pair insert(const_reference r_val) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) return (insert_imp(r_val, traits_base::m_store_extra_indicator)); } @@ -413,19 +398,15 @@ namespace pb_ds inline const_iterator end() const; -#ifdef PB_DS_GP_HT_MAP_DEBUG__ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif #ifdef PB_DS_HT_MAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_HT_MAP_TRACE_ +#endif private: typedef PB_DS_TYPES_TRAITS_C_DEC traits_base; @@ -462,9 +443,9 @@ namespace pb_ds typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base; -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ +#endif typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base; @@ -525,13 +506,13 @@ namespace pb_ds inline pointer insert_new_imp(const_reference r_val, size_type pos) { - PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); + _GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); if (do_resize_if_needed()) pos = find_ins_pos(PB_DS_V2F(r_val), traits_base::m_store_extra_indicator); - PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); + _GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status); entry* const p_e = m_a_entries + pos; @@ -541,10 +522,10 @@ namespace pb_ds resize_base::notify_inserted(++m_num_used_e); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: insert_new(PB_DS_V2F(p_e->m_value));) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (&p_e->m_value); } @@ -552,7 +533,7 @@ namespace pb_ds inline pointer insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) { - PB_DS_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != + _GLIBCXX_DEBUG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != valid_entry_status); if (do_resize_if_needed()) @@ -560,7 +541,7 @@ namespace pb_ds PB_DS_V2F(r_val), traits_base::m_store_extra_indicator); - PB_DS_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != + _GLIBCXX_DEBUG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != valid_entry_status); entry* const p_e = m_a_entries + r_pos_hash_pair.first; @@ -573,10 +554,10 @@ namespace pb_ds resize_base::notify_inserted(++m_num_used_e); - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(p_e->m_value));) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (&p_e->m_value); } @@ -585,7 +566,7 @@ namespace pb_ds inline mapped_reference subscript_imp(const_key_reference r_key, store_hash_false_type) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) const size_type pos = find_ins_pos(r_key, traits_base::m_store_extra_indicator); @@ -599,7 +580,7 @@ namespace pb_ds mapped_type()), pos)->second); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return (p_e->m_value.second); } @@ -607,7 +588,7 @@ namespace pb_ds inline mapped_reference subscript_imp(const_key_reference r_key, store_hash_true_type) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) comp_hash pos_hash_pair = find_ins_pos(r_key, traits_base::m_store_extra_indicator); @@ -619,7 +600,7 @@ namespace pb_ds mapped_type()), pos_hash_pair)->second); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); return ((m_a_entries + pos_hash_pair.first)->m_value.second); } @@ -649,7 +630,7 @@ namespace pb_ds { resize_base::notify_find_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) return (NULL); @@ -662,7 +643,7 @@ namespace pb_ds { resize_base::notify_find_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return ((pointer)&p_e->m_value); } @@ -670,13 +651,13 @@ namespace pb_ds case erased_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_find_search_collision(); } - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) resize_base::notify_find_search_end(); @@ -708,7 +689,7 @@ namespace pb_ds { resize_base::notify_find_search_end(); - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) return (NULL); @@ -722,7 +703,7 @@ namespace pb_ds { resize_base::notify_find_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return ((pointer)&p_e->m_value); } @@ -730,13 +711,13 @@ namespace pb_ds case erased_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_find_search_collision(); } - PB_DS_DBG_ONLY(map_debug_base:: + _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);) resize_base::notify_find_search_end(); @@ -764,7 +745,7 @@ namespace pb_ds void inc_it_state(const_pointer& r_p_value, size_type& r_pos) const { - PB_DS_DBG_ASSERT(r_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(r_p_value != NULL); for (++r_pos; r_pos < m_num_e; ++r_pos) { @@ -817,15 +798,15 @@ namespace pb_ds r_p_value = NULL; } -#ifdef PB_DS_GP_HT_MAP_DEBUG__ +#ifdef _GLIBCXX_DEBUG + void + assert_entry_array_valid(const entry_array a_entries, + store_hash_false_type) const; void - assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) const; - - void - assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) const; - -#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ + assert_entry_array_valid(const entry_array a_entries, + store_hash_true_type) const; +#endif private: static entry_allocator s_entry_allocator; @@ -880,10 +861,6 @@ namespace pb_ds #undef PB_DS_V2F #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - #undef PB_DS_STATIC_ASSERT } // namespace detail diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp index 0d627df1855..ef5ea837ff7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp @@ -66,7 +66,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type) const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); - PB_DS_DBG_ASSERT(pos < m_num_e); + _GLIBCXX_DEBUG_ASSERT(pos < m_num_e); entry* const p_e = m_a_entries + pos; @@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type) { resize_base::notify_insert_search_end(); - PB_DS_DBG_ONLY( + _GLIBCXX_DEBUG_ONLY( map_debug_base::check_key_does_not_exist(r_key);) return ((ins_pos == m_num_e)? pos : ins_pos); @@ -92,13 +92,13 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type) { resize_base::notify_insert_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return (pos); } break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_insert_search_collision(); @@ -124,14 +124,14 @@ insert_imp(const_reference r_val, store_hash_false_type) if (m_a_entries[pos].m_stat == valid_entry_status) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return (std::make_pair( & (m_a_entries + pos)->m_value, false)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); return (std::make_pair( insert_new_imp(r_val, pos), diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp index ff11ce3db9c..4f2ae016ed8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp @@ -50,7 +50,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: find_ins_pos(const_key_reference r_key, store_hash_true_type) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); @@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type) { resize_base::notify_insert_search_end(); - PB_DS_DBG_ONLY( + _GLIBCXX_DEBUG_ONLY( map_debug_base::check_key_does_not_exist(r_key);) return ((ins_pos == m_num_e)? @@ -97,13 +97,13 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type) { resize_base::notify_insert_search_end(); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return (std::make_pair(pos, pos_hash_pair.second)); } break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; resize_base::notify_insert_search_collision(); @@ -127,18 +127,18 @@ insert_imp(const_reference r_val, store_hash_true_type) comp_hash pos_hash_pair = find_ins_pos(r_key, traits_base::m_store_extra_indicator); - PB_DS_DBG_ASSERT(pos_hash_pair.first < m_num_e); + _GLIBCXX_DEBUG_ASSERT(pos_hash_pair.first < m_num_e); entry_pointer p_e =& m_a_entries[pos_hash_pair.first]; if (p_e->m_stat == valid_entry_status) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); return (std::make_pair(&p_e->m_value, false)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); return (std::make_pair( insert_new_imp(r_val, pos_hash_pair), diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp index 842169c08d3..fb31e2b0d1f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp @@ -81,7 +81,7 @@ do_resize_if_needed_no_throw() catch(...) { } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -96,7 +96,7 @@ resize_imp(size_type new_size) if (new_size == m_num_e) return; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) const size_type old_size = m_num_e; @@ -132,7 +132,7 @@ resize_imp(size_type new_size) // At this point no exceptions can be thrown. - PB_DS_DBG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator);) + _GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator);) Resize_Policy::notify_resized(new_size); @@ -142,7 +142,7 @@ resize_imp(size_type new_size) m_a_entries = a_entries_resized; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp index 1430d7171b1..32e1b111bdc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp @@ -73,12 +73,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash return; case erased_entry_status: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); break; case valid_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp index 4ab893023d9..e3dd24c070f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp @@ -76,12 +76,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash return; case erased_entry_status: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); break; case valid_entry_status: break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp index 4973c5bd31e..f41e38040e1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp @@ -70,7 +70,7 @@ trace() const std::cerr << PB_DS_V2F(m_a_entries[i].m_value); break; default: - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); }; std::cerr << std::endl; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp index bd07117b11c..e72a47ef825 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp @@ -51,48 +51,15 @@ namespace pb_ds { - namespace detail { - -#ifdef PROBE_FN_BASE_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PROBE_FN_BASE_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PROBE_FN_BASE_DEBUG - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - probe_fn_base< \ - Allocator> - template class probe_fn_base { protected: - ~probe_fn_base(); + ~probe_fn_base() { } }; - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - ~probe_fn_base() - { } - -#undef PB_DS_CLASS_T_DEC -#undef PB_DS_CLASS_C_DEC - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace detail - +} // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PROBE_FN_BASE_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp b/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp index f31d3c8303a..5d524859cfb 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp @@ -50,22 +50,13 @@ #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_RANGED_HASH_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_RANGED_HASH_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_RANGED_HASH_FN_DEBUG - template #include +#include namespace pb_ds { namespace detail { - -#ifdef PB_DS_RANGED_PROBE_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG - template +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ - #define PB_DS_CLASS_C_DEC \ - left_child_next_sibling_heap_const_iterator_< \ - Node, \ - Allocator> + left_child_next_sibling_heap_const_iterator_ #define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_node_const_point_iterator_< \ - Node, \ - Allocator> + left_child_next_sibling_heap_node_const_point_iterator_ // Const point-type iterator. template @@ -127,24 +114,18 @@ namespace pb_ds // Compares content to a different iterator object. inline bool operator==(const PB_DS_CLASS_C_DEC& other) const - { - return (base_type::m_p_nd == other.m_p_nd); - } + { return (base_type::m_p_nd == other.m_p_nd); } // Compares content (negatively) to a different iterator object. inline bool operator!=(const PB_DS_CLASS_C_DEC& other) const - { - return (base_type::m_p_nd != other.m_p_nd); - } + { return (base_type::m_p_nd != other.m_p_nd); } inline PB_DS_CLASS_C_DEC& operator++() { - PB_DS_DBG_ASSERT(base_type::m_p_nd != NULL); - + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != NULL); inc(); - return (*this); } @@ -152,9 +133,7 @@ namespace pb_ds operator++(int) { PB_DS_CLASS_C_DEC ret_it(base_type::m_p_nd); - operator++(); - return (ret_it); } @@ -165,10 +144,8 @@ namespace pb_ds if (base_type::m_p_nd->m_p_next_sibling != NULL) { base_type::m_p_nd = base_type::m_p_nd->m_p_next_sibling; - while (base_type::m_p_nd->m_p_l_child != NULL) base_type::m_p_nd = base_type::m_p_nd->m_p_l_child; - return; } @@ -176,7 +153,6 @@ namespace pb_ds { node_pointer p_next = base_type::m_p_nd; base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent; - if (base_type::m_p_nd == NULL || base_type::m_p_nd->m_p_l_child == p_next) return; } @@ -184,14 +160,9 @@ namespace pb_ds }; #undef PB_DS_CLASS_C_DEC - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp index 954b1335b9d..ea45b624ac1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp @@ -49,29 +49,18 @@ #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ;m_p_prev_or_parent -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ - #define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - left_child_next_sibling_heap_node_const_point_iterator_< \ - Node, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + left_child_next_sibling_heap_node_const_point_iterator_ // Const point-type iterator. template @@ -79,10 +68,7 @@ namespace pb_ds { protected: - typedef - typename Allocator::template rebind< - Node>::other::pointer - node_pointer; + typedef typename Allocator::template rebind::other::pointer node_pointer; public: @@ -127,49 +113,39 @@ namespace pb_ds // Default constructor. inline - left_child_next_sibling_heap_node_const_point_iterator_() - - : m_p_nd(NULL) + left_child_next_sibling_heap_node_const_point_iterator_() : m_p_nd(NULL) { } // Copy constructor. inline - left_child_next_sibling_heap_node_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) - - : m_p_nd(other.m_p_nd) + left_child_next_sibling_heap_node_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd) { } // Access. inline const_pointer operator->() const { - PB_DS_DBG_ASSERT(m_p_nd != NULL); - - return (&m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL); + return &m_p_nd->m_value; } // Access. inline const_reference operator*() const { - PB_DS_DBG_ASSERT(m_p_nd != NULL); - - return (m_p_nd->m_value); + _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL); + return m_p_nd->m_value; } // Compares content to a different iterator object. inline bool operator==(const PB_DS_CLASS_C_DEC& other) const - { - return (m_p_nd == other.m_p_nd); - } + { return m_p_nd == other.m_p_nd; } // Compares content (negatively) to a different iterator object. inline bool operator!=(const PB_DS_CLASS_C_DEC& other) const - { - return (m_p_nd != other.m_p_nd); - } + { return m_p_nd != other.m_p_nd; } public: node_pointer m_p_nd; @@ -178,11 +154,7 @@ namespace pb_ds #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp index 97d8277e69d..0d310d511d4 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp @@ -58,7 +58,7 @@ left_child_next_sibling_heap_() : m_p_root(NULL), m_size(0) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -68,7 +68,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) : m_p_root(NULL), m_size(0) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -80,13 +80,13 @@ left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) : { m_size = other.m_size; - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) m_p_root = recursive_copy_node(other.m_p_root); m_size = other.m_size; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -94,15 +94,15 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp index 72c0ca1b0ef..f16e912018f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp @@ -44,20 +44,18 @@ * Contains an implementation class for left_child_next_sibling_heap_. */ -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { - PB_DS_DBG_ASSERT(m_p_root == NULL || m_p_root->m_p_prev_or_parent == NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_root == NULL || m_p_root->m_p_prev_or_parent == NULL); if (m_p_root != NULL) assert_node_consistent(m_p_root, Single_Link_Roots); - assert_size(); - assert_iterators(); } @@ -73,25 +71,21 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const assert_node_consistent(p_nd->m_p_next_sibling, single_link); if (single_link) - PB_DS_DBG_ASSERT(p_nd->m_p_prev_or_parent == NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent == NULL); else if (p_nd->m_p_next_sibling != NULL) - PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); if (p_nd->m_p_l_child == NULL) return; const_node_pointer p_child = p_nd->m_p_l_child; - while (p_child != NULL) { const_node_pointer p_next_child = p_child->m_p_next_sibling; - - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); - + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); p_child = p_next_child; } - - PB_DS_DBG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); } PB_DS_CLASS_T_DEC @@ -100,11 +94,9 @@ PB_DS_CLASS_C_DEC:: assert_iterators() const { const size_type calc_size = std::distance(begin(), end()); - if (calc_size == size()) return; - - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); } PB_DS_CLASS_T_DEC @@ -114,17 +106,14 @@ assert_size() const { if (size_from_node(m_p_root) == m_size) return; - - PB_DS_DBG_ASSERT(0); + _GLIBCXX_DEBUG_ASSERT(0); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size_under_node(const_node_pointer p_nd) -{ - return 1 + size_from_node(p_nd->m_p_l_child); -} +{ return 1 + size_from_node(p_nd->m_p_l_child); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type @@ -132,14 +121,11 @@ PB_DS_CLASS_C_DEC:: size_from_node(const_node_pointer p_nd) { size_type ret = 0; - while (p_nd != NULL) { ret += 1 + size_from_node(p_nd->m_p_l_child); - p_nd = p_nd->m_p_next_sibling; } - return ret; } @@ -149,17 +135,13 @@ PB_DS_CLASS_C_DEC:: degree(const_node_pointer p_nd) { size_type ret = 0; - const_node_pointer p_child = p_nd->m_p_l_child; - while (p_child != NULL) { ++ret; - p_child = p_child->m_p_next_sibling; } - return ret; } -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp index 4b88eec98f7..52817639f99 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp @@ -50,8 +50,7 @@ PB_DS_CLASS_C_DEC:: clear() { clear_imp(m_p_root); - - PB_DS_DBG_ASSERT(m_size == 0); + _GLIBCXX_DEBUG_ASSERT(m_size == 0); m_p_root = NULL; } @@ -60,11 +59,9 @@ inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_nd) { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - p_nd->~node(); - s_node_allocator.deallocate(p_nd, 1); } @@ -76,11 +73,8 @@ clear_imp(node_pointer p_nd) while (p_nd != NULL) { clear_imp(p_nd->m_p_l_child); - node_pointer p_next = p_nd->m_p_next_sibling; - actual_erase_node(p_nd); - p_nd = p_next; } } @@ -90,40 +84,30 @@ void PB_DS_CLASS_C_DEC:: to_linked_list() { - PB_DS_DBG_ONLY(assert_valid();) - - node_pointer p_cur = m_p_root; - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + node_pointer p_cur = m_p_root; while (p_cur != NULL) if (p_cur->m_p_l_child != NULL) { node_pointer p_child_next = p_cur->m_p_l_child->m_p_next_sibling; - p_cur->m_p_l_child->m_p_next_sibling = p_cur->m_p_next_sibling; - p_cur->m_p_next_sibling = p_cur->m_p_l_child; - p_cur->m_p_l_child = p_child_next; } else p_cur = p_cur->m_p_next_sibling; -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG const_node_pointer p_counter = m_p_root; - size_type count = 0; - while (p_counter != NULL) { ++count; - - PB_DS_DBG_ASSERT(p_counter->m_p_l_child == NULL); - + _GLIBCXX_DEBUG_ASSERT(p_counter->m_p_l_child == NULL); p_counter = p_counter->m_p_next_sibling; } - - PB_DS_DBG_ASSERT(count == m_size); -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ + _GLIBCXX_DEBUG_ASSERT(count == m_size); +#endif } PB_DS_CLASS_T_DEC @@ -133,37 +117,27 @@ PB_DS_CLASS_C_DEC:: prune(Pred pred) { node_pointer p_cur = m_p_root; - m_p_root = NULL; - node_pointer p_out = NULL; - while (p_cur != NULL) { node_pointer p_next = p_cur->m_p_next_sibling; - if (pred(p_cur->m_value)) { p_cur->m_p_next_sibling = p_out; - if (p_out != NULL) p_out->m_p_prev_or_parent = p_cur; - p_out = p_cur; } else { p_cur->m_p_next_sibling = m_p_root; - if (m_p_root != NULL) m_p_root->m_p_prev_or_parent = p_cur; - m_p_root = p_cur; } - p_cur = p_next; } - return p_out; } @@ -173,11 +147,9 @@ PB_DS_CLASS_C_DEC:: bubble_to_top(node_pointer p_nd) { node_pointer p_parent = parent(p_nd); - while (p_parent != NULL) { swap_with_parent(p_nd, p_parent); - p_parent = parent(p_nd); } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp index 32c36783697..479690d2bc9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp @@ -93,8 +93,8 @@ inline void PB_DS_CLASS_C_DEC:: make_child_of(node_pointer p_nd, node_pointer p_new_parent) { - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(p_new_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_new_parent != NULL); p_nd->m_p_next_sibling = p_new_parent->m_p_l_child; @@ -130,9 +130,9 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent) if (p_parent == m_p_root) m_p_root = p_nd; - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(p_parent != NULL); - PB_DS_DBG_ASSERT(parent(p_nd) == p_parent); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent); const bool nd_direct_child = p_parent->m_p_l_child == p_nd; const bool parent_root = p_parent->m_p_prev_or_parent == NULL; @@ -144,8 +144,8 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent) std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child); std::swap(p_parent->m_metadata, p_nd->m_metadata); - PB_DS_DBG_ASSERT(p_nd->m_p_l_child != NULL); - PB_DS_DBG_ASSERT(p_parent->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != NULL); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != NULL); if (p_nd->m_p_next_sibling != NULL) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd; @@ -169,13 +169,13 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent) } else { - PB_DS_DBG_ASSERT(p_nd->m_p_l_child == p_nd); - PB_DS_DBG_ASSERT(p_parent->m_p_prev_or_parent == p_parent); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent); p_nd->m_p_l_child = p_parent; p_parent->m_p_prev_or_parent = p_nd; } - PB_DS_DBG_ASSERT(parent(p_parent) == p_nd); + _GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp index 411c4f28b14..e06358d2f22 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp @@ -59,24 +59,15 @@ #include #ifdef PB_DS_LC_NS_HEAP_TRACE_ #include -#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ +#endif +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ - -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG #define PB_DS_CLASS_T_DEC \ template< \ typename Value_Type, \ @@ -84,16 +75,16 @@ namespace pb_ds typename Node_Metadata, \ class Allocator, \ bool Single_Link_Roots> -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#else #define PB_DS_CLASS_T_DEC \ template< \ typename Value_Type, \ class Cmp_Fn, \ typename Node_Metadata, \ class Allocator> -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap_< \ Value_Type, \ @@ -101,30 +92,30 @@ namespace pb_ds Node_Metadata, \ Allocator, \ Single_Link_Roots> -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#else #define PB_DS_CLASS_C_DEC \ left_child_next_sibling_heap_< \ Value_Type, \ Cmp_Fn, \ Node_Metadata, \ Allocator> -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif /** * class description = "Base class for some types of h3ap$"> **/ -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG template -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#else template -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif class left_child_next_sibling_heap_ : public Cmp_Fn { @@ -152,8 +143,7 @@ namespace pb_ds enum { - simple_value = is_simple< - Value_Type>::value + simple_value = is_simple::value }; typedef integral_constant no_throw_copies_t; @@ -250,11 +240,9 @@ namespace pb_ds clear(); #ifdef PB_DS_LC_NS_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ +#endif protected: @@ -289,8 +277,7 @@ namespace pb_ds node_pointer prune(Pred pred); -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; @@ -302,15 +289,12 @@ namespace pb_ds static size_type degree(const_node_pointer p_nd); - -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif #ifdef PB_DS_LC_NS_HEAP_TRACE_ - static void trace_node(const_node_pointer, size_type level); - -#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ +#endif protected: node_pointer m_p_root; @@ -318,8 +302,7 @@ namespace pb_ds size_type m_size; private: -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_iterators() const; @@ -328,8 +311,7 @@ namespace pb_ds static size_type size_from_node(const_node_pointer p_nd); - -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif node_pointer recursive_copy_node(const_node_pointer p_nd); @@ -341,15 +323,13 @@ namespace pb_ds get_new_node_for_insert(const_reference r_val, true_type); #ifdef PB_DS_LC_NS_HEAP_TRACE_ - template static void trace_node_metadata(const_node_pointer p_nd, type_to_type); static void trace_node_metadata(const_node_pointer, type_to_type); - -#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ +#endif private: static node_allocator s_node_allocator; @@ -367,14 +347,9 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp index b9cc9dd81c6..932b3412390 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp @@ -73,69 +73,57 @@ copy_from_range(It first_it, It last_it) PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: -PB_DS_CLASS_NAME() : - m_p_l(NULL) -{ - PB_DS_DBG_ONLY(assert_valid();) - } +PB_DS_CLASS_NAME() : m_p_l(NULL) +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC template PB_DS_CLASS_C_DEC:: -PB_DS_CLASS_NAME(It first_it, It last_it) : - m_p_l(NULL) +PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(NULL) { copy_from_range(first_it, last_it); - - PB_DS_DBG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(assert_valid();); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: -PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_LU_MAP_DEBUG_ - PB_DS_MAP_DEBUG_BASE_C_DEC(), -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ - m_p_l(NULL) +PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : +#ifdef _GLIBCXX_DEBUG + map_debug_base(), +#endif +m_p_l(NULL) { try { - for (const_iterator it = other.begin(); it != other.end(); ++it) { - entry_pointer p_l = - allocate_new_entry( * it, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); + entry_pointer p_l = allocate_new_entry(*it, + PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); p_l->m_p_next = m_p_l; - m_p_l = p_l; } } catch(...) { deallocate_all(); - throw; } - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - - PB_DS_DBG_ONLY(map_debug_base::swap(other);) - - std::swap(m_p_l, other.m_p_l); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);) + std::swap(m_p_l, other.m_p_l); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) +} PB_DS_CLASS_T_DEC void @@ -143,23 +131,17 @@ PB_DS_CLASS_C_DEC:: deallocate_all() { entry_pointer p_l = m_p_l; - while (p_l != NULL) { entry_pointer p_next_l = p_l->m_p_next; - actual_erase_entry(p_l); - p_l = p_next_l; } - m_p_l = NULL; } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_CLASS_NAME() -{ - deallocate_all(); -} +{ deallocate_all(); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp index a48c17db804..1427f83749b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains implementations of cc_ht_map_'s debug-mode functions. */ -#ifdef PB_DS_LU_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,15 +52,12 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { size_type calc_size = 0; - for (const_iterator it = begin(); it != end(); ++it) { map_debug_base::check_key_exists(PB_DS_V2F(*it)); - ++calc_size; } - map_debug_base::check_size(calc_size); } -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp index 5800540b2cb..d23c76beb2f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp @@ -49,7 +49,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase(const_key_reference r_key) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) if (m_p_l == NULL) return false; @@ -94,7 +94,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) size_type num_ersd = 0; @@ -126,7 +126,7 @@ erase_if(Pred pred) p_l = p_l->m_p_next; } - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) return (num_ersd); } @@ -136,9 +136,9 @@ void PB_DS_CLASS_C_DEC:: erase_next(entry_pointer p_l) { - PB_DS_DBG_ASSERT(p_l != NULL); - PB_DS_DBG_ASSERT(p_l != m_p_l); - PB_DS_DBG_ASSERT(p_l->m_p_next != NULL); + _GLIBCXX_DEBUG_ASSERT(p_l != NULL); + _GLIBCXX_DEBUG_ASSERT(p_l != m_p_l); + _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != NULL); entry_pointer p_next_l = p_l->m_p_next->m_p_next; @@ -152,7 +152,7 @@ void PB_DS_CLASS_C_DEC:: actual_erase_entry(entry_pointer p_l) { - PB_DS_DBG_ONLY(map_debug_base::erase_existing( + _GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing( PB_DS_V2F(p_l->m_value));) p_l->~entry(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp index ce8d995b212..dd43185896e 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp @@ -56,7 +56,7 @@ find_imp(const_key_reference r_key) const { apply_update(m_p_l, s_metadata_type_indicator); - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);) return m_p_l; } @@ -86,7 +86,7 @@ find_imp(const_key_reference r_key) const p_l = p_next; } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return NULL; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp index ad42590c408..a9b94ead688 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp @@ -51,19 +51,19 @@ inline std::pair< PB_DS_CLASS_C_DEC:: insert(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); if (p_l != NULL) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists( PB_DS_V2F(r_val));) return std::make_pair(point_iterator(&p_l->m_value), false); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( PB_DS_V2F(r_val));) p_l = allocate_new_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); @@ -72,7 +72,7 @@ insert(const_reference r_val) m_p_l = p_l; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return std::make_pair(point_iterator(&p_l->m_value), true); } @@ -92,7 +92,7 @@ allocate_new_entry(const_reference r_val, false_type) cond.set_no_action(); - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(r_val));) init_entry_metadata(p_l, s_metadata_type_indicator); @@ -109,7 +109,7 @@ allocate_new_entry(const_reference r_val, true_type) new (&p_l->m_value) value_type(r_val); - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(r_val));) init_entry_metadata(p_l, s_metadata_type_indicator); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp index 3c76377aa45..4fd72070a16 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp @@ -51,7 +51,7 @@ begin() { if (m_p_l == NULL) { - PB_DS_DBG_ASSERT(empty()); + _GLIBCXX_DEBUG_ASSERT(empty()); return (end()); } @@ -66,7 +66,7 @@ begin() const { if (m_p_l == NULL) { - PB_DS_DBG_ASSERT(empty()); + _GLIBCXX_DEBUG_ASSERT(empty()); return (end()); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp index 5451f56ae09..6eaa370f0b1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp @@ -51,94 +51,56 @@ #include #include #include -#ifdef PB_DS_LU_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG #include -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif #ifdef PB_DS_LU_MAP_TRACE_ #include -#endif // PB_DS_LU_MAP_TRACE_ +#endif +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_LU_MAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_LU_MAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ - template< \ - typename Key, \ - typename Mapped, \ - class Eq_Fn, \ - class Allocator, \ - class Update_Policy> +#define PB_DS_CLASS_T_DEC \ + template #ifdef PB_DS_DATA_TRUE_INDICATOR -#define PB_DS_CLASS_NAME \ - lu_map_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#define PB_DS_CLASS_NAME lu_map_data_ +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR -#define PB_DS_CLASS_NAME \ - lu_map_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#define PB_DS_CLASS_NAME lu_map_no_data_ +#endif -#define PB_DS_CLASS_C_DEC \ - PB_DS_CLASS_NAME< \ - Key, \ - Mapped, \ - Eq_Fn, \ - Allocator, \ - Update_Policy> +#define PB_DS_CLASS_C_DEC \ + PB_DS_CLASS_NAME -#define PB_DS_TYPES_TRAITS_C_DEC \ - types_traits< \ - Key, \ - Mapped, \ - Allocator, \ - false> +#define PB_DS_TYPES_TRAITS_C_DEC \ + types_traits -#ifdef PB_DS_USE_MAP_DEBUG_BASE -#define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - Eq_Fn, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG +#define PB_DS_MAP_DEBUG_BASE_C_DEC \ + map_debug_base::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR - -#ifdef PB_DS_LU_MAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_LU_MAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif /* Skip to the lu, my darling. */ - // list-based (with updates) associative container. template class PB_DS_CLASS_NAME : -#ifdef PB_DS_LU_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG protected PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif public PB_DS_TYPES_TRAITS_C_DEC { private: - struct entry : public lu_map_entry_metadata_base< - typename Update_Policy::metadata_type> + struct entry : public lu_map_entry_metadata_base { typename PB_DS_TYPES_TRAITS_C_DEC::value_type m_value; @@ -172,9 +133,7 @@ namespace pb_ds typedef typename entry_allocator::reference entry_reference; - typedef - typename entry_allocator::const_reference - const_entry_reference; + typedef typename entry_allocator::const_reference const_entry_reference; typedef typename Allocator::template rebind::other @@ -265,21 +224,21 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR typedef point_iterator_ point_iterator; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_point_iterator_ point_iterator; -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif typedef const_point_iterator_ const_point_iterator; #ifdef PB_DS_DATA_TRUE_INDICATOR typedef iterator_ iterator; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR typedef const_iterator_ iterator; -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif typedef const_iterator_ const_iterator; @@ -311,39 +270,31 @@ namespace pb_ds operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - PB_DS_DBG_ONLY(assert_valid();) - - return insert(std::make_pair(r_key, mapped_type())).first->second; -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return insert(std::make_pair(r_key, mapped_type())).first->second; +#else insert(r_key); - - return (traits_base::s_null_mapped); -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR + return traits_base::s_null_mapped; +#endif } - inline std::pair< - point_iterator, - bool> + inline std::pair insert(const_reference r_val); inline point_iterator find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) - - entry_pointer p_e = find_imp(r_key); - - return point_iterator(p_e == NULL? NULL :& p_e->m_value); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + entry_pointer p_e = find_imp(r_key); + return point_iterator(p_e == NULL ? NULL: &p_e->m_value); } inline const_point_iterator find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) - - entry_pointer p_e = find_imp(r_key); - - return const_point_iterator(p_e == NULL? NULL :& p_e->m_value); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + entry_pointer p_e = find_imp(r_key); + return const_point_iterator(p_e == NULL ? NULL: &p_e->m_value); } inline bool @@ -368,26 +319,22 @@ namespace pb_ds inline const_iterator end() const; -#ifdef PB_DS_LU_MAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif #ifdef PB_DS_LU_MAP_TRACE_ - void trace() const; - -#endif // PB_DS_LU_MAP_TRACE_ +#endif private: typedef PB_DS_TYPES_TRAITS_C_DEC traits_base; -#ifdef PB_DS_LU_MAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_LU_MAP_DEBUG_ +#endif typedef typename PB_DS_TYPES_TRAITS_C_DEC:: @@ -433,7 +380,6 @@ namespace pb_ds inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const { r_pos = r_pos->m_p_next; - r_p_value = (r_pos == NULL)? NULL :& r_pos->m_value; } @@ -454,7 +400,7 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif friend class const_iterator_; @@ -479,22 +425,14 @@ namespace pb_ds #include #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_TYPES_TRAITS_C_DEC - #undef PB_DS_MAP_DEBUG_BASE_C_DEC - #undef PB_DS_CLASS_NAME #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp index b154a9baf06..fce62566edc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/map_debug_base.hpp @@ -38,7 +38,7 @@ // representation about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. - + /** * @file map_debug_base.hpp * Contains a debug-mode base for all maps. @@ -47,37 +47,23 @@ #ifndef PB_DS_MAP_DEBUG_BASE_HPP #define PB_DS_MAP_DEBUG_BASE_HPP -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG -#include #include #include -#include +#include +#include namespace pb_ds { - namespace detail { -#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - map_debug_base< \ - Key, \ - Eq_Fn, \ - Const_Key_Reference> +#define PB_DS_CLASS_C_DEC \ + map_debug_base template class map_debug_base @@ -119,23 +105,20 @@ namespace pb_ds template void - split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other); + split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&); void join(PB_DS_CLASS_C_DEC& other); private: - typedef std::list< Key> key_set; + typedef std::list< Key> key_set; + typedef typename key_set::iterator key_set_iterator; + typedef typename key_set::const_iterator const_key_set_iterator; - typedef typename key_set::iterator key_set_iterator; - - typedef typename key_set::const_iterator const_key_set_iterator; - - private: -#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG +#ifdef _GLIBCXX_DEBUG void assert_valid() const; -#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG +#endif const_key_set_iterator find(const_key_reference r_key) const; @@ -143,51 +126,37 @@ namespace pb_ds key_set_iterator find(const_key_reference r_key); - private: - key_set m_key_set; - - Eq_Fn m_eq; + key_set m_key_set; + Eq_Fn m_eq; }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: map_debug_base() - { - PB_DS_DBG_ONLY(assert_valid();) - } + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - map_debug_base(const PB_DS_CLASS_C_DEC& other) : - m_key_set(other.m_key_set) - { - PB_DS_DBG_ONLY(assert_valid();) - } + map_debug_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set) + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~map_debug_base() - { - PB_DS_DBG_ONLY(assert_valid();) - } + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_new(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) - - pb_ds::test::dbg_ex_allocator alloc; - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + pb_ds::test::dbg_ex_allocator alloc; const double orig_throw_prob = alloc.get_throw_prob(); - alloc.set_throw_prob(0); - if (find(r_key) != m_key_set.end()) { std::cerr << "insert_new " << r_key << std::endl; - abort(); } @@ -198,78 +167,63 @@ namespace pb_ds catch(...) { std::cerr << "insert_new 1" << r_key << std::endl; - abort(); } - alloc.set_throw_prob(orig_throw_prob); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: erase_existing(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) - - key_set_iterator it = find(r_key); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + key_set_iterator it = find(r_key); if (it == m_key_set.end()) { std::cerr << "erase_existing " << r_key << std::endl; - abort(); } - m_key_set.erase(it); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(assert_valid();) - - m_key_set.clear(); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + m_key_set.clear(); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: check_key_exists(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) - - if (find(r_key) == m_key_set.end()) - { - std::cerr << "check_key_exists " << r_key << std::endl; - - abort(); - } - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + if (find(r_key) == m_key_set.end()) + { + std::cerr << "check_key_exists " << r_key << std::endl; + abort(); + } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: check_key_does_not_exist(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) - - if (find(r_key) != m_key_set.end()) - { - std::cerr << "check_key_does_not_exist " << r_key << std::endl; - - abort(); - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + if (find(r_key) != m_key_set.end()) + { + std::cerr << "check_key_does_not_exist " << r_key << std::endl; + abort(); + } } PB_DS_CLASS_T_DEC @@ -277,45 +231,38 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: check_size(size_type size) const { - PB_DS_DBG_ONLY(assert_valid();) - - const size_type key_set_size = m_key_set.size(); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + const size_type key_set_size = m_key_set.size(); if (size != key_set_size) { - std::cerr << "check_size " << size << " " << key_set_size << std::endl; - + std::cerr << "check_size " << size + << " " << key_set_size << std::endl; abort(); } - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - - m_key_set.swap(other.m_key_set); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + m_key_set.swap(other.m_key_set); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::const_key_set_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) - - for (const_key_set_iterator it = m_key_set.begin(); it != m_key_set.end(); - ++it) - if (m_eq(*it, r_key)) - return (it); - - return (m_key_set.end()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + typedef const_key_set_iterator iterator_type; + for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it) + if (m_eq(*it, r_key)) + return it; + return m_key_set.end(); } PB_DS_CLASS_T_DEC @@ -323,49 +270,39 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) - - key_set_iterator it = m_key_set.begin(); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + key_set_iterator it = m_key_set.begin(); while (it != m_key_set.end()) { if (m_eq(*it, r_key)) - return (it); - + return it; ++it; } + return it; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } - return (it); - - PB_DS_DBG_ONLY(assert_valid();) - } - -#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { const_key_set_iterator prime_it = m_key_set.begin(); - while (prime_it != m_key_set.end()) { const_key_set_iterator sec_it = prime_it; - ++sec_it; - while (sec_it != m_key_set.end()) { - assert(!m_eq(*sec_it, * prime_it)); - assert(!m_eq(*prime_it, * sec_it)); - + _GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it)); + _GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it)); ++sec_it; } - ++prime_it; } } -#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG +#endif PB_DS_CLASS_T_DEC template @@ -374,25 +311,18 @@ namespace pb_ds split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other) { pb_ds::test::dbg_ex_allocator alloc; - const double orig_throw_prob = alloc.get_throw_prob(); - alloc.set_throw_prob(0); - other.clear(); - key_set_iterator it = m_key_set.begin(); - while (it != m_key_set.end()) if (cmp_fn(r_key, * it)) { other.insert_new(*it); - it = m_key_set.erase(it); } else ++it; - alloc.set_throw_prob(orig_throw_prob); } @@ -402,37 +332,25 @@ namespace pb_ds join(PB_DS_CLASS_C_DEC& other) { pb_ds::test::dbg_ex_allocator alloc; - const double orig_throw_prob = alloc.get_throw_prob(); - alloc.set_throw_prob(0); - key_set_iterator it = other.m_key_set.begin(); - while (it != other.m_key_set.end()) { insert_new(*it); - it = other.m_key_set.erase(it); } - - PB_DS_DBG_ASSERT(other.m_key_set.empty()); - + _GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty()); alloc.set_throw_prob(orig_throw_prob); } #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace detail - +} // namespace detail } // namespace pb_ds -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#endif -#endif // #ifndef PB_DS_MAP_DEBUG_BASE_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp index 47e6e67b332..072fce447a8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp @@ -48,23 +48,19 @@ template class cond_dtor { public: - cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size) : m_a_vec(a_vec), - m_r_last_it(r_last_it), - m_max_size(total_size), - m_no_action(false) + cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size) + : m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size), + m_no_action(false) { } ~cond_dtor() { if (m_no_action) return; - iterator it = m_a_vec; - while (it != m_r_last_it) { it->~value_type(); - ++it; } @@ -74,16 +70,11 @@ public: inline void set_no_action() - { - m_no_action = true; - } + { m_no_action = true; } protected: value_vector m_a_vec; - iterator& m_r_last_it; - const Size_Type m_max_size; - bool m_no_action; }; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp index 642f79b8243..ecd6aeab386 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp @@ -59,9 +59,7 @@ PB_DS_OV_TREE_CLASS_NAME() : m_a_metadata(NULL), m_end_it(NULL), m_size(0) -{ - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -71,9 +69,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : m_a_metadata(NULL), m_end_it(NULL), m_size(0) -{ - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -84,19 +80,17 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_updat m_a_metadata(NULL), m_end_it(NULL), m_size(0) -{ - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } +{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_OV_TREE_DEBUG_ - PB_DS_MAP_DEBUG_BASE_C_DEC(other), -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG + map_debug_base(other), +#endif #ifdef PB_DS_TREE_TRACE PB_DS_TREE_TRACE_BASE_C_DEC(other), -#endif // #ifdef PB_DS_TREE_TRACE +#endif cmp_fn_base(other), node_update(other), m_a_values(NULL), @@ -105,9 +99,8 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : m_size(0) { copy_from_ordered_range(other.begin(), other.end()); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) +} PB_DS_CLASS_T_DEC template @@ -124,7 +117,7 @@ copy_from_range(It first_it, It last_it) typename Allocator::template rebind< value_type>::other> map_type; -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR +#else typedef std::set< key_type, @@ -132,10 +125,9 @@ copy_from_range(It first_it, It last_it) typename Allocator::template rebind< Key>::other> map_type; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif map_type m(first_it, last_it); - copy_from_ordered_range(m.begin(), m.end()); } @@ -146,64 +138,51 @@ PB_DS_CLASS_C_DEC:: copy_from_ordered_range(It first_it, It last_it) { const size_type size = std::distance(first_it, last_it); - if (size == 0) return; value_vector a_values = s_value_alloc.allocate(size); - iterator target_it = a_values; It source_it = first_it; It source_end_it = last_it; cond_dtor cd(a_values, target_it, size); - while (source_it != source_end_it) { - new (const_cast( - static_cast(target_it))) + new (const_cast(static_cast(target_it))) value_type(*source_it++); ++target_it; } reallocate_metadata((node_update* )this, size); - cd.set_no_action(); - m_a_values = a_values; - m_size = size; - m_end_it = m_a_values + m_size; - update(PB_DS_node_begin_imp(), (node_update* )this); -#ifdef PB_DS_OV_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const_iterator dbg_it = m_a_values; - while (dbg_it != m_end_it) { map_debug_base::insert_new(PB_DS_V2F(*dbg_it)); - dbg_it++; } - PB_DS_CLASS_C_DEC::assert_valid(); -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#endif } PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: -copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it) +copy_from_ordered_range(It first_it, It last_it, It other_first_it, + It other_last_it) { clear(); - - const size_type size = - std::distance(first_it, last_it) + - std::distance(other_first_it, other_last_it); + const size_type size = std::distance(first_it, last_it) + + std::distance(other_first_it, other_last_it); value_vector a_values = s_value_alloc.allocate(size); @@ -212,13 +191,10 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_las It source_end_it = last_it; cond_dtor cd(a_values, target_it, size); - while (source_it != source_end_it) { - new (const_cast( - static_cast(target_it))) + new (const_cast(static_cast(target_it))) value_type(*source_it++); - ++target_it; } @@ -227,37 +203,27 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_las while (source_it != source_end_it) { - new (const_cast( - static_cast(target_it))) + new (const_cast(static_cast(target_it))) value_type(*source_it++); - ++target_it; } reallocate_metadata((node_update* )this, size); - cd.set_no_action(); - m_a_values = a_values; - m_size = size; - m_end_it = m_a_values + m_size; - update(PB_DS_node_begin_imp(), (node_update* )this); -#ifdef PB_DS_OV_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const_iterator dbg_it = m_a_values; - while (dbg_it != m_end_it) { map_debug_base::insert_new(PB_DS_V2F(*dbg_it)); - dbg_it++; } - PB_DS_CLASS_C_DEC::assert_valid(); -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#endif } PB_DS_CLASS_T_DEC @@ -265,14 +231,11 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - - value_swap(other); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void @@ -280,24 +243,18 @@ PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { std::swap(m_a_values, other.m_a_values); - std::swap(m_a_metadata, other.m_a_metadata); - std::swap(m_size, other.m_size); - std::swap(m_end_it, other.m_end_it); - - PB_DS_DBG_ONLY(map_debug_base::swap(other);) - } + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_OV_TREE_CLASS_NAME() { - PB_DS_DBG_ONLY(assert_valid();) - - cond_dtor cd(m_a_values, m_end_it, m_size); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + cond_dtor cd(m_a_values, m_end_it, m_size); reallocate_metadata((node_update* )this, 0); } @@ -314,12 +271,9 @@ PB_DS_CLASS_C_DEC:: update(node_iterator nd_it, Node_Update* p_update) { const_node_iterator end_it = PB_DS_node_end_imp(); - if (nd_it == end_it) return; - update(nd_it.get_l_child(), p_update); update(nd_it.get_r_child(), p_update); - node_update::operator()(nd_it, end_it); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp index d5e9b5eab5a..e8b418da345 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for ov_tree_. */ -#ifdef PB_DS_OV_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -54,13 +54,10 @@ assert_valid() const std::cout << "av1" << std::endl; if (m_a_values == NULL || m_end_it == NULL || m_size == 0) - PB_DS_DBG_ASSERT(m_a_values == NULL&& m_end_it == NULL&& - m_size == 0); + _GLIBCXX_DEBUG_ASSERT(m_a_values == NULL&& m_end_it == NULL && m_size == 0); std::cout << "av2" << std::endl; - assert_iterators(); - std::cout << "av3" << std::endl; } @@ -70,40 +67,24 @@ PB_DS_CLASS_C_DEC:: assert_iterators() const { map_debug_base::check_size(m_size); - size_type iterated_num = 0; - const_iterator prev_it = end(); - - PB_DS_DBG_ASSERT( m_end_it == m_a_values + m_size); - + _GLIBCXX_DEBUG_ASSERT( m_end_it == m_a_values + m_size); for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; - - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( - PB_DS_V2F(*it));) - - PB_DS_DBG_ASSERT(lower_bound( - PB_DS_V2F(*it)) == it); - - const_iterator upper_bound_it = upper_bound( - PB_DS_V2F(*it)); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(PB_DS_V2F(*it));) + _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); + const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; - - PB_DS_DBG_ASSERT(upper_bound_it == it); - + _GLIBCXX_DEBUG_ASSERT(upper_bound_it == it); if (prev_it != end()) - PB_DS_DBG_ASSERT(Cmp_Fn::operator()( - PB_DS_V2F(*prev_it), - PB_DS_V2F(*it))); - + _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), + PB_DS_V2F(*it))); prev_it = it; } - - PB_DS_DBG_ASSERT(iterated_num == m_size); + _GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); } -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp index 5fbf91b171a..c6ff3531143 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp @@ -49,11 +49,11 @@ void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (m_size == 0) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } @@ -64,7 +64,7 @@ clear() cond_dtor cd(m_a_values, m_end_it, m_size); } - PB_DS_DBG_ONLY(map_debug_base::clear();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) m_a_values = NULL; @@ -72,7 +72,7 @@ clear() m_end_it = m_a_values; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) #ifdef PB_DS_REGRESSION typename Allocator::group_throw_prob_adjustor adjust(m_size); @@ -112,7 +112,7 @@ erase_if(Pred pred) cond_dtor cd(a_new_values, target_it, new_size); - PB_DS_DBG_ONLY(map_debug_base::clear()); + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear()); for (source_it = begin(); source_it != m_end_it; ++source_it) { @@ -122,7 +122,7 @@ erase_if(Pred pred) static_cast(target_it))) value_type(*source_it); - PB_DS_DBG_ONLY(map_debug_base::insert_new( + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new( PB_DS_V2F(*source_it))); ++target_it; @@ -145,7 +145,7 @@ erase_if(Pred pred) update(node_begin(), (node_update* )this); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (num_val_ersd); } @@ -156,19 +156,19 @@ It PB_DS_CLASS_C_DEC:: erase_imp(It it) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (it == end()) return end(); - PB_DS_DBG_ONLY( + _GLIBCXX_DEBUG_ONLY( PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));) #ifdef PB_DS_REGRESSION typename Allocator::group_throw_prob_adjustor adjust(m_size); #endif // #ifdef PB_DS_REGRESSION - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); value_vector a_values = s_value_alloc.allocate(m_size - 1); @@ -179,14 +179,14 @@ erase_imp(It it) cond_dtor cd(a_values, target_it, m_size - 1); - PB_DS_DBG_ONLY(size_type cnt = 0;) + _GLIBCXX_DEBUG_ONLY(size_type cnt = 0;) while (source_it != source_end_it) { if (source_it != it) { - PB_DS_DBG_ONLY(++cnt;) - PB_DS_DBG_ASSERT(cnt != m_size); + _GLIBCXX_DEBUG_ONLY(++cnt;) + _GLIBCXX_DEBUG_ASSERT(cnt != m_size); new (const_cast( static_cast(target_it))) @@ -200,13 +200,13 @@ erase_imp(It it) ++source_it; } - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); reallocate_metadata((node_update* )this, m_size - 1); cd.set_no_action(); - PB_DS_DBG_ONLY( + _GLIBCXX_DEBUG_ONLY( PB_DS_CLASS_C_DEC::erase_existing(PB_DS_V2F(*it));) { cond_dtor cd1(m_a_values, m_end_it, m_size); @@ -220,7 +220,7 @@ erase_imp(It it) update(node_begin(), (node_update* )this); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (It(ret_it)); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp index 27fb02fe74c..bb7c4dc0153 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp @@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (m_size); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp index c9a852a7ed5..719a824dfc9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp @@ -47,11 +47,9 @@ #ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP #define PB_DS_OV_TREE_NODE_ITERATORS_HPP -#ifdef PB_DS_OV_TREE_DEBUG_ -#include -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ #include #include +#include namespace pb_ds { @@ -60,25 +58,11 @@ namespace pb_ds #define PB_DS_STATIC_ASSERT(UNIQUE, E) \ typedef \ - static_assert_dumclass< \ - sizeof(static_assert<(bool)(E)>)> \ + static_assert_dumclass)> \ UNIQUE##static_assert_type -#ifdef PB_DS_OV_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X); -#define PB_DS_DBG_VERIFY(X) PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_OV_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) ((void)0) -#define PB_DS_DBG_VERIFY(X) X -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ - #define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \ - ov_tree_node_const_it_< \ - Value_Type, \ - Metadata_Type, \ - Allocator> + ov_tree_node_const_it_ // Const node reference. template @@ -109,8 +93,7 @@ namespace pb_ds inline static Ptr mid_pointer(Ptr p_begin, Ptr p_end) { - PB_DS_DBG_ASSERT(p_end >= p_begin); - + _GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); return (p_begin + (p_end - p_begin) / 2); } @@ -146,47 +129,36 @@ namespace pb_ds public: inline - ov_tree_node_const_it_(const_pointer p_nd = NULL, const_pointer p_begin_nd = NULL, const_pointer p_end_nd = NULL, const_metadata_pointer p_metadata = NULL) : m_p_value(const_cast(p_nd)), - m_p_begin_value(const_cast(p_begin_nd)), - m_p_end_value(const_cast(p_end_nd)), - m_p_metadata(p_metadata) + ov_tree_node_const_it_(const_pointer p_nd = NULL, const_pointer p_begin_nd = NULL, const_pointer p_end_nd = NULL, const_metadata_pointer p_metadata = NULL) : m_p_value(const_cast(p_nd)), m_p_begin_value(const_cast(p_begin_nd)), m_p_end_value(const_cast(p_end_nd)), m_p_metadata(p_metadata) { } inline const_reference operator*() const - { - return (m_p_value); - } + { return m_p_value; } inline const_metadata_reference get_metadata() const { enum { - has_metadata = - !is_same< - Metadata_Type, - null_node_metadata>::value + has_metadata = !is_same::value }; PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata); - - PB_DS_DBG_ASSERT(m_p_metadata != NULL); - - return (*m_p_metadata); + _GLIBCXX_DEBUG_ASSERT(m_p_metadata != NULL); + return *m_p_metadata; } inline this_type get_l_child() const { if (m_p_begin_value == m_p_value) - return (this_type( m_p_begin_value, m_p_begin_value, m_p_begin_value)); + return (this_type(m_p_begin_value, m_p_begin_value, m_p_begin_value)); const_metadata_pointer p_begin_metadata = m_p_metadata - (m_p_value - m_p_begin_value); - return (this_type( - mid_pointer(m_p_begin_value, m_p_value), + return (this_type(mid_pointer(m_p_begin_value, m_p_value), m_p_begin_value, m_p_value, mid_pointer(p_begin_metadata, m_p_metadata))); @@ -196,15 +168,14 @@ namespace pb_ds get_r_child() const { if (m_p_value == m_p_end_value) - return (this_type( m_p_end_value, m_p_end_value, m_p_end_value)); + return (this_type(m_p_end_value, m_p_end_value, m_p_end_value)); const_metadata_pointer p_end_metadata = m_p_metadata + (m_p_end_value - m_p_value); - return (this_type( - mid_pointer(m_p_value + 1, m_p_end_value), + return (this_type(mid_pointer(m_p_value + 1, m_p_end_value), m_p_value + 1, - m_p_end_value,(m_p_metadata == NULL)? + m_p_end_value,(m_p_metadata == NULL) ? NULL : mid_pointer(m_p_metadata + 1, p_end_metadata))); } @@ -220,14 +191,12 @@ namespace pb_ds if (is_other_end) return (is_end); - return (m_p_value == other.m_p_value); + return m_p_value == other.m_p_value; } inline bool operator!=(const this_type& other) const - { - return (!operator==(other)); - } + { return !operator==(other); } public: pointer m_p_value; @@ -238,10 +207,7 @@ namespace pb_ds }; #define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \ - ov_tree_node_it_< \ - Value_Type, \ - Metadata_Type, \ - Allocator> + ov_tree_node_it_ // Node reference. template @@ -292,22 +258,19 @@ namespace pb_ds // Access. inline reference operator*() const - { - return (reference(base_type::m_p_value)); - } + { return reference(base_type::m_p_value); } // Returns the node reference associated with the left node. inline ov_tree_node_it_ get_l_child() const { if (base_type::m_p_begin_value == base_type::m_p_value) - return (this_type( base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value)); + return (this_type(base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value)); const_metadata_pointer p_begin_metadata = base_type::m_p_metadata - (base_type::m_p_value - base_type::m_p_begin_value); - return (this_type( - base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value), + return (this_type(base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value), base_type::m_p_begin_value, base_type::m_p_value, base_type::mid_pointer(p_begin_metadata, base_type::m_p_metadata))); @@ -318,13 +281,12 @@ namespace pb_ds get_r_child() const { if (base_type::m_p_value == base_type::m_p_end_value) - return (this_type( base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value)); + return (this_type(base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value)); const_metadata_pointer p_end_metadata = base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value); - return (this_type( - base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value), + return (this_type(base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value), base_type::m_p_value + 1, base_type::m_p_end_value,(base_type::m_p_metadata == NULL)? NULL : base_type::mid_pointer(base_type::m_p_metadata + 1, p_end_metadata))); @@ -333,16 +295,10 @@ namespace pb_ds }; #undef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC - #undef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC - #undef PB_DS_STATIC_ASSERT -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace detail +} // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp index e338abf7529..242169cd7ba 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp @@ -58,105 +58,72 @@ #include #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_OV_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X); -#define PB_DS_DBG_VERIFY(X) PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_OV_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) ((void)0) -#define PB_DS_DBG_VERIFY(X) X -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ - template< \ - typename Key, \ - typename Mapped, \ - class Cmp_Fn, \ - class Node_And_It_Traits, \ - class Allocator> +#define PB_DS_CLASS_T_DEC \ + template #ifdef PB_DS_DATA_TRUE_INDICATOR -#define PB_DS_OV_TREE_CLASS_NAME \ - ov_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#define PB_DS_OV_TREE_CLASS_NAME ov_tree_data_ +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR -#define PB_DS_OV_TREE_CLASS_NAME \ - ov_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#define PB_DS_OV_TREE_CLASS_NAME ov_tree_no_data_ +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_data_ -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR +#else #define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_no_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif -#define PB_DS_CLASS_C_DEC \ - PB_DS_OV_TREE_CLASS_NAME< \ - Key, \ - Mapped, \ - Cmp_Fn, \ - Node_And_It_Traits, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + PB_DS_OV_TREE_CLASS_NAME -#define PB_DS_TYPES_TRAITS_C_DEC \ - types_traits< \ - Key, \ - Mapped, \ - Allocator, \ - false> +#define PB_DS_TYPES_TRAITS_C_DEC \ + types_traits -#ifdef PB_DS_USE_MAP_DEBUG_BASE -#define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - eq_by_less, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG +#define PB_DS_MAP_DEBUG_BASE_C_DEC \ + map_debug_base, \ + typename Allocator::template rebind::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #ifdef PB_DS_TREE_TRACE -#define PB_DS_TREE_TRACE_BASE_C_DEC \ - tree_trace_base< \ - typename Node_And_It_Traits::const_node_iterator, \ - typename Node_And_It_Traits::node_iterator, \ - Cmp_Fn, \ - false, \ - Allocator> -#endif // #ifdef PB_DS_TREE_TRACE +#define PB_DS_TREE_TRACE_BASE_C_DEC \ + tree_trace_base +#endif // Ordered-vector tree associative-container. - template + template class PB_DS_OV_TREE_CLASS_NAME : -#ifdef PB_DS_OV_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG protected PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#endif #ifdef PB_DS_TREE_TRACE public PB_DS_TREE_TRACE_BASE_C_DEC, -#endif // #ifdef PB_DS_TREE_TRACE +#endif public Cmp_Fn, public Node_And_It_Traits::node_update, public PB_DS_TYPES_TRAITS_C_DEC @@ -179,9 +146,9 @@ namespace pb_ds typedef Cmp_Fn cmp_fn_base; -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#endif typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer mapped_pointer_; @@ -268,9 +235,9 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR typedef pointer point_iterator; -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR +#else typedef const_point_iterator point_iterator; -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif typedef const_point_iterator const_iterator; @@ -322,79 +289,55 @@ namespace pb_ds operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - PB_DS_DBG_ONLY(assert_valid();) - - point_iterator it = lower_bound(r_key); - - if (it != end()&& !Cmp_Fn::operator()( - r_key, - PB_DS_V2F(*it))) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + point_iterator it = lower_bound(r_key); + if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); - - PB_DS_DBG_ONLY(assert_valid();) - - return (it->second); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return it->second; } - PB_DS_DBG_ONLY(assert_valid();) - - return (insert_new_val(it, - std::make_pair( - r_key, - mapped_type()))->second); -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second); +#else insert(r_key); - - return (traits_base::s_null_mapped); -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR + return traits_base::s_null_mapped; +#endif } inline std::pair insert(const_reference r_value) { - PB_DS_DBG_ONLY(assert_valid();) - - const_key_reference r_key = PB_DS_V2F(r_value); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + const_key_reference r_key = PB_DS_V2F(r_value); point_iterator it = lower_bound(r_key); - if (it != end()&& !Cmp_Fn::operator()( - r_key, - PB_DS_V2F(*it))) + if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) { - PB_DS_DBG_ONLY(assert_valid();) - - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); - - return (std::make_pair(it, false)); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); + return std::make_pair(it, false); } - PB_DS_DBG_ONLY(assert_valid();) - - return (std::make_pair(insert_new_val(it, r_value), true)); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return std::make_pair(insert_new_val(it, r_value), true); } inline point_iterator lower_bound(const_key_reference r_key) { pointer it = m_a_values; - pointer e_it = m_a_values + m_size; - while (it != e_it) { pointer mid_it = it + ((e_it - it) >> 1); - - if (cmp_fn_base::operator()( - PB_DS_V2F(*mid_it), - r_key)) + if (cmp_fn_base::operator()(PB_DS_V2F(*mid_it), r_key)) it = ++mid_it; else e_it = mid_it; } - - return (it); + return it; } inline const_point_iterator @@ -407,53 +350,38 @@ namespace pb_ds upper_bound(const_key_reference r_key) { iterator pot_it = lower_bound(r_key); - - if (pot_it != end()&& !Cmp_Fn::operator()( - r_key, - PB_DS_V2F(*pot_it))) + if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); return (++pot_it); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); - - return (pot_it); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); + return pot_it; } inline const_point_iterator upper_bound(const_key_reference r_key) const - { - return (const_cast(*this).upper_bound(r_key)); - } + { return const_cast(*this).upper_bound(r_key); } inline point_iterator find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) - - iterator pot_it = lower_bound(r_key); - - if (pot_it != end()&& !Cmp_Fn::operator()( - r_key, - PB_DS_V2F(*pot_it))) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + iterator pot_it = lower_bound(r_key); + if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); return (pot_it); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); - - return (end()); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key)); + return end(); } inline const_point_iterator find(const_key_reference r_key) const - { - return (const_cast(*this).find(r_key)); - } + { return (const_cast(*this).find(r_key)); } bool erase(const_key_reference r_key); @@ -464,9 +392,7 @@ namespace pb_ds inline iterator erase(iterator it) - { - return (erase_imp(it)); - } + { return erase_imp(it); } void clear(); @@ -479,27 +405,19 @@ namespace pb_ds inline iterator begin() - { - return (m_a_values); - } + { return m_a_values; } inline const_iterator begin() const - { - return (m_a_values); - } + { return m_a_values; } inline iterator end() - { - return (m_end_it); - } + { return m_end_it; } inline const_iterator end() const - { - return (m_end_it); - } + { return m_end_it; } inline const_node_iterator node_begin() const; @@ -544,22 +462,19 @@ namespace pb_ds inline static Ptr mid_pointer(Ptr p_begin, Ptr p_end) { - PB_DS_DBG_ASSERT(p_end >= p_begin); - + _GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); return (p_begin + (p_end - p_begin) / 2); } inline iterator insert_new_val(iterator it, const_reference r_value) { - PB_DS_DBG_ONLY(assert_valid();) - + _GLIBCXX_DEBUG_ONLY(assert_valid();) #ifdef PB_DS_REGRESSION typename Allocator::group_throw_prob_adjustor adjust(m_size); -#endif // #ifdef PB_DS_REGRESSION +#endif - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( - PB_DS_V2F(r_value))); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(PB_DS_V2F(r_value))); value_vector a_values = s_value_alloc.allocate(m_size + 1); @@ -569,65 +484,47 @@ namespace pb_ds iterator ret_it; cond_dtor cd(a_values, target_it, m_size + 1); - while (source_it != it) { - new (const_cast( - static_cast(target_it))) + new (const_cast(static_cast(target_it))) value_type(*source_it++); - ++target_it; } - new (const_cast( - static_cast(ret_it = target_it))) + new (const_cast(static_cast(ret_it = target_it))) value_type(r_value); - ++target_it; while (source_it != source_end_it) { - new (const_cast( - static_cast(target_it))) + new (const_cast(static_cast(target_it))) value_type(*source_it++); - ++target_it; } reallocate_metadata((node_update* )this, m_size + 1); - cd.set_no_action(); - if (m_size != 0) { cond_dtor cd1(m_a_values, m_end_it, m_size); } ++m_size; - m_a_values = a_values; - m_end_it = m_a_values + m_size; - - PB_DS_DBG_ONLY(map_debug_base::insert_new( - PB_DS_V2F(r_value))); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_value))); update(node_begin(), (node_update* )this); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - - return (ret_it); + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + return ret_it; } -#ifdef PB_DS_OV_TREE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; void assert_iterators() const; - -#endif // #ifdef PB_DS_OV_TREE_DEBUG_ +#endif template It @@ -669,27 +566,18 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_OV_TREE_CLASS_NAME - #undef PB_DS_TYPES_TRAITS_C_DEC - #undef PB_DS_MAP_DEBUG_BASE_C_DEC - #ifdef PB_DS_TREE_TRACE #undef PB_DS_TREE_TRACE_BASE_C_DEC -#endif // #ifdef PB_DS_TREE_TRACE +#endif #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - #undef PB_DS_CONST_NODE_ITERATOR_NAME } // namespace detail diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp index 193241f09b0..e20086b6718 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp @@ -49,15 +49,15 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (m_size == 0) { other.clear(); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -66,8 +66,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { value_swap(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -76,8 +76,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) r_key, PB_DS_V2F(*(end() - 1)))) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -86,13 +86,13 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { value_swap(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } - PB_DS_DBG_ONLY(map_debug_base::join(other);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) iterator it = upper_bound(r_key); @@ -106,7 +106,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) // No exceptions from this point. - PB_DS_DBG_ONLY(map_debug_base::split( + _GLIBCXX_DEBUG_ONLY(map_debug_base::split( r_key,(Cmp_Fn& )(*this), other);) @@ -118,8 +118,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) value_swap(new_this); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -127,8 +127,8 @@ void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (other.m_size == 0) return; @@ -168,12 +168,12 @@ join(PB_DS_CLASS_C_DEC& other) // No exceptions from this point. - PB_DS_DBG_ONLY(map_debug_base::join(other);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) value_swap(new_this); other.clear(); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp index 280d10f191c..6534f208604 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp @@ -53,14 +53,14 @@ copy_from_range(It first_it, It last_it) while (first_it != last_it) push(*(first_it++)); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap_() { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -68,7 +68,7 @@ PB_DS_CLASS_C_DEC:: pairing_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -76,7 +76,7 @@ PB_DS_CLASS_C_DEC:: pairing_heap_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -84,11 +84,11 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_BASE_C_DEC::swap(other); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp index 115b48cf225..5e6bb373968 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp @@ -44,17 +44,16 @@ * Contains an implementation class for a pairing heap. */ -#ifdef PB_DS_PAIRING_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { - PB_DS_DBG_ASSERT(base_type::m_p_root == NULL || - base_type::m_p_root->m_p_next_sibling == NULL); - + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root == NULL + || base_type::m_p_root->m_p_next_sibling == NULL); base_type::assert_valid(); } -#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp index 4d33eaccba0..038b490b46c 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp @@ -49,139 +49,107 @@ void PB_DS_CLASS_C_DEC:: pop() { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_root = join_node_children(base_type::m_p_root); - PB_DS_DBG_ONLY(assert_node_consistent(p_new_root, false);) - - if (p_new_root != NULL) - p_new_root->m_p_prev_or_parent = NULL; + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_new_root, false);) + if (p_new_root != NULL) + p_new_root->m_p_prev_or_parent = NULL; base_type::actual_erase_node(base_type::m_p_root); - base_type::m_p_root = p_new_root; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); remove_node(it.m_p_nd); - base_type::actual_erase_node(it.m_p_nd); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: remove_node(node_pointer p_nd) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_child = join_node_children(p_nd); -#ifdef PB_DS_PAIRING_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG if (p_new_child != NULL) base_type::assert_node_consistent(p_new_child, false); -#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_ +#endif if (p_nd == base_type::m_p_root) { if (p_new_child != NULL) p_new_child->m_p_prev_or_parent = NULL; - base_type::m_p_root = p_new_child; - - PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);) - - return; + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);) + return; } - PB_DS_DBG_ASSERT(p_nd->m_p_prev_or_parent != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != NULL); if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd) { if (p_new_child != NULL) { p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; - if (p_new_child->m_p_next_sibling != NULL) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; - p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child; - - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) - - return; + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + return; } p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling; - if (p_nd->m_p_next_sibling != NULL) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) - - return; + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + return; } if (p_new_child != NULL) { p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; - if (p_new_child->m_p_next_sibling != NULL) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; - p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child; - - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) - - return; + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + return; } p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling; - if (p_nd->m_p_next_sibling != NULL) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) - } + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) +} PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: join_node_children(node_pointer p_nd) { - PB_DS_DBG_ASSERT(p_nd != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); node_pointer p_ret = p_nd->m_p_l_child; - if (p_ret == NULL) return NULL; - while (p_ret->m_p_next_sibling != NULL) p_ret = forward_join(p_ret, p_ret->m_p_next_sibling); - while (p_ret->m_p_prev_or_parent != p_nd) p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret); - - PB_DS_DBG_ONLY(assert_node_consistent(p_ret, false);) - - return p_ret; + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret, false);) + return p_ret; } PB_DS_CLASS_T_DEC @@ -189,36 +157,27 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: forward_join(node_pointer p_nd, node_pointer p_next) { - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling == p_next); - + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - base_type::make_child_of(p_nd, p_next); - - return p_next->m_p_next_sibling == NULL? - p_next : - p_next->m_p_next_sibling; + return p_next->m_p_next_sibling == NULL + ? p_next : p_next->m_p_next_sibling; } if (p_next->m_p_next_sibling != NULL) { p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd; - p_nd->m_p_next_sibling = p_next->m_p_next_sibling; - base_type::make_child_of(p_next, p_nd); - return p_nd->m_p_next_sibling; } p_nd->m_p_next_sibling = NULL; - base_type::make_child_of(p_next, p_nd); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false)); - + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); return p_nd; } @@ -227,24 +186,20 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: back_join(node_pointer p_nd, node_pointer p_next) { - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(p_next->m_p_next_sibling == NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == NULL); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - base_type::make_child_of(p_nd, p_next); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_next, false)); - + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_next, false)); return p_next; } p_nd->m_p_next_sibling = NULL; - base_type::make_child_of(p_next, p_nd); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false)); - + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); return p_nd; } @@ -254,49 +209,34 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) - + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid();) - - return 0; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return 0; } - base_type::to_linked_list(); - node_pointer p_out = base_type::prune(pred); - size_type ersd = 0; - while (p_out != NULL) { ++ersd; - node_pointer p_next = p_out->m_p_next_sibling; - base_type::actual_erase_node(p_out); - p_out = p_next; } node_pointer p_cur = base_type::m_p_root; - base_type::m_p_root = NULL; - while (p_cur != NULL) { node_pointer p_next = p_cur->m_p_next_sibling; - p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = NULL; push_imp(p_cur); - p_cur = p_next; } - - PB_DS_DBG_ONLY(assert_valid();) - - return ersd; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp index 6e6093f7347..f74b0bbbf3c 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp @@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); return base_type::m_p_root->m_value; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp index d3ebfbd453e..41ff3918b85 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp @@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); push_imp(p_new_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return point_iterator(p_new_nd); } @@ -78,14 +78,14 @@ push_imp(node_pointer p_nd) p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = NULL; base_type::make_child_of(base_type::m_p_root, p_nd); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false)); + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); base_type::m_p_root = p_nd; } else { base_type::make_child_of(p_nd, base_type::m_p_root); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); } } @@ -94,7 +94,7 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) remove_node(it.m_p_nd); @@ -102,6 +102,6 @@ modify(point_iterator it, const_reference r_new_val) push_imp(it.m_p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp index e43ef4e0e42..64754749796 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp @@ -55,47 +55,35 @@ #include #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_PAIRING_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAIRING_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - pairing_heap_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + pairing_heap_ -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_BASE_C_DEC \ +#ifdef _GLIBCXX_DEBUG +#define PB_DS_BASE_C_DEC \ left_child_next_sibling_heap_< \ Value_Type, \ Cmp_Fn, \ null_left_child_next_sibling_heap_node_metadata, \ Allocator, \ false> -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#else #define PB_DS_BASE_C_DEC \ left_child_next_sibling_heap_< \ Value_Type, \ Cmp_Fn, \ null_left_child_next_sibling_heap_node_metadata, \ Allocator> -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#endif /** * class description = "P4ri|\|g h3ap$"> @@ -195,7 +183,7 @@ namespace pb_ds void copy_from_range(It first_it, It last_it); -#ifdef PB_DS_PAIRING_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG void assert_valid() const; #endif @@ -229,9 +217,6 @@ namespace pb_ds #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp index 1d23cc1359d..29b802500ac 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp @@ -50,15 +50,15 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) other.clear(); if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) while (p_out != NULL) { - PB_DS_DBG_ASSERT(base_type::m_size > 0); + _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; @@ -83,7 +83,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) node_pointer p_cur = base_type::m_p_root; @@ -100,8 +100,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_cur = p_next; } - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -109,13 +109,13 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (other.m_p_root == NULL) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -125,14 +125,14 @@ join(PB_DS_CLASS_C_DEC& other) else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value)) { base_type::make_child_of(base_type::m_p_root, other.m_p_root); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(other.m_p_root, false)); + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(other.m_p_root, false)); base_type::m_p_root = other.m_p_root; } else { base_type::make_child_of(other.m_p_root, base_type::m_p_root); - PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); } base_type::m_size += other.m_size; @@ -140,7 +140,7 @@ join(PB_DS_CLASS_C_DEC& other) other.m_p_root = NULL; other.m_size = 0; - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp index 4f6d921c77d..79dc307258a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp @@ -95,7 +95,7 @@ public: node_pointer_pointer operator->() { - PB_DS_DBG_ONLY(const_iterator::assert_referencible();) + _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) return (const_iterator::m_p_p_cur); } @@ -103,7 +103,7 @@ public: node_pointer operator*() { - PB_DS_DBG_ONLY(const_iterator::assert_referencible();) + _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) return (*const_iterator::m_p_p_cur); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp index d0e1ce98ce8..cd383755896 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp @@ -59,21 +59,18 @@ public: public: inline - const_iterator(node_pointer_pointer p_p_cur = NULL, node_pointer_pointer p_p_end = NULL) : m_p_p_cur(p_p_cur), - m_p_p_end(p_p_end) + const_iterator(node_pointer_pointer p_p_cur = NULL, + node_pointer_pointer p_p_end = NULL) + : m_p_p_cur(p_p_cur), m_p_p_end(p_p_end) { } inline bool operator==(const const_iterator& other) const - { - return (m_p_p_cur == other.m_p_p_cur); - } + { return m_p_p_cur == other.m_p_p_cur; } inline bool operator!=(const const_iterator& other) const - { - return (m_p_p_cur != other.m_p_p_cur); - } + { return m_p_p_cur != other.m_p_p_cur; } inline const_iterator& operator++() @@ -81,48 +78,40 @@ public: do ++m_p_p_cur; while (m_p_p_cur != m_p_p_end&& * m_p_p_cur == NULL); - - return (*this); + return *this; } inline const_iterator operator++(int) { const_iterator ret_it(*this); - operator++(); - - return (ret_it); + return ret_it; } const node_pointer_pointer operator->() const { - PB_DS_DBG_ONLY(assert_referencible();) - - return (m_p_p_cur); + _GLIBCXX_DEBUG_ONLY(assert_referencible();) + return (m_p_p_cur); } const_node_pointer operator*() const { - PB_DS_DBG_ONLY(assert_referencible();) - - return (*m_p_p_cur); + _GLIBCXX_DEBUG_ONLY(assert_referencible();) + return (*m_p_p_cur); } protected: -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG void assert_referencible() const - { - PB_DS_DBG_ASSERT(m_p_p_cur != m_p_p_end&& * m_p_p_cur != NULL); - } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ + { _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end&& * m_p_p_cur != NULL); } +#endif public: node_pointer_pointer m_p_p_cur; - node_pointer_pointer m_p_p_end; }; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp index 6e39599f0e9..5664eb0bef9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp @@ -63,9 +63,8 @@ PB_DS_CLASS_NAME() : m_size(0) { initialize(); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -75,79 +74,64 @@ PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) : m_size(0) { initialize(); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG map_debug_base(other), -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif synth_e_access_traits(other), node_update(other), m_p_head(s_head_allocator.allocate(1)), m_size(0) { initialize(); - m_size = other.m_size; - - PB_DS_DBG_ONLY(other.assert_valid();) - + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (other.m_p_head->m_p_parent == NULL) { - PB_DS_DBG_ONLY(assert_valid();) - - return; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return; } - try { - m_p_head->m_p_parent = - recursive_copy_node(other.m_p_head->m_p_parent); + m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent); } catch(...) { s_head_allocator.deallocate(m_p_head, 1); - throw; } m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); - m_p_head->m_p_parent->m_p_parent = m_p_head; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - - value_swap(other); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + value_swap(other); std::swap((e_access_traits& )(*this), (e_access_traits& )other); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: value_swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(map_debug_base::swap(other);) - - std::swap(m_p_head, other.m_p_head); - + _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);) + std::swap(m_p_head, other.m_p_head); std::swap(m_size, other.m_size); } @@ -156,7 +140,6 @@ PB_DS_CLASS_C_DEC:: ~PB_DS_CLASS_NAME() { clear(); - s_head_allocator.deallocate(m_p_head, 1); } @@ -166,12 +149,9 @@ PB_DS_CLASS_C_DEC:: initialize() { new (m_p_head) head(); - m_p_head->m_p_parent = NULL; - m_p_head->m_p_min = m_p_head; m_p_head->m_p_max = m_p_head; - m_size = 0; } @@ -190,33 +170,22 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: recursive_copy_node(const_node_pointer p_other_nd) { - PB_DS_DBG_ASSERT(p_other_nd != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_other_nd != NULL); if (p_other_nd->m_type == pat_trie_leaf_node_type) { - const_leaf_pointer p_other_leaf = - static_cast(p_other_nd); + const_leaf_pointer p_other_leaf = static_cast(p_other_nd); leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); - cond_dealtor cond(p_new_lf); - new (p_new_lf) leaf(p_other_leaf->value()); - apply_update(p_new_lf, (node_update* )this); - cond.set_no_action_dtor(); - return (p_new_lf); } - PB_DS_DBG_ASSERT(p_other_nd->m_type == - pat_trie_internal_node_type); - + _GLIBCXX_DEBUG_ASSERT(p_other_nd->m_type == pat_trie_internal_node_type); node_pointer a_p_children[internal_node::arr_size]; - size_type child_i = 0; - const_internal_node_pointer p_other_internal_nd = static_cast(p_other_nd); @@ -224,39 +193,28 @@ recursive_copy_node(const_node_pointer p_other_nd) p_other_internal_nd->begin(); internal_node_pointer p_ret; - try { while (child_it != p_other_internal_nd->end()) a_p_children[child_i++] = recursive_copy_node(*(child_it++)); - p_ret = s_internal_node_allocator.allocate(1); } catch(...) { while (child_i-- > 0) clear_imp(a_p_children[child_i]); - throw; } - new (p_ret) internal_node( - p_other_internal_nd->get_e_ind(), + new (p_ret) internal_node(p_other_internal_nd->get_e_ind(), pref_begin(a_p_children[0])); --child_i; - - PB_DS_DBG_ASSERT(child_i > 1); - + _GLIBCXX_DEBUG_ASSERT(child_i > 1); do - p_ret->add_child( - a_p_children[child_i], - pref_begin(a_p_children[child_i]), - pref_end(a_p_children[child_i]), - this); + p_ret->add_child(a_p_children[child_i], pref_begin(a_p_children[child_i]), + pref_end(a_p_children[child_i]), this); while (child_i-- > 0); - apply_update(p_ret, (node_update* )this); - - return (p_ret); + return p_ret; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp index 1345913a5ae..a2253a6a502 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for pat_trie_. */ -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -53,25 +53,19 @@ assert_valid() const { if (m_p_head->m_p_parent != NULL) m_p_head->m_p_parent->assert_valid(this); - assert_iterators(); - assert_reverse_iterators(); - if (m_p_head->m_p_parent == NULL) { - PB_DS_DBG_ASSERT(m_p_head->m_p_min == m_p_head); - PB_DS_DBG_ASSERT(m_p_head->m_p_max == m_p_head); - - PB_DS_DBG_ASSERT(empty()); - + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min == m_p_head); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max == m_p_head); + _GLIBCXX_DEBUG_ASSERT(empty()); return; } - PB_DS_DBG_ASSERT(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type); - PB_DS_DBG_ASSERT(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type); - - PB_DS_DBG_ASSERT(!empty()); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(!empty()); } PB_DS_CLASS_T_DEC @@ -80,19 +74,14 @@ PB_DS_CLASS_C_DEC:: assert_iterators() const { size_type calc_size = 0; - for (const_iterator it = begin(); it != end(); ++it) { ++calc_size; - map_debug_base::check_key_exists(PB_DS_V2F(*it)); - - PB_DS_DBG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); - - PB_DS_DBG_ASSERT(--upper_bound(PB_DS_V2F(*it)) == it); + _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); + _GLIBCXX_DEBUG_ASSERT(--upper_bound(PB_DS_V2F(*it)) == it); } - - PB_DS_DBG_ASSERT(calc_size == m_size); + _GLIBCXX_DEBUG_ASSERT(calc_size == m_size); } PB_DS_CLASS_T_DEC @@ -101,19 +90,14 @@ PB_DS_CLASS_C_DEC:: assert_reverse_iterators() const { size_type calc_size = 0; - for (const_reverse_iterator it = rbegin(); it != rend(); ++it) { ++calc_size; - const_node_pointer p_nd = - const_cast(this)->find_imp( - PB_DS_V2F(*it)); - - PB_DS_DBG_ASSERT(p_nd == it.m_p_nd); + const_cast(this)->find_imp(PB_DS_V2F(*it)); + _GLIBCXX_DEBUG_ASSERT(p_nd == it.m_p_nd); } - - PB_DS_DBG_ASSERT(calc_size == m_size); + _GLIBCXX_DEBUG_ASSERT(calc_size == m_size); } PB_DS_CLASS_T_DEC @@ -123,22 +107,17 @@ recursive_count_leafs(const_node_pointer p_nd) { if (p_nd == NULL) return (0); - if (p_nd->m_type == pat_trie_leaf_node_type) return (1); - - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); - + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); size_type ret = 0; - for (typename internal_node::const_iterator it = static_cast(p_nd)->begin(); it != static_cast(p_nd)->end(); ++it) ret += recursive_count_leafs(*it); - - return (ret); + return ret; } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp index 1fc7b26f865..29c76eae4ce 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp @@ -53,29 +53,29 @@ erase(const_key_reference r_key) if (p_nd == NULL || p_nd->m_type == pat_trie_internal_node_type) { - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( r_key)); return (false); } - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); if (!synth_e_access_traits::equal_keys( PB_DS_V2F(reinterpret_cast(p_nd)->value()), r_key)) { - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist( r_key)); return (false); } - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); erase_leaf(static_cast(p_nd)); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (true); } @@ -85,7 +85,7 @@ void PB_DS_CLASS_C_DEC:: erase_fixup(internal_node_pointer p_nd) { - PB_DS_DBG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1); + _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1); if (std::distance(p_nd->begin(), p_nd->end()) == 1) { @@ -95,7 +95,7 @@ erase_fixup(internal_node_pointer p_nd) m_p_head->m_p_parent =* p_nd->begin(); else { - PB_DS_DBG_ASSERT(p_parent->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type); node_pointer p_new_child =* p_nd->begin(); @@ -114,25 +114,25 @@ erase_fixup(internal_node_pointer p_nd) if (p_parent == m_p_head) return; - PB_DS_DBG_ASSERT(p_parent->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type); p_nd = static_cast(p_parent); } while (true) { - PB_DS_DBG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); + _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); p_nd->update_prefixes(this); apply_update(p_nd, (node_update* )this); - PB_DS_DBG_ONLY(p_nd->assert_valid(this);) + _GLIBCXX_DEBUG_ONLY(p_nd->assert_valid(this);) if (p_nd->m_p_parent->m_type == pat_trie_head_node_type) return; - PB_DS_DBG_ASSERT(p_nd->m_p_parent->m_type == + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == pat_trie_internal_node_type); p_nd = static_cast(p_nd->m_p_parent); @@ -144,10 +144,10 @@ inline void PB_DS_CLASS_C_DEC:: actual_erase_leaf(leaf_pointer p_l) { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_l->value()))); + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_l->value()))); p_l->~leaf(); @@ -159,7 +159,7 @@ void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (empty()) return; @@ -170,9 +170,9 @@ clear() initialize(); - PB_DS_DBG_ONLY(map_debug_base::clear();) + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -182,7 +182,7 @@ clear_imp(node_pointer p_nd) { if (p_nd->m_type == pat_trie_internal_node_type) { - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); for (typename internal_node::iterator it = static_cast(p_nd)->begin(); @@ -200,7 +200,7 @@ clear_imp(node_pointer p_nd) return; } - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); static_cast(p_nd)->~leaf(); @@ -213,7 +213,7 @@ inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: erase(const_iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it == end()) return (it); @@ -222,11 +222,11 @@ erase(const_iterator it) ++ret_it; - PB_DS_DBG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -237,7 +237,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it == end()) return (it); @@ -246,11 +246,11 @@ erase(iterator it) ++ret_it; - PB_DS_DBG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -261,7 +261,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: erase(const_reverse_iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it.m_p_nd == m_p_head) return (it); @@ -270,11 +270,11 @@ erase(const_reverse_iterator it) ++ret_it; - PB_DS_DBG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -285,7 +285,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it.m_p_nd == m_p_head) return (it); @@ -294,11 +294,11 @@ erase(reverse_iterator it) ++ret_it; - PB_DS_DBG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); + _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -312,13 +312,13 @@ erase_if(Pred pred) { size_type num_ersd = 0; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) iterator it = begin(); while (it != end()) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (pred(*it)) { @@ -330,7 +330,7 @@ erase_if(Pred pred) ++it; } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (num_ersd); } @@ -344,16 +344,16 @@ erase_leaf(leaf_pointer p_l) if (p_l->m_p_parent->m_type == pat_trie_head_node_type) { - PB_DS_DBG_ASSERT(size() == 1); + _GLIBCXX_DEBUG_ASSERT(size() == 1); clear(); return; } - PB_DS_DBG_ASSERT(size() > 1); + _GLIBCXX_DEBUG_ASSERT(size() > 1); - PB_DS_DBG_ASSERT(p_l->m_p_parent->m_type == + _GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == pat_trie_internal_node_type); internal_node_pointer p_parent = diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp index 3462019dc60..f76bc303d94 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp @@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = find_imp(r_key); if (p_nd == NULL || p_nd->m_type != pat_trie_leaf_node_type) { - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (end()); } @@ -64,12 +64,12 @@ find(const_key_reference r_key) PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key)); return (iterator(p_nd)); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (end()); } @@ -79,14 +79,14 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) const_node_pointer p_nd = const_cast(this)->find_imp(r_key); if (p_nd == NULL || p_nd->m_type != pat_trie_leaf_node_type) { - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (end()); } @@ -95,13 +95,13 @@ find(const_key_reference r_key) const PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists( r_key)); return (const_iterator(const_cast(p_nd))); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);) return (end()); } @@ -120,11 +120,11 @@ find_imp(const_key_reference r_key) synth_e_access_traits::end(r_key); node_pointer p_nd = m_p_head->m_p_parent; - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); while (p_nd->m_type != pat_trie_leaf_node_type) { - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); node_pointer p_next_nd = static_cast(p_nd)->get_child_node( b_it, e_it, this); @@ -147,7 +147,7 @@ lower_bound_imp(const_key_reference r_key) return (m_p_head); node_pointer p_nd = m_p_head->m_p_parent; - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); typename PB_DS_CLASS_C_DEC::const_e_iterator b_it = synth_e_access_traits::begin(r_key); @@ -173,7 +173,7 @@ lower_bound_imp(const_key_reference r_key) return (it.m_p_nd); } - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); const size_type new_checked_ind = static_cast(p_nd)->get_e_ind(); @@ -209,7 +209,7 @@ upper_bound(const_key_reference r_key) { point_iterator l_bound_it = lower_bound(r_key); - PB_DS_DBG_ASSERT(l_bound_it == end() || + _GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || !synth_e_access_traits::cmp_keys( PB_DS_V2F(*l_bound_it), r_key)); @@ -230,7 +230,7 @@ upper_bound(const_key_reference r_key) const { const_point_iterator l_bound_it = lower_bound(r_key); - PB_DS_DBG_ASSERT(l_bound_it == end() || + _GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || !synth_e_access_traits::cmp_keys( PB_DS_V2F(*l_bound_it), r_key)); @@ -253,7 +253,7 @@ pref_begin(const_node_pointer p_nd) return (synth_e_access_traits::begin( PB_DS_V2F(static_cast(p_nd)->value()))); - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); return (static_cast(p_nd)->pref_b_it()); } @@ -267,7 +267,7 @@ pref_end(const_node_pointer p_nd) return (synth_e_access_traits::end( PB_DS_V2F(static_cast(p_nd)->value()))); - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); return (static_cast(p_nd)->pref_e_it()); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp index db6864bba68..14f80575384 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp @@ -47,10 +47,8 @@ #ifndef PB_DS_PAT_TRIE_IHEAD_HPP #define PB_DS_PAT_TRIE_IHEAD_HPP -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#include -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ #include +#include namespace pb_ds { @@ -78,16 +76,6 @@ namespace pb_ds Metadata, \ Allocator> -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ - template::other::pointer node_pointer; -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef typename PB_DS_BASE_C_DEC::subtree_debug_info subtree_debug_info; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif public: pat_trie_head(); -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG virtual subtree_debug_info assert_valid_imp(const_e_access_traits_pointer p_traits) const; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif public: node_pointer m_p_min; @@ -129,34 +117,26 @@ namespace pb_ds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - pat_trie_head() : - PB_DS_BASE_C_DEC(pat_trie_head_node_type) + pat_trie_head() : PB_DS_BASE_C_DEC(pat_trie_head_node_type) { } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::subtree_debug_info PB_DS_CLASS_C_DEC:: assert_valid_imp(const_e_access_traits_pointer /*p_traits*/) const { - PB_DS_DBG_ASSERT(false); - - return (subtree_debug_info()); + _GLIBCXX_DEBUG_ASSERT(false); + return subtree_debug_info(); } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PAT_TRIE_HEAD_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp index 39b798311b6..c4290156ab1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp @@ -49,33 +49,26 @@ void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); split_join_branch_bag bag; - if (!join_prep(other, bag)) { - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); return; } - m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, other.m_p_head->m_p_parent, 0, bag); + m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, + other.m_p_head->m_p_parent, 0, bag); m_p_head->m_p_parent->m_p_parent = m_p_head; - m_size += other.m_size; - other.initialize(); - - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); - - PB_DS_DBG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(assert_valid();); } PB_DS_CLASS_T_DEC @@ -83,39 +76,30 @@ bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - - if (other.m_size == 0) - return (false); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + if (other.m_size == 0) + return false; if (m_size == 0) { value_swap(other); - - return (false); + return false; } - const bool greater = synth_e_access_traits::cmp_keys( - PB_DS_V2F(static_cast( - m_p_head->m_p_max)->value()), - PB_DS_V2F(static_cast( + const bool greater = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast( + m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast( other.m_p_head->m_p_min)->value())); - const bool lesser = synth_e_access_traits::cmp_keys( - PB_DS_V2F(static_cast( - other.m_p_head->m_p_max)->value()), - PB_DS_V2F(static_cast( - m_p_head->m_p_min)->value())); + const bool lesser = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast( + other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast(m_p_head->m_p_min)->value())); - if (!greater&& !lesser) + if (!greater && !lesser) throw join_error(); rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); - - PB_DS_DBG_ONLY(map_debug_base::join(other);) - - return (true); + _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) + return true; } PB_DS_CLASS_T_DEC @@ -127,125 +111,89 @@ rec_join_prep(const_node_pointer p_l, const_node_pointer p_r, split_join_branch_ { if (p_r->m_type == pat_trie_leaf_node_type) { - rec_join_prep( - static_cast(p_l), - static_cast(p_r), - r_bag); - + rec_join_prep(static_cast(p_l), + static_cast(p_r), r_bag); return; } - PB_DS_DBG_ASSERT(p_r->m_type == pat_trie_internal_node_type); - - rec_join_prep( - static_cast(p_l), - static_cast(p_r), - r_bag); - + _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type); + rec_join_prep(static_cast(p_l), + static_cast(p_r), r_bag); return; } - PB_DS_DBG_ASSERT(p_l->m_type == pat_trie_internal_node_type); - + _GLIBCXX_DEBUG_ASSERT(p_l->m_type == pat_trie_internal_node_type); if (p_r->m_type == pat_trie_leaf_node_type) { - rec_join_prep( - static_cast(p_l), - static_cast(p_r), - r_bag); - + rec_join_prep(static_cast(p_l), + static_cast(p_r), r_bag); return; } - PB_DS_DBG_ASSERT(p_r->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type); - rec_join_prep( - static_cast(p_l), - static_cast(p_r), - r_bag); + rec_join_prep(static_cast(p_l), + static_cast(p_r), r_bag); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -rec_join_prep(const_leaf_pointer /*p_l*/, const_leaf_pointer /*p_r*/, split_join_branch_bag& r_bag) -{ - r_bag.add_branch(); -} +rec_join_prep(const_leaf_pointer /*p_l*/, const_leaf_pointer /*p_r*/, + split_join_branch_bag& r_bag) +{ r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -rec_join_prep(const_leaf_pointer /*p_l*/, const_internal_node_pointer /*p_r*/, split_join_branch_bag& r_bag) -{ - r_bag.add_branch(); -} +rec_join_prep(const_leaf_pointer /*p_l*/, const_internal_node_pointer /*p_r*/, + split_join_branch_bag& r_bag) +{ r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -rec_join_prep(const_internal_node_pointer /*p_l*/, const_leaf_pointer /*p_r*/, split_join_branch_bag& r_bag) -{ - r_bag.add_branch(); -} +rec_join_prep(const_internal_node_pointer /*p_l*/, const_leaf_pointer /*p_r*/, + split_join_branch_bag& r_bag) +{ r_bag.add_branch(); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -rec_join_prep(const_internal_node_pointer p_l, const_internal_node_pointer p_r, split_join_branch_bag& r_bag) +rec_join_prep(const_internal_node_pointer p_l, const_internal_node_pointer p_r, + split_join_branch_bag& r_bag) { - if (p_l->get_e_ind() == p_r->get_e_ind()&& - synth_e_access_traits::equal_prefixes( - p_l->pref_b_it(), - p_l->pref_e_it(), - p_r->pref_b_it(), - p_r->pref_e_it())) + if (p_l->get_e_ind() == p_r->get_e_ind() && + synth_e_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), + p_r->pref_b_it(), p_r->pref_e_it())) { for (typename internal_node::const_iterator it = p_r->begin(); it != p_r->end(); ++ it) { - const_node_pointer p_l_join_child = - p_l->get_join_child(*it, this); - + const_node_pointer p_l_join_child = p_l->get_join_child(*it, this); if (p_l_join_child != NULL) rec_join_prep(p_l_join_child, * it, r_bag); } - return; } - if (p_r->get_e_ind() < p_l->get_e_ind()&& - p_r->should_be_mine( - p_l->pref_b_it(), - p_l->pref_e_it(), - 0, - this)) + if (p_r->get_e_ind() < p_l->get_e_ind() && + p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { - const_node_pointer p_r_join_child = - p_r->get_join_child(p_l, this); - + const_node_pointer p_r_join_child = p_r->get_join_child(p_l, this); if (p_r_join_child != NULL) rec_join_prep(p_r_join_child, p_l, r_bag); - return; } - if (p_r->get_e_ind() < p_l->get_e_ind()&& - p_r->should_be_mine( - p_l->pref_b_it(), - p_l->pref_e_it(), - 0, - this)) + if (p_r->get_e_ind() < p_l->get_e_ind() && + p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { - const_node_pointer p_r_join_child = - p_r->get_join_child(p_l, this); - + const_node_pointer p_r_join_child = p_r->get_join_child(p_l, this); if (p_r_join_child != NULL) rec_join_prep(p_r_join_child, p_l, r_bag); - return; } - r_bag.add_branch(); } @@ -254,12 +202,10 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag) { - PB_DS_DBG_ASSERT(p_r != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_r != NULL); if (p_l == NULL) { apply_update(p_r, (node_update* )this); - return (p_r); } @@ -267,54 +213,37 @@ rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind, split_join_b { if (p_r->m_type == pat_trie_leaf_node_type) { - node_pointer p_ret = rec_join( - static_cast(p_l), - static_cast(p_r), - r_bag); - + node_pointer p_ret = rec_join(static_cast(p_l), + static_cast(p_r), r_bag); apply_update(p_ret, (node_update* )this); - - return (p_ret); + return p_ret; } - PB_DS_DBG_ASSERT(p_r->m_type == pat_trie_internal_node_type); - - node_pointer p_ret = rec_join( - static_cast(p_l), + _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type); + node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), - checked_ind, - r_bag); - + checked_ind, r_bag); apply_update(p_ret, (node_update* )this); - - return (p_ret); + return p_ret; } - PB_DS_DBG_ASSERT(p_l->m_type == pat_trie_internal_node_type); - + _GLIBCXX_DEBUG_ASSERT(p_l->m_type == pat_trie_internal_node_type); if (p_r->m_type == pat_trie_leaf_node_type) { - node_pointer p_ret = rec_join( - static_cast(p_l), + node_pointer p_ret = rec_join(static_cast(p_l), static_cast(p_r), - checked_ind, - r_bag); - + checked_ind, r_bag); apply_update(p_ret, (node_update* )this); - - return (p_ret); + return p_ret; } - PB_DS_DBG_ASSERT(p_r->m_type == pat_trie_internal_node_type); - - node_pointer p_ret = rec_join( - static_cast(p_l), - static_cast(p_r), + _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type); + node_pointer p_ret = rec_join(static_cast(p_l), + static_cast(p_r), r_bag); apply_update(p_ret, (node_update* )this); - - return (p_ret); + return p_ret; } PB_DS_CLASS_T_DEC @@ -322,37 +251,29 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(leaf_pointer p_l, leaf_pointer p_r, split_join_branch_bag& r_bag) { - PB_DS_DBG_ASSERT(p_r != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_r != NULL); if (p_l == NULL) return (p_r); - node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_ret) == 2); - - return (p_ret); + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == 2); + return p_ret; } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: -rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag) +rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind, + split_join_branch_bag& r_bag) { -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ - - PB_DS_DBG_ASSERT(p_r != NULL); +#endif + _GLIBCXX_DEBUG_ASSERT(p_r != NULL); node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag); - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_ret) == - lhs_leafs + rhs_leafs); - - return (p_ret); + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); + return p_ret; } PB_DS_CLASS_T_DEC @@ -360,58 +281,37 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag) { - PB_DS_DBG_ASSERT(p_l != NULL); - PB_DS_DBG_ASSERT(p_r != NULL); + _GLIBCXX_DEBUG_ASSERT(p_l != NULL); + _GLIBCXX_DEBUG_ASSERT(p_r != NULL); -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif - if (!p_l->should_be_mine( - pref_begin(p_r), - pref_end(p_r), - checked_ind, - this)) + if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this)) { node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - - PB_DS_DBG_ONLY(p_ret->assert_valid(this);) - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_ret) == - lhs_leafs + rhs_leafs); - - return (p_ret); + _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == + lhs_leafs + rhs_leafs); + return p_ret; } - node_pointer p_pot_child = p_l->add_child( - p_r, - pref_begin(p_r), - pref_end(p_r), - this); - + node_pointer p_pot_child = p_l->add_child(p_r, pref_begin(p_r), + pref_end(p_r), this); if (p_pot_child != p_r) { - node_pointer p_new_child = rec_join( - p_pot_child, - p_r, - p_l->get_e_ind(), + node_pointer p_new_child = rec_join(p_pot_child, p_r, p_l->get_e_ind(), r_bag); - p_l->replace_child( - p_new_child, - pref_begin(p_new_child), - pref_end(p_new_child), - this); + p_l->replace_child(p_new_child, pref_begin(p_new_child), + pref_end(p_new_child), this); } - PB_DS_DBG_ONLY(p_l->assert_valid(this)); - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_l) == - lhs_leafs + rhs_leafs); - - return (p_l); + _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this)); + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); + return p_l; } PB_DS_CLASS_T_DEC @@ -419,171 +319,97 @@ typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch_bag& r_bag) { - PB_DS_DBG_ASSERT(p_l != NULL); - PB_DS_DBG_ASSERT(p_r != NULL); + _GLIBCXX_DEBUG_ASSERT(p_l != NULL); + _GLIBCXX_DEBUG_ASSERT(p_r != NULL); -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif - if (p_l->get_e_ind() == p_r->get_e_ind()&& - synth_e_access_traits::equal_prefixes( - p_l->pref_b_it(), - p_l->pref_e_it(), - p_r->pref_b_it(), - p_r->pref_e_it())) + if (p_l->get_e_ind() == p_r->get_e_ind() && + synth_e_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), + p_r->pref_b_it(), p_r->pref_e_it())) { for (typename internal_node::iterator it = p_r->begin(); it != p_r->end(); ++ it) { - node_pointer p_new_child = rec_join( - p_l->get_join_child(*it, this), - * it, - 0, - r_bag); - - p_l->replace_child( - p_new_child, - pref_begin(p_new_child), - pref_end(p_new_child), - this); + node_pointer p_new_child = rec_join(p_l->get_join_child(*it, this), + * it, 0, r_bag); + p_l->replace_child(p_new_child, pref_begin(p_new_child), + pref_end(p_new_child), this); } p_r->~internal_node(); - s_internal_node_allocator.deallocate(p_r, 1); - - PB_DS_DBG_ONLY(p_l->assert_valid(this);) - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_l) == - lhs_leafs + rhs_leafs); - - return (p_l); + _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); + return p_l; } - if (p_l->get_e_ind() < p_r->get_e_ind()&& - p_l->should_be_mine( - p_r->pref_b_it(), - p_r->pref_e_it(), - 0, - this)) + if (p_l->get_e_ind() < p_r->get_e_ind() && + p_l->should_be_mine(p_r->pref_b_it(), p_r->pref_e_it(), 0, this)) { - node_pointer p_new_child = rec_join( - p_l->get_join_child(p_r, this), - p_r, - 0, - r_bag); - - p_l->replace_child( - p_new_child, - pref_begin(p_new_child), - pref_end(p_new_child), - this); - - PB_DS_DBG_ONLY(p_l->assert_valid(this);) - - return (p_l); + node_pointer p_new_child = rec_join(p_l->get_join_child(p_r, this), + p_r, 0, r_bag); + p_l->replace_child(p_new_child, pref_begin(p_new_child), + pref_end(p_new_child), this); + _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) + return p_l; } - if (p_r->get_e_ind() < p_l->get_e_ind()&& - p_r->should_be_mine( - p_l->pref_b_it(), - p_l->pref_e_it(), - 0, - this)) + if (p_r->get_e_ind() < p_l->get_e_ind() && + p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) { - node_pointer p_new_child = rec_join( - p_r->get_join_child(p_l, this), - p_l, - 0, - r_bag); + node_pointer p_new_child = rec_join(p_r->get_join_child(p_l, this), p_l, + 0, r_bag); - p_r->replace_child( - p_new_child, - pref_begin(p_new_child), - pref_end(p_new_child), - this); + p_r->replace_child(p_new_child, pref_begin(p_new_child), + pref_end(p_new_child), this); - PB_DS_DBG_ONLY(p_r->assert_valid(this);) - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_r) == - lhs_leafs + rhs_leafs); - - return (p_r); + _GLIBCXX_DEBUG_ONLY(p_r->assert_valid(this);) + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_r) == lhs_leafs + rhs_leafs); + return p_r; } node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - - PB_DS_DBG_ONLY(p_ret->assert_valid(this);) - - PB_DS_DBG_ASSERT(recursive_count_leafs(p_ret) == - lhs_leafs + rhs_leafs); - - return (p_ret); + _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) + _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); + return p_ret; } PB_DS_CLASS_T_DEC -inline std::pair< - typename PB_DS_CLASS_C_DEC::iterator, - bool> +inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_val) { node_pointer p_lf = find_imp(PB_DS_V2F(r_val)); - - if (p_lf != NULL&& p_lf->m_type == pat_trie_leaf_node_type&& - synth_e_access_traits::equal_keys( - PB_DS_V2F(static_cast(p_lf)->value()), - PB_DS_V2F(r_val))) + if (p_lf != NULL && p_lf->m_type == pat_trie_leaf_node_type && + synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast(p_lf)->value()), PB_DS_V2F(r_val))) { - PB_DS_DBG_ONLY(map_debug_base::check_key_exists( - PB_DS_V2F(r_val))); - - PB_DS_DBG_ONLY(assert_valid();) - - return (std::make_pair( - iterator(p_lf), - false)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(PB_DS_V2F(r_val))); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return std::make_pair(iterator(p_lf), false); } - PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist( - PB_DS_V2F(r_val))); + _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(PB_DS_V2F(r_val))); leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); - cond_dealtor cond(p_new_lf); new (p_new_lf) leaf(r_val); - apply_update(p_new_lf, (node_update* )this); - cond.set_call_destructor(); - split_join_branch_bag bag; - bag.add_branch(); - - m_p_head->m_p_parent = - rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag); - + m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag); m_p_head->m_p_parent->m_p_parent = m_p_head; - cond.set_no_action_dtor(); - ++m_size; - update_min_max_for_inserted_leaf(p_new_lf); - - PB_DS_DBG_ONLY(map_debug_base::insert_new( - PB_DS_V2F(r_val));) - - PB_DS_DBG_ONLY(assert_valid();) - - return (std::make_pair( - point_iterator(p_new_lf), - true)); + _GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return std::make_pair(point_iterator(p_new_lf), true); } PB_DS_CLASS_T_DEC @@ -592,24 +418,18 @@ PB_DS_CLASS_C_DEC:: keys_diff_ind(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r) { size_type diff_pos = 0; - while (b_l != e_l) { if (b_r == e_r) return (diff_pos); - if (e_access_traits::e_pos(*b_l) != e_access_traits::e_pos(*b_r)) return (diff_pos); - ++b_l; ++b_r; - ++diff_pos; } - - PB_DS_DBG_ASSERT(b_r != e_r); - - return (diff_pos); + _GLIBCXX_DEBUG_ASSERT(b_r != e_r); + return diff_pos; } PB_DS_CLASS_T_DEC @@ -617,33 +437,22 @@ typename PB_DS_CLASS_C_DEC::internal_node_pointer PB_DS_CLASS_C_DEC:: insert_branch(node_pointer p_l, node_pointer p_r, split_join_branch_bag& r_bag) { - typename synth_e_access_traits::const_iterator left_b_it = - pref_begin(p_l); - typename synth_e_access_traits::const_iterator left_e_it = - pref_end(p_l); + typename synth_e_access_traits::const_iterator left_b_it = pref_begin(p_l); + typename synth_e_access_traits::const_iterator left_e_it = pref_end(p_l); + typename synth_e_access_traits::const_iterator right_b_it = pref_begin(p_r); + typename synth_e_access_traits::const_iterator right_e_it = pref_end(p_r); - typename synth_e_access_traits::const_iterator right_b_it = - pref_begin(p_r); - typename synth_e_access_traits::const_iterator right_e_it = - pref_end(p_r); - - const size_type diff_ind = - keys_diff_ind(left_b_it, left_e_it, right_b_it, right_e_it); + const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it, + right_b_it, right_e_it); internal_node_pointer p_new_nd = r_bag.get_branch(); - new (p_new_nd) internal_node(diff_ind, left_b_it); - - p_new_nd->add_child( p_l, left_b_it, left_e_it, this); - - p_new_nd->add_child( p_r, right_b_it, right_e_it, this); - + p_new_nd->add_child(p_l, left_b_it, left_e_it, this); + p_new_nd->add_child(p_r, right_b_it, right_e_it, this); p_l->m_p_parent = p_new_nd; p_r->m_p_parent = p_new_nd; - - PB_DS_DBG_ONLY(p_new_nd->assert_valid(this);) - - return (p_new_nd); + _GLIBCXX_DEBUG_ONLY(p_new_nd->assert_valid(this);) + return (p_new_nd); } PB_DS_CLASS_T_DEC @@ -652,14 +461,11 @@ PB_DS_CLASS_C_DEC:: update_min_max_for_inserted_leaf(leaf_pointer p_new_lf) { if (m_p_head->m_p_min == m_p_head || - synth_e_access_traits::cmp_keys( - PB_DS_V2F(p_new_lf->value()), + synth_e_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()), PB_DS_V2F(static_cast(m_p_head->m_p_min)->value()))) m_p_head->m_p_min = p_new_lf; if (m_p_head->m_p_max == m_p_head || - synth_e_access_traits::cmp_keys( - PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()), - PB_DS_V2F(p_new_lf->value()))) + synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value()))) m_p_head->m_p_max = p_new_lf; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp index b8020bc367f..41329e2715b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp @@ -47,9 +47,7 @@ #ifndef PB_DS_PAT_TRIE_INTERNAL_NODE_HPP #define PB_DS_PAT_TRIE_INTERNAL_NODE_HPP -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#include -#endif +#include namespace pb_ds { @@ -71,16 +69,6 @@ namespace pb_ds #define PB_DS_STATIC_ASSERT(UNIQUE, E) \ typedef static_assert_dumclass)> UNIQUE##static_assert_type -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) { if((X)==0); } -#define PB_DS_DBG_ONLY(X) ; -#endif - templatem_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_first->m_type == pat_trie_internal_node_type); m_pref_b_it = static_cast(p_first)->pref_b_it(); } m_pref_e_it = m_pref_b_it; @@ -326,7 +314,7 @@ namespace pb_ds const_e_access_traits_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); return m_a_p_children[i]; } @@ -337,8 +325,8 @@ namespace pb_ds const_e_access_traits_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); - PB_DS_DBG_ASSERT(m_a_p_children[i] != NULL); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != NULL); return iterator(m_a_p_children + i, m_a_p_children + i); } @@ -364,7 +352,7 @@ namespace pb_ds } size_type i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); if (m_a_p_children[i] != NULL) return m_a_p_children[i]; @@ -375,7 +363,7 @@ namespace pb_ds if (m_a_p_children[i]->m_type == pat_trie_leaf_node_type) return m_a_p_children[i]; - PB_DS_DBG_ASSERT(m_a_p_children[i]->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i]->m_type == pat_trie_internal_node_type); return static_cast(m_a_p_children[i])->leftmost_descendant(); } @@ -390,7 +378,7 @@ namespace pb_ds const_e_access_traits_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); if (m_a_p_children[i] == NULL) { m_a_p_children[i] = p_nd; @@ -431,7 +419,7 @@ namespace pb_ds e_it = static_cast(p_nd)->pref_e_it(); } i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); return m_a_p_children[i]; } @@ -447,7 +435,7 @@ namespace pb_ds m_a_p_children[i] = NULL; return; } - PB_DS_DBG_ASSERT(i != arr_size); + _GLIBCXX_DEBUG_ASSERT(i != arr_size); } PB_DS_CLASS_T_DEC @@ -469,7 +457,7 @@ namespace pb_ds const_e_access_traits_pointer p_traits) { const size_type i = get_pref_pos(b_it, e_it, p_traits); - PB_DS_DBG_ASSERT(i < arr_size); + _GLIBCXX_DEBUG_ASSERT(i < arr_size); m_a_p_children[i] = p_nd; p_nd->m_p_parent = this; } @@ -528,7 +516,7 @@ namespace pb_ds node_pointer p_pot =* begin(); if (p_pot->m_type == pat_trie_leaf_node_type) return (static_cast(p_pot)); - PB_DS_DBG_ASSERT(p_pot->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == pat_trie_internal_node_type); return static_cast(p_pot)->leftmost_descendant(); } @@ -546,14 +534,14 @@ namespace pb_ds rightmost_descendant() { const size_type num_children = std::distance(begin(), end()); - PB_DS_DBG_ASSERT(num_children >= 2); + _GLIBCXX_DEBUG_ASSERT(num_children >= 2); iterator it = begin(); std::advance(it, num_children - 1); node_pointer p_pot =* it; if (p_pot->m_type == pat_trie_leaf_node_type) return static_cast(p_pot); - PB_DS_DBG_ASSERT(p_pot->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == pat_trie_internal_node_type); return static_cast(p_pot)->rightmost_descendant(); } @@ -565,13 +553,13 @@ namespace pb_ds return const_cast(this)->rightmost_descendant(); } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: e_ind() const { return m_e_ind; } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type @@ -584,30 +572,30 @@ namespace pb_ds return i; } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::subtree_debug_info PB_DS_CLASS_C_DEC:: assert_valid_imp(const_e_access_traits_pointer p_traits) const { - PB_DS_DBG_ASSERT(base_type::m_type == pat_trie_internal_node_type); - PB_DS_DBG_ASSERT(static_cast(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); - PB_DS_DBG_ASSERT(std::distance(begin(), end()) >= 2); + _GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(static_cast(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); + _GLIBCXX_DEBUG_ASSERT(std::distance(begin(), end()) >= 2); for (typename pat_trie_internal_node::const_iterator it = begin(); it != end(); ++it) { const_node_pointer p_nd =* it; - PB_DS_DBG_ASSERT(p_nd->m_p_parent == this); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent == this); subtree_debug_info child_ret = p_nd->assert_valid_imp(p_traits); - PB_DS_DBG_ASSERT(static_cast(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); - PB_DS_DBG_ASSERT(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); - PB_DS_DBG_ASSERT(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast(it.m_p_p_cur - m_a_p_children)); + _GLIBCXX_DEBUG_ASSERT(static_cast(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); + _GLIBCXX_DEBUG_ASSERT(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); + _GLIBCXX_DEBUG_ASSERT(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast(it.m_p_p_cur - m_a_p_children)); } return std::make_pair(pref_b_it(), pref_e_it()); } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC @@ -615,10 +603,6 @@ namespace pb_ds #undef PB_DS_LEAF_C_DEC #undef PB_DS_STATIC_ASSERT -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp index e2eae3d4e48..db990b16346 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp @@ -47,6 +47,8 @@ #ifndef PB_DS_PAT_TRIE_LEAF_HPP #define PB_DS_PAT_TRIE_LEAF_HPP +#include + namespace pb_ds { namespace detail @@ -79,16 +81,6 @@ namespace pb_ds E_Access_Traits, \ Allocator> -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ - template::other::const_pointer const_e_access_traits_pointer; -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef typename PB_DS_BASE_C_DEC::subtree_debug_info subtree_debug_info; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif typedef PB_DS_BASE_C_DEC base_type; @@ -124,15 +116,13 @@ namespace pb_ds inline const_reference value() const; -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG virtual subtree_debug_info assert_valid_imp(const_e_access_traits_pointer p_traits) const; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#ifdef PB_DS_PAT_TRIE_DEBUG_ virtual ~pat_trie_leaf(); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif private: pat_trie_leaf(const PB_DS_CLASS_C_DEC& other); @@ -144,64 +134,45 @@ namespace pb_ds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pat_trie_leaf(const_reference r_val) : - PB_DS_BASE_C_DEC(pat_trie_leaf_node_type), - m_value(r_val) + PB_DS_BASE_C_DEC(pat_trie_leaf_node_type), m_value(r_val) { } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reference PB_DS_CLASS_C_DEC:: value() - { - return (m_value); - } + { return m_value; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: value() const - { - return (m_value); - } + { return m_value; } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::subtree_debug_info PB_DS_CLASS_C_DEC:: assert_valid_imp(const_e_access_traits_pointer p_traits) const { - PB_DS_DBG_ASSERT(base_type::m_type == pat_trie_leaf_node_type); - + _GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_leaf_node_type); subtree_debug_info ret; - const_reference r_val = value(); - - return (std::make_pair( - p_traits->begin(p_traits->extract_key(r_val)), - p_traits->end(p_traits->extract_key(r_val)))); + return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)), + p_traits->end(p_traits->extract_key(r_val))); } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#ifdef PB_DS_PAT_TRIE_DEBUG_ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - ~pat_trie_leaf() - { } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ + ~pat_trie_leaf() { } +#endif #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_BASE_C_DEC - #undef PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PAT_TRIE_NODE_BASE_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp index eeafb51d6b3..de995fb87db 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp @@ -100,26 +100,24 @@ namespace pb_ds E_Access_Traits>::other::const_pointer const_e_access_traits_pointer; -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef std::pair< typename E_Access_Traits::const_iterator, typename E_Access_Traits::const_iterator> subtree_debug_info; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif public: pat_trie_node_base(pat_trie_node_type type); -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG void assert_valid(const_e_access_traits_pointer p_traits) const; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#ifdef PB_DS_PAT_TRIE_DEBUG_ virtual subtree_debug_info assert_valid_imp(const_e_access_traits_pointer p_traits) const = 0; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif public: node_pointer m_p_parent; @@ -129,27 +127,22 @@ namespace pb_ds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - pat_trie_node_base(pat_trie_node_type type) : - m_type(type) + pat_trie_node_base(pat_trie_node_type type) : m_type(type) { } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid(const_e_access_traits_pointer p_traits) const - { - assert_valid_imp(p_traits); - } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ + { assert_valid_imp(p_traits); } +#endif #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PAT_TRIE_NODE_BASE_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp index 24d9d51cb26..ec6eaaf9826 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp @@ -47,21 +47,13 @@ #ifndef PB_DS_PAT_TRIE_NODE_ITERATORS_HPP #define PB_DS_PAT_TRIE_NODE_ITERATORS_HPP +#include + namespace pb_ds { namespace detail { -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ - #define PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC \ pat_trie_const_node_it_< \ Node, \ @@ -136,7 +128,7 @@ namespace pb_ds m_p_traits->extract_key( static_cast(m_p_nd)->value()))); - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); return (static_cast(m_p_nd)->pref_b_it()); } @@ -149,7 +141,7 @@ namespace pb_ds m_p_traits->extract_key( static_cast(m_p_nd)->value()))); - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); return (static_cast(m_p_nd)->pref_e_it()); } @@ -198,36 +190,29 @@ namespace pb_ds */ inline - pat_trie_const_node_it_(node_pointer p_nd = NULL, const_e_access_traits_pointer p_traits = NULL) : m_p_nd(const_cast(p_nd)), - m_p_traits(p_traits) + pat_trie_const_node_it_(node_pointer p_nd = NULL, + const_e_access_traits_pointer p_traits = NULL) + : m_p_nd(const_cast(p_nd)), m_p_traits(p_traits) { } // Subtree valid prefix. - inline std::pair< - const_e_iterator, - const_e_iterator> + inline std::pair valid_prefix() const - { - return (std::make_pair( - pref_begin(), - pref_end())); - } + { return std::make_pair(pref_begin(), pref_end()); } - // Const access; returns the __const iterator* associated with the current leaf. + // Const access; returns the __const iterator* associated with + // the current leaf. inline const_reference operator*() const { - PB_DS_DBG_ASSERT(num_children() == 0); - - return (Const_Iterator(m_p_nd)); + _GLIBCXX_DEBUG_ASSERT(num_children() == 0); + return Const_Iterator(m_p_nd); } // Metadata access. inline const_metadata_reference get_metadata() const - { - return (m_p_nd->get_metadata()); - } + { return m_p_nd->get_metadata(); } // Returns the number of children in the corresponding node. inline size_type @@ -235,41 +220,32 @@ namespace pb_ds { if (m_p_nd->m_type == pat_trie_leaf_node_type) return (0); - - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); - - return (std::distance( - static_cast(m_p_nd)->begin(), - static_cast(m_p_nd)->end())); + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); + return std::distance(static_cast(m_p_nd)->begin(), static_cast(m_p_nd)->end()); } - // Returns a __const node __iterator to the corresponding node's i-th child. + // Returns a __const node __iterator to the corresponding node's + // i-th child. PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC get_child(size_type i) const { - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); - + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type); typename Internal_Node::iterator it = static_cast(m_p_nd)->begin(); std::advance(it, i); - - return (PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC(*it, m_p_traits)); + return PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC(*it, m_p_traits); } // Compares content to a different iterator object. inline bool operator==(const PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC& other) const - { - return (m_p_nd == other.m_p_nd); - } + { return (m_p_nd == other.m_p_nd); } // Compares content (negatively) to a different iterator object. inline bool operator!=(const PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC& other) const - { - return (m_p_nd != other.m_p_nd); - } + { return m_p_nd != other.m_p_nd; } private: @@ -343,9 +319,8 @@ namespace pb_ds inline reference operator*() const { - PB_DS_DBG_ASSERT(base_type::num_children() == 0); - - return (Iterator(base_type::m_p_nd)); + _GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0); + return Iterator(base_type::m_p_nd); } @@ -353,15 +328,14 @@ namespace pb_ds PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC get_child(size_type i) const { - PB_DS_DBG_ASSERT(base_type::m_p_nd->m_type == + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == pat_trie_internal_node_type); typename Internal_Node::iterator it = static_cast(base_type::m_p_nd)->begin(); std::advance(it, i); - - return (PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC(*it, base_type::m_p_traits)); + return PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC(*it, base_type::m_p_traits); } private: @@ -369,15 +343,10 @@ namespace pb_ds }; #undef PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC - #undef PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PAT_TRIE_NODE_ITERATORS_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp index 25093e7e434..8fbc2246b36 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp @@ -66,41 +66,29 @@ #include #include #include -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG #include -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE +#endif +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ - #define PB_DS_CLASS_T_DEC \ - template< \ - typename Key, \ - typename Mapped, \ - class Node_And_It_Traits, \ - class Allocator> + template #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CLASS_NAME \ pat_trie_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_CLASS_NAME \ pat_trie_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_CLASS_C_DEC \ PB_DS_CLASS_NAME< \ @@ -116,29 +104,23 @@ namespace pb_ds Allocator, \ false> -#ifdef PB_DS_USE_MAP_DEBUG_BASE +#ifdef _GLIBCXX_DEBUG #define PB_DS_MAP_DEBUG_BASE_C_DEC \ - map_debug_base< \ - Key, \ - eq_by_less< \ - Key, \ - std::less< \ - Key> >, \ - typename Allocator::template rebind< \ - Key>::other::const_reference> -#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE + map_debug_base >, typename Allocator::template rebind::other::const_reference> +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_STATIC_ASSERT(UNIQUE, E) \ typedef \ @@ -154,9 +136,9 @@ namespace pb_ds class Node_And_It_Traits, class Allocator> class PB_DS_CLASS_NAME : -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG public PB_DS_MAP_DEBUG_BASE_C_DEC, -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif public Node_And_It_Traits::synth_e_access_traits, public Node_And_It_Traits::node_update, public PB_DS_TYPES_TRAITS_C_DEC @@ -228,9 +210,9 @@ namespace pb_ds #include -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif #include @@ -571,8 +553,7 @@ namespace pb_ds inline static leaf_pointer rightmost_descendant(node_pointer p_nd); -#ifdef PB_DS_PAT_TRIE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; @@ -584,11 +565,9 @@ namespace pb_ds static size_type recursive_count_leafs(const_node_pointer p_nd); - -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif #ifdef PB_DS_PAT_TRIE_TRACE_ - static void trace_node(const_node_pointer p_nd, size_type level); @@ -597,18 +576,23 @@ namespace pb_ds trace_node_metadata(const_node_pointer p_nd, type_to_type); static void - trace_node_metadata(const_node_pointer, type_to_type); - -#endif // #ifdef PB_DS_PAT_TRIE_TRACE_ + trace_node_metadata(const_node_pointer, + type_to_type); +#endif leaf_pointer - split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag); + split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, + split_join_branch_bag& r_bag); node_pointer - rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag); + rec_split(node_pointer p_nd, const_e_iterator b_it, + const_e_iterator e_it, PB_DS_CLASS_C_DEC& other, + split_join_branch_bag& r_bag); void - split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_node::iterator child_b_it, size_type num_children, split_join_branch_bag& r_bag); + split_insert_branch(size_type e_ind, const_e_iterator b_it, + typename internal_node::iterator child_b_it, + size_type num_children, split_join_branch_bag&); private: static head_allocator s_head_allocator; @@ -635,23 +619,15 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_NAME - #undef PB_DS_TYPES_TRAITS_C_DEC - #undef PB_DS_MAP_DEBUG_BASE_C_DEC #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - #undef PB_DS_STATIC_ASSERT } // namespace detail diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp index 2e159d76818..b26ad6ed9d2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp @@ -47,9 +47,7 @@ #ifndef PB_DS_PAT_TRIE_FIND_ITERATORS_HPP #define PB_DS_PAT_TRIE_FIND_ITERATORS_HPP -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#include -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#include namespace pb_ds { @@ -96,15 +94,6 @@ namespace pb_ds !Is_Forward_Iterator, \ Allocator> -#ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_PAT_TRIE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ // Const iterator. template() const { - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type); - + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type); return (&static_cast(m_p_nd)->value()); } inline const_reference operator*() const { - PB_DS_DBG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type); - + _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type); return (static_cast(m_p_nd)->value()); } inline bool - operator==(const PB_DS_CONST_IT_C_DEC - & other) const + operator==(const PB_DS_CONST_IT_C_DEC& other) const { return (m_p_nd == other.m_p_nd); } inline bool - operator==(const PB_DS_CONST_ODIR_IT_C_DEC - & other) const + operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const { return (m_p_nd == other.m_p_nd); } inline bool - operator!=(const PB_DS_CONST_IT_C_DEC& - other) const + operator!=(const PB_DS_CONST_IT_C_DEC& other) const { return (m_p_nd != other.m_p_nd); } inline bool - operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& - other) const + operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const { return (m_p_nd != other.m_p_nd); } @@ -238,18 +217,14 @@ namespace pb_ds operator++() { inc(integral_constant()); - return (*this); } inline PB_DS_CONST_IT_C_DEC operator++(int) { - PB_DS_CONST_IT_C_DEC - ret_it(m_p_nd); - + PB_DS_CONST_IT_C_DEC ret_it(m_p_nd); operator++(); - return (ret_it); } @@ -257,27 +232,21 @@ namespace pb_ds operator--() { dec(integral_constant()); - return (*this); } inline PB_DS_CONST_IT_C_DEC operator--(int) { - PB_DS_CONST_IT_C_DEC - ret_it(m_p_nd); - + PB_DS_CONST_IT_C_DEC ret_it(m_p_nd); operator--(); - return (ret_it); } protected: inline void inc(false_type) - { - dec(true_type()); - } + { dec(true_type()); } void inc(true_type) @@ -285,35 +254,28 @@ namespace pb_ds if (m_p_nd->m_type == pat_trie_head_node_type) { m_p_nd = static_cast(m_p_nd)->m_p_min; - return; } node_pointer p_y = m_p_nd->m_p_parent; - - while (p_y->m_type != pat_trie_head_node_type&& + while (p_y->m_type != pat_trie_head_node_type && get_larger_sibling(m_p_nd) == NULL) { m_p_nd = p_y; - p_y = p_y->m_p_parent; } if (p_y->m_type == pat_trie_head_node_type) { m_p_nd = p_y; - return; } - m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd)); } inline void dec(false_type) - { - inc(true_type()); - } + { inc(true_type()); } void dec(true_type) @@ -321,27 +283,22 @@ namespace pb_ds if (m_p_nd->m_type == pat_trie_head_node_type) { m_p_nd = static_cast(m_p_nd)->m_p_max; - return; } node_pointer p_y = m_p_nd->m_p_parent; - - while (p_y->m_type != pat_trie_head_node_type&& + while (p_y->m_type != pat_trie_head_node_type && get_smaller_sibling(m_p_nd) == NULL) { m_p_nd = p_y; - p_y = p_y->m_p_parent; } if (p_y->m_type == pat_trie_head_node_type) { m_p_nd = p_y; - return; } - m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd)); } @@ -352,13 +309,11 @@ namespace pb_ds static_cast(p_nd->m_p_parent); typename Internal_Node::iterator it = p_parent->begin(); - while (*it != p_nd) ++it; typename Internal_Node::iterator next_it = it; ++next_it; - return ((next_it == p_parent->end())? NULL :* next_it); } @@ -372,22 +327,17 @@ namespace pb_ds if (*it == p_nd) return (NULL); - typename Internal_Node::iterator prev_it; - do { prev_it = it; - ++it; - if (*it == p_nd) return (*prev_it); } while (true); - PB_DS_DBG_ASSERT(false); - + _GLIBCXX_DEBUG_ASSERT(false); return (NULL); } @@ -405,7 +355,6 @@ namespace pb_ds { if (p_nd->m_type == pat_trie_leaf_node_type) return (static_cast(p_nd)); - return (static_cast(p_nd)->rightmost_descendant()); } @@ -478,7 +427,6 @@ namespace pb_ds operator=(const PB_DS_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; - return (*this); } @@ -487,14 +435,13 @@ namespace pb_ds operator=(const PB_DS_ODIR_IT_C_DEC& other) { base_it_type::m_p_nd = other.m_p_nd; - return (*this); } inline pointer operator->() const { - PB_DS_DBG_ASSERT(base_it_type::m_p_nd->m_type == + _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type); return (&static_cast(base_it_type::m_p_nd)->value()); @@ -503,9 +450,7 @@ namespace pb_ds inline reference operator*() const { - PB_DS_DBG_ASSERT(base_it_type::m_p_nd->m_type == - pat_trie_leaf_node_type); - + _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type); return (static_cast(base_it_type::m_p_nd)->value()); } @@ -514,38 +459,29 @@ namespace pb_ds { PB_DS_CONST_IT_C_DEC:: operator++(); - return (*this); } inline PB_DS_IT_C_DEC operator++(int) { - PB_DS_IT_C_DEC - ret_it(base_it_type::m_p_nd); - + PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd); operator++(); - return (ret_it); } inline PB_DS_IT_C_DEC& operator--() { - PB_DS_CONST_IT_C_DEC:: - operator--(); - + PB_DS_CONST_IT_C_DEC::operator--(); return (*this); } inline PB_DS_IT_C_DEC operator--(int) { - PB_DS_IT_C_DEC - ret_it(base_it_type::m_p_nd); - + PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd); operator--(); - return (ret_it); } @@ -556,19 +492,12 @@ namespace pb_ds }; #undef PB_DS_CONST_IT_C_DEC - #undef PB_DS_CONST_ODIR_IT_C_DEC - #undef PB_DS_IT_C_DEC - #undef PB_DS_ODIR_IT_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_PAT_TRIE_FIND_ITERATORS_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp index 91ce90a4eab..63553ec92a4 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp @@ -49,13 +49,10 @@ inline void PB_DS_CLASS_C_DEC:: actual_erase_node(node_pointer p_z) { - PB_DS_DBG_ASSERT(m_size > 0); + _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - - PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); - + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); p_z->~node(); - s_node_allocator.deallocate(p_z, 1); } @@ -67,24 +64,19 @@ update_min_max_for_erased_node(node_pointer p_z) if (m_size == 1) { m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; - return; } if (m_p_head->m_p_left == p_z) { iterator it(p_z); - ++it; - m_p_head->m_p_left = it.m_p_nd; } else if (m_p_head->m_p_right == p_z) { iterator it(p_z); - --it; - m_p_head->m_p_right = it.m_p_nd; } } @@ -94,18 +86,13 @@ void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(assert_valid(true, true);) - - clear_imp(m_p_head->m_p_parent); - + _GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) + clear_imp(m_p_head->m_p_parent); m_size = 0; - initialize(); - - PB_DS_DBG_ONLY(map_debug_base::clear();) - - PB_DS_DBG_ONLY(assert_valid(true, true);) - } + _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) + _GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) +} PB_DS_CLASS_T_DEC void @@ -114,13 +101,9 @@ clear_imp(node_pointer p_nd) { if (p_nd == NULL) return; - clear_imp(p_nd->m_p_left); - clear_imp(p_nd->m_p_right); - p_nd->~Node(); - s_node_allocator.deallocate(p_nd, 1); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp index a88ba0fad8b..84e6fddc088 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp @@ -50,14 +50,12 @@ PB_DS_CLASS_C_DEC:: rotate_left(node_pointer p_x) { node_pointer p_y = p_x->m_p_right; - p_x->m_p_right = p_y->m_p_left; if (p_y->m_p_left != NULL) p_y->m_p_left->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; - if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_left) @@ -68,10 +66,10 @@ rotate_left(node_pointer p_x) p_y->m_p_left = p_x; p_x->m_p_parent = p_y; - PB_DS_DBG_ONLY(assert_node_consistent(p_x);) - PB_DS_DBG_ONLY(assert_node_consistent(p_y);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) - apply_update(p_x, (Node_Update* )this); + apply_update(p_x, (Node_Update* )this); apply_update(p_x->m_p_parent, (Node_Update* )this); } @@ -81,14 +79,12 @@ PB_DS_CLASS_C_DEC:: rotate_right(node_pointer p_x) { node_pointer p_y = p_x->m_p_left; - p_x->m_p_left = p_y->m_p_right; if (p_y->m_p_right != NULL) p_y->m_p_right->m_p_parent = p_x; p_y->m_p_parent = p_x->m_p_parent; - if (p_x == m_p_head->m_p_parent) m_p_head->m_p_parent = p_y; else if (p_x == p_x->m_p_parent->m_p_right) @@ -99,10 +95,10 @@ rotate_right(node_pointer p_x) p_y->m_p_right = p_x; p_x->m_p_parent = p_y; - PB_DS_DBG_ONLY(assert_node_consistent(p_x);) - PB_DS_DBG_ONLY(assert_node_consistent(p_y);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) - apply_update(p_x, (Node_Update* )this); + apply_update(p_x, (Node_Update* )this); apply_update(p_x->m_p_parent, (Node_Update* )this); } @@ -112,15 +108,12 @@ PB_DS_CLASS_C_DEC:: rotate_parent(node_pointer p_nd) { node_pointer p_parent = p_nd->m_p_parent; - if (p_nd == p_parent->m_p_left) rotate_right(p_parent); else rotate_left(p_parent); - - PB_DS_DBG_ASSERT(p_parent->m_p_parent = p_nd); - PB_DS_DBG_ASSERT(p_nd->m_p_left == p_parent || - p_nd->m_p_right == p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent); } PB_DS_CLASS_T_DEC @@ -135,10 +128,9 @@ inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer p_nd, Node_Update_* p_update) { - p_update->operator()( - & PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == NULL)? + p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == NULL) ? NULL : - & PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == NULL)? + & PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == NULL) ? NULL : & PB_DS_V2F(p_nd->m_p_right->m_value)); } @@ -152,7 +144,6 @@ update_to_top(node_pointer p_nd, Node_Update_* p_update) while (p_nd != m_p_head) { apply_update(p_nd, p_update); - p_nd = p_nd->m_p_parent; } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp index 12d27b3b174..ed5d890f6f2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp @@ -49,29 +49,21 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); split_join_branch_bag bag; - leaf_pointer p_split_lf = split_prep(r_key, other, bag); - if (p_split_lf == NULL) { - PB_DS_DBG_ASSERT(bag.empty()); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - - return; + _GLIBCXX_DEBUG_ASSERT(bag.empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + return; } - PB_DS_DBG_ASSERT(!bag.empty()); - + _GLIBCXX_DEBUG_ASSERT(!bag.empty()); other.clear(); - - m_p_head->m_p_parent = rec_split( - m_p_head->m_p_parent, + m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf), pref_end(p_split_lf), other, @@ -84,13 +76,11 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) other.m_p_head->m_p_min = other.leftmost_descendant(other.m_p_head->m_p_parent); - other.m_size = std::distance( - other.PB_DS_CLASS_C_DEC::begin(), + other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(), other.PB_DS_CLASS_C_DEC::end()); m_size -= other.m_size; - - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); } PB_DS_CLASS_T_DEC @@ -98,67 +88,49 @@ typename PB_DS_CLASS_C_DEC::leaf_pointer PB_DS_CLASS_C_DEC:: split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) { - PB_DS_DBG_ASSERT(r_bag.empty()); - + _GLIBCXX_DEBUG_ASSERT(r_bag.empty()); if (m_size == 0) { other.clear(); - - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); return (NULL); } - if (synth_e_access_traits::cmp_keys( - r_key, + if (synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(static_cast(m_p_head->m_p_min)->value()))) { other.clear(); - value_swap(other); - - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); return (NULL); } - if (!synth_e_access_traits::cmp_keys( - r_key, + if (!synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()))) { - PB_DS_DBG_ONLY(assert_valid();); - PB_DS_DBG_ONLY(other.assert_valid();); - + _GLIBCXX_DEBUG_ONLY(assert_valid();); + _GLIBCXX_DEBUG_ONLY(other.assert_valid();); return (NULL); } iterator it = lower_bound(r_key); - if (!synth_e_access_traits::equal_keys( - PB_DS_V2F(*it), - r_key)) + if (!synth_e_access_traits::equal_keys(PB_DS_V2F(*it), r_key)) --it; node_pointer p_nd = it.m_p_nd; - - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); - + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); leaf_pointer p_ret_l = static_cast(p_nd); - while (p_nd->m_type != pat_trie_head_node_type) { r_bag.add_branch(); - p_nd = p_nd->m_p_parent; } + _GLIBCXX_DEBUG_ONLY(map_debug_base::split(r_key,(synth_e_access_traits& )(*this), other);) - PB_DS_DBG_ONLY(map_debug_base::split( - r_key,(synth_e_access_traits& )(*this), - other);) - - return (p_ret_l); + return (p_ret_l); } PB_DS_CLASS_T_DEC @@ -168,36 +140,26 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS { if (p_nd->m_type == pat_trie_leaf_node_type) { - PB_DS_DBG_ASSERT(other.m_p_head->m_p_parent == NULL); - + _GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == NULL); return (p_nd); } - PB_DS_DBG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + internal_node_pointer p_internal_nd = static_cast(p_nd); - internal_node_pointer p_internal_nd = - static_cast(p_nd); - - node_pointer p_child_ret = rec_split( - p_internal_nd->get_child_node(b_it, e_it, this), - b_it, - e_it, - other, - r_bag); - - PB_DS_DBG_ONLY(p_child_ret->assert_valid(this);) - - p_internal_nd->replace_child( p_child_ret, b_it, e_it, this); + node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag); + _GLIBCXX_DEBUG_ONLY(p_child_ret->assert_valid(this);) + p_internal_nd->replace_child(p_child_ret, b_it, e_it, this); apply_update(p_internal_nd, (node_update* )this); - typename internal_node::iterator child_it = + typename internal_node::iterator child_it = p_internal_nd->get_child_it(b_it, e_it, this); const size_type lhs_num_children = std::distance(p_internal_nd->begin(), child_it) + 1; - PB_DS_DBG_ASSERT(lhs_num_children > 0); + _GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0); size_type rhs_num_children = std::distance(p_internal_nd->begin(), p_internal_nd->end()) - @@ -206,55 +168,37 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS if (rhs_num_children == 0) { apply_update(p_internal_nd, (node_update* )this); - return (p_internal_nd); } ++child_it; - other.split_insert_branch(p_internal_nd->get_e_ind(), - b_it, - child_it, - rhs_num_children, - r_bag); - - child_it = - p_internal_nd->get_child_it(b_it, e_it, this); + b_it, child_it, rhs_num_children, r_bag); + child_it = p_internal_nd->get_child_it(b_it, e_it, this); ++child_it; - while (rhs_num_children != 0) { child_it = p_internal_nd->remove_child(child_it); - --rhs_num_children; } apply_update(p_internal_nd, (node_update* )this); - - PB_DS_DBG_ASSERT(std::distance( - p_internal_nd->begin(), - p_internal_nd->end()) >= 1); + _GLIBCXX_DEBUG_ASSERT(std::distance(p_internal_nd->begin(), + p_internal_nd->end()) >= 1); if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1) { p_internal_nd->update_prefixes(this); - - PB_DS_DBG_ONLY(p_internal_nd->assert_valid(this);) - - apply_update(p_internal_nd, (node_update* )this); - + _GLIBCXX_DEBUG_ONLY(p_internal_nd->assert_valid(this);) + apply_update(p_internal_nd, (node_update* )this); return (p_internal_nd); } node_pointer p_ret =* p_internal_nd->begin(); - p_internal_nd->~internal_node(); - s_internal_node_allocator.deallocate(p_internal_nd, 1); - apply_update(p_ret, (node_update* )this); - return (p_ret); } @@ -263,17 +207,16 @@ void PB_DS_CLASS_C_DEC:: split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_node::iterator child_b_it, size_type num_children, split_join_branch_bag& r_bag) { -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG if (m_p_head->m_p_parent != NULL) m_p_head->m_p_parent->assert_valid(this); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif const size_type total_num_children =((m_p_head->m_p_parent == NULL)? 0 : 1) + num_children; if (total_num_children == 0) { - PB_DS_DBG_ASSERT(m_p_head->m_p_parent == NULL); - + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == NULL); return; } @@ -281,56 +224,37 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no { if (m_p_head->m_p_parent != NULL) { - PB_DS_DBG_ONLY(m_p_head->m_p_parent->assert_valid(this);) - - return; + _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) + return; } - PB_DS_DBG_ASSERT(m_p_head->m_p_parent == NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == NULL); m_p_head->m_p_parent =* child_b_it; - m_p_head->m_p_parent->m_p_parent = m_p_head; - apply_update(m_p_head->m_p_parent, (node_update* )this); - - PB_DS_DBG_ONLY(m_p_head->m_p_parent->assert_valid(this);) - - return; + _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) + return; } - PB_DS_DBG_ASSERT(total_num_children > 1); - + _GLIBCXX_DEBUG_ASSERT(total_num_children > 1); internal_node_pointer p_new_root = r_bag.get_branch(); - new (p_new_root) internal_node(e_ind, b_it); - size_type num_inserted = 0; - while (num_inserted++ < num_children) { - PB_DS_DBG_ONLY((*child_b_it)->assert_valid(this);) - - p_new_root->add_child( - * child_b_it, - pref_begin(*child_b_it), - pref_end(*child_b_it), - this); - + _GLIBCXX_DEBUG_ONLY((*child_b_it)->assert_valid(this);) + p_new_root->add_child(*child_b_it, pref_begin(*child_b_it), + pref_end(*child_b_it), this); ++child_b_it; } if (m_p_head->m_p_parent != NULL) - p_new_root->add_child( - m_p_head->m_p_parent, + p_new_root->add_child(m_p_head->m_p_parent, pref_begin(m_p_head->m_p_parent), - pref_end(m_p_head->m_p_parent), - this); + pref_end(m_p_head->m_p_parent), this); m_p_head->m_p_parent = p_new_root; - p_new_root->m_p_parent = m_p_head; - apply_update(m_p_head->m_p_parent, (node_update* )this); - - PB_DS_DBG_ONLY(m_p_head->m_p_parent->assert_valid(this);) - } + _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp index 3448de10e8f..436e03a08b4 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp @@ -76,7 +76,7 @@ public: internal_node_pointer get_branch() { - PB_DS_DBG_ASSERT(!m_bag.empty()); + _GLIBCXX_DEBUG_ASSERT(!m_bag.empty()); internal_node_pointer p_nd =* m_bag.begin(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp index 68f3473e6d4..79cd72cba2b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp @@ -96,10 +96,10 @@ namespace pb_ds inline static const_key_reference extract_key(const_reference r_val); -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG bool operator()(const_key_reference r_lhs, const_key_reference r_rhs); -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif private: inline static const_key_reference @@ -136,14 +136,11 @@ namespace pb_ds { if (b_r == e_r) return (false); - if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r)) return (false); - ++b_l; ++b_r; } - return (!compare_after || b_r == e_r); } @@ -168,22 +165,18 @@ namespace pb_ds { if (b_r == e_r) return (false); - const typename base_type::size_type l_pos = base_type::e_pos(*b_l); const typename base_type::size_type r_pos = base_type::e_pos(*b_r); - if (l_pos != r_pos) return (l_pos < r_pos); - ++b_l; ++b_r; } if (!compare_after) return (false); - return (b_r != e_r); } @@ -223,7 +216,7 @@ namespace pb_ds return (r_val.first); } -#ifdef PB_DS_PAT_TRIE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC bool PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: @@ -231,13 +224,12 @@ namespace pb_ds { return (cmp_keys(r_lhs, r_rhs)); } -#endif // #ifdef PB_DS_PAT_TRIE_DEBUG_ +#endif #undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC - #undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp index 58290bfd160..de220d95351 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp @@ -60,7 +60,7 @@ PB_DS_CLASS_NAME() { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -70,7 +70,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -90,7 +90,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -98,11 +98,11 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_BASE_C_DEC::swap(other); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp index 13e93cae75a..3a4049e9f8d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation for rb_tree_. */ -#ifdef PB_DS_RB_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type @@ -56,16 +56,12 @@ assert_node_consistent(const node_pointer p_nd) const const size_type l_height = assert_node_consistent(p_nd->m_p_left); const size_type r_height = assert_node_consistent(p_nd->m_p_right); - if (p_nd->m_red) { - PB_DS_DBG_ASSERT(is_effectively_black(p_nd->m_p_left)); - - PB_DS_DBG_ASSERT(is_effectively_black(p_nd->m_p_right)); + _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_left)); + _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_right)); } - - PB_DS_DBG_ASSERT(l_height == r_height); - + _GLIBCXX_DEBUG_ASSERT(l_height == r_height); return ((p_nd->m_red? 0 : 1) + l_height); } @@ -75,18 +71,14 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { PB_DS_BASE_C_DEC::assert_valid(); - const node_pointer p_head = PB_DS_BASE_C_DEC::m_p_head; - - PB_DS_DBG_ASSERT(p_head->m_red); - + _GLIBCXX_DEBUG_ASSERT(p_head->m_red); if (p_head->m_p_parent != NULL) { - PB_DS_DBG_ASSERT(!p_head->m_p_parent->m_red); - + _GLIBCXX_DEBUG_ASSERT(!p_head->m_p_parent->m_red); assert_node_consistent(p_head->m_p_parent); } } -#endif // #ifdef PB_DS_RB_TREE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp index e3aadc5515d..cfe212589fc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp @@ -64,7 +64,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it == PB_DS_BASE_C_DEC::end()) return (it); @@ -75,7 +75,7 @@ erase(iterator it) erase_node(it.m_p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -85,7 +85,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it.m_p_nd == PB_DS_BASE_C_DEC::m_p_head) return (it); @@ -96,7 +96,7 @@ erase(reverse_iterator it) erase_node(it.m_p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -107,7 +107,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) size_type num_ersd = 0; @@ -125,7 +125,7 @@ erase_if(Pred pred) ++it; } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (num_ersd); } @@ -139,7 +139,7 @@ erase_node(node_pointer p_nd) PB_DS_BASE_C_DEC::actual_erase_node(p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); } PB_DS_CLASS_T_DEC @@ -240,7 +240,7 @@ void PB_DS_CLASS_C_DEC:: remove_fixup(node_pointer p_x, node_pointer p_new_x_parent) { - PB_DS_DBG_ASSERT(p_x == NULL || p_x->m_p_parent == p_new_x_parent); + _GLIBCXX_DEBUG_ASSERT(p_x == NULL || p_x->m_p_parent == p_new_x_parent); while (p_x != PB_DS_BASE_C_DEC::m_p_head->m_p_parent&& is_effectively_black(p_x)) diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp index 891c43b6332..d0e5e10fa1b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp @@ -49,7 +49,7 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) std::pair ins_pair = PB_DS_BASE_C_DEC::insert_leaf(r_value); @@ -58,12 +58,12 @@ insert(const_reference r_value) { ins_pair.first.m_p_nd->m_red = true; - PB_DS_DBG_ONLY(this->structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) insert_fixup(ins_pair.first.m_p_nd); } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (ins_pair); } @@ -73,7 +73,7 @@ inline void PB_DS_CLASS_C_DEC:: insert_fixup(node_pointer p_nd) { - PB_DS_DBG_ASSERT(p_nd->m_red == true); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_red == true); while (p_nd != PB_DS_BASE_C_DEC::m_p_head->m_p_parent&& p_nd->m_p_parent->m_red) diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp index c4cc743cfa5..7942480811b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp @@ -52,37 +52,28 @@ #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR #define PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR #include -#endif // #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR #define PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR #include -#endif // #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif +#endif #include #include #include #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_RB_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_RB_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_RB_TREE_DEBUG_ - #define PB_DS_CLASS_T_DEC \ template< \ typename Key, \ @@ -94,22 +85,22 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CLASS_NAME \ rb_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR - -#ifdef PB_DS_DATA_FALSE_INDICATOR -#define PB_DS_CLASS_NAME \ - rb_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_BASE_CLASS_NAME \ bin_search_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif + +#ifdef PB_DS_DATA_FALSE_INDICATOR +#define PB_DS_CLASS_NAME \ + rb_tree_no_data_ +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_BASE_CLASS_NAME \ bin_search_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_CLASS_C_DEC \ PB_DS_CLASS_NAME< \ @@ -131,13 +122,13 @@ namespace pb_ds #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif template + inline std::pair insert(const_reference r_value); inline mapped_reference operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - PB_DS_DBG_ONLY(assert_valid();) - - std::pair ins_pair = - PB_DS_BASE_C_DEC::insert_leaf( - value_type( - r_key, - mapped_type())); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + std::pair ins_pair = + PB_DS_BASE_C_DEC::insert_leaf(value_type(r_key, mapped_type())); if (ins_pair.second == true) { ins_pair.first.m_p_nd->m_red = true; - - PB_DS_DBG_ONLY(this->structure_only_assert_valid();) - - insert_fixup(ins_pair.first.m_p_nd); + _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) + insert_fixup(ins_pair.first.m_p_nd); } - - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (ins_pair.first.m_p_nd->m_value.second); -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR +#else insert(r_key); - return (PB_DS_BASE_C_DEC::s_null_mapped); -#endif // #ifdef PB_DS_DATA_TRUE +#endif } inline bool @@ -288,15 +269,13 @@ namespace pb_ds private: -#ifdef PB_DS_RB_TREE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; size_type assert_node_consistent(const node_pointer p_nd) const; - -#endif // #ifdef PB_DS_RB_TREE_DEBUG_ +#endif inline static bool is_effectively_black(const node_pointer p_nd); @@ -350,19 +329,11 @@ namespace pb_ds #include #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_NAME - #undef PB_DS_BASE_CLASS_NAME - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp index 633f027a7ba..8cb57501fc7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp @@ -49,85 +49,68 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - - PB_DS_DBG_ONLY(other.assert_valid();) - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) - - if (PB_DS_BASE_C_DEC::join_prep(other) == false) - { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - - return; - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) + if (PB_DS_BASE_C_DEC::join_prep(other) == false) + { + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + return; + } const node_pointer p_x = other.split_min(); - join_imp(p_x, other.m_p_head->m_p_parent); - PB_DS_BASE_C_DEC::join_finish(other); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_valid();) - - PB_DS_DBG_ONLY(other.assert_valid();) - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) + } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: join_imp(node_pointer p_x, node_pointer p_r) { - PB_DS_DBG_ASSERT(p_x != NULL); - + _GLIBCXX_DEBUG_ASSERT(p_x != NULL); if (p_r != NULL) p_r->m_red = false; - const size_type h = - black_height(PB_DS_BASE_C_DEC::m_p_head->m_p_parent); + const size_type h = black_height(PB_DS_BASE_C_DEC::m_p_head->m_p_parent); const size_type other_h = black_height(p_r); - node_pointer p_x_l; node_pointer p_x_r; - std::pair join_pos; - const bool right_join = h >= other_h; - if (right_join) { - join_pos = find_join_pos_right( PB_DS_BASE_C_DEC::m_p_head->m_p_parent, h, other_h); - + join_pos = find_join_pos_right(PB_DS_BASE_C_DEC::m_p_head->m_p_parent, + h, other_h); p_x_l = join_pos.first; p_x_r = p_r; } else { p_x_l = PB_DS_BASE_C_DEC::m_p_head->m_p_parent; - PB_DS_BASE_C_DEC::m_p_head->m_p_parent = p_r; if (p_r != NULL) p_r->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; - join_pos = find_join_pos_left( PB_DS_BASE_C_DEC::m_p_head->m_p_parent, h, other_h); - + join_pos = find_join_pos_left(PB_DS_BASE_C_DEC::m_p_head->m_p_parent, + h, other_h); p_x_r = join_pos.first; } node_pointer p_parent = join_pos.second; - if (p_parent == PB_DS_BASE_C_DEC::m_p_head) { PB_DS_BASE_C_DEC::m_p_head->m_p_parent = p_x; - p_x->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; } else { p_x->m_p_parent = p_parent; - if (right_join) p_x->m_p_parent->m_p_right = p_x; else @@ -145,14 +128,10 @@ join_imp(node_pointer p_x, node_pointer p_r) p_x->m_red = true; PB_DS_BASE_C_DEC::initialize_min_max(); - - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) - - PB_DS_BASE_C_DEC::update_to_top(p_x, (node_update* )this); - + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) + PB_DS_BASE_C_DEC::update_to_top(p_x, (node_update* )this); insert_fixup(p_x); - - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid()); + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid()); } PB_DS_CLASS_T_DEC @@ -162,14 +141,12 @@ split_min() { node_pointer p_min = PB_DS_BASE_C_DEC::m_p_head->m_p_left; -#ifdef PB_DS_RB_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const node_pointer p_head = PB_DS_BASE_C_DEC::m_p_head; - - PB_DS_DBG_ASSERT(p_min != p_head); -#endif // #ifdef PB_DS_RB_TREE_DEBUG_ + _GLIBCXX_DEBUG_ASSERT(p_min != p_head); +#endif remove_node(p_min); - return (p_min); } @@ -180,40 +157,34 @@ std::pair< PB_DS_CLASS_C_DEC:: find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r) { - PB_DS_DBG_ASSERT(h_l >= h_r); + _GLIBCXX_DEBUG_ASSERT(h_l >= h_r); if (PB_DS_BASE_C_DEC::m_p_head->m_p_parent == NULL) - return (std::make_pair((node_pointer)NULL, - PB_DS_BASE_C_DEC::m_p_head)); + return (std::make_pair((node_pointer)NULL, PB_DS_BASE_C_DEC::m_p_head)); node_pointer p_l_parent = PB_DS_BASE_C_DEC::m_p_head; - while (h_l > h_r) { if (p_l->m_red == false) { - PB_DS_DBG_ASSERT(h_l > 0); - + _GLIBCXX_DEBUG_ASSERT(h_l > 0); --h_l; } p_l_parent = p_l; - p_l = p_l->m_p_right; } if (!is_effectively_black(p_l)) { p_l_parent = p_l; - p_l = p_l->m_p_right; } - PB_DS_DBG_ASSERT(is_effectively_black(p_l)); - PB_DS_DBG_ASSERT(black_height(p_l) == h_r); - PB_DS_DBG_ASSERT(p_l == NULL || p_l->m_p_parent == p_l_parent); - - return (std::make_pair(p_l, p_l_parent)); + _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_l)); + _GLIBCXX_DEBUG_ASSERT(black_height(p_l) == h_r); + _GLIBCXX_DEBUG_ASSERT(p_l == NULL || p_l->m_p_parent == p_l_parent); + return std::make_pair(p_l, p_l_parent); } PB_DS_CLASS_T_DEC @@ -223,40 +194,33 @@ std::pair< PB_DS_CLASS_C_DEC:: find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r) { - PB_DS_DBG_ASSERT(h_r > h_l); - + _GLIBCXX_DEBUG_ASSERT(h_r > h_l); if (PB_DS_BASE_C_DEC::m_p_head->m_p_parent == NULL) return (std::make_pair((node_pointer)NULL, PB_DS_BASE_C_DEC::m_p_head)); - node_pointer p_r_parent = PB_DS_BASE_C_DEC::m_p_head; - while (h_r > h_l) { if (p_r->m_red == false) { - PB_DS_DBG_ASSERT(h_r > 0); - + _GLIBCXX_DEBUG_ASSERT(h_r > 0); --h_r; } p_r_parent = p_r; - p_r = p_r->m_p_left; } if (!is_effectively_black(p_r)) { p_r_parent = p_r; - p_r = p_r->m_p_left; } - PB_DS_DBG_ASSERT(is_effectively_black(p_r)); - PB_DS_DBG_ASSERT(black_height(p_r) == h_l); - PB_DS_DBG_ASSERT(p_r == NULL || p_r->m_p_parent == p_r_parent); - - return (std::make_pair(p_r, p_r_parent)); + _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_r)); + _GLIBCXX_DEBUG_ASSERT(black_height(p_r) == h_l); + _GLIBCXX_DEBUG_ASSERT(p_r == NULL || p_r->m_p_parent == p_r_parent); + return std::make_pair(p_r, p_r_parent); } PB_DS_CLASS_T_DEC @@ -265,16 +229,13 @@ PB_DS_CLASS_C_DEC:: black_height(node_pointer p_nd) { size_type h = 1; - while (p_nd != NULL) { if (p_nd->m_red == false) ++h; - p_nd = p_nd->m_p_left; } - - return (h); + return h; } PB_DS_CLASS_T_DEC @@ -282,68 +243,55 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid()); - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::assert_valid();) if (PB_DS_BASE_C_DEC::split_prep(r_key, other) == false) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); - + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); return; } - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) - - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid();) - - node_pointer p_nd = upper_bound(r_key).m_p_nd; - + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid();) + node_pointer p_nd = upper_bound(r_key).m_p_nd; do { node_pointer p_next_nd = p_nd->m_p_parent; - - if (Cmp_Fn::operator()( - r_key, - PB_DS_V2F(p_nd->m_value))) + if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) split_at_node(p_nd, other); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid();) - - p_nd = p_next_nd; + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid();) + p_nd = p_next_nd; } while (p_nd != PB_DS_BASE_C_DEC::m_p_head); PB_DS_BASE_C_DEC::split_finish(other); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); node_pointer p_l = p_nd->m_p_left; node_pointer p_r = p_nd->m_p_right; - node_pointer p_parent = p_nd->m_p_parent; - if (p_parent == PB_DS_BASE_C_DEC::m_p_head) { PB_DS_BASE_C_DEC::m_p_head->m_p_parent = p_l; - if (p_l != NULL) { p_l->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; - p_l->m_red = false; } } @@ -364,11 +312,8 @@ split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) } PB_DS_BASE_C_DEC::initialize_min_max(); - other.join_imp(p_nd, p_r); - - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid()); - - PB_DS_DBG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid()); + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.PB_DS_BASE_C_DEC::structure_only_assert_valid()); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp index 5b3b1b16fd1..8b439c805e9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp @@ -48,7 +48,7 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap_() { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -56,7 +56,7 @@ PB_DS_CLASS_C_DEC:: rc_binomial_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -68,7 +68,7 @@ rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other) : base_type::find_max(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -81,14 +81,14 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) base_type::swap(other); m_rc.swap(other.m_rc); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp index ffeb9bba4eb..e621cb58ca9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation for rc_binomial_heap_. */ -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { base_type::assert_valid(false); - if (!base_type::empty()) { - PB_DS_DBG_ASSERT(base_type::m_p_max != NULL); - + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_max != NULL); base_type::assert_max(); } @@ -65,36 +63,27 @@ assert_valid() const if (m_rc.empty()) { base_type::assert_valid(true); - - PB_DS_DBG_ASSERT(next_2_pointer(base_type::m_p_root) == NULL); - + _GLIBCXX_DEBUG_ASSERT(next_2_pointer(base_type::m_p_root) == NULL); return; } const_node_pointer p_nd = next_2_pointer(base_type::m_p_root); - typename rc_t::const_iterator it = m_rc.end(); --it; while (p_nd != NULL) { - PB_DS_DBG_ASSERT(*it == p_nd); - + _GLIBCXX_DEBUG_ASSERT(*it == p_nd); const_node_pointer p_next = p_nd->m_p_next_sibling; - - PB_DS_DBG_ASSERT(p_next != NULL); - - PB_DS_DBG_ASSERT(p_nd->m_metadata == p_next->m_metadata); - - PB_DS_DBG_ASSERT(p_next->m_p_next_sibling == NULL || + _GLIBCXX_DEBUG_ASSERT(p_next != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_next->m_metadata); + _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == NULL || p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); --it; - p_nd = next_2_pointer(next_after_0_pointer(p_nd)); } - - PB_DS_DBG_ASSERT(it + 1 == m_rc.begin()); + _GLIBCXX_DEBUG_ASSERT(it + 1 == m_rc.begin()); } PB_DS_CLASS_T_DEC @@ -135,4 +124,4 @@ next_after_0_pointer(const_node_pointer p_nd) return next_after_0_pointer(p_next); } -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP__DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp index 2e6bc3dd91f..b38141cc6cb 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp @@ -50,11 +50,8 @@ PB_DS_CLASS_C_DEC:: pop() { make_binomial_heap(); - - PB_DS_DBG_ASSERT(!base_type::empty()); - + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); base_type::pop(); - base_type::find_max(); } @@ -64,7 +61,6 @@ PB_DS_CLASS_C_DEC:: clear() { base_type::clear(); - m_rc.clear(); } @@ -74,21 +70,19 @@ PB_DS_CLASS_C_DEC:: make_binomial_heap() { node_pointer p_nd = base_type::m_p_root; - while (p_nd != NULL) { node_pointer p_next = p_nd->m_p_next_sibling; - if (p_next == NULL) p_nd = p_next; else if (p_nd->m_metadata == p_next->m_metadata) p_nd = link_with_next_sibling(p_nd); else if (p_nd->m_metadata < p_next->m_metadata) p_nd = p_next; -#ifdef PB_DS_RC_BINOMIAL_HEAP__DEBUG_ +#ifdef _GLIBCXX_DEBUG else - PB_DS_DBG_ASSERT(0); -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP__DEBUG_ + _GLIBCXX_DEBUG_ASSERT(0); +#endif } m_rc.clear(); @@ -101,14 +95,10 @@ PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { make_binomial_heap(); - const size_type ersd = base_type::erase_if(pred); - base_type::find_max(); - - PB_DS_DBG_ONLY(assert_valid();) - - return ersd; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return ersd; } PB_DS_CLASS_T_DEC @@ -117,9 +107,7 @@ PB_DS_CLASS_C_DEC:: erase(point_iterator it) { make_binomial_heap(); - base_type::erase(it); - base_type::find_max(); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp index 5a9ae2f1fdc..c0f0d01f746 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp @@ -49,11 +49,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) make_0_exposed(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); @@ -73,7 +73,7 @@ push(const_reference r_val) if (p_nd->m_p_next_sibling != NULL&& p_nd->m_p_next_sibling->m_metadata == 0) m_rc.push(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return point_iterator(p_nd); } @@ -83,7 +83,7 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) make_binomial_heap(); @@ -91,7 +91,7 @@ modify(point_iterator it, const_reference r_new_val) base_type::find_max(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -101,8 +101,8 @@ link_with_next_sibling(node_pointer p_nd) { node_pointer p_next = p_nd->m_p_next_sibling; - PB_DS_DBG_ASSERT(p_next != NULL); - PB_DS_DBG_ASSERT(p_next->m_p_prev_or_parent == p_nd); + _GLIBCXX_DEBUG_ASSERT(p_next != NULL); + _GLIBCXX_DEBUG_ASSERT(p_next->m_p_prev_or_parent == p_nd); if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value)) { @@ -150,8 +150,8 @@ make_0_exposed() m_rc.pop(); - PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling != NULL); - PB_DS_DBG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata); node_pointer p_res = link_with_next_sibling(p_nd); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp index 437e5224c16..dc7869ca7a7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp @@ -52,23 +52,11 @@ namespace pb_ds namespace detail { -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - rc< \ - Node, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + rc template class rc @@ -137,17 +125,15 @@ namespace pb_ds const const_iterator end() const; -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG void assert_valid() const; -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ +#endif private: node_pointer m_a_entries[max_entries]; @@ -157,75 +143,62 @@ namespace pb_ds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - rc() : - m_over_top(0) - { - PB_DS_DBG_ONLY(assert_valid();) - } + rc() : m_over_top(0) + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - rc(const PB_DS_CLASS_C_DEC& other) : - m_over_top(0) - { - PB_DS_DBG_ONLY(assert_valid();) - } + rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0) + { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - const size_type over_top = - std::max(m_over_top, other.m_over_top); + const size_type over_top = std::max(m_over_top, other.m_over_top); for (size_type i = 0; i < over_top; ++i) std::swap(m_a_entries[i], other.m_a_entries[i]); std::swap(m_over_top, other.m_over_top); - - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: push(entry p_nd) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(m_over_top < max_entries); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); m_a_entries[m_over_top++] = p_nd; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: pop() { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!empty()); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!empty()); --m_over_top; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: top() const { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!empty()); - - return* (m_a_entries + m_over_top - 1); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!empty()); + return *(m_a_entries + m_over_top - 1); } PB_DS_CLASS_T_DEC @@ -233,56 +206,45 @@ namespace pb_ds PB_DS_CLASS_C_DEC:: empty() const { - PB_DS_DBG_ONLY(assert_valid();) - - return m_over_top == 0; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + return m_over_top == 0; } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const - { - return m_over_top; - } + { return m_over_top; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { - PB_DS_DBG_ONLY(assert_valid();) - - m_over_top = 0; - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) + m_over_top = 0; + _GLIBCXX_DEBUG_ONLY(assert_valid();) + } PB_DS_CLASS_T_DEC const typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const - { - return& m_a_entries[0]; - } + { return& m_a_entries[0]; } PB_DS_CLASS_T_DEC const typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const - { - return& m_a_entries[m_over_top]; - } + { return& m_a_entries[m_over_top]; } -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const - { - PB_DS_DBG_ASSERT(m_over_top < max_entries); - } -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ + { _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); } +#endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ PB_DS_CLASS_T_DEC @@ -291,23 +253,16 @@ namespace pb_ds trace() const { std::cout << "rc" << std::endl; - for (size_type i = 0; i < m_over_top; ++i) std::cerr << m_a_entries[i] << std::endl; - std::cout << std::endl; } -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ +#endif #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace detail +} // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_RC_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp index dbab1e98e2d..42417ed82fe 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp @@ -48,48 +48,27 @@ * Redundant-counter binomial heap. */ -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ -#include -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ #include #include #include #include +#include namespace pb_ds { namespace detail { - -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - rc_binomial_heap_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + rc_binomial_heap_ -#define PB_DS_BASE_C_DEC \ - binomial_heap_base_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_BASE_C_DEC \ + binomial_heap_base_ -#define PB_DS_RC_C_DEC \ - rc< \ - typename PB_DS_BASE_C_DEC::node, \ - Allocator> +#define PB_DS_RC_C_DEC \ + rc /** * class description = "8y|\|0|\/|i41 h34p 74813"> @@ -174,19 +153,15 @@ namespace pb_ds void join(PB_DS_CLASS_C_DEC& other); -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; - -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ +#endif private: @@ -199,15 +174,13 @@ namespace pb_ds void make_binomial_heap(); -#ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG static const_node_pointer next_2_pointer(const_node_pointer p_nd); static const_node_pointer next_after_0_pointer(const_node_pointer p_nd); - -#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_DEBUG_ +#endif private: rc_t m_rc; @@ -227,10 +200,5 @@ namespace pb_ds #undef PB_DS_BASE_C_DEC #undef PB_DS_RC_C_DEC - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp index d83b322a022..356732b4e0a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp @@ -50,8 +50,8 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) make_binomial_heap(); other.make_binomial_heap(); @@ -61,8 +61,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) base_type::find_max(); other.find_max(); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -70,8 +70,8 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) make_binomial_heap(); other.make_binomial_heap(); @@ -81,7 +81,7 @@ join(PB_DS_CLASS_C_DEC& other) base_type::find_max(); other.find_max(); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp index e2992866138..2733030dd00 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp @@ -52,61 +52,61 @@ PB_DS_CLASS_C_DEC:: hash_load_check_resize_trigger(float load_min, float load_max) : m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0), m_next_grow_size(0), m_resize_needed(false) -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_start() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_collision() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_end() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_start() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_collision() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_end() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_start() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_collision() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_end() -{ PB_DS_DBG_ONLY(assert_valid();) } +{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void @@ -115,7 +115,7 @@ notify_inserted(size_type num_entries) { m_resize_needed = (num_entries >= m_next_grow_size); size_base::set_size(num_entries); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -125,7 +125,7 @@ notify_erased(size_type num_entries) { size_base::set_size(num_entries); m_resize_needed = num_entries <= m_next_shrink_size; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -133,7 +133,7 @@ inline bool PB_DS_CLASS_C_DEC:: is_resize_needed() const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return m_resize_needed; } @@ -142,7 +142,7 @@ inline bool PB_DS_CLASS_C_DEC:: is_grow_needed(size_type /*size*/, size_type num_entries) const { - PB_DS_DBG_ASSERT(m_resize_needed); + _GLIBCXX_DEBUG_ASSERT(m_resize_needed); return num_entries >= m_next_grow_size; } @@ -168,7 +168,7 @@ notify_resized(size_type new_size) static_cast(m_next_grow_size) << " " << std::endl; #endif - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -181,9 +181,9 @@ notify_externally_resized(size_type new_size) size_type new_shrink_size = size_type(m_load_min * new_size ); if (new_grow_size >= m_next_grow_size) { - PB_DS_DBG_ASSERT(new_shrink_size > m_next_shrink_size); + _GLIBCXX_DEBUG_ASSERT(new_shrink_size > m_next_shrink_size); m_next_grow_size = new_grow_size; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ std::cerr << "hlcrt::notify_externally_resized1 " << @@ -196,7 +196,7 @@ notify_externally_resized(size_type new_size) return; } - PB_DS_DBG_ASSERT(new_shrink_size <= m_next_shrink_size); + _GLIBCXX_DEBUG_ASSERT(new_shrink_size <= m_next_shrink_size); m_next_shrink_size = new_shrink_size; #ifdef PB_DS_HT_MAP_RESIZE_TRACE_ @@ -208,7 +208,7 @@ notify_externally_resized(size_type new_size) static_cast(m_next_grow_size) << " " << std::endl; #endif - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -216,10 +216,10 @@ void PB_DS_CLASS_C_DEC:: notify_cleared() { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) size_base::set_size(0); m_resize_needed = (0 < m_next_shrink_size); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -227,8 +227,8 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) size_base::swap(other); std::swap(m_load_min, other.m_load_min); @@ -237,8 +237,8 @@ swap(PB_DS_CLASS_C_DEC& other) std::swap(m_next_grow_size, other.m_next_grow_size); std::swap(m_next_shrink_size, other.m_next_shrink_size); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -285,14 +285,14 @@ PB_DS_CLASS_C_DEC:: do_resize(size_type) { abort(); } -#ifdef PB_DS_HASH_POLICY_DEBUG +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { - PB_DS_DBG_ASSERT(m_load_max > m_load_min); - PB_DS_DBG_ASSERT(m_next_grow_size >= m_next_shrink_size); + _GLIBCXX_DEBUG_ASSERT(m_load_max > m_load_min); + _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= m_next_shrink_size); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp index 07ba7cf3ca2..459fdc1d755 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp @@ -60,7 +60,7 @@ PB_DS_CLASS_NAME() { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -70,7 +70,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -90,7 +90,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : { initialize(); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -98,13 +98,13 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_BASE_C_DEC::swap(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp index dc5bb05f430..6f78bf24073 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation class for splay_tree_. */ -#ifdef PB_DS_SPLAY_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,9 +52,7 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { PB_DS_BASE_C_DEC::assert_valid(); - const node_pointer p_head = PB_DS_BASE_C_DEC::m_p_head; - assert_special_imp(p_head); } @@ -68,19 +66,15 @@ assert_special_imp(const node_pointer p_nd) const if (p_nd == PB_DS_BASE_C_DEC::m_p_head) { - PB_DS_DBG_ASSERT(p_nd->m_special); - + _GLIBCXX_DEBUG_ASSERT(p_nd->m_special); assert_special_imp(p_nd->m_p_parent); - return; } - PB_DS_DBG_ASSERT(!p_nd->m_special); - + _GLIBCXX_DEBUG_ASSERT(!p_nd->m_special); assert_special_imp(p_nd->m_p_left); - assert_special_imp(p_nd->m_p_right); } -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp index 015eb783c4c..272bd365bec 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp @@ -64,7 +64,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it == PB_DS_BASE_C_DEC::end()) return (it); @@ -75,7 +75,7 @@ erase(iterator it) erase_node(it.m_p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -85,7 +85,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); if (it.m_p_nd == PB_DS_BASE_C_DEC::m_p_head) return (it); @@ -96,7 +96,7 @@ erase(reverse_iterator it) erase_node(it.m_p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ret_it); } @@ -107,7 +107,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) size_type num_ersd = 0; @@ -125,7 +125,7 @@ erase_if(Pred pred) ++it; } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return (num_ersd); } @@ -135,12 +135,12 @@ void PB_DS_CLASS_C_DEC:: erase_node(node_pointer p_nd) { - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); splay(p_nd); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(p_nd == this->m_p_head->m_p_parent); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); node_pointer p_l = p_nd->m_p_left; node_pointer p_r = p_nd->m_p_right; @@ -156,14 +156,14 @@ erase_node(node_pointer p_nd) if (p_l != NULL) p_l->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } node_pointer p_target_r = leftmost(p_r); - PB_DS_DBG_ASSERT(p_target_r != NULL); + _GLIBCXX_DEBUG_ASSERT(p_target_r != NULL); p_r->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; @@ -171,11 +171,11 @@ erase_node(node_pointer p_nd) splay(p_target_r); - PB_DS_DBG_ONLY(p_target_r->m_p_left = NULL); + _GLIBCXX_DEBUG_ONLY(p_target_r->m_p_left = NULL); - PB_DS_DBG_ASSERT(p_target_r->m_p_parent == this->m_p_head); + _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_parent == this->m_p_head); - PB_DS_DBG_ASSERT(this->m_p_head->m_p_parent == + _GLIBCXX_DEBUG_ASSERT(this->m_p_head->m_p_parent == p_target_r); p_target_r->m_p_left = p_l; @@ -183,7 +183,7 @@ erase_node(node_pointer p_nd) if (p_l != NULL) p_l->m_p_parent = p_target_r; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) apply_update(p_target_r, (node_update* )this); } @@ -193,7 +193,7 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: leftmost(node_pointer p_nd) { - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); while (p_nd->m_p_left != NULL) p_nd = p_nd->m_p_left; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp index a0f9cc1cb68..6be38e2abe0 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp @@ -75,7 +75,7 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) { - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) node_pointer p_nd = PB_DS_BASE_C_DEC::m_p_head->m_p_parent; @@ -98,7 +98,7 @@ inline const typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) const { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = PB_DS_BASE_C_DEC::m_p_head->m_p_parent; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp index a9af7ddb16f..c9f3768566e 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp @@ -49,18 +49,18 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) std::pair ins_pair = insert_leaf_imp(r_value); ins_pair.first.m_p_nd->m_special = false; - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); splay(ins_pair.first.m_p_nd); - PB_DS_DBG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); return (ins_pair); } @@ -70,7 +70,7 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf_imp(const_reference r_value) { - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::structure_only_assert_valid();) if (PB_DS_BASE_C_DEC::m_size == 0) return (std::make_pair( @@ -106,7 +106,7 @@ insert_leaf_imp(const_reference r_value) PB_DS_BASE_C_DEC::insert_leaf_new(r_value, PB_DS_BASE_C_DEC::m_p_head->m_p_right, false), true)); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::check_key_does_not_exist( + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::check_key_does_not_exist( PB_DS_V2F(r_value))); p_nd = p_pot->m_p_left; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp index 4006159b06a..1525b5cbb03 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp @@ -51,52 +51,47 @@ splay(node_pointer p_nd) { while (p_nd->m_p_parent != PB_DS_BASE_C_DEC::m_p_head) { -#ifdef PB_DS_SPLAY_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG { node_pointer p_head = PB_DS_BASE_C_DEC::m_p_head; - assert_special_imp(p_head); } -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ +#endif - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) - if (p_nd->m_p_parent->m_p_parent == - PB_DS_BASE_C_DEC::m_p_head) + if (p_nd->m_p_parent->m_p_parent == PB_DS_BASE_C_DEC::m_p_head) { PB_DS_BASE_C_DEC::rotate_parent(p_nd); - - PB_DS_DBG_ASSERT(p_nd == this->m_p_head->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); } else { const node_pointer p_parent = p_nd->m_p_parent; const node_pointer p_grandparent = p_parent->m_p_parent; -#ifdef PB_DS_SPLAY_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG const size_type total = PB_DS_BASE_C_DEC::recursive_count(p_grandparent); + _GLIBCXX_DEBUG_ASSERT(total >= 3); +#endif - PB_DS_DBG_ASSERT(total >= 3); -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ - - if (p_parent->m_p_left == p_nd&& + if (p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent) splay_zig_zag_left(p_nd, p_parent, p_grandparent); - else if (p_parent->m_p_right == p_nd&& + else if (p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zag_right(p_nd, p_parent, p_grandparent); - else if (p_parent->m_p_left == p_nd&& + else if (p_parent->m_p_left == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zig_left(p_nd, p_parent, p_grandparent); else splay_zig_zig_right(p_nd, p_parent, p_grandparent); - - PB_DS_DBG_ASSERT(total ==this->recursive_count(p_nd)); + _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); } - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) + } } PB_DS_CLASS_T_DEC @@ -104,13 +99,13 @@ inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { - PB_DS_DBG_ASSERT(p_parent == p_nd->m_p_parent); - PB_DS_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) - PB_DS_DBG_ASSERT(p_parent->m_p_left == p_nd&& - p_grandparent->m_p_right == p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && + p_grandparent->m_p_right == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); @@ -139,13 +134,13 @@ inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { - PB_DS_DBG_ASSERT(p_parent == p_nd->m_p_parent); - PB_DS_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) - PB_DS_DBG_ASSERT(p_parent->m_p_right == p_nd&& - p_grandparent->m_p_left == p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && + p_grandparent->m_p_left == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); @@ -174,12 +169,12 @@ inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { - PB_DS_DBG_ASSERT(p_parent == p_nd->m_p_parent); - PB_DS_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) - PB_DS_DBG_ASSERT(p_parent->m_p_left == p_nd&& + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); @@ -209,12 +204,12 @@ inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { - PB_DS_DBG_ASSERT(p_parent == p_nd->m_p_parent); - PB_DS_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_grandparent);) - PB_DS_DBG_ASSERT(p_parent->m_p_right == p_nd&& + _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd&& p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); @@ -236,9 +231,7 @@ splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_gra if (p_c != NULL) p_c->m_p_parent = p_grandparent; - PB_DS_BASE_C_DEC::update_to_top( - p_grandparent, (node_update* )this); - + PB_DS_BASE_C_DEC::update_to_top(p_grandparent, (node_update* )this); splay_zz_end(p_nd, p_parent, p_grandparent); } @@ -246,16 +239,16 @@ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zz_start(node_pointer p_nd, -#ifdef PB_DS_SPLAY_TREE_DEBUG_ +#ifdef _GLIBCXX_DEBUG node_pointer p_parent, -#else // #ifdef PB_DS_SPLAY_TREE_DEBUG_ +#else node_pointer /*p_parent*/, -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ +#endif node_pointer p_grandparent) { - PB_DS_DBG_ASSERT(p_nd != NULL); - PB_DS_DBG_ASSERT(p_parent != NULL); - PB_DS_DBG_ASSERT(p_grandparent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_grandparent != NULL); const bool grandparent_head = p_grandparent->m_p_parent == PB_DS_BASE_C_DEC::m_p_head; @@ -266,7 +259,6 @@ splay_zz_start(node_pointer p_nd, PB_DS_BASE_C_DEC::m_p_head->m_p_parent; p_nd->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; - return; } @@ -292,6 +284,6 @@ splay_zz_end(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparen apply_update(p_parent, (node_update* )this); apply_update(p_nd, (node_update* )this); - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) - } + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_node_consistent(p_nd);) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp index 9a36582ade0..281b47d2f97 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp @@ -78,35 +78,26 @@ #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR #define PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR #include -#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR #define PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR #include -#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif +#endif #include #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_SPLAY_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_SPLAY_TREE_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ - #define PB_DS_CLASS_T_DEC \ template< \ typename Key, \ @@ -118,22 +109,22 @@ namespace pb_ds #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_CLASS_NAME \ splay_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_CLASS_NAME \ splay_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #ifdef PB_DS_DATA_TRUE_INDICATOR #define PB_DS_BASE_CLASS_NAME \ bin_search_tree_data_ -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_BASE_CLASS_NAME \ bin_search_tree_no_data_ -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif #define PB_DS_CLASS_C_DEC \ PB_DS_CLASS_NAME< \ @@ -155,13 +146,13 @@ namespace pb_ds #define PB_DS_V2F(X) (X).first #define PB_DS_V2S(X) (X).second #define PB_DS_EP2VP(X)& ((X)->m_value) -#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR +#endif #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() #define PB_DS_EP2VP(X)& ((X)->m_value.first) -#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR +#endif // $p14y 7r33 7481. template ins_pair = - insert_leaf_imp( - value_type( - r_key, - mapped_type())); + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + std::pair ins_pair = + insert_leaf_imp(value_type(r_key, mapped_type())); ins_pair.first.m_p_nd->m_special = false; - - PB_DS_DBG_ONLY(PB_DS_BASE_C_DEC::assert_valid()); - + _GLIBCXX_DEBUG_ONLY(PB_DS_BASE_C_DEC::assert_valid()); splay(ins_pair.first.m_p_nd); - - PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) - - return (ins_pair.first.m_p_nd->m_value.second); -#else // #ifdef PB_DS_DATA_TRUE_INDICATOR + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + return ins_pair.first.m_p_nd->m_value.second; +#else insert(r_key); - - return (PB_DS_BASE_C_DEC::s_null_mapped); -#endif // #ifdef PB_DS_DATA_TRUE + return PB_DS_BASE_C_DEC::s_null_mapped; +#endif } inline point_iterator @@ -326,15 +308,13 @@ namespace pb_ds inline const node_pointer find_imp(const_key_reference r_key) const; -#ifdef PB_DS_SPLAY_TREE_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; void assert_special_imp(const node_pointer p_nd) const; - -#endif // #ifdef PB_DS_SPLAY_TREE_DEBUG_ +#endif void splay(node_pointer p_nd); @@ -374,23 +354,14 @@ namespace pb_ds #include #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_NAME - #undef PB_DS_BASE_CLASS_NAME - #undef PB_DS_BASE_C_DEC #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp index 78606a8aafc..f8f73df9d80 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp @@ -49,29 +49,29 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (PB_DS_BASE_C_DEC::join_prep(other) == false) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } node_pointer p_target_r = other.leftmost(other.m_p_head); - PB_DS_DBG_ASSERT(p_target_r != NULL); + _GLIBCXX_DEBUG_ASSERT(p_target_r != NULL); other.splay(p_target_r); - PB_DS_DBG_ASSERT(p_target_r == other.m_p_head->m_p_parent); - PB_DS_DBG_ASSERT(p_target_r->m_p_left == NULL); + _GLIBCXX_DEBUG_ASSERT(p_target_r == other.m_p_head->m_p_parent); + _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left == NULL); p_target_r->m_p_left = PB_DS_BASE_C_DEC::m_p_head->m_p_parent; - PB_DS_DBG_ASSERT(p_target_r->m_p_left != NULL); + _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left != NULL); p_target_r->m_p_left->m_p_parent = p_target_r; PB_DS_BASE_C_DEC::m_p_head->m_p_parent = p_target_r; @@ -81,8 +81,8 @@ join(PB_DS_CLASS_C_DEC& other) PB_DS_BASE_C_DEC::join_finish(other); - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -90,25 +90,25 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); if (PB_DS_BASE_C_DEC::split_prep(r_key, other) == false) { - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); return; } node_pointer p_upper_bound = upper_bound(r_key).m_p_nd; - PB_DS_DBG_ASSERT(p_upper_bound != NULL); + _GLIBCXX_DEBUG_ASSERT(p_upper_bound != NULL); splay(p_upper_bound); - PB_DS_DBG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head); + _GLIBCXX_DEBUG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head); node_pointer p_new_root = p_upper_bound->m_p_left; - PB_DS_DBG_ASSERT(p_new_root != NULL); + _GLIBCXX_DEBUG_ASSERT(p_new_root != NULL); PB_DS_BASE_C_DEC::m_p_head->m_p_parent = p_new_root; p_new_root->m_p_parent = PB_DS_BASE_C_DEC::m_p_head; @@ -121,7 +121,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) PB_DS_BASE_C_DEC::split_finish(other); - PB_DS_DBG_ONLY(assert_valid()); - PB_DS_DBG_ONLY(other.assert_valid()); + _GLIBCXX_DEBUG_ONLY(assert_valid()); + _GLIBCXX_DEBUG_ONLY(other.assert_valid()); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp index 783711269d9..1b0c6e53644 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp @@ -52,9 +52,8 @@ copy_from_range(It first_it, It last_it) { while (first_it != last_it) push(*(first_it++)); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -62,9 +61,8 @@ thin_heap_() : m_p_max(NULL) { initialize(); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -73,9 +71,8 @@ thin_heap_(const Cmp_Fn& r_cmp_fn) : m_p_max(NULL) { initialize(); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -83,29 +80,24 @@ thin_heap_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other) { initialize(); - m_p_max = base_type::m_p_root; - for (node_pointer p_nd = base_type::m_p_root; p_nd != NULL; p_nd = p_nd->m_p_next_sibling) if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) m_p_max = p_nd; - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - - base_type::swap(other); - + _GLIBCXX_DEBUG_ONLY(assert_valid();) + base_type::swap(other); std::swap(m_p_max, other.m_p_max); - - PB_DS_DBG_ONLY(assert_valid();) - } + _GLIBCXX_DEBUG_ONLY(assert_valid();) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -116,7 +108,5 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: initialize() -{ - std::fill(m_a_aux, m_a_aux + max_rank, static_cast(NULL)); -} +{ std::fill(m_a_aux, m_a_aux + max_rank, static_cast(NULL)); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp index e6d89db3683..310907d8834 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp @@ -44,7 +44,7 @@ * Contains an implementation for thin_heap_. */ -#ifdef PB_DS_THIN_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void @@ -52,11 +52,8 @@ PB_DS_CLASS_C_DEC:: assert_valid() const { base_type::assert_valid(); - assert_node_consistent(base_type::m_p_root, true); - assert_max(); - assert_aux_null(); } @@ -66,7 +63,7 @@ PB_DS_CLASS_C_DEC:: assert_aux_null() const { for (size_type i = 0; i < max_rank; ++i) - PB_DS_DBG_ASSERT(m_a_aux[i] == NULL); + _GLIBCXX_DEBUG_ASSERT(m_a_aux[i] == NULL); } PB_DS_CLASS_T_DEC @@ -76,18 +73,15 @@ assert_max() const { if (m_p_max == NULL) { - PB_DS_DBG_ASSERT(base_type::empty()); - + _GLIBCXX_DEBUG_ASSERT(base_type::empty()); return; } - PB_DS_DBG_ASSERT(!base_type::empty()); - - PB_DS_DBG_ASSERT(base_type::parent(m_p_max) == NULL); - PB_DS_DBG_ASSERT(m_p_max->m_p_prev_or_parent == NULL); - + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_max->m_p_prev_or_parent == NULL); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) - PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); + _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC @@ -96,32 +90,29 @@ PB_DS_CLASS_C_DEC:: assert_node_consistent(const_node_pointer p_nd, bool root) const { base_type::assert_node_consistent(p_nd, root); - if (p_nd == NULL) return; assert_node_consistent(p_nd->m_p_next_sibling, root); assert_node_consistent(p_nd->m_p_l_child, false); - if (!root) { if (p_nd->m_metadata == 0) - PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling == NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == NULL); else - PB_DS_DBG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); } if (p_nd->m_p_l_child != NULL) - PB_DS_DBG_ASSERT(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); const bool unmarked_valid =(p_nd->m_p_l_child == NULL&& p_nd->m_metadata == 0) ||(p_nd->m_p_l_child != NULL&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); const bool marked_valid =(p_nd->m_p_l_child == NULL&& p_nd->m_metadata == 1) ||(p_nd->m_p_l_child != NULL&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); - PB_DS_DBG_ASSERT(unmarked_valid || marked_valid); - + _GLIBCXX_DEBUG_ASSERT(unmarked_valid || marked_valid); if (root) - PB_DS_DBG_ASSERT(unmarked_valid); + _GLIBCXX_DEBUG_ASSERT(unmarked_valid); } -#endif // #ifdef PB_DS_THIN_HEAP_DEBUG_ +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp index 9fd81f75d03..9f409df158a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp @@ -49,10 +49,10 @@ void PB_DS_CLASS_C_DEC:: pop() { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); - PB_DS_DBG_ASSERT(m_p_max != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL); node_pointer p_nd = m_p_max; @@ -60,7 +60,7 @@ pop() base_type::actual_erase_node(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -125,7 +125,7 @@ add_to_aux(node_pointer p_nd) while (m_a_aux[r] != NULL) { - PB_DS_DBG_ASSERT(p_nd->m_metadata < rank_bound()); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); if (Cmp_Fn::operator()(m_a_aux[r]->m_value, p_nd->m_value)) make_child_of(m_a_aux[r], p_nd); @@ -141,7 +141,7 @@ add_to_aux(node_pointer p_nd) ++r; } - PB_DS_DBG_ASSERT(p_nd->m_metadata < rank_bound()); + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); m_a_aux[r] = p_nd; } @@ -151,8 +151,8 @@ inline void PB_DS_CLASS_C_DEC:: make_child_of(node_pointer p_nd, node_pointer p_new_parent) { - PB_DS_DBG_ASSERT(p_nd->m_metadata == p_new_parent->m_metadata); - PB_DS_DBG_ASSERT(m_a_aux[p_nd->m_metadata] == p_nd || + _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_new_parent->m_metadata); + _GLIBCXX_DEBUG_ASSERT(m_a_aux[p_nd->m_metadata] == p_nd || m_a_aux[p_nd->m_metadata] == p_new_parent); ++p_new_parent->m_metadata; @@ -183,7 +183,7 @@ make_from_aux() ++i; } - PB_DS_DBG_ONLY(assert_aux_null();) + _GLIBCXX_DEBUG_ONLY(assert_aux_null();) } PB_DS_CLASS_T_DEC @@ -224,8 +224,8 @@ void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_nd = it.m_p_nd; @@ -233,7 +233,7 @@ erase(point_iterator it) base_type::actual_erase_node(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -242,11 +242,11 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return 0; } @@ -281,7 +281,7 @@ erase_if(Pred pred) p_cur = p_next; } - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp index 9a3fb87be15..256bd1ceed3 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp @@ -49,9 +49,9 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ASSERT(!base_type::empty()); + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); - PB_DS_DBG_ASSERT(m_p_max != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL); return m_p_max->m_value; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp index 3eacd78e7b0..451793fee05 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp @@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = base_type::get_new_node_for_insert(r_val); @@ -63,7 +63,7 @@ push(const_reference r_val) m_p_max = base_type::m_p_root = p_nd; - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return point_iterator(p_nd); } @@ -76,7 +76,7 @@ push(const_reference r_val) update_max(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return point_iterator(p_nd); } @@ -139,7 +139,7 @@ fix(node_pointer p_y) } else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1) { - PB_DS_DBG_ASSERT(p_y->m_p_l_child != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != NULL); if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2) { @@ -172,11 +172,11 @@ inline void PB_DS_CLASS_C_DEC:: fix_root(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent == NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == NULL); make_root(p_y); - PB_DS_DBG_ONLY(assert_node_consistent(p_y, true);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, true);) } PB_DS_CLASS_T_DEC @@ -184,12 +184,12 @@ inline void PB_DS_CLASS_C_DEC:: fix_sibling_rank_1_unmarked(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != NULL); - PB_DS_DBG_ONLY(node_pointer p_w = p_y->m_p_l_child;) - PB_DS_DBG_ASSERT(p_w != NULL); - PB_DS_DBG_ASSERT(p_w->m_p_next_sibling == NULL); - PB_DS_DBG_ASSERT(p_y->m_p_next_sibling == NULL); + _GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;) + _GLIBCXX_DEBUG_ASSERT(p_w != NULL); + _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == NULL); p_y->m_p_next_sibling = p_y->m_p_l_child; @@ -197,7 +197,7 @@ fix_sibling_rank_1_unmarked(node_pointer p_y) p_y->m_p_l_child = NULL; - PB_DS_DBG_ONLY(assert_node_consistent(p_y, false);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) } PB_DS_CLASS_T_DEC @@ -205,12 +205,12 @@ inline void PB_DS_CLASS_C_DEC:: fix_sibling_rank_1_marked(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent != NULL); - PB_DS_DBG_ASSERT(p_y->m_p_l_child == NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == NULL); p_y->m_metadata = 0; - PB_DS_DBG_ONLY(assert_node_consistent(p_y, false);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) } PB_DS_CLASS_T_DEC @@ -218,23 +218,23 @@ inline void PB_DS_CLASS_C_DEC:: fix_sibling_general_unmarked(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != NULL); node_pointer p_w = p_y->m_p_l_child; - PB_DS_DBG_ASSERT(p_w != NULL); - PB_DS_DBG_ASSERT(p_w->m_p_next_sibling != NULL); + _GLIBCXX_DEBUG_ASSERT(p_w != NULL); + _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != NULL); p_y->m_p_l_child = p_w->m_p_next_sibling; p_w->m_p_next_sibling->m_p_prev_or_parent = p_y; p_w->m_p_next_sibling = p_y->m_p_next_sibling; - PB_DS_DBG_ASSERT(p_w->m_p_next_sibling != NULL); + _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != NULL); p_w->m_p_next_sibling->m_p_prev_or_parent = p_w; p_y->m_p_next_sibling = p_w; p_w->m_p_prev_or_parent = p_y; - PB_DS_DBG_ONLY(assert_node_consistent(p_y, false);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) } PB_DS_CLASS_T_DEC @@ -242,11 +242,11 @@ inline void PB_DS_CLASS_C_DEC:: fix_sibling_general_marked(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != NULL); --p_y->m_metadata; - PB_DS_DBG_ONLY(assert_node_consistent(p_y, false);) + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) } PB_DS_CLASS_T_DEC @@ -254,7 +254,7 @@ inline void PB_DS_CLASS_C_DEC:: fix_child(node_pointer p_y) { - PB_DS_DBG_ASSERT(p_y->m_p_prev_or_parent != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != NULL); if (p_y->m_p_next_sibling != NULL) p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent; @@ -272,10 +272,10 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = it.m_p_nd; - PB_DS_DBG_ASSERT(p_nd != NULL); + _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); const bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value); @@ -289,7 +289,7 @@ modify(point_iterator it, const_reference r_new_val) make_root_and_link(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } @@ -298,13 +298,13 @@ modify(point_iterator it, const_reference r_new_val) { update_max(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } node_pointer p_y = p_nd->m_p_prev_or_parent; - PB_DS_DBG_ASSERT(p_y != NULL); + _GLIBCXX_DEBUG_ASSERT(p_y != NULL); if (p_nd->m_p_next_sibling != NULL) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y; @@ -318,7 +318,7 @@ modify(point_iterator it, const_reference r_new_val) make_root_and_link(p_nd); - PB_DS_DBG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp index 58c7e18ad58..a24d0aac009 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp @@ -50,15 +50,15 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) other.clear(); if (base_type::empty()) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } @@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) while (p_out != NULL) { - PB_DS_DBG_ASSERT(base_type::m_size > 0); + _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0); --base_type::m_size; ++other.m_size; @@ -81,7 +81,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) node_pointer p_cur = base_type::m_p_root; @@ -98,8 +98,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_cur = p_next; } - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC @@ -107,8 +107,8 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) node_pointer p_other = other.m_p_root; @@ -127,6 +127,6 @@ join(PB_DS_CLASS_C_DEC& other) other.m_size = 0; other.m_p_max = NULL; - PB_DS_DBG_ONLY(assert_valid();) - PB_DS_DBG_ONLY(other.assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp index 4c4f423584d..6d1f4ba9ca8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp @@ -52,55 +52,33 @@ * Tarjan and Kaplan. */ -#ifdef PB_DS_THIN_HEAP_DEBUG_ -#include -#endif // #ifdef PB_DS_THIN_HEAP_DEBUG_ #include #include #include #include #include +#include namespace pb_ds { namespace detail { -#ifdef PB_DS_THIN_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_THIN_HEAP_DEBUG_ -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_THIN_HEAP_DEBUG_ - -#define PB_DS_CLASS_T_DEC \ +#define PB_DS_CLASS_T_DEC \ template -#define PB_DS_CLASS_C_DEC \ - thin_heap_< \ - Value_Type, \ - Cmp_Fn, \ - Allocator> +#define PB_DS_CLASS_C_DEC \ + thin_heap_ -#ifdef PB_DS_LC_NS_HEAP_DEBUG_ +#ifdef _GLIBCXX_DEBUG +#define PB_DS_BASE_C_DEC \ + left_child_next_sibling_heap_ +#else #define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - typename Allocator::size_type, \ - Allocator, \ - true> -#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ -#define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - typename Allocator::size_type, \ - Allocator> -#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_ + left_child_next_sibling_heap_ +#endif /** * class description = "t|-|i|\| h34p"> @@ -209,22 +187,18 @@ namespace pb_ds void copy_from_range(It first_it, It last_it); -#ifdef PB_DS_THIN_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_valid() const; void assert_max() const; - -#endif // #ifdef PB_DS_THIN_HEAP_DEBUG_ +#endif #ifdef PB_DS_THIN_HEAP_TRACE_ - void trace() const; - -#endif // #ifdef PB_DS_THIN_HEAP_TRACE_ +#endif private: enum @@ -291,15 +265,13 @@ namespace pb_ds inline node_pointer join(node_pointer p_lhs, node_pointer p_rhs) const; -#ifdef PB_DS_THIN_HEAP_DEBUG_ - +#ifdef _GLIBCXX_DEBUG void assert_node_consistent(const_node_pointer p_nd, bool root) const; void assert_aux_null() const; - -#endif // #ifdef PB_DS_THIN_HEAP_DEBUG_ +#endif private: node_pointer m_p_max; @@ -313,7 +285,6 @@ namespace pb_ds }; // Taken from the SGI implementation; acknowledged in the docs. - static const std::size_t g_a_rank_bounds[num_distinct_rank_bounds] = { /* Dealing cards... */ @@ -377,16 +348,10 @@ namespace pb_ds #include #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_THIN_HEAP_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/types_traits.hpp b/libstdc++-v3/include/ext/pb_ds/detail/types_traits.hpp index 58522c1c402..88f8757ce41 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/types_traits.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/types_traits.hpp @@ -56,24 +56,15 @@ namespace pb_ds namespace detail { - template + template struct vt_base_selector { typedef value_type_base< Key, Mapped, Allocator, Store_Extra> type; }; - template - struct types_traits : public vt_base_selector< - Key, - Mapped, - Allocator, - Store_Extra>::type + template + struct types_traits + : public vt_base_selector::type { typedef typename Allocator::template rebind< Key>::other key_allocator; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp index 180cd409587..e1e93a5eed9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp @@ -105,7 +105,7 @@ public: inline const_pointer operator->() const { - PB_DS_DBG_ASSERT(m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_value != NULL); return (m_p_value); } @@ -114,7 +114,7 @@ public: inline const_reference operator*() const { - PB_DS_DBG_ASSERT(m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_value != NULL); return (*m_p_value); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp index da13bde5f9c..11afafbbb57 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp @@ -103,7 +103,7 @@ public: inline pointer operator->() const { - PB_DS_DBG_ASSERT(base_type::m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != NULL); return (const_cast(base_type::m_p_value)); } @@ -112,7 +112,7 @@ public: inline reference operator*() const { - PB_DS_DBG_ASSERT(base_type::m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != NULL); return (const_cast(*base_type::m_p_value)); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp index 5ef1c9e8966..7b96425b145 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp @@ -92,7 +92,7 @@ public: inline pointer operator->() const { - PB_DS_DBG_ASSERT(m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_value != NULL); return (m_p_value); } @@ -101,7 +101,7 @@ public: inline reference operator*() const { - PB_DS_DBG_ASSERT(m_p_value != NULL); + _GLIBCXX_DEBUG_ASSERT(m_p_value != NULL); return (*m_p_value); } diff --git a/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp b/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp index 1451fa8c847..3d3f20bac32 100644 --- a/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp @@ -47,17 +47,6 @@ #ifndef PB_DS_HASH_POLICY_HPP #define PB_DS_HASH_POLICY_HPP -#ifdef PB_DS_HASH_POLICY_DEBUG -# include -# define PB_DS_DBG_ASSERT(X) assert(X) -# define PB_DS_DBG_VERIFY(X) assert(X) -# define PB_DS_DBG_ONLY(X) X -#else -# define PB_DS_DBG_ASSERT(X) -# define PB_DS_DBG_VERIFY(X) {if((X)==0);} -# define PB_DS_DBG_ONLY(X) ; -#endif - #include #include #include @@ -288,7 +277,7 @@ namespace pb_ds typedef PB_DS_SIZE_BASE_C_DEC size_base; -#ifdef PB_DS_HASH_POLICY_DEBUG +#ifdef _GLIBCXX_DEBUG void assert_valid() const; #endif @@ -615,10 +604,6 @@ namespace pb_ds #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace pb_ds #endif diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp index 65b3c8d8270..937cc6735df 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp +++ b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp @@ -59,16 +59,6 @@ namespace pb_ds namespace test { -#ifdef NATIVE_HASH_MULTIMAP_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef NATIVE_HASH_MULTIMAP_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef NATIVE_HASH_MULTIMAP_DEBUG - #define PB_DS_CLASS_T_DEC \ template< \ typename Key, \ @@ -216,36 +206,25 @@ namespace pb_ds static std::string desc() { - return (make_xml_tag( "type", "value", "__gnucxx_hash_multimap")); + return (make_xml_tag("type", "value", "__gnucxx_hash_multimap")); } }; PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: - native_hash_multimap() -#ifdef __GNUC__ - : - base_type(Init_Size) -#endif // #ifdef __GNUC__ + native_hash_multimap() : base_type(Init_Size) { } PB_DS_CLASS_T_DEC template PB_DS_CLASS_C_DEC:: - native_hash_multimap(It f, It l) : - base_type(f, l) + native_hash_multimap(It f, It l) : base_type(f, l) { } #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_BASE_C_DEC -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - } // namespace test } // namespace pb_ds diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp index f428ca8cdea..42b9766e3c7 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp +++ b/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp @@ -57,16 +57,6 @@ namespace pb_ds namespace test { -#ifdef NATIVE_HASH_SET_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef NATIVE_HASH_SET_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef NATIVE_HASH_SET_DEBUG - #define PB_DS_CLASS_T_DEC \ template @@ -155,7 +145,6 @@ namespace pb_ds { if (it->second == r_val.second) return it; - ++it; } @@ -179,7 +168,6 @@ namespace pb_ds { if (it->second == r_val.second) return it; - ++it; } @@ -198,7 +186,7 @@ namespace pb_ds static std::string desc() { - return (make_xml_tag( "type", "value", "std_multimap")); + return (make_xml_tag("type", "value", "std_multimap")); } }; @@ -210,21 +198,13 @@ namespace pb_ds PB_DS_CLASS_T_DEC template PB_DS_CLASS_C_DEC:: - native_multimap(It f, It l) : - base_type(f, l) + native_multimap(It f, It l) : base_type(f, l) { } #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - #undef PB_DS_BASE_C_DEC - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY - - } // namespace test +} // namespace test } // namespace pb_ds diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp index eedce6bed01..53072db887b 100644 --- a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp +++ b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator.hpp @@ -51,17 +51,8 @@ namespace pb_ds { - namespace test { - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - dbg_ex_allocator< \ - T> - template class dbg_ex_allocator : public detail::dbg_ex_allocator_base { @@ -80,127 +71,59 @@ namespace pb_ds typedef dbg_ex_allocator other; }; - dbg_ex_allocator() throw(); + dbg_ex_allocator() throw() { } - dbg_ex_allocator(const PB_DS_CLASS_C_DEC& ) throw(); + dbg_ex_allocator(const dbg_ex_allocator& ) throw() { } template - dbg_ex_allocator(const dbg_ex_allocator& ) throw(); + dbg_ex_allocator(const dbg_ex_allocator& ) throw() { } - ~dbg_ex_allocator() throw(); + ~dbg_ex_allocator() throw() { } size_type - max_size() const throw(); + max_size() const throw() + { return std::allocator().max_size(); } pointer allocate(size_type num, std::allocator::const_pointer hint = 0); void - construct(pointer p, const T& r_val); + construct(pointer p, const T& r_val) + { return std::allocator().construct(p, r_val); } void - destroy(pointer p); + destroy(pointer p) + { std::allocator().destroy(p); } void - deallocate(pointer p, size_type num); + deallocate(pointer p, size_type num) + { + erase(p, sizeof(T) * num); + std::allocator().deallocate(p, num); + } void - check_allocated(pointer p, size_type num); + check_allocated(pointer p, size_type num) + { detail::dbg_ex_allocator_base::check_allocated(p, sizeof(T) * num); } }; - PB_DS_CLASS_T_DEC - inline bool - operator==(const PB_DS_CLASS_C_DEC& , const PB_DS_CLASS_C_DEC& ); - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - dbg_ex_allocator() throw() - { } - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - dbg_ex_allocator(const PB_DS_CLASS_C_DEC& ) throw() - { } - - PB_DS_CLASS_T_DEC - template - PB_DS_CLASS_C_DEC:: - dbg_ex_allocator(const dbg_ex_allocator& ) throw() - { } - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - ~dbg_ex_allocator() throw() - { } - - PB_DS_CLASS_T_DEC - typename PB_DS_CLASS_C_DEC::size_type - PB_DS_CLASS_C_DEC:: - max_size() const throw() - { - return (std::allocator().max_size()); - } - - PB_DS_CLASS_T_DEC - typename PB_DS_CLASS_C_DEC::pointer - PB_DS_CLASS_C_DEC:: + template + typename dbg_ex_allocator::pointer + dbg_ex_allocator:: allocate(size_type num, std::allocator::const_pointer hint/*= 0*/) { cond_throw(); - T* const a_t = std::allocator().allocate(num, hint); - - insert(a_t, sizeof(T)* num); - - return (a_t); + insert(a_t, sizeof(T) * num); + return a_t; } - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - construct(pointer p, const T& r_val) - { - return (std::allocator().construct(p, r_val)); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - destroy(pointer p) - { - std::allocator().destroy(p); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - deallocate(pointer p, size_type num) - { - erase(p, sizeof(T)* num); - - std::allocator().deallocate(p, num); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - check_allocated(pointer p, size_type num) - { - detail::dbg_ex_allocator_base::check_allocated(p, sizeof(T)* num); - } - - PB_DS_CLASS_T_DEC + template inline bool - operator==(const PB_DS_CLASS_C_DEC& , const PB_DS_CLASS_C_DEC& ) - { - return (true); - } - -#undef PB_DS_CLASS_T_DEC -#undef PB_DS_CLASS_C_DEC + operator==(const dbg_ex_allocator& , const dbg_ex_allocator& ) + { return true; } } // namespace test - } // namespace pb_ds -#endif // #ifndef PB_DS_DBG_EX_ALLOCATOR_HPP +#endif diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp index caedd36aa52..9831281e3f1 100644 --- a/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp +++ b/libstdc++-v3/testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp @@ -57,13 +57,10 @@ namespace pb_ds { - namespace test { - namespace detail { - class dbg_ex_allocator_base; std::ostream& @@ -96,14 +93,11 @@ namespace pb_ds group_throw_prob_adjustor(size_t size) : m_orig_throw_prob(s_throw_prob) { s_throw_prob = - 1 - ::pow((double)( - 1 - s_throw_prob),(double)(0.5 / (size + 1))); + 1 - ::pow(double(1 - s_throw_prob), double(0.5 / (size + 1))); } ~group_throw_prob_adjustor() - { - s_throw_prob = m_orig_throw_prob; - } + { s_throw_prob = m_orig_throw_prob; } private: const double m_orig_throw_prob; @@ -113,14 +107,10 @@ namespace pb_ds { public: zero_throw_prob_adjustor() : m_orig_throw_prob(s_throw_prob) - { - s_throw_prob = 0; - } + { s_throw_prob = 0; } ~zero_throw_prob_adjustor() - { - s_throw_prob = m_orig_throw_prob; - } + { s_throw_prob = m_orig_throw_prob; } private: const double m_orig_throw_prob; @@ -143,17 +133,12 @@ namespace pb_ds check_allocated(void* p_r, size_t size); private: - typedef std::pair< label, size_t> alloc_data_t; + typedef std::pair alloc_data_t; + typedef std::map map_t; + typedef map_t::value_type entry_t; + typedef map_t::const_iterator const_iterator; + typedef map_t::const_reference const_reference; - typedef std::map< void* , alloc_data_t> map_t; - - typedef map_t::value_type entry_t; - - typedef map_t::const_iterator const_iterator; - - typedef map_t::const_reference const_reference; - - private: static void print_to_ostream(std::ostream& r_os); @@ -163,25 +148,16 @@ namespace pb_ds static entry_t make_entry(void* p_r, size_t size); - private: static twister_rand_gen s_g; + static map_t s_map; + static double s_throw_prob; + static size_t s_label; - static map_t s_map; - - static double s_throw_prob; - - static size_t s_label; - - friend std::ostream& operator<<(std::ostream& r_os, const dbg_ex_allocator_base& r_dbg); + friend std::ostream& operator<<(std::ostream& r_os, + const dbg_ex_allocator_base& r_dbg); }; - - std::ostream& - operator<<(std::ostream& r_os, const dbg_ex_allocator_base& r_dbg); - } // namespace detail - } // namespace test - } // namespace pb_ds #endif // #ifndef PB_DS_DBG_EX_ALLOCATOR_BASE_HPP diff --git a/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp b/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp index a46ad2c0604..36942033139 100644 --- a/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp +++ b/libstdc++-v3/testsuite/util/regression/res_mng/forced_exception.hpp @@ -49,15 +49,11 @@ namespace pb_ds { - namespace test { - struct forced_exception { }; - } // namespace test - } // namespace pb_ds #endif // #ifndef PB_DS_FORCED_EXCEPTION_HPP diff --git a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc b/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc index 2163eb704fb..879844a0259 100644 --- a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc +++ b/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc @@ -43,23 +43,14 @@ * @file twister_rand_gen.cc */ -#include #include +#include +#include namespace pb_ds { namespace test { -#ifdef PB_DS_TWISTER_RAND_GEN_DEBUG -#define PB_DS_DBG_ASSERT(X) assert(X) -#define PB_DS_DBG_VERIFY(X) assert(X) -#define PB_DS_DBG_ONLY(X) X -#else // #ifdef PB_DS_TWISTER_RAND_GEN_DEBUG -#define PB_DS_DBG_ASSERT(X) -#define PB_DS_DBG_VERIFY(X) {if((X)==0);} -#define PB_DS_DBG_ONLY(X) ; -#endif // #ifdef PB_DS_TWISTER_RAND_GEN_DEBUG - twister_rand_gen:: twister_rand_gen(unsigned int seed) : m_base_generator(seed) @@ -76,14 +67,14 @@ namespace pb_ds twister_rand_gen:: get_unsigned_long(unsigned long min, unsigned long max) { - PB_DS_DBG_ASSERT(max >= min); + _GLIBCXX_DEBUG_ASSERT(max >= min); const double prob = get_prob(); const unsigned long rand_word = (unsigned long)((max - min + 1) * prob) + min; - PB_DS_DBG_ASSERT(rand_word <= max); + _GLIBCXX_DEBUG_ASSERT(rand_word <= max); return rand_word; } @@ -101,13 +92,9 @@ namespace pb_ds const double ret = eng_res / eng_range; - PB_DS_DBG_ASSERT(ret >=0 && ret <= 1); + _GLIBCXX_DEBUG_ASSERT(ret >=0 && ret <= 1); return ret; } - -#undef PB_DS_DBG_ASSERT -#undef PB_DS_DBG_VERIFY -#undef PB_DS_DBG_ONLY } // namespace test } // namespace pb_ds