Commit 47bea7b8 by Benjamin Kosnik Committed by Benjamin Kosnik

debug.h (_GLIBCXX_DEBUG_ONLY): New.

2006-09-08  Benjamin Kosnik  <bkoz@redhat.com>

	* 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.

From-SVN: r116766
parent 5de1a1eb
...@@ -60,6 +60,7 @@ namespace __gnu_debug ...@@ -60,6 +60,7 @@ namespace __gnu_debug
# define _GLIBCXX_DEBUG_ASSERT(_Condition) # define _GLIBCXX_DEBUG_ASSERT(_Condition)
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
# define _GLIBCXX_DEBUG_ONLY(_Statement) ;
# define __glibcxx_requires_cond(_Cond,_Msg) # define __glibcxx_requires_cond(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last) # define __glibcxx_requires_valid_range(_First,_Last)
# define __glibcxx_requires_sorted(_First,_Last) # define __glibcxx_requires_sorted(_First,_Last)
...@@ -109,6 +110,7 @@ namespace std ...@@ -109,6 +110,7 @@ namespace std
#else #else
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
#endif #endif
# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last) \ # define __glibcxx_requires_valid_range(_First,_Last) \
......
// Bitmap Allocator. -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -52,23 +52,14 @@ ...@@ -52,23 +52,14 @@
// For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock. // For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock.
#include <bits/gthr.h> #include <bits/gthr.h>
// Define this to enable error checking withing the allocator #include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT
// itself(to debug the allocator itself).
//#define _BALLOC_SANITY_CHECK
/** @brief The constant in the expression below is the alignment /** @brief The constant in the expression below is the alignment
* required in bytes. * required in bytes.
*/ */
#define _BALLOC_ALIGN_BYTES 8 #define _BALLOC_ALIGN_BYTES 8
#if defined _BALLOC_SANITY_CHECK
#include <cassert>
#define _BALLOC_ASSERT(_EXPR) assert(_EXPR)
#else
#define _BALLOC_ASSERT(_EXPR)
#endif
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
using std::size_t; using std::size_t;
...@@ -618,7 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -618,7 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
_M_curr_bmap = reinterpret_cast<size_t*> _M_curr_bmap = reinterpret_cast<size_t*>
(_M_vbp[_M_curr_index].first) - 1; (_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_last_bmap_in_block = _M_curr_bmap
- ((_M_vbp[_M_curr_index].second - ((_M_vbp[_M_curr_index].second
...@@ -904,7 +895,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -904,7 +895,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
typedef typename typedef typename
balloc::__mini_vector<_Block_pair> _BPVector; 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 // Complexity: O(lg(N)). Where, N is the number of block of size
// sizeof(value_type). // sizeof(value_type).
void void
...@@ -919,7 +910,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -919,7 +910,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
(_S_mem_blocks.begin(), _S_mem_blocks.end(), (_S_mem_blocks.begin(), _S_mem_blocks.end(),
__gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff)); __gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff));
_BALLOC_ASSERT(__bpi == _S_mem_blocks.end()); _GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end());
} }
#endif #endif
...@@ -937,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -937,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
void void
_S_refill_pool() throw(std::bad_alloc) _S_refill_pool() throw(std::bad_alloc)
{ {
#if defined _BALLOC_SANITY_CHECK #if defined _GLIBCXX_DEBUG
_S_check_for_free_blocks(); _S_check_for_free_blocks();
#endif #endif
...@@ -1110,14 +1101,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1110,14 +1101,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
_Difference_type __diff; _Difference_type __diff;
long __displacement; 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*> if (__gnu_cxx::balloc::_Inclusive_between<_Alloc_block*>
(__real_p) (__real_p)
(_S_mem_blocks[_S_last_dealloc_index])) (_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! // Initial Assumption was correct!
__diff = _S_last_dealloc_index; __diff = _S_last_dealloc_index;
...@@ -1132,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1132,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
__gnu_cxx::balloc:: __gnu_cxx::balloc::
_Inclusive_between<_Alloc_block*>(__real_p)); _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(); __diff = _iter - _S_mem_blocks.begin();
__displacement = __real_p - _S_mem_blocks[__diff].first; __displacement = __real_p - _S_mem_blocks[__diff].first;
...@@ -1152,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1152,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
(_S_mem_blocks[__diff].first) (_S_mem_blocks[__diff].first)
- (__gnu_cxx::balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1); - (__gnu_cxx::balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1);
_BALLOC_ASSERT(*__puse_count != 0); _GLIBCXX_DEBUG_ASSERT(*__puse_count != 0);
--(*__puse_count); --(*__puse_count);
...@@ -1182,7 +1173,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1182,7 +1173,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
if (_S_last_dealloc_index >= _S_mem_blocks.size()) if (_S_last_dealloc_index >= _S_mem_blocks.size())
{ {
_S_last_dealloc_index =(__diff != -1 ? __diff : 0); _S_last_dealloc_index =(__diff != -1 ? __diff : 0);
_BALLOC_ASSERT(_S_last_dealloc_index >= 0); _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0);
} }
} }
} }
......
...@@ -58,40 +58,26 @@ ...@@ -58,40 +58,26 @@
#include <ext/pb_ds/detail/tree_trace_base.hpp> #include <ext/pb_ds/detail/tree_trace_base.hpp>
#include <utility> #include <utility>
#include <functional> #include <functional>
#include <assert.h> #include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail 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 \ #define PB_DS_CLASS_T_DEC \
template< \ template<typename Key, typename Mapped, class Cmp_Fn, \
typename Key, \ class Node_And_It_Traits, class Allocator>
typename Mapped, \
class Cmp_Fn, \
class Node_And_It_Traits, \
class Allocator>
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_CLASS_NAME \ #define PB_DS_CLASS_NAME \
bin_search_tree_data_ bin_search_tree_data_
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif
#ifdef PB_DS_DATA_FALSE_INDICATOR #ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_CLASS_NAME \ #define PB_DS_CLASS_NAME \
bin_search_tree_no_data_ bin_search_tree_no_data_
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR #endif
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
PB_DS_CLASS_NAME< \ PB_DS_CLASS_NAME< \
...@@ -108,26 +94,23 @@ namespace pb_ds ...@@ -108,26 +94,23 @@ namespace pb_ds
Allocator, \ Allocator, \
false> false>
#ifdef PB_DS_USE_MAP_DEBUG_BASE #ifdef _GLIBCXX_DEBUG
#define PB_DS_MAP_DEBUG_BASE_C_DEC \ #define PB_DS_MAP_DEBUG_BASE_C_DEC \
map_debug_base< \ map_debug_base<Key, eq_by_less<Key, Cmp_Fn>, \
Key, \ typename Allocator::template rebind<Key>::other::const_reference>
eq_by_less<Key, Cmp_Fn>, \ #endif
typename Allocator::template rebind< \
Key>::other::const_reference>
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_V2F(X) (X).first #define PB_DS_V2F(X) (X).first
#define PB_DS_V2S(X) (X).second #define PB_DS_V2S(X) (X).second
#define PB_DS_EP2VP(X)& ((X)->m_value) #define PB_DS_EP2VP(X)& ((X)->m_value)
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif
#ifdef PB_DS_DATA_FALSE_INDICATOR #ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_V2F(X) (X) #define PB_DS_V2F(X) (X)
#define PB_DS_V2S(X) Mapped_Data() #define PB_DS_V2S(X) Mapped_Data()
#define PB_DS_EP2VP(X)& ((X)->m_value.first) #define PB_DS_EP2VP(X)& ((X)->m_value.first)
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR #endif
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
#define PB_DS_TREE_TRACE_BASE_C_DEC \ #define PB_DS_TREE_TRACE_BASE_C_DEC \
...@@ -137,7 +120,7 @@ namespace pb_ds ...@@ -137,7 +120,7 @@ namespace pb_ds
Cmp_Fn, \ Cmp_Fn, \
true, \ true, \
Allocator> Allocator>
#endif // #ifdef PB_DS_TREE_TRACE #endif
/** /**
* class description = "8i|\|4ree $34rc|-| 7r33 74813."> * class description = "8i|\|4ree $34rc|-| 7r33 74813.">
...@@ -148,12 +131,12 @@ namespace pb_ds ...@@ -148,12 +131,12 @@ namespace pb_ds
class Node_And_It_Traits, class Node_And_It_Traits,
class Allocator> class Allocator>
class PB_DS_CLASS_NAME : class PB_DS_CLASS_NAME :
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #ifdef _GLIBCXX_DEBUG
public PB_DS_MAP_DEBUG_BASE_C_DEC, public PB_DS_MAP_DEBUG_BASE_C_DEC,
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #endif
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
public PB_DS_TREE_TRACE_BASE_C_DEC, public PB_DS_TREE_TRACE_BASE_C_DEC,
#endif // #ifdef PB_DS_TREE_TRACE #endif
public Cmp_Fn, public Cmp_Fn,
public PB_DS_TYPES_TRAITS_C_DEC, public PB_DS_TYPES_TRAITS_C_DEC,
public Node_And_It_Traits::node_update public Node_And_It_Traits::node_update
...@@ -178,9 +161,9 @@ namespace pb_ds ...@@ -178,9 +161,9 @@ namespace pb_ds
private: private:
typedef cond_dealtor< node, Allocator> cond_dealtor_t; 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; typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #endif
public: public:
...@@ -203,7 +186,6 @@ namespace pb_ds ...@@ -203,7 +186,6 @@ namespace pb_ds
const_key_reference; const_key_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type; typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type;
typedef typedef
...@@ -221,8 +203,7 @@ namespace pb_ds ...@@ -221,8 +203,7 @@ namespace pb_ds
typedef typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference
const_mapped_reference; const_mapped_reference;
#endif
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type; typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type;
...@@ -426,8 +407,7 @@ namespace pb_ds ...@@ -426,8 +407,7 @@ namespace pb_ds
size_type size_type
recursive_count(node_pointer p_nd) const; recursive_count(node_pointer p_nd) const;
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid() const;
...@@ -436,12 +416,10 @@ namespace pb_ds ...@@ -436,12 +416,10 @@ namespace pb_ds
void void
assert_node_consistent(const node_pointer p_nd) const; assert_node_consistent(const node_pointer p_nd) const;
#endif
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
private: private:
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_iterators() const; assert_iterators() const;
...@@ -476,8 +454,7 @@ namespace pb_ds ...@@ -476,8 +454,7 @@ namespace pb_ds
node_consistent_t node_consistent_t
assert_node_consistent_(const node_pointer p_nd) const; assert_node_consistent_(const node_pointer p_nd) const;
#endif
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
void void
initialize(); initialize();
...@@ -516,15 +493,11 @@ namespace pb_ds ...@@ -516,15 +493,11 @@ namespace pb_ds
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
#undef PB_DS_TREE_TRACE_BASE_C_DEC #undef PB_DS_TREE_TRACE_BASE_C_DEC
#endif // #ifdef PB_DS_TREE_TRACE #endif
#undef PB_DS_V2F #undef PB_DS_V2F
#undef PB_DS_EP2VP #undef PB_DS_EP2VP
#undef PB_DS_V2S #undef PB_DS_V2S
#undef PB_DS_DBG_ASSERT
#undef PB_DS_DBG_VERIFY
#undef PB_DS_DBG_ONLY
} // namespace detail } // namespace detail
} // namespace pb_ds } // namespace pb_ds
...@@ -50,26 +50,20 @@ PB_DS_CLASS_C_DEC::s_node_allocator; ...@@ -50,26 +50,20 @@ PB_DS_CLASS_C_DEC::s_node_allocator;
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
m_p_head(s_node_allocator.allocate(1)),
m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(structure_only_assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
Cmp_Fn(r_cmp_fn), Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
m_p_head(s_node_allocator.allocate(1)),
m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(structure_only_assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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) : ...@@ -80,79 +74,64 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
m_size(0) m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(structure_only_assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : 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), map_debug_base(other),
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #endif
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
PB_DS_TREE_TRACE_BASE_C_DEC(other), PB_DS_TREE_TRACE_BASE_C_DEC(other),
#endif // #ifdef PB_DS_TREE_TRACE #endif
Cmp_Fn(other), Cmp_Fn(other),
node_update(other), node_update(other),
m_p_head(s_node_allocator.allocate(1)), m_p_head(s_node_allocator.allocate(1)),
m_size(0) m_size(0)
{ {
initialize(); initialize();
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
PB_DS_DBG_ONLY(other.structure_only_assert_valid();)
try try
{ {
m_p_head->m_p_parent = m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
recursive_copy_node(other.m_p_head->m_p_parent);
if (m_p_head->m_p_parent != NULL) if (m_p_head->m_p_parent != NULL)
m_p_head->m_p_parent->m_p_parent = m_p_head; m_p_head->m_p_parent->m_p_parent = m_p_head;
m_size = other.m_size; m_size = other.m_size;
initialize_min_max(); initialize_min_max();
} }
catch(...) catch(...)
{ {
PB_DS_DBG_ONLY(map_debug_base::clear();) _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
s_node_allocator.deallocate(m_p_head, 1);
s_node_allocator.deallocate(m_p_head, 1);
throw; throw;
} }
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(structure_only_assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(other.structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
value_swap(other);
value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_DBG_ONLY(structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
PB_DS_DBG_ONLY(other.structure_only_assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other) value_swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(map_debug_base::swap(other);) _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);)
std::swap(m_p_head, other.m_p_head);
std::swap(m_p_head, other.m_p_head);
std::swap(m_size, other.m_size); std::swap(m_size, other.m_size);
} }
...@@ -161,7 +140,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -161,7 +140,6 @@ PB_DS_CLASS_C_DEC::
~PB_DS_CLASS_NAME() ~PB_DS_CLASS_NAME()
{ {
clear(); clear();
s_node_allocator.deallocate(m_p_head, 1); s_node_allocator.deallocate(m_p_head, 1);
} }
...@@ -173,7 +151,6 @@ initialize() ...@@ -173,7 +151,6 @@ initialize()
m_p_head->m_p_parent = NULL; m_p_head->m_p_parent = NULL;
m_p_head->m_p_left = m_p_head; m_p_head->m_p_left = m_p_head;
m_p_head->m_p_right = m_p_head; m_p_head->m_p_right = m_p_head;
m_size = 0; m_size = 0;
} }
...@@ -186,7 +163,6 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -186,7 +163,6 @@ recursive_copy_node(const node_pointer p_nd)
return (NULL); return (NULL);
node_pointer p_ret = s_node_allocator.allocate(1); node_pointer p_ret = s_node_allocator.allocate(1);
try try
{ {
new (p_ret) node(*p_nd); new (p_ret) node(*p_nd);
...@@ -194,7 +170,6 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -194,7 +170,6 @@ recursive_copy_node(const node_pointer p_nd)
catch(...) catch(...)
{ {
s_node_allocator.deallocate(p_ret, 1); s_node_allocator.deallocate(p_ret, 1);
throw; throw;
} }
...@@ -203,13 +178,11 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -203,13 +178,11 @@ recursive_copy_node(const node_pointer p_nd)
try try
{ {
p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left); 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); p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right);
} }
catch(...) catch(...)
{ {
clear_imp(p_ret); clear_imp(p_ret);
throw; throw;
} }
...@@ -219,9 +192,8 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -219,9 +192,8 @@ recursive_copy_node(const node_pointer p_nd)
if (p_ret->m_p_right != NULL) if (p_ret->m_p_right != NULL)
p_ret->m_p_right->m_p_parent = p_ret; p_ret->m_p_right->m_p_parent = p_ret;
PB_DS_DBG_ONLY(assert_node_consistent(p_ret);) _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret);)
return p_ret;
return (p_ret);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -232,25 +204,20 @@ initialize_min_max() ...@@ -232,25 +204,20 @@ initialize_min_max()
if (m_p_head->m_p_parent == NULL) if (m_p_head->m_p_parent == NULL)
{ {
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return; return;
} }
{ {
node_pointer p_min = m_p_head->m_p_parent; node_pointer p_min = m_p_head->m_p_parent;
while (p_min->m_p_left != NULL) while (p_min->m_p_left != NULL)
p_min = p_min->m_p_left; p_min = p_min->m_p_left;
m_p_head->m_p_left = p_min; m_p_head->m_p_left = p_min;
} }
{ {
node_pointer p_max = m_p_head->m_p_parent; node_pointer p_max = m_p_head->m_p_parent;
while (p_max->m_p_right != NULL) while (p_max->m_p_right != NULL)
p_max = p_max->m_p_right; p_max = p_max->m_p_right;
m_p_head->m_p_right = p_max; m_p_head->m_p_right = p_max;
} }
} }
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains an implementation class for bin_search_tree_. * Contains an implementation class for bin_search_tree_.
*/ */
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_ #ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -52,20 +52,16 @@ PB_DS_CLASS_C_DEC:: ...@@ -52,20 +52,16 @@ PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid() const
{ {
structure_only_assert_valid(); structure_only_assert_valid();
assert_consistent_with_debug_base(); assert_consistent_with_debug_base();
assert_size(); assert_size();
assert_iterators(); assert_iterators();
if (m_p_head->m_p_parent == NULL) if (m_p_head->m_p_parent == NULL)
{ {
PB_DS_DBG_ASSERT(m_size == 0); _GLIBCXX_DEBUG_ASSERT(m_size == 0);
} }
else else
{ {
PB_DS_DBG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
} }
} }
...@@ -74,24 +70,21 @@ void ...@@ -74,24 +70,21 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
structure_only_assert_valid() const 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) if (m_p_head->m_p_parent == 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);
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);
} }
else else
{ {
PB_DS_DBG_ASSERT(m_p_head->m_p_parent->m_p_parent == 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);
PB_DS_DBG_ASSERT(m_p_head->m_p_left != m_p_head); _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head);
PB_DS_DBG_ASSERT(m_p_head->m_p_right != m_p_head);
} }
if (m_p_head->m_p_parent != NULL) if (m_p_head->m_p_parent != NULL)
assert_node_consistent(m_p_head->m_p_parent); assert_node_consistent(m_p_head->m_p_parent);
assert_min(); assert_min();
assert_max(); assert_max();
} }
...@@ -116,22 +109,18 @@ assert_node_consistent_(const node_pointer p_nd) const ...@@ -116,22 +109,18 @@ assert_node_consistent_(const node_pointer p_nd) const
assert_node_consistent_with_right(p_nd); assert_node_consistent_with_right(p_nd);
const std::pair<const_pointer, const_pointer> const std::pair<const_pointer, const_pointer>
l_range = l_range = assert_node_consistent_(p_nd->m_p_left);
assert_node_consistent_(p_nd->m_p_left);
if (l_range.second != NULL) if (l_range.second != NULL)
PB_DS_DBG_ASSERT(Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
PB_DS_V2F(*l_range.second), PB_DS_V2F(p_nd->m_value)));
PB_DS_V2F(p_nd->m_value)));
const std::pair<const_pointer, const_pointer> const std::pair<const_pointer, const_pointer>
r_range = r_range = assert_node_consistent_(p_nd->m_p_right);
assert_node_consistent_(p_nd->m_p_right);
if (r_range.first != NULL) if (r_range.first != NULL)
PB_DS_DBG_ASSERT(Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(p_nd->m_value), PB_DS_V2F(*r_range.first)));
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)); 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 ...@@ -143,12 +132,9 @@ assert_node_consistent_with_left(const node_pointer p_nd) const
{ {
if (p_nd->m_p_left == NULL) if (p_nd->m_p_left == NULL)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd);
PB_DS_DBG_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_DBG_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 PB_DS_CLASS_T_DEC
...@@ -158,11 +144,8 @@ assert_node_consistent_with_right(const node_pointer p_nd) const ...@@ -158,11 +144,8 @@ assert_node_consistent_with_right(const node_pointer p_nd) const
{ {
if (p_nd->m_p_right == NULL) if (p_nd->m_p_right == NULL)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd);
PB_DS_DBG_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_DBG_ASSERT(!Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_p_right->m_value),
PB_DS_V2F(p_nd->m_value))); PB_DS_V2F(p_nd->m_value)));
} }
...@@ -181,18 +164,15 @@ assert_min_imp(const node_pointer p_nd) const ...@@ -181,18 +164,15 @@ assert_min_imp(const node_pointer p_nd) const
{ {
if (p_nd == NULL) 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; return;
} }
if (p_nd->m_p_left == NULL) 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; return;
} }
assert_min_imp(p_nd->m_p_left); assert_min_imp(p_nd->m_p_left);
} }
...@@ -211,15 +191,13 @@ assert_max_imp(const node_pointer p_nd) const ...@@ -211,15 +191,13 @@ assert_max_imp(const node_pointer p_nd) const
{ {
if (p_nd == NULL) 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; return;
} }
if (p_nd->m_p_right == NULL) 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; return;
} }
...@@ -232,61 +210,40 @@ PB_DS_CLASS_C_DEC:: ...@@ -232,61 +210,40 @@ PB_DS_CLASS_C_DEC::
assert_iterators() const assert_iterators() const
{ {
size_type iterated_num = 0; size_type iterated_num = 0;
const_iterator prev_it = end(); const_iterator prev_it = end();
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
++iterated_num; ++iterated_num;
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
PB_DS_DBG_ASSERT(lower_bound( const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
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; --upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd);
PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd);
if (prev_it != end()) if (prev_it != end())
PB_DS_DBG_ASSERT(Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*prev_it), PB_DS_V2F(*it)));
PB_DS_V2F(*it)));
prev_it = 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; size_type reverse_iterated_num = 0;
const_reverse_iterator reverse_prev_it = rend(); const_reverse_iterator reverse_prev_it = rend();
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
++reverse_it) ++reverse_it)
{ {
++reverse_iterated_num; ++reverse_iterated_num;
_GLIBCXX_DEBUG_ASSERT(lower_bound(
PB_DS_DBG_ASSERT(lower_bound(
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
const_iterator upper_bound_it = upper_bound( const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
PB_DS_V2F(*reverse_it));
--upper_bound_it; --upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
if (reverse_prev_it != rend()) if (reverse_prev_it != rend())
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
PB_DS_V2F(*reverse_prev_it), PB_DS_V2F(*reverse_it)));
PB_DS_V2F(*reverse_it)));
reverse_prev_it = reverse_it; reverse_prev_it = reverse_it;
} }
_GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size);
PB_DS_DBG_ASSERT(reverse_iterated_num == m_size);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -295,7 +252,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -295,7 +252,6 @@ PB_DS_CLASS_C_DEC::
assert_consistent_with_debug_base() const assert_consistent_with_debug_base() const
{ {
map_debug_base::check_size(m_size); map_debug_base::check_size(m_size);
assert_consistent_with_debug_base(m_p_head->m_p_parent); 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 ...@@ -306,10 +262,7 @@ assert_consistent_with_debug_base(const node_pointer p_nd) const
{ {
if (p_nd == NULL) if (p_nd == NULL)
return; 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_left);
assert_consistent_with_debug_base(p_nd->m_p_right); assert_consistent_with_debug_base(p_nd->m_p_right);
} }
...@@ -319,7 +272,7 @@ void ...@@ -319,7 +272,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_size() const 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
...@@ -49,10 +49,10 @@ inline void ...@@ -49,10 +49,10 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_z) actual_erase_node(node_pointer p_z)
{ {
PB_DS_DBG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --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(); p_z->~node();
...@@ -94,7 +94,7 @@ void ...@@ -94,7 +94,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
PB_DS_DBG_ONLY(structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
clear_imp(m_p_head->m_p_parent); clear_imp(m_p_head->m_p_parent);
...@@ -102,9 +102,9 @@ clear() ...@@ -102,9 +102,9 @@ clear()
initialize(); 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 PB_DS_CLASS_T_DEC
......
...@@ -139,7 +139,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -139,7 +139,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) 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_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_nd = m_p_head->m_p_parent;
...@@ -165,7 +165,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator ...@@ -165,7 +165,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const 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_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_nd = m_p_head->m_p_parent;
......
...@@ -49,7 +49,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -49,7 +49,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_leaf(const_reference r_value) 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) if (m_size == 0)
return (std::make_pair( return (std::make_pair(
...@@ -80,15 +80,15 @@ insert_leaf(const_reference r_value) ...@@ -80,15 +80,15 @@ insert_leaf(const_reference r_value)
PB_DS_V2F(r_value), PB_DS_V2F(r_value),
PB_DS_V2F(p_pot->m_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))); PB_DS_V2F(r_value)));
return (std::make_pair(p_pot, false)); 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))); PB_DS_V2F(r_value)));
p_nd = p_pot->m_p_left; 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) ...@@ -115,8 +115,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
if (left_nd) if (left_nd)
{ {
PB_DS_DBG_ASSERT(p_nd->m_p_left == NULL); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == NULL);
PB_DS_DBG_ASSERT(Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
PB_DS_V2F(r_value), PB_DS_V2F(r_value),
PB_DS_V2F(p_nd->m_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) ...@@ -127,8 +127,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
} }
else else
{ {
PB_DS_DBG_ASSERT(p_nd->m_p_right == NULL); _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == NULL);
PB_DS_DBG_ASSERT(Cmp_Fn::operator()( _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_value), PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value))); PB_DS_V2F(r_value)));
...@@ -142,11 +142,11 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) ...@@ -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; 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); 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))); PB_DS_V2F(r_value)));
return (iterator(p_new_nd)); return (iterator(p_new_nd));
...@@ -167,7 +167,7 @@ insert_imp_empty(const_reference r_value) ...@@ -167,7 +167,7 @@ insert_imp_empty(const_reference r_value)
p_new_node->m_p_left = p_new_node->m_p_right = NULL; 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))); PB_DS_V2F(r_value)));
update_to_top(m_p_head->m_p_parent, (node_update* )this); update_to_top(m_p_head->m_p_parent, (node_update* )this);
......
...@@ -47,10 +47,8 @@ ...@@ -47,10 +47,8 @@
#ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
#define 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 <cassert>
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
#include <ext/pb_ds/tag_and_trait.hpp> #include <ext/pb_ds/tag_and_trait.hpp>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
...@@ -101,16 +99,6 @@ namespace pb_ds ...@@ -101,16 +99,6 @@ namespace pb_ds
!Is_Forward_Iterator, \ !Is_Forward_Iterator, \
Allocator> 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. // Const iterator.
template<typename Node_Pointer, template<typename Node_Pointer,
typename Value_Type, typename Value_Type,
...@@ -142,124 +130,96 @@ namespace pb_ds ...@@ -142,124 +130,96 @@ namespace pb_ds
public: public:
inline inline
bin_search_tree_const_it_(const Node_Pointer p_nd = NULL) : m_p_nd(const_cast<Node_Pointer>(p_nd)) bin_search_tree_const_it_(const Node_Pointer p_nd = NULL)
: m_p_nd(const_cast<Node_Pointer>(p_nd))
{ } { }
inline inline
bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
other) : m_p_nd(other.m_p_nd) : m_p_nd(other.m_p_nd)
{ } { }
inline inline
PB_DS_TREE_CONST_IT_C_DEC& PB_DS_TREE_CONST_IT_C_DEC&
operator=(const PB_DS_TREE_CONST_IT_C_DEC& operator=(const PB_DS_TREE_CONST_IT_C_DEC& other)
other)
{ {
m_p_nd = other.m_p_nd; m_p_nd = other.m_p_nd;
return *this;
return (*this);
} }
inline inline
PB_DS_TREE_CONST_IT_C_DEC& PB_DS_TREE_CONST_IT_C_DEC&
operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
other)
{ {
m_p_nd = other.m_p_nd; m_p_nd = other.m_p_nd;
return *this;
return (*this);
} }
inline const_pointer inline const_pointer
operator->() const operator->() const
{ {
PB_DS_DBG_ASSERT(m_p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
return &m_p_nd->m_value;
return (&m_p_nd->m_value);
} }
inline const_reference inline const_reference
operator*() const operator*() const
{ {
PB_DS_DBG_ASSERT(m_p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
return m_p_nd->m_value;
return (m_p_nd->m_value);
} }
inline bool inline bool
operator==(const PB_DS_TREE_CONST_IT_C_DEC operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const
& other) const { return m_p_nd == other.m_p_nd; }
{
return (m_p_nd == other.m_p_nd);
}
inline bool inline bool
operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const
& other) const { return m_p_nd == other.m_p_nd; }
{
return (m_p_nd == other.m_p_nd);
}
inline bool inline bool
operator!=(const PB_DS_TREE_CONST_IT_C_DEC& operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const
other) const { return m_p_nd != other.m_p_nd; }
{
return (m_p_nd != other.m_p_nd);
}
inline bool inline bool
operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const
other) const { return m_p_nd != other.m_p_nd; }
{
return (m_p_nd != other.m_p_nd);
}
inline PB_DS_TREE_CONST_IT_C_DEC& inline PB_DS_TREE_CONST_IT_C_DEC&
operator++() operator++()
{ {
PB_DS_DBG_ASSERT(m_p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
inc(integral_constant<int,Is_Forward_Iterator>()); inc(integral_constant<int,Is_Forward_Iterator>());
return *this;
return (*this);
} }
inline PB_DS_TREE_CONST_IT_C_DEC inline PB_DS_TREE_CONST_IT_C_DEC
operator++(int) operator++(int)
{ {
PB_DS_TREE_CONST_IT_C_DEC PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
ret_it(m_p_nd);
operator++(); operator++();
return ret_it;
return (ret_it);
} }
inline PB_DS_TREE_CONST_IT_C_DEC& inline PB_DS_TREE_CONST_IT_C_DEC&
operator--() operator--()
{ {
dec(integral_constant<int,Is_Forward_Iterator>()); dec(integral_constant<int,Is_Forward_Iterator>());
return *this;
return (*this);
} }
inline PB_DS_TREE_CONST_IT_C_DEC inline PB_DS_TREE_CONST_IT_C_DEC
operator--(int) operator--(int)
{ {
PB_DS_TREE_CONST_IT_C_DEC PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
ret_it(m_p_nd);
operator--(); operator--();
return ret_it;
return (ret_it);
} }
protected: protected:
inline void inline void
inc(false_type) inc(false_type)
{ { dec(true_type()); }
dec(true_type());
}
void void
inc(true_type) inc(true_type)
...@@ -268,26 +228,21 @@ namespace pb_ds ...@@ -268,26 +228,21 @@ namespace pb_ds
m_p_nd->m_p_parent->m_p_parent == m_p_nd) m_p_nd->m_p_parent->m_p_parent == m_p_nd)
{ {
m_p_nd = m_p_nd->m_p_left; m_p_nd = m_p_nd->m_p_left;
return; return;
} }
if (m_p_nd->m_p_right != NULL) if (m_p_nd->m_p_right != NULL)
{ {
m_p_nd = m_p_nd->m_p_right; m_p_nd = m_p_nd->m_p_right;
while (m_p_nd->m_p_left != NULL) while (m_p_nd->m_p_left != NULL)
m_p_nd = m_p_nd->m_p_left; m_p_nd = m_p_nd->m_p_left;
return; return;
} }
Node_Pointer p_y = m_p_nd->m_p_parent; Node_Pointer p_y = m_p_nd->m_p_parent;
while (m_p_nd == p_y->m_p_right) while (m_p_nd == p_y->m_p_right)
{ {
m_p_nd = p_y; m_p_nd = p_y;
p_y = p_y->m_p_parent; p_y = p_y->m_p_parent;
} }
...@@ -297,42 +252,32 @@ namespace pb_ds ...@@ -297,42 +252,32 @@ namespace pb_ds
inline void inline void
dec(false_type) dec(false_type)
{ { inc(true_type()); }
inc(true_type());
}
void void
dec(true_type) dec(true_type)
{ {
if (m_p_nd->special()&& if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd)
m_p_nd->m_p_parent->m_p_parent == m_p_nd)
{ {
m_p_nd = m_p_nd->m_p_right; m_p_nd = m_p_nd->m_p_right;
return; return;
} }
if (m_p_nd->m_p_left != NULL) if (m_p_nd->m_p_left != NULL)
{ {
Node_Pointer p_y = m_p_nd->m_p_left; Node_Pointer p_y = m_p_nd->m_p_left;
while (p_y->m_p_right != NULL) while (p_y->m_p_right != NULL)
p_y = p_y->m_p_right; p_y = p_y->m_p_right;
m_p_nd = p_y; m_p_nd = p_y;
return; return;
} }
Node_Pointer p_y = m_p_nd->m_p_parent; Node_Pointer p_y = m_p_nd->m_p_parent;
while (m_p_nd == p_y->m_p_left) while (m_p_nd == p_y->m_p_left)
{ {
m_p_nd = p_y; m_p_nd = p_y;
p_y = p_y->m_p_parent; p_y = p_y->m_p_parent;
} }
if (m_p_nd->m_p_left != p_y) if (m_p_nd->m_p_left != p_y)
m_p_nd = p_y; m_p_nd = p_y;
} }
...@@ -358,11 +303,13 @@ namespace pb_ds ...@@ -358,11 +303,13 @@ namespace pb_ds
public: public:
inline 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 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 inline
...@@ -370,8 +317,7 @@ namespace pb_ds ...@@ -370,8 +317,7 @@ namespace pb_ds
operator=(const PB_DS_TREE_IT_C_DEC& other) operator=(const PB_DS_TREE_IT_C_DEC& other)
{ {
base_it_type::m_p_nd = other.m_p_nd; base_it_type::m_p_nd = other.m_p_nd;
return *this;
return (*this);
} }
inline inline
...@@ -379,64 +325,51 @@ namespace pb_ds ...@@ -379,64 +325,51 @@ namespace pb_ds
operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other) operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other)
{ {
base_it_type::m_p_nd = other.m_p_nd; base_it_type::m_p_nd = other.m_p_nd;
return *this;
return (*this);
} }
inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer
operator->() const operator->() const
{ {
PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL);
return &base_it_type::m_p_nd->m_value;
return (&base_it_type::m_p_nd->m_value);
} }
inline typename PB_DS_TREE_CONST_IT_C_DEC::reference inline typename PB_DS_TREE_CONST_IT_C_DEC::reference
operator*() const operator*() const
{ {
PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL);
return base_it_type::m_p_nd->m_value;
return (base_it_type::m_p_nd->m_value);
} }
inline PB_DS_TREE_IT_C_DEC& inline PB_DS_TREE_IT_C_DEC&
operator++() operator++()
{ {
PB_DS_TREE_CONST_IT_C_DEC:: PB_DS_TREE_CONST_IT_C_DEC:: operator++();
operator++(); return *this;
return (*this);
} }
inline PB_DS_TREE_IT_C_DEC inline PB_DS_TREE_IT_C_DEC
operator++(int) operator++(int)
{ {
PB_DS_TREE_IT_C_DEC PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
ret_it(base_it_type::m_p_nd);
operator++(); operator++();
return ret_it;
return (ret_it);
} }
inline PB_DS_TREE_IT_C_DEC& inline PB_DS_TREE_IT_C_DEC&
operator--() operator--()
{ {
PB_DS_TREE_CONST_IT_C_DEC:: PB_DS_TREE_CONST_IT_C_DEC:: operator--();
operator--(); return *this;
return (*this);
} }
inline PB_DS_TREE_IT_C_DEC inline PB_DS_TREE_IT_C_DEC
operator--(int) operator--(int)
{ {
PB_DS_TREE_IT_C_DEC PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
ret_it(base_it_type::m_p_nd);
operator--(); operator--();
return ret_it;
return (ret_it);
} }
protected: protected:
...@@ -444,18 +377,11 @@ namespace pb_ds ...@@ -444,18 +377,11 @@ namespace pb_ds
}; };
#undef PB_DS_TREE_CONST_IT_C_DEC #undef PB_DS_TREE_CONST_IT_C_DEC
#undef PB_DS_TREE_CONST_ODIR_IT_C_DEC #undef PB_DS_TREE_CONST_ODIR_IT_C_DEC
#undef PB_DS_TREE_IT_C_DEC #undef PB_DS_TREE_IT_C_DEC
#undef PB_DS_TREE_ODIR_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 detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP #endif
...@@ -49,10 +49,10 @@ inline void ...@@ -49,10 +49,10 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
actual_erase_node(node_pointer p_z) actual_erase_node(node_pointer p_z)
{ {
PB_DS_DBG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --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(); p_z->~node();
...@@ -94,7 +94,7 @@ void ...@@ -94,7 +94,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
PB_DS_DBG_ONLY(structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
clear_imp(m_p_head->m_p_parent); clear_imp(m_p_head->m_p_parent);
...@@ -102,9 +102,9 @@ clear() ...@@ -102,9 +102,9 @@ clear()
initialize(); 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 PB_DS_CLASS_T_DEC
......
...@@ -68,8 +68,8 @@ rotate_left(node_pointer p_x) ...@@ -68,8 +68,8 @@ rotate_left(node_pointer p_x)
p_y->m_p_left = p_x; p_y->m_p_left = p_x;
p_x->m_p_parent = p_y; p_x->m_p_parent = p_y;
PB_DS_DBG_ONLY(assert_node_consistent(p_x);) _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
PB_DS_DBG_ONLY(assert_node_consistent(p_y);) _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); apply_update(p_x->m_p_parent, (node_update* )this);
...@@ -99,8 +99,8 @@ rotate_right(node_pointer p_x) ...@@ -99,8 +99,8 @@ rotate_right(node_pointer p_x)
p_y->m_p_right = p_x; p_y->m_p_right = p_x;
p_x->m_p_parent = p_y; p_x->m_p_parent = p_y;
PB_DS_DBG_ONLY(assert_node_consistent(p_x);) _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
PB_DS_DBG_ONLY(assert_node_consistent(p_y);) _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); apply_update(p_x->m_p_parent, (node_update* )this);
...@@ -118,8 +118,8 @@ rotate_parent(node_pointer p_nd) ...@@ -118,8 +118,8 @@ rotate_parent(node_pointer p_nd)
else else
rotate_left(p_parent); rotate_left(p_parent);
PB_DS_DBG_ASSERT(p_parent->m_p_parent = p_nd); _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
PB_DS_DBG_ASSERT(p_nd->m_p_left == p_parent || _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
p_nd->m_p_right == p_parent); p_nd->m_p_right == p_parent);
} }
......
...@@ -49,8 +49,8 @@ bool ...@@ -49,8 +49,8 @@ bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other) join_prep(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
if (other.m_size == 0) if (other.m_size == 0)
return (false); return (false);
...@@ -78,7 +78,7 @@ join_prep(PB_DS_CLASS_C_DEC& other) ...@@ -78,7 +78,7 @@ join_prep(PB_DS_CLASS_C_DEC& other)
m_size += other.m_size; m_size += other.m_size;
PB_DS_DBG_ONLY(map_debug_base::join(other);) _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
return (true); return (true);
} }
...@@ -98,15 +98,15 @@ bool ...@@ -98,15 +98,15 @@ bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
other.clear(); other.clear();
if (m_size == 0) if (m_size == 0)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return (false); return (false);
} }
...@@ -115,8 +115,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -115,8 +115,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
value_swap(other); value_swap(other);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return (false); return (false);
} }
...@@ -125,8 +125,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -125,8 +125,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
r_key, r_key,
PB_DS_V2F(m_p_head->m_p_right->m_value))) PB_DS_V2F(m_p_head->m_p_right->m_value)))
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return (false); return (false);
} }
...@@ -135,13 +135,13 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -135,13 +135,13 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
value_swap(other); value_swap(other);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return (false); return (false);
} }
PB_DS_DBG_ONLY(map_debug_base::split( _GLIBCXX_DEBUG_ONLY(map_debug_base::split(
r_key,(Cmp_Fn& )(*this), r_key,(Cmp_Fn& )(*this),
other);) other);)
...@@ -162,8 +162,8 @@ split_finish(PB_DS_CLASS_C_DEC& other) ...@@ -162,8 +162,8 @@ split_finish(PB_DS_CLASS_C_DEC& other)
initialize_min_max(); initialize_min_max();
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
...@@ -63,44 +63,25 @@ ...@@ -63,44 +63,25 @@
#include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp> #include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp>
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
#include <iostream> #include <iostream>
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_ #endif
#include <ext/pb_ds/detail/type_utils.hpp> #include <ext/pb_ds/detail/type_utils.hpp>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail namespace detail
{ {
#define PB_DS_CLASS_T_DEC \
#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<typename Value_Type, class Cmp_Fn, class Allocator> template<typename Value_Type, class Cmp_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
binary_heap_< \ binary_heap_<Value_Type, Cmp_Fn, Allocator>
Value_Type, \
Cmp_Fn, \
Allocator>
#define PB_DS_ENTRY_CMP_DEC \ #define PB_DS_ENTRY_CMP_DEC \
entry_cmp< \ entry_cmp<Value_Type, Cmp_Fn, is_simple<Value_Type>::value, Allocator>::type
Value_Type, \
Cmp_Fn, \
is_simple< \
Value_Type>::value, \
Allocator>::type
#define PB_DS_RESIZE_POLICY_DEC \ #define PB_DS_RESIZE_POLICY_DEC \
resize_policy< \ resize_policy<typename Allocator::size_type>
typename Allocator::size_type>
/** /**
* class description = "Base class for some types of h3ap$"> * class description = "Base class for some types of h3ap$">
...@@ -113,8 +94,7 @@ namespace pb_ds ...@@ -113,8 +94,7 @@ namespace pb_ds
private: private:
enum enum
{ {
simple_value = is_simple< simple_value = is_simple<Value_Type>::value
Value_Type>::value
}; };
typedef integral_constant<int, simple_value> no_throw_copies_t; typedef integral_constant<int, simple_value> no_throw_copies_t;
...@@ -276,11 +256,9 @@ namespace pb_ds ...@@ -276,11 +256,9 @@ namespace pb_ds
join(PB_DS_CLASS_C_DEC& other); join(PB_DS_CLASS_C_DEC& other);
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
void void
trace() const; trace() const;
#endif
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
protected: protected:
...@@ -336,22 +314,18 @@ namespace pb_ds ...@@ -336,22 +314,18 @@ namespace pb_ds
size_type size_type
partition(Pred pred); partition(Pred pred);
#ifdef PB_DS_BINARY_HEAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid() const;
#endif
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
void void
trace_entry(const entry& r_e, false_type) const; trace_entry(const entry& r_e, false_type) const;
void void
trace_entry(const entry& r_e, true_type) const; trace_entry(const entry& r_e, true_type) const;
#endif
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
private: private:
static entry_allocator s_entry_allocator; static entry_allocator s_entry_allocator;
...@@ -379,18 +353,11 @@ namespace pb_ds ...@@ -379,18 +353,11 @@ namespace pb_ds
#include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_ENTRY_CMP_DEC #undef PB_DS_ENTRY_CMP_DEC
#undef PB_DS_RESIZE_POLICY_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 detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BINARY_HEAP_HPP #endif
...@@ -49,35 +49,18 @@ ...@@ -49,35 +49,18 @@
#define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP #define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
#include <ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp> #include <ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail namespace detail
{ {
#ifdef BINARY_HEAP_DEBUG_ #define PB_DS_CLASS_C_DEC \
#define PB_DS_DBG_ASSERT(X) assert(X) binary_heap_const_iterator_<Value_Type, Entry, Simple, Allocator>
#define PB_DS_DBG_VERIFY(X) assert(X)
#define PB_DS_DBG_ONLY(X) X #define PB_DS_BASE_C_DEC \
#else // #ifdef BINARY_HEAP_DEBUG_ binary_heap_const_point_iterator_<Value_Type, Entry, Simple, Allocator>
#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_< \
Value_Type, \
Entry, \
Simple, \
Allocator>
#define PB_DS_BASE_C_DEC \
binary_heap_const_point_iterator_< \
Value_Type, \
Entry, \
Simple, \
Allocator>
// Const point-type iterator. // Const point-type iterator.
template<typename Value_Type, template<typename Value_Type,
...@@ -135,53 +118,41 @@ namespace pb_ds ...@@ -135,53 +118,41 @@ namespace pb_ds
inline bool inline bool
operator==(const PB_DS_CLASS_C_DEC& other) const operator==(const PB_DS_CLASS_C_DEC& other) const
{ {
return (base_type::m_p_e == other.m_p_e); return base_type::m_p_e == other.m_p_e;
} }
// Compares content (negatively) to a different iterator object. // Compares content (negatively) to a different iterator object.
inline bool inline bool
operator!=(const PB_DS_CLASS_C_DEC& other) const operator!=(const PB_DS_CLASS_C_DEC& other) const
{ {
return (base_type::m_p_e != other.m_p_e); return base_type::m_p_e != other.m_p_e;
} }
inline PB_DS_CLASS_C_DEC& inline PB_DS_CLASS_C_DEC&
operator++() operator++()
{ {
PB_DS_DBG_ASSERT(base_type::m_p_e != NULL); _GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != NULL);
inc(); inc();
return *this;
return (*this);
} }
inline PB_DS_CLASS_C_DEC inline PB_DS_CLASS_C_DEC
operator++(int) operator++(int)
{ {
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_e); PB_DS_CLASS_C_DEC ret_it(base_type::m_p_e);
operator++(); operator++();
return ret_it;
return (ret_it);
} }
private: private:
void void
inc() inc()
{ { ++base_type::m_p_e; }
++base_type::m_p_e;
}
}; };
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_BASE_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 detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP #endif
...@@ -49,35 +49,18 @@ ...@@ -49,35 +49,18 @@
#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP #define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
#include <ext/pb_ds/tag_and_trait.hpp> #include <ext/pb_ds/tag_and_trait.hpp>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail namespace detail
{ {
#ifdef BINARY_HEAP_DEBUG_ #define PB_DS_CLASS_T_DEC \
#define PB_DS_DBG_ASSERT(X) assert(X) template<typename Value_Type, typename Entry, bool Simple, class Allocator>
#define PB_DS_DBG_VERIFY(X) assert(X)
#define PB_DS_DBG_ONLY(X) X #define PB_DS_CLASS_C_DEC \
#else // #ifdef BINARY_HEAP_DEBUG_ binary_heap_const_point_iterator_<Value_Type, Entry, Simple, Allocator>
#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< \
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>
// Const point-type iterator. // Const point-type iterator.
template<typename Value_Type, template<typename Value_Type,
...@@ -136,62 +119,48 @@ namespace pb_ds ...@@ -136,62 +119,48 @@ namespace pb_ds
// Default constructor. // Default constructor.
inline inline
binary_heap_const_point_iterator_() binary_heap_const_point_iterator_() : m_p_e(NULL) { }
: m_p_e(NULL)
{ }
// Copy constructor. // Copy constructor.
inline inline
binary_heap_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) binary_heap_const_point_iterator_(const PB_DS_CLASS_C_DEC& other)
: m_p_e(other.m_p_e)
: m_p_e(other.m_p_e)
{ } { }
// Access. // Access.
inline const_pointer inline const_pointer
operator->() const operator->() const
{ {
PB_DS_DBG_ASSERT(m_p_e != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
return to_ptr(integral_constant<int,Simple>());
return (to_ptr(integral_constant<int,Simple>()));
} }
// Access. // Access.
inline const_reference inline const_reference
operator*() const operator*() const
{ {
PB_DS_DBG_ASSERT(m_p_e != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
return *to_ptr(integral_constant<int,Simple>());
return (*to_ptr(integral_constant<int,Simple>()));
} }
// Compares content to a different iterator object. // Compares content to a different iterator object.
inline bool inline bool
operator==(const PB_DS_CLASS_C_DEC& other) const 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. // Compares content (negatively) to a different iterator object.
inline bool inline bool
operator!=(const PB_DS_CLASS_C_DEC& other) const 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: private:
inline const_pointer inline const_pointer
to_ptr(true_type) const to_ptr(true_type) const
{ { return m_p_e; }
return m_p_e;
}
inline const_pointer inline const_pointer
to_ptr(false_type) const to_ptr(false_type) const
{ { return *m_p_e; }
return* m_p_e;
}
public: public:
entry_pointer m_p_e; entry_pointer m_p_e;
...@@ -200,11 +169,7 @@ namespace pb_ds ...@@ -200,11 +169,7 @@ namespace pb_ds
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_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 } // namespace pb_ds
#endif // #ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP #endif
...@@ -71,7 +71,7 @@ copy_from_range(It first_it, It last_it) ...@@ -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<entry_cmp& >(*this)); std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -81,7 +81,7 @@ binary_heap_() : ...@@ -81,7 +81,7 @@ binary_heap_() :
m_actual_size(resize_policy::min_size), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_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 PB_DS_CLASS_T_DEC
...@@ -92,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -92,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) :
m_actual_size(resize_policy::min_size), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_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 PB_DS_CLASS_T_DEC
...@@ -104,8 +104,8 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -104,8 +104,8 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
m_actual_size(other.m_actual_size), m_actual_size(other.m_actual_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries); _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
const_iterator first_it = other.begin(); const_iterator first_it = other.begin();
const_iterator last_it = other.end(); const_iterator last_it = other.end();
...@@ -129,7 +129,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -129,7 +129,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
throw; throw;
} }
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -137,16 +137,16 @@ void ...@@ -137,16 +137,16 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries); _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other); value_swap(other);
std::swap((entry_cmp& )(*this), (entry_cmp& )other); std::swap((entry_cmp& )(*this), (entry_cmp& )other);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains an implementation class for a binary_heap. * Contains an implementation class for a binary_heap.
*/ */
#ifdef PB_DS_BINARY_HEAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -53,28 +53,26 @@ assert_valid() const ...@@ -53,28 +53,26 @@ assert_valid() const
{ {
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
s_entry_allocator.check_allocated(m_a_entries, m_actual_size); s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
#endif // #ifdef PB_DS_REGRESSION #endif
resize_policy::assert_valid(); resize_policy::assert_valid();
_GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size);
PB_DS_DBG_ASSERT(m_size <= m_actual_size);
for (size_type i = 0; i < m_size; ++i) for (size_type i = 0; i < m_size; ++i)
{ {
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
s_value_allocator.check_allocated(m_a_entries[i], 1); s_value_allocator.check_allocated(m_a_entries[i], 1);
#endif // #ifdef PB_DS_REGRESSION #endif
if (left_child(i) < m_size) 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) 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
...@@ -71,7 +71,7 @@ clear() ...@@ -71,7 +71,7 @@ clear()
m_size = 0; m_size = 0;
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -95,8 +95,8 @@ inline void ...@@ -95,8 +95,8 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
erase_at(m_a_entries, 0, s_no_throw_copies_ind); erase_at(m_a_entries, 0, s_no_throw_copies_ind);
...@@ -104,10 +104,10 @@ pop() ...@@ -104,10 +104,10 @@ pop()
resize_for_erase_if_needed(); resize_for_erase_if_needed();
PB_DS_DBG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --m_size;
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -116,7 +116,7 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -116,7 +116,7 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
typedef typedef
typename entry_pred< typename entry_pred<
...@@ -128,7 +128,7 @@ erase_if(Pred pred) ...@@ -128,7 +128,7 @@ erase_if(Pred pred)
const size_type left = partition(pred_t(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; const size_type ersd = m_size - left;
...@@ -157,7 +157,7 @@ erase_if(Pred pred) ...@@ -157,7 +157,7 @@ erase_if(Pred pred)
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this)); std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return ersd; return ersd;
} }
...@@ -167,8 +167,8 @@ inline void ...@@ -167,8 +167,8 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
const size_type fix_pos = it.m_p_e - m_a_entries; const size_type fix_pos = it.m_p_e - m_a_entries;
...@@ -178,15 +178,15 @@ erase(point_iterator it) ...@@ -178,15 +178,15 @@ erase(point_iterator it)
resize_for_erase_if_needed(); resize_for_erase_if_needed();
PB_DS_DBG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --m_size;
PB_DS_DBG_ASSERT(fix_pos <= m_size); _GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size);
if (fix_pos != m_size) if (fix_pos != m_size)
fix(m_a_entries + fix_pos); fix(m_a_entries + fix_pos);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -206,7 +206,7 @@ resize_for_erase_if_needed() ...@@ -206,7 +206,7 @@ resize_for_erase_if_needed()
resize_policy::notify_shrink_resize(); 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); std::copy(m_a_entries, m_a_entries + m_size - 1, a_new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size);
...@@ -230,7 +230,7 @@ partition(Pred pred) ...@@ -230,7 +230,7 @@ partition(Pred pred)
while (right + 1 != left) while (right + 1 != left)
{ {
PB_DS_DBG_ASSERT(left <= m_size); _GLIBCXX_DEBUG_ASSERT(left <= m_size);
if (!pred(m_a_entries[left])) if (!pred(m_a_entries[left]))
++left; ++left;
...@@ -238,7 +238,7 @@ partition(Pred pred) ...@@ -238,7 +238,7 @@ partition(Pred pred)
--right; --right;
else else
{ {
PB_DS_DBG_ASSERT(left < right); _GLIBCXX_DEBUG_ASSERT(left < right);
std::swap(m_a_entries[left], m_a_entries[right]); std::swap(m_a_entries[left], m_a_entries[right]);
......
...@@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
return top_imp(s_no_throw_copies_ind); return top_imp(s_no_throw_copies_ind);
} }
......
...@@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) 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); insert_value(r_val, s_no_throw_copies_ind);
std::push_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this)); std::push_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return point_iterator(m_a_entries); return point_iterator(m_a_entries);
} }
...@@ -105,7 +105,7 @@ resize_for_insert_if_needed() ...@@ -105,7 +105,7 @@ resize_for_insert_if_needed()
{ {
if (!resize_policy::resize_needed_for_grow(m_size)) 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; return;
} }
...@@ -131,13 +131,13 @@ void ...@@ -131,13 +131,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) 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); swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
fix(it.m_p_e); fix(it.m_p_e);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -160,7 +160,7 @@ fix(entry_pointer p_e) ...@@ -160,7 +160,7 @@ fix(entry_pointer p_e)
parent_i = parent(i); parent_i = parent(i);
} }
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return; return;
} }
...@@ -170,7 +170,7 @@ fix(entry_pointer p_e) ...@@ -170,7 +170,7 @@ fix(entry_pointer p_e)
const size_type left_child_i = left_child(i); const size_type left_child_i = left_child(i);
const size_type right_child_i = right_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 = const bool smaller_than_left_child =
left_child_i < m_size&& left_child_i < m_size&&
......
...@@ -47,27 +47,16 @@ ...@@ -47,27 +47,16 @@
#ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
#define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail namespace detail
{ {
#ifdef PB_DS_BINARY_HEAP_DEBUG_ #define PB_DS_CLASS_T_DEC template<typename Size_Type>
#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<typename Size_Type>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC resize_policy<Size_Type>
resize_policy< \
Size_Type>
template<typename Size_Type> template<typename Size_Type>
class resize_policy class resize_policy
...@@ -117,17 +106,15 @@ namespace pb_ds ...@@ -117,17 +106,15 @@ namespace pb_ds
void void
notify_arbitrary(size_type actual_size); notify_arbitrary(size_type actual_size);
#ifdef PB_DS_BINARY_HEAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid() const;
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_ #endif
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
void void
trace() const; trace() const;
#endif
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
private: private:
enum enum
...@@ -138,7 +125,6 @@ namespace pb_ds ...@@ -138,7 +125,6 @@ namespace pb_ds
private: private:
size_type m_next_shrink_size; size_type m_next_shrink_size;
size_type m_next_grow_size; size_type m_next_grow_size;
}; };
...@@ -148,9 +134,7 @@ namespace pb_ds ...@@ -148,9 +134,7 @@ namespace pb_ds
resize_policy() : resize_policy() :
m_next_shrink_size(0), m_next_shrink_size(0),
m_next_grow_size(min_size) m_next_grow_size(min_size)
{ { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
PB_DS_DBG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -166,8 +150,7 @@ namespace pb_ds ...@@ -166,8 +150,7 @@ namespace pb_ds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
resize_needed_for_grow(size_type size) const 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; return size == m_next_grow_size;
} }
...@@ -176,8 +159,7 @@ namespace pb_ds ...@@ -176,8 +159,7 @@ namespace pb_ds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
resize_needed_for_shrink(size_type size) const 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; return size == m_next_shrink_size;
} }
...@@ -185,9 +167,7 @@ namespace pb_ds ...@@ -185,9 +167,7 @@ namespace pb_ds
inline typename PB_DS_CLASS_C_DEC::size_type inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
get_new_size_for_grow() const get_new_size_for_grow() const
{ { return m_next_grow_size* factor; }
return m_next_grow_size* factor;
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type inline typename PB_DS_CLASS_C_DEC::size_type
...@@ -195,7 +175,6 @@ namespace pb_ds ...@@ -195,7 +175,6 @@ namespace pb_ds
get_new_size_for_shrink() const get_new_size_for_shrink() const
{ {
const size_type half_size = m_next_grow_size / factor; const size_type half_size = m_next_grow_size / factor;
return std::max(static_cast<size_type>(min_size), half_size); return std::max(static_cast<size_type>(min_size), half_size);
} }
...@@ -205,10 +184,8 @@ namespace pb_ds ...@@ -205,10 +184,8 @@ namespace pb_ds
get_new_size_for_arbitrary(size_type size) const get_new_size_for_arbitrary(size_type size) const
{ {
size_type ret = min_size; size_type ret = min_size;
while (ret < size) while (ret < size)
ret *= factor; ret *= factor;
return ret; return ret;
} }
...@@ -217,33 +194,27 @@ namespace pb_ds ...@@ -217,33 +194,27 @@ namespace pb_ds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_grow_resize() notify_grow_resize()
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
PB_DS_DBG_ASSERT(m_next_grow_size >= min_size);
m_next_grow_size *= factor; m_next_grow_size *= factor;
m_next_shrink_size = m_next_grow_size / ratio; m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_shrink_resize() notify_shrink_resize()
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
m_next_shrink_size /= factor;
m_next_shrink_size /= factor;
if (m_next_shrink_size == 1) if (m_next_shrink_size == 1)
m_next_shrink_size = 0; m_next_shrink_size = 0;
m_next_grow_size = m_next_grow_size =
std::max(m_next_grow_size / factor, static_cast<size_type>(min_size)); std::max(m_next_grow_size / factor, static_cast<size_type>(min_size));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -251,24 +222,22 @@ namespace pb_ds ...@@ -251,24 +222,22 @@ namespace pb_ds
notify_arbitrary(size_type actual_size) notify_arbitrary(size_type actual_size)
{ {
m_next_grow_size = actual_size; m_next_grow_size = actual_size;
m_next_shrink_size = m_next_grow_size / ratio; m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_DBG_ONLY(assert_valid();) #ifdef _GLIBCXX_DEBUG
}
#ifdef PB_DS_BINARY_HEAP_DEBUG_
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const 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); 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_ #ifdef PB_DS_BINARY_HEAP_TRACE_
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -279,17 +248,12 @@ namespace pb_ds ...@@ -279,17 +248,12 @@ namespace pb_ds
std::cerr << "shrink = " << m_next_shrink_size << std::cerr << "shrink = " << m_next_shrink_size <<
" grow = " << m_next_grow_size << std::endl; " 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_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_DBG_ASSERT } // namespace detail
#undef PB_DS_DBG_VERIFY
#undef PB_DS_DBG_ONLY
} // namespace detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP #endif
...@@ -50,7 +50,7 @@ void ...@@ -50,7 +50,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
typedef typedef
typename entry_pred< typename entry_pred<
...@@ -62,11 +62,11 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -62,11 +62,11 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
const size_type left = partition(pred_t(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; 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 = const size_type actual_size =
resize_policy::get_new_size_for_arbitrary(left); resize_policy::get_new_size_for_arbitrary(left);
...@@ -97,7 +97,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -97,7 +97,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
for (size_type i = 0; i < other.m_size; ++i) for (size_type i = 0; i < other.m_size; ++i)
erase_at(other.m_a_entries, i, s_no_throw_copies_ind); 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, m_a_entries + left, a_entries);
std::copy(m_a_entries + left, m_a_entries + m_size, a_other_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) ...@@ -119,8 +119,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
resize_policy::notify_arbitrary(m_actual_size); resize_policy::notify_arbitrary(m_actual_size);
other.notify_arbitrary(other.m_actual_size); other.notify_arbitrary(other.m_actual_size);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -128,8 +128,8 @@ inline void ...@@ -128,8 +128,8 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
const size_type size = m_size + other.m_size; const size_type size = m_size + other.m_size;
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(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) ...@@ -173,7 +173,7 @@ join(PB_DS_CLASS_C_DEC& other)
other.notify_arbitrary(resize_policy::min_size); other.notify_arbitrary(resize_policy::min_size);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_DBG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
...@@ -50,9 +50,7 @@ ...@@ -50,9 +50,7 @@
* Modified from CLRS. * Modified from CLRS.
*/ */
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ #include <debug/debug.h>
#include <cassert>
#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
#include <ext/pb_ds/detail/cond_dealtor.hpp> #include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp> #include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
...@@ -62,30 +60,14 @@ namespace pb_ds ...@@ -62,30 +60,14 @@ namespace pb_ds
namespace detail namespace detail
{ {
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ #define PB_DS_CLASS_T_DEC \
#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 \
template<typename Value_Type, class Cmp_Fn, class Allocator> template<typename Value_Type, class Cmp_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
binomial_heap_< \ binomial_heap_<Value_Type, Cmp_Fn, Allocator>
Value_Type, \
Cmp_Fn, \
Allocator>
#define PB_DS_BASE_C_DEC \ #define PB_DS_BASE_C_DEC \
binomial_heap_base_< \ binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
Value_Type, \
Cmp_Fn, \
Allocator>
/** /**
* class description = "8y|\|0|\/|i41 h34p 74813"> * class description = "8y|\|0|\/|i41 h34p 74813">
...@@ -140,12 +122,10 @@ namespace pb_ds ...@@ -140,12 +122,10 @@ namespace pb_ds
~binomial_heap_(); ~binomial_heap_();
protected: protected:
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid() const;
#endif
#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
}; };
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
...@@ -156,10 +136,5 @@ namespace pb_ds ...@@ -156,10 +136,5 @@ namespace pb_ds
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_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 detail
} // namespace pb_ds } // namespace pb_ds
...@@ -47,28 +47,21 @@ ...@@ -47,28 +47,21 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_() binomial_heap_()
{ { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
PB_DS_DBG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_(const Cmp_Fn& r_cmp_fn) : binomial_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn) PB_DS_BASE_C_DEC(r_cmp_fn)
{ { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
PB_DS_DBG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_(const PB_DS_CLASS_C_DEC& other) : binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other) PB_DS_BASE_C_DEC(other)
{ { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
PB_DS_DBG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
~binomial_heap_() ~binomial_heap_() { }
{ }
...@@ -44,14 +44,12 @@ ...@@ -44,14 +44,12 @@
* Contains an implementation for binomial_heap_. * Contains an implementation for binomial_heap_.
*/ */
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid() const
{ { base_type::assert_valid(true); }
base_type::assert_valid(true);
}
#endif // #ifdef PB_DS_BINOMIAL_HEAP__DEBUG_ #endif
...@@ -53,9 +53,7 @@ ...@@ -53,9 +53,7 @@
* Modified from CLRS. * Modified from CLRS.
*/ */
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ #include <debug/debug.h>
#include <cassert>
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
#include <ext/pb_ds/detail/cond_dealtor.hpp> #include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp> #include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
...@@ -66,41 +64,22 @@ namespace pb_ds ...@@ -66,41 +64,22 @@ namespace pb_ds
namespace detail namespace detail
{ {
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ #define PB_DS_CLASS_T_DEC \
#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 \
template<typename Value_Type, class Cmp_Fn, class Allocator> template<typename Value_Type, class Cmp_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
binomial_heap_base_< \ binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
Value_Type, \
Cmp_Fn, \ #ifdef _GLIBCXX_DEBUG
Allocator> #define PB_DS_BASE_C_DEC \
left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
#ifdef PB_DS_LC_NS_HEAP_DEBUG_ typename Allocator::size_type, \
#define PB_DS_BASE_C_DEC \ Allocator, false>
left_child_next_sibling_heap_< \ #else
Value_Type, \ #define PB_DS_BASE_C_DEC \
Cmp_Fn, \ left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
typename Allocator::size_type, \ typename Allocator::size_type, Allocator>
Allocator, \ #endif
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_
/** /**
* class description = "8y|\|0|\/|i41 h34p 74813"> * class description = "8y|\|0|\/|i41 h34p 74813">
...@@ -212,15 +191,13 @@ namespace pb_ds ...@@ -212,15 +191,13 @@ namespace pb_ds
inline void inline void
find_max(); find_max();
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_valid(bool strictly_binomial) const; assert_valid(bool strictly_binomial) const;
void void
assert_max() const; assert_max() const;
#endif
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
private: private:
...@@ -236,12 +213,10 @@ namespace pb_ds ...@@ -236,12 +213,10 @@ namespace pb_ds
inline node_pointer inline node_pointer
join(node_pointer p_lhs, node_pointer p_rhs) const; join(node_pointer p_lhs, node_pointer p_rhs) const;
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_ #ifdef _GLIBCXX_DEBUG
void void
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const; assert_node_consistent(const_node_pointer, bool, bool) const;
#endif
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
protected: protected:
node_pointer m_p_max; node_pointer m_p_max;
...@@ -255,16 +230,11 @@ namespace pb_ds ...@@ -255,16 +230,11 @@ namespace pb_ds
#include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_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 detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP #endif
...@@ -53,7 +53,7 @@ copy_from_range(It first_it, It last_it) ...@@ -53,7 +53,7 @@ copy_from_range(It first_it, It last_it)
while (first_it != last_it) while (first_it != last_it)
push(*(first_it++)); push(*(first_it++));
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -61,7 +61,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -61,7 +61,7 @@ PB_DS_CLASS_C_DEC::
binomial_heap_base_() : binomial_heap_base_() :
m_p_max(NULL) m_p_max(NULL)
{ {
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -70,7 +70,7 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) : ...@@ -70,7 +70,7 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn), PB_DS_BASE_C_DEC(r_cmp_fn),
m_p_max(NULL) m_p_max(NULL)
{ {
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -79,7 +79,7 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) : ...@@ -79,7 +79,7 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other), PB_DS_BASE_C_DEC(other),
m_p_max(NULL) m_p_max(NULL)
{ {
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -87,13 +87,13 @@ void ...@@ -87,13 +87,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
base_type::swap(other); base_type::swap(other);
std::swap(m_p_max, other.m_p_max); 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 PB_DS_CLASS_T_DEC
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains an implementation class for a base of binomial heaps. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -52,9 +52,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -52,9 +52,7 @@ PB_DS_CLASS_C_DEC::
assert_valid(bool strictly_binomial) const assert_valid(bool strictly_binomial) const
{ {
base_type::assert_valid(); base_type::assert_valid();
assert_node_consistent(base_type::m_p_root, strictly_binomial, true); assert_node_consistent(base_type::m_p_root, strictly_binomial, true);
assert_max(); assert_max();
} }
...@@ -65,11 +63,9 @@ assert_max() const ...@@ -65,11 +63,9 @@ assert_max() const
{ {
if (m_p_max == NULL) if (m_p_max == NULL)
return; return;
_GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == NULL);
PB_DS_DBG_ASSERT(base_type::parent(m_p_max) == NULL);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) 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 PB_DS_CLASS_T_DEC
...@@ -77,32 +73,25 @@ void ...@@ -77,32 +73,25 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const 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); base_type::assert_node_consistent(p_nd, false);
if (p_nd == NULL) if (p_nd == NULL)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd));
PB_DS_DBG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd)); _GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) ==
PB_DS_DBG_ASSERT(base_type::size_under_node(p_nd) ==
static_cast<size_type>(1 << p_nd->m_metadata)); static_cast<size_type>(1 << p_nd->m_metadata));
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing); assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing);
assert_node_consistent(p_nd->m_p_l_child, true, false); assert_node_consistent(p_nd->m_p_l_child, true, false);
if (p_nd->m_p_next_sibling != NULL) if (p_nd->m_p_next_sibling != NULL)
if (increasing) if (increasing)
{ {
if (strictly_binomial) 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 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 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
...@@ -49,13 +49,13 @@ void ...@@ -49,13 +49,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == NULL) if (m_p_max == NULL)
find_max(); find_max();
PB_DS_DBG_ASSERT(m_p_max != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL);
node_pointer p_nd = m_p_max; node_pointer p_nd = m_p_max;
...@@ -65,7 +65,7 @@ pop() ...@@ -65,7 +65,7 @@ pop()
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -73,8 +73,8 @@ void ...@@ -73,8 +73,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
remove_parentless_node(node_pointer p_nd) remove_parentless_node(node_pointer p_nd)
{ {
PB_DS_DBG_ASSERT(p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
PB_DS_DBG_ASSERT(base_type::parent(p_nd) == NULL); _GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == NULL);
node_pointer p_cur_root = p_nd == base_type::m_p_root? node_pointer p_cur_root = p_nd == base_type::m_p_root?
p_nd->m_p_next_sibling : p_nd->m_p_next_sibling :
...@@ -119,8 +119,8 @@ void ...@@ -119,8 +119,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::bubble_to_top(it.m_p_nd); base_type::bubble_to_top(it.m_p_nd);
...@@ -130,7 +130,7 @@ erase(point_iterator it) ...@@ -130,7 +130,7 @@ erase(point_iterator it)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -139,11 +139,11 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -139,11 +139,11 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
if (base_type::empty()) if (base_type::empty())
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
return 0; return 0;
} }
...@@ -191,7 +191,7 @@ erase_if(Pred pred) ...@@ -191,7 +191,7 @@ erase_if(Pred pred)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
return ersd; return ersd;
} }
......
...@@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
PB_DS_DBG_ONLY(assert_valid(false);) _GLIBCXX_DEBUG_ONLY(assert_valid(false);)
PB_DS_DBG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == NULL) if (m_p_max == NULL)
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max(); const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max();
PB_DS_DBG_ASSERT(m_p_max != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_max != NULL);
return m_p_max->m_value; return m_p_max->m_value;
} }
......
...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) 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); node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
...@@ -57,7 +57,7 @@ push(const_reference r_val) ...@@ -57,7 +57,7 @@ push(const_reference r_val)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
return point_iterator(p_nd); return point_iterator(p_nd);
} }
...@@ -120,7 +120,7 @@ insert_node(node_pointer p_nd) ...@@ -120,7 +120,7 @@ insert_node(node_pointer p_nd)
p_nd->m_metadata = 0; 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_p_l_child = p_nd;
base_type::m_p_root->m_metadata = 1; base_type::m_p_root->m_metadata = 1;
...@@ -177,11 +177,11 @@ void ...@@ -177,11 +177,11 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) 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; node_pointer p_nd = it.m_p_nd;
PB_DS_DBG_ASSERT(p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false);) _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); 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) ...@@ -204,7 +204,7 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
return; return;
} }
...@@ -217,6 +217,6 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -217,6 +217,6 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
} }
...@@ -50,15 +50,15 @@ void ...@@ -50,15 +50,15 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ONLY(other.assert_valid(true);) _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
other.clear(); other.clear();
if (base_type::empty()) if (base_type::empty())
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ONLY(other.assert_valid(true);) _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
return; return;
} }
...@@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
while (p_out != NULL) 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; --base_type::m_size;
++other.m_size; ++other.m_size;
...@@ -92,7 +92,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -92,7 +92,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_out = p_next; 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; node_pointer p_cur = base_type::m_p_root;
...@@ -120,8 +120,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -120,8 +120,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
m_p_max = NULL; m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ONLY(other.assert_valid(true);) _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -129,8 +129,8 @@ inline void ...@@ -129,8 +129,8 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ONLY(other.assert_valid(true);) _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
node_pointer p_other = other.m_p_root; node_pointer p_other = other.m_p_root;
...@@ -153,8 +153,8 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -153,8 +153,8 @@ join(PB_DS_CLASS_C_DEC& other)
other.m_size = 0; other.m_size = 0;
other.m_p_max = NULL; other.m_p_max = NULL;
PB_DS_DBG_ONLY(assert_valid(true);) _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_DBG_ONLY(other.assert_valid(true);) _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
...@@ -78,7 +78,7 @@ cmp_with_other(const Other_Map_Type& other) const ...@@ -78,7 +78,7 @@ cmp_with_other(const Other_Map_Type& other) const
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
if (p_mapped_value->second != it->second) if (p_mapped_value->second != it->second)
return (false); return (false);
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif
} }
return (true); return (true);
......
...@@ -67,106 +67,87 @@ PB_DS_CLASS_T_DEC ...@@ -67,106 +67,87 @@ PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : PB_DS_CLASS_NAME() :
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)), ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)),
m_a_p_entries(s_entry_pointer_allocator.allocate( m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : PB_DS_CLASS_NAME(const Hash_Fn& r_hash_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_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_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : 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), 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_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_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
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_cleared(); Resize_Policy::notify_cleared();
ranged_hash_fn_base::notify_resized(m_num_e_p); ranged_hash_fn_base::notify_resized(m_num_e_p);
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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_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), PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
ranged_hash_fn_base( ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
resize_base::get_nearest_larger_size(1),
r_hash_fn, r_hash_fn,
r_comb_hash_fn), r_comb_hash_fn),
m_a_p_entries(s_entry_pointer_allocator.allocate( m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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_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), PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
Resize_Policy(r_resize_policy), Resize_Policy(r_resize_policy),
ranged_hash_fn_base( ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
resize_base::get_nearest_larger_size(1),
r_hash_fn, r_hash_fn,
r_comb_hash_fn), r_comb_hash_fn),
m_a_p_entries(s_entry_pointer_allocator.allocate( m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef PB_DS_CC_HT_MAP_DEBUG_ #ifdef _GLIBCXX_DEBUG
PB_DS_MAP_DEBUG_BASE_C_DEC(other), map_debug_base(other),
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_ #endif
PB_DS_HASH_EQ_FN_C_DEC(other), PB_DS_HASH_EQ_FN_C_DEC(other),
resize_base(other), resize_base(other),
ranged_hash_fn_base(other), ranged_hash_fn_base(other),
m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate( m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e_p(resize_base::get_nearest_larger_size(1)), m_num_e_p(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
try try
{ {
copy_from_range(other.begin(), other.end()); copy_from_range(other.begin(), other.end());
...@@ -174,44 +155,34 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -174,44 +155,34 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
catch(...) catch(...)
{ {
deallocate_all(); deallocate_all();
throw; throw;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
~PB_DS_CLASS_NAME() ~PB_DS_CLASS_NAME()
{ { deallocate_all(); }
deallocate_all();
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(assert_valid());
PB_DS_DBG_ONLY(other.assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid());
std::swap(m_a_p_entries, other.m_a_p_entries); 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_e_p, other.m_num_e_p);
std::swap(m_num_used_e, other.m_num_used_e); std::swap(m_num_used_e, other.m_num_used_e);
ranged_hash_fn_base::swap(other); ranged_hash_fn_base::swap(other);
hash_eq_fn_base::swap(other); hash_eq_fn_base::swap(other);
resize_base::swap(other); resize_base::swap(other);
PB_DS_DBG_ONLY(map_debug_base::swap(other)); _GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other));
_GLIBCXX_DEBUG_ONLY(assert_valid());
PB_DS_DBG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_DBG_ONLY(other.assert_valid());
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -220,7 +191,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -220,7 +191,6 @@ PB_DS_CLASS_C_DEC::
deallocate_all() deallocate_all()
{ {
clear(); clear();
s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p); s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p);
} }
...@@ -229,11 +199,8 @@ void ...@@ -229,11 +199,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
initialize() 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_resized(m_num_e_p);
Resize_Policy::notify_cleared(); Resize_Policy::notify_cleared();
ranged_hash_fn_base::notify_resized(m_num_e_p); ranged_hash_fn_base::notify_resized(m_num_e_p);
} }
...@@ -56,8 +56,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral ...@@ -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. // At this point no exceptions can be thrown.
p_e->m_p_next = m_a_p_entries[pos]; p_e->m_p_next = m_a_p_entries[pos];
m_a_p_entries[pos] = p_e; m_a_p_entries[pos] = p_e;
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);) }
}
...@@ -51,15 +51,13 @@ PB_DS_CLASS_C_DEC:: ...@@ -51,15 +51,13 @@ PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_reference r_val, size_type pos, true_type) constructor_insert_new_imp(const_reference r_val, size_type pos, true_type)
{ {
// Following lines might throw an exception. // 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. // At this point no exceptions can be thrown.
p_e->m_p_next = m_a_p_entries[pos]; 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; 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; m_a_p_entries[pos] = p_e;
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);) }
}
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains implementations of cc_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -52,7 +52,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -52,7 +52,6 @@ PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid() const
{ {
map_debug_base::check_size(m_num_used_e); map_debug_base::check_size(m_num_used_e);
assert_entry_pointer_array_valid(m_a_p_entries); assert_entry_pointer_array_valid(m_a_p_entries);
} }
...@@ -62,25 +61,20 @@ PB_DS_CLASS_C_DEC:: ...@@ -62,25 +61,20 @@ PB_DS_CLASS_C_DEC::
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const
{ {
size_type iterated_num_used_e = 0; size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e_p; ++pos) for (size_type pos = 0; pos < m_num_e_p; ++pos)
{ {
entry_pointer p_e = a_p_entries[pos]; entry_pointer p_e = a_p_entries[pos];
while (p_e != NULL) while (p_e != NULL)
{ {
++iterated_num_used_e; ++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; p_e = p_e->m_p_next;
} }
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e);
PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e);
} }
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ #endif
...@@ -44,14 +44,13 @@ ...@@ -44,14 +44,13 @@
* Contains implementations of cc_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_type) const 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)); { map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); }
}
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ #endif
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains implementations of cc_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const 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)); 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 = _GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second);
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second);
} }
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__ #endif
...@@ -49,7 +49,7 @@ inline void ...@@ -49,7 +49,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_entry_pointer(entry_pointer& r_p_e) 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))); PB_DS_V2F(r_p_e->m_value)));
entry_pointer p_e = r_p_e; entry_pointer p_e = r_p_e;
...@@ -58,7 +58,7 @@ erase_entry_pointer(entry_pointer& r_p_e) ...@@ -58,7 +58,7 @@ erase_entry_pointer(entry_pointer& r_p_e)
rels_entry(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); resize_base::notify_erased(--m_num_used_e);
} }
......
...@@ -50,7 +50,7 @@ inline bool ...@@ -50,7 +50,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key) erase(const_key_reference r_key)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (erase_in_pos_imp(r_key, return (erase_in_pos_imp(r_key,
ranged_hash_fn_base::operator()(r_key))); ranged_hash_fn_base::operator()(r_key)));
...@@ -61,7 +61,7 @@ inline bool ...@@ -61,7 +61,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_in_pos_imp(const_key_reference r_key, size_type pos) 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]; 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) ...@@ -71,10 +71,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
{ {
resize_base::notify_erase_search_end(); 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);) r_key);)
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false); return (false);
} }
...@@ -85,14 +85,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) ...@@ -85,14 +85,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
PB_DS_DBG_ONLY(map_debug_base:: _GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists(r_key);) check_key_exists(r_key);)
erase_entry_pointer(m_a_p_entries[pos]); erase_entry_pointer(m_a_p_entries[pos]);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true); return (true);
} }
...@@ -105,10 +105,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) ...@@ -105,10 +105,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
{ {
resize_base::notify_erase_search_end(); 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);) check_key_does_not_exist(r_key);)
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false); return (false);
} }
...@@ -119,14 +119,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) ...@@ -119,14 +119,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
PB_DS_DBG_ONLY(map_debug_base:: _GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists(r_key);) check_key_exists(r_key);)
erase_entry_pointer(p_e->m_p_next); erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true); return (true);
} }
......
...@@ -50,7 +50,7 @@ inline bool ...@@ -50,7 +50,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) 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]; 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) ...@@ -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(); resize_base::notify_erase_search_end();
PB_DS_DBG_ONLY(map_debug_base:: _GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_does_not_exist( check_key_does_not_exist(
r_key);) r_key);)
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false); return (false);
} }
...@@ -77,14 +77,14 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -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(); 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);) r_key);)
erase_entry_pointer(m_a_p_entries[r_pos_hash_pair.first]); erase_entry_pointer(m_a_p_entries[r_pos_hash_pair.first]);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true); return (true);
} }
...@@ -97,10 +97,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -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(); 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);) check_key_does_not_exist(r_key);)
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false); return (false);
} }
...@@ -113,7 +113,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -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(); resize_base::notify_erase_search_end();
PB_DS_DBG_ONLY(map_debug_base:: _GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists( check_key_exists(
r_key);) r_key);)
...@@ -121,7 +121,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -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(); do_resize_if_needed_no_throw();
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true); return (true);
} }
......
...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) 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)); 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 ...@@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer( r_key, traits_base::m_store_extra_indicator)); return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer( r_key, traits_base::m_store_extra_indicator));
} }
......
...@@ -52,7 +52,7 @@ inline std::pair< ...@@ -52,7 +52,7 @@ inline std::pair<
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, store_hash_false_type) 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); const_key_reference r_key = PB_DS_V2F(r_val);
...@@ -74,13 +74,13 @@ insert_imp(const_reference r_val, store_hash_false_type) ...@@ -74,13 +74,13 @@ insert_imp(const_reference r_val, store_hash_false_type)
if (p_e != NULL) 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 ( return (
std::make_pair( & p_e->m_value, false)); 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( return (std::make_pair(
insert_new_imp(r_val, pos), insert_new_imp(r_val, pos),
......
...@@ -52,7 +52,7 @@ inline std::pair< ...@@ -52,7 +52,7 @@ inline std::pair<
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, store_hash_true_type) 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); const_key_reference r_key = PB_DS_V2F(r_val);
...@@ -77,12 +77,12 @@ insert_imp(const_reference r_val, store_hash_true_type) ...@@ -77,12 +77,12 @@ insert_imp(const_reference r_val, store_hash_true_type)
if (p_e != NULL) 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)); 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( return (std::make_pair(
insert_new_imp(r_val, pos_hash_pair), insert_new_imp(r_val, pos_hash_pair),
......
...@@ -81,7 +81,7 @@ do_resize_if_needed_no_throw() ...@@ -81,7 +81,7 @@ do_resize_if_needed_no_throw()
catch(...) catch(...)
{ } { }
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -89,7 +89,7 @@ void ...@@ -89,7 +89,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size) resize_imp(size_type new_size)
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
if (new_size == m_num_e_p) if (new_size == m_num_e_p)
return; return;
...@@ -123,7 +123,7 @@ resize_imp(size_type new_size) ...@@ -123,7 +123,7 @@ resize_imp(size_type new_size)
Resize_Policy::notify_resized(new_size); Resize_Policy::notify_resized(new_size);
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -143,13 +143,13 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res ...@@ -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; 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); s_entry_pointer_allocator.deallocate(m_a_p_entries, old_size);
m_a_p_entries = a_p_entries_resized; m_a_p_entries = a_p_entries_resized;
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
......
...@@ -49,34 +49,20 @@ ...@@ -49,34 +49,20 @@
#define PB_DS_HASH_EQ_FN_HPP #define PB_DS_HASH_EQ_FN_HPP
#include <utility> #include <utility>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail 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<typename Key, class Eq_Fn, class Allocator, bool Store_Hash> template<typename Key, class Eq_Fn, class Allocator, bool Store_Hash>
struct hash_eq_fn; struct hash_eq_fn;
#define PB_DS_CLASS_T_DEC \ #define PB_DS_CLASS_T_DEC \
template<typename Key, class Eq_Fn, class Allocator> template<typename Key, class Eq_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
hash_eq_fn< \ hash_eq_fn<Key, Eq_Fn, Allocator, false>
Key, \
Eq_Fn, \
Allocator, \
false>
/** /**
* Specialization 1- The client requests that hash values not be stored. * Specialization 1- The client requests that hash values not be stored.
...@@ -110,9 +96,7 @@ namespace pb_ds ...@@ -110,9 +96,7 @@ namespace pb_ds
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(const PB_DS_CLASS_C_DEC& other) 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_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -124,22 +108,16 @@ namespace pb_ds ...@@ -124,22 +108,16 @@ namespace pb_ds
inline bool inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const 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_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \ #define PB_DS_CLASS_T_DEC \
template<typename Key, class Eq_Fn, class Allocator> template<typename Key, class Eq_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
hash_eq_fn< \ hash_eq_fn<Key, Eq_Fn, Allocator, true>
Key, \
Eq_Fn, \
Allocator, \
true>
/** /**
* Specialization 2- The client requests that hash values be stored. * Specialization 2- The client requests that hash values be stored.
...@@ -161,7 +139,8 @@ namespace pb_ds ...@@ -161,7 +139,8 @@ namespace pb_ds
hash_eq_fn(const Eq_Fn& r_eq_fn); hash_eq_fn(const Eq_Fn& r_eq_fn);
inline bool 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 inline void
swap(const PB_DS_CLASS_C_DEC& other); swap(const PB_DS_CLASS_C_DEC& other);
...@@ -181,12 +160,13 @@ namespace pb_ds ...@@ -181,12 +160,13 @@ namespace pb_ds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline bool inline bool
PB_DS_CLASS_C_DEC:: 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) || _GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
lhs_hash == rhs_hash); || lhs_hash == rhs_hash);
return (lhs_hash == rhs_hash&& return (lhs_hash == rhs_hash &&
eq_fn_base::operator()(r_lhs_key, r_rhs_key)); eq_fn_base::operator()(r_lhs_key, r_rhs_key));
} }
...@@ -194,18 +174,12 @@ namespace pb_ds ...@@ -194,18 +174,12 @@ namespace pb_ds
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(const PB_DS_CLASS_C_DEC& other) 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_T_DEC
#undef PB_DS_CLASS_C_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 } // namespace pb_ds
#endif // #ifndef PB_DS_HASH_EQ_FN_HPP #endif
...@@ -63,44 +63,38 @@ PB_DS_CLASS_T_DEC ...@@ -63,44 +63,38 @@ PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : PB_DS_CLASS_NAME() :
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
hash_eq_fn_base(r_eq_fn), hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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 ...@@ -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), hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn), r_hash_fn, r_comb_hash_fn),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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 ...@@ -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), hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn, r_probe_fn), r_hash_fn, r_comb_hash_fn, r_probe_fn),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_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 ...@@ -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), resize_base(r_resize_policy),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn, r_probe_fn), r_hash_fn, r_comb_hash_fn, r_probe_fn),
m_a_entries(s_entry_allocator.allocate( m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
resize_base::get_nearest_larger_size(1))),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_e(resize_base::get_nearest_larger_size(1)),
m_num_used_e(0) m_num_used_e(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef PB_DS_GP_HT_MAP_DEBUG__ #ifdef _GLIBCXX_DEBUG
PB_DS_MAP_DEBUG_BASE_C_DEC(other), map_debug_base(other),
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ #endif
hash_eq_fn_base(other), hash_eq_fn_base(other),
resize_base(other), resize_base(other),
ranged_probe_fn_base(other), ranged_probe_fn_base(other),
...@@ -172,7 +160,6 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& 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) for (size_type i = 0; i < m_num_e; ++i)
{ {
m_a_entries[i].m_stat = other.m_a_entries[i].m_stat; m_a_entries[i].m_stat = other.m_a_entries[i].m_stat;
if (m_a_entries[i].m_stat == valid_entry_status) if (m_a_entries[i].m_stat == valid_entry_status)
new (m_a_entries + i) entry(other.m_a_entries[i]); 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) : ...@@ -180,11 +167,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
catch(...) catch(...)
{ {
deallocate_all(); deallocate_all();
throw; 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_T_DEC
...@@ -199,25 +185,17 @@ void ...@@ -199,25 +185,17 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
PB_DS_DBG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(assert_valid());
PB_DS_DBG_ONLY(other.assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid());
std::swap(m_a_entries, other.m_a_entries); std::swap(m_a_entries, other.m_a_entries);
std::swap(m_num_e, other.m_num_e); std::swap(m_num_e, other.m_num_e);
std::swap(m_num_used_e, other.m_num_used_e); std::swap(m_num_used_e, other.m_num_used_e);
ranged_probe_fn_base::swap(other); ranged_probe_fn_base::swap(other);
hash_eq_fn_base::swap(other); hash_eq_fn_base::swap(other);
resize_base::swap(other); resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other));
PB_DS_DBG_ONLY(map_debug_base::swap(other)); _GLIBCXX_DEBUG_ONLY(assert_valid());
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_DBG_ONLY(assert_valid());
PB_DS_DBG_ONLY(other.assert_valid());
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -226,9 +204,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -226,9 +204,7 @@ PB_DS_CLASS_C_DEC::
deallocate_all() deallocate_all()
{ {
clear(); clear();
erase_all_valid_entries(m_a_entries, m_num_e); erase_all_valid_entries(m_a_entries, m_num_e);
s_entry_allocator.deallocate(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) ...@@ -240,7 +216,6 @@ erase_all_valid_entries(entry_array a_entries_resized, size_type size)
for (size_type pos = 0; pos < size; ++pos) for (size_type pos = 0; pos < size; ++pos)
{ {
entry_pointer p_e =& a_entries_resized[pos]; entry_pointer p_e =& a_entries_resized[pos];
if (p_e->m_stat == valid_entry_status) if (p_e->m_stat == valid_entry_status)
p_e->m_value.~value_type(); p_e->m_value.~value_type();
} }
...@@ -252,11 +227,8 @@ PB_DS_CLASS_C_DEC:: ...@@ -252,11 +227,8 @@ PB_DS_CLASS_C_DEC::
initialize() initialize()
{ {
Resize_Policy::notify_resized(m_num_e); Resize_Policy::notify_resized(m_num_e);
Resize_Policy::notify_cleared(); Resize_Policy::notify_cleared();
ranged_probe_fn_base::notify_resized(m_num_e); ranged_probe_fn_base::notify_resized(m_num_e);
for (size_type i = 0; i < m_num_e; ++i) for (size_type i = 0; i < m_num_e; ++i)
m_a_entries[i].m_stat = (entry_status)empty_entry_status; m_a_entries[i].m_stat = (entry_status)empty_entry_status;
} }
......
...@@ -50,7 +50,7 @@ inline void ...@@ -50,7 +50,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>) constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>)
{ {
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; 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 ...@@ -58,6 +58,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral
p_e->m_stat = valid_entry_status; 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);) insert_new(p_e->m_value.first);)
} }
...@@ -50,7 +50,7 @@ inline void ...@@ -50,7 +50,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_type) 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; 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 ...@@ -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; 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);) insert_new(p_e->m_value.first);)
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains implementations of gp_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -52,11 +52,10 @@ PB_DS_CLASS_C_DEC:: ...@@ -52,11 +52,10 @@ PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid() const
{ {
map_debug_base::check_size(m_num_used_e); map_debug_base::check_size(m_num_used_e);
assert_entry_array_valid(m_a_entries, traits_base::m_store_extra_indicator); assert_entry_array_valid(m_a_entries, traits_base::m_store_extra_indicator);
} }
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp>
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ #endif
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains implementations of gp_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -74,11 +74,11 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) con ...@@ -74,11 +74,11 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) con
break; break;
} }
default: 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
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* Contains implementations of gp_ht_map_'s debug-mode functions. * 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 PB_DS_CLASS_T_DEC
void void
...@@ -56,7 +56,6 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons ...@@ -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) for (size_type pos = 0; pos < m_num_e; ++pos)
{ {
const_entry_pointer p_e =& a_entries[pos]; const_entry_pointer p_e =& a_entries[pos];
switch(p_e->m_stat) switch(p_e->m_stat)
{ {
case empty_entry_status: case empty_entry_status:
...@@ -64,26 +63,21 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons ...@@ -64,26 +63,21 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons
break; break;
case valid_entry_status: case valid_entry_status:
{ {
const_key_reference r_key = const_key_reference r_key = PB_DS_V2F(p_e->m_value);
PB_DS_V2F(p_e->m_value);
map_debug_base::check_key_exists(r_key); map_debug_base::check_key_exists(r_key);
const comp_hash pos_hash_pair = const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
ranged_probe_fn_base::operator()(r_key);
PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second);
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second);
++iterated_num_used_e; ++iterated_num_used_e;
break; break;
} }
default: 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
...@@ -49,9 +49,9 @@ inline void ...@@ -49,9 +49,9 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_entry(entry_pointer p_e) 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));) PB_DS_V2F(p_e->m_value));)
typedef typedef
...@@ -62,7 +62,7 @@ erase_entry(entry_pointer p_e) ...@@ -62,7 +62,7 @@ erase_entry(entry_pointer p_e)
p_e->m_stat = erased_entry_status; 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); resize_base::notify_erased(--m_num_used_e);
} }
...@@ -90,7 +90,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -90,7 +90,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) 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; size_type num_ersd = 0;
...@@ -109,7 +109,7 @@ erase_if(Pred pred) ...@@ -109,7 +109,7 @@ erase_if(Pred pred)
do_resize_if_needed_no_throw(); 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); return (num_ersd);
} }
......
...@@ -50,7 +50,7 @@ inline bool ...@@ -50,7 +50,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_imp(const_key_reference r_key, false_type) 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); size_type hash = ranged_probe_fn_base::operator()(r_key);
...@@ -71,7 +71,7 @@ erase_imp(const_key_reference r_key, false_type) ...@@ -71,7 +71,7 @@ erase_imp(const_key_reference r_key, false_type)
{ {
resize_base::notify_erase_search_end(); 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)); r_key));
return (false); return (false);
...@@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, false_type) ...@@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, false_type)
case erased_entry_status: case erased_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_erase_search_collision(); resize_base::notify_erase_search_collision();
......
...@@ -69,7 +69,7 @@ erase_imp(const_key_reference r_key, true_type) ...@@ -69,7 +69,7 @@ erase_imp(const_key_reference r_key, true_type)
{ {
resize_base::notify_erase_search_end(); 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)); r_key));
return (false); return (false);
...@@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, true_type) ...@@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, true_type)
case erased_entry_status: case erased_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_erase_search_collision(); resize_base::notify_erase_search_collision();
......
...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) 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))); 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 ...@@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (const_cast<PB_DS_CLASS_C_DEC& >(*this). return (const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_extra_indicator)); find_key_pointer(r_key, traits_base::m_store_extra_indicator));
......
...@@ -52,26 +52,17 @@ ...@@ -52,26 +52,17 @@
#include <utility> #include <utility>
#ifdef PB_DS_HT_MAP_TRACE_ #ifdef PB_DS_HT_MAP_TRACE_
#include <iostream> #include <iostream>
#endif // PB_DS_HT_MAP_TRACE_ #endif
#ifdef PB_DS_USE_MAP_DEBUG_BASE #ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/map_debug_base.hpp> #include <ext/pb_ds/detail/map_debug_base.hpp>
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE #endif
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail 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 \ #define PB_DS_CLASS_T_DEC \
template< \ template< \
typename Key, \ typename Key, \
...@@ -85,14 +76,12 @@ namespace pb_ds ...@@ -85,14 +76,12 @@ namespace pb_ds
class Resize_Policy> class Resize_Policy>
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_CLASS_NAME \ #define PB_DS_CLASS_NAME gp_ht_map_data_
gp_ht_map_data_ #endif
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
#ifdef PB_DS_DATA_FALSE_INDICATOR #ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_CLASS_NAME \ #define PB_DS_CLASS_NAME gp_ht_map_no_data_
gp_ht_map_no_data_ #endif
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
PB_DS_CLASS_NAME< \ PB_DS_CLASS_NAME< \
...@@ -129,24 +118,20 @@ namespace pb_ds ...@@ -129,24 +118,20 @@ namespace pb_ds
Allocator, \ Allocator, \
Store_Hash> Store_Hash>
#ifdef PB_DS_USE_MAP_DEBUG_BASE #ifdef _GLIBCXX_DEBUG
#define PB_DS_MAP_DEBUG_BASE_C_DEC \ #define PB_DS_MAP_DEBUG_BASE_C_DEC \
map_debug_base< \ map_debug_base<Key, Eq_Fn, typename Allocator::template rebind<Key>::other::const_reference>
Key, \ #endif
Eq_Fn, \
typename Allocator::template rebind< \
Key>::other::const_reference>
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
#define PB_DS_V2F(X) (X).first #define PB_DS_V2F(X) (X).first
#define PB_DS_V2S(X) (X).second #define PB_DS_V2S(X) (X).second
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif
#ifdef PB_DS_DATA_FALSE_INDICATOR #ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_V2F(X) (X) #define PB_DS_V2F(X) (X)
#define PB_DS_V2S(X) Mapped() #define PB_DS_V2S(X) Mapped()
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR #endif
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \ #define PB_DS_STATIC_ASSERT(UNIQUE, E) \
typedef \ typedef \
...@@ -164,9 +149,9 @@ namespace pb_ds ...@@ -164,9 +149,9 @@ namespace pb_ds
class Probe_Fn, class Probe_Fn,
class Resize_Policy> class Resize_Policy>
class PB_DS_CLASS_NAME : class PB_DS_CLASS_NAME :
#ifdef PB_DS_GP_HT_MAP_DEBUG__ #ifdef _GLIBCXX_DEBUG
protected PB_DS_MAP_DEBUG_BASE_C_DEC, 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 PB_DS_HASH_EQ_FN_C_DEC,
public Resize_Policy, public Resize_Policy,
public PB_DS_RANGED_PROBE_FN_C_DEC, public PB_DS_RANGED_PROBE_FN_C_DEC,
...@@ -362,7 +347,7 @@ namespace pb_ds ...@@ -362,7 +347,7 @@ namespace pb_ds
inline std::pair<point_iterator, bool> inline std::pair<point_iterator, bool>
insert(const_reference r_val) 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)); return (insert_imp(r_val, traits_base::m_store_extra_indicator));
} }
...@@ -413,19 +398,15 @@ namespace pb_ds ...@@ -413,19 +398,15 @@ namespace pb_ds
inline const_iterator inline const_iterator
end() const; end() const;
#ifdef PB_DS_GP_HT_MAP_DEBUG__ #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid() const;
#endif
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
#ifdef PB_DS_HT_MAP_TRACE_ #ifdef PB_DS_HT_MAP_TRACE_
void void
trace() const; trace() const;
#endif
#endif // #ifdef PB_DS_HT_MAP_TRACE_
private: private:
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base; typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
...@@ -462,9 +443,9 @@ namespace pb_ds ...@@ -462,9 +443,9 @@ namespace pb_ds
typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base; 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; 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; typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
...@@ -525,13 +506,13 @@ namespace pb_ds ...@@ -525,13 +506,13 @@ namespace pb_ds
inline pointer inline pointer
insert_new_imp(const_reference r_val, size_type pos) 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()) if (do_resize_if_needed())
pos = find_ins_pos(PB_DS_V2F(r_val), pos = find_ins_pos(PB_DS_V2F(r_val),
traits_base::m_store_extra_indicator); 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; entry* const p_e = m_a_entries + pos;
...@@ -541,10 +522,10 @@ namespace pb_ds ...@@ -541,10 +522,10 @@ namespace pb_ds
resize_base::notify_inserted(++m_num_used_e); 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));) 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); return (&p_e->m_value);
} }
...@@ -552,7 +533,7 @@ namespace pb_ds ...@@ -552,7 +533,7 @@ namespace pb_ds
inline pointer inline pointer
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) 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); valid_entry_status);
if (do_resize_if_needed()) if (do_resize_if_needed())
...@@ -560,7 +541,7 @@ namespace pb_ds ...@@ -560,7 +541,7 @@ namespace pb_ds
PB_DS_V2F(r_val), PB_DS_V2F(r_val),
traits_base::m_store_extra_indicator); 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); valid_entry_status);
entry* const p_e = m_a_entries + r_pos_hash_pair.first; entry* const p_e = m_a_entries + r_pos_hash_pair.first;
...@@ -573,10 +554,10 @@ namespace pb_ds ...@@ -573,10 +554,10 @@ namespace pb_ds
resize_base::notify_inserted(++m_num_used_e); 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_V2F(p_e->m_value));)
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
return (&p_e->m_value); return (&p_e->m_value);
} }
...@@ -585,7 +566,7 @@ namespace pb_ds ...@@ -585,7 +566,7 @@ namespace pb_ds
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference r_key, store_hash_false_type) 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 = const size_type pos =
find_ins_pos(r_key, traits_base::m_store_extra_indicator); find_ins_pos(r_key, traits_base::m_store_extra_indicator);
...@@ -599,7 +580,7 @@ namespace pb_ds ...@@ -599,7 +580,7 @@ namespace pb_ds
mapped_type()), mapped_type()),
pos)->second); 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); return (p_e->m_value.second);
} }
...@@ -607,7 +588,7 @@ namespace pb_ds ...@@ -607,7 +588,7 @@ namespace pb_ds
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference r_key, store_hash_true_type) 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 = comp_hash pos_hash_pair =
find_ins_pos(r_key, traits_base::m_store_extra_indicator); find_ins_pos(r_key, traits_base::m_store_extra_indicator);
...@@ -619,7 +600,7 @@ namespace pb_ds ...@@ -619,7 +600,7 @@ namespace pb_ds
mapped_type()), mapped_type()),
pos_hash_pair)->second); 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); return ((m_a_entries + pos_hash_pair.first)->m_value.second);
} }
...@@ -649,7 +630,7 @@ namespace pb_ds ...@@ -649,7 +630,7 @@ namespace pb_ds
{ {
resize_base::notify_find_search_end(); 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);) check_key_does_not_exist(r_key);)
return (NULL); return (NULL);
...@@ -662,7 +643,7 @@ namespace pb_ds ...@@ -662,7 +643,7 @@ namespace pb_ds
{ {
resize_base::notify_find_search_end(); 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); return ((pointer)&p_e->m_value);
} }
...@@ -670,13 +651,13 @@ namespace pb_ds ...@@ -670,13 +651,13 @@ namespace pb_ds
case erased_entry_status: case erased_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_find_search_collision(); 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);) check_key_does_not_exist(r_key);)
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
...@@ -708,7 +689,7 @@ namespace pb_ds ...@@ -708,7 +689,7 @@ namespace pb_ds
{ {
resize_base::notify_find_search_end(); 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);) check_key_does_not_exist(r_key);)
return (NULL); return (NULL);
...@@ -722,7 +703,7 @@ namespace pb_ds ...@@ -722,7 +703,7 @@ namespace pb_ds
{ {
resize_base::notify_find_search_end(); 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); return ((pointer)&p_e->m_value);
} }
...@@ -730,13 +711,13 @@ namespace pb_ds ...@@ -730,13 +711,13 @@ namespace pb_ds
case erased_entry_status: case erased_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_find_search_collision(); 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);) check_key_does_not_exist(r_key);)
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
...@@ -764,7 +745,7 @@ namespace pb_ds ...@@ -764,7 +745,7 @@ namespace pb_ds
void void
inc_it_state(const_pointer& r_p_value, size_type& r_pos) const 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) for (++r_pos; r_pos < m_num_e; ++r_pos)
{ {
...@@ -817,15 +798,15 @@ namespace pb_ds ...@@ -817,15 +798,15 @@ namespace pb_ds
r_p_value = NULL; r_p_value = NULL;
} }
#ifdef PB_DS_GP_HT_MAP_DEBUG__ #ifdef _GLIBCXX_DEBUG
void void
assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) const; assert_entry_array_valid(const entry_array a_entries,
store_hash_false_type) const;
void void
assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) const; assert_entry_array_valid(const entry_array a_entries,
store_hash_true_type) const;
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__ #endif
private: private:
static entry_allocator s_entry_allocator; static entry_allocator s_entry_allocator;
...@@ -880,10 +861,6 @@ namespace pb_ds ...@@ -880,10 +861,6 @@ namespace pb_ds
#undef PB_DS_V2F #undef PB_DS_V2F
#undef PB_DS_V2S #undef PB_DS_V2S
#undef PB_DS_DBG_ASSERT
#undef PB_DS_DBG_VERIFY
#undef PB_DS_DBG_ONLY
#undef PB_DS_STATIC_ASSERT #undef PB_DS_STATIC_ASSERT
} // namespace detail } // namespace detail
......
...@@ -66,7 +66,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type) ...@@ -66,7 +66,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
const size_type pos = const size_type pos =
ranged_probe_fn_base::operator()(r_key, hash, i); 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; entry* const p_e = m_a_entries + pos;
...@@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type) ...@@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
PB_DS_DBG_ONLY( _GLIBCXX_DEBUG_ONLY(
map_debug_base::check_key_does_not_exist(r_key);) map_debug_base::check_key_does_not_exist(r_key);)
return ((ins_pos == m_num_e)? pos : ins_pos); 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) ...@@ -92,13 +92,13 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
{ {
resize_base::notify_insert_search_end(); 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); return (pos);
} }
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_insert_search_collision(); resize_base::notify_insert_search_collision();
...@@ -124,14 +124,14 @@ insert_imp(const_reference r_val, store_hash_false_type) ...@@ -124,14 +124,14 @@ insert_imp(const_reference r_val, store_hash_false_type)
if (m_a_entries[pos].m_stat == valid_entry_status) 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( return (std::make_pair(
& (m_a_entries + pos)->m_value, & (m_a_entries + pos)->m_value,
false)); 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( return (std::make_pair(
insert_new_imp(r_val, pos), insert_new_imp(r_val, pos),
......
...@@ -50,7 +50,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash ...@@ -50,7 +50,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find_ins_pos(const_key_reference r_key, store_hash_true_type) 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); 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) ...@@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type)
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
PB_DS_DBG_ONLY( _GLIBCXX_DEBUG_ONLY(
map_debug_base::check_key_does_not_exist(r_key);) map_debug_base::check_key_does_not_exist(r_key);)
return ((ins_pos == m_num_e)? return ((ins_pos == m_num_e)?
...@@ -97,13 +97,13 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type) ...@@ -97,13 +97,13 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type)
{ {
resize_base::notify_insert_search_end(); 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)); return (std::make_pair(pos, pos_hash_pair.second));
} }
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
resize_base::notify_insert_search_collision(); resize_base::notify_insert_search_collision();
...@@ -127,18 +127,18 @@ insert_imp(const_reference r_val, store_hash_true_type) ...@@ -127,18 +127,18 @@ insert_imp(const_reference r_val, store_hash_true_type)
comp_hash pos_hash_pair = comp_hash pos_hash_pair =
find_ins_pos(r_key, traits_base::m_store_extra_indicator); 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]; entry_pointer p_e =& m_a_entries[pos_hash_pair.first];
if (p_e->m_stat == valid_entry_status) 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)); 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( return (std::make_pair(
insert_new_imp(r_val, pos_hash_pair), insert_new_imp(r_val, pos_hash_pair),
......
...@@ -81,7 +81,7 @@ do_resize_if_needed_no_throw() ...@@ -81,7 +81,7 @@ do_resize_if_needed_no_throw()
catch(...) catch(...)
{ } { }
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -96,7 +96,7 @@ resize_imp(size_type new_size) ...@@ -96,7 +96,7 @@ resize_imp(size_type new_size)
if (new_size == m_num_e) if (new_size == m_num_e)
return; return;
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
const size_type old_size = m_num_e; const size_type old_size = m_num_e;
...@@ -132,7 +132,7 @@ resize_imp(size_type new_size) ...@@ -132,7 +132,7 @@ resize_imp(size_type new_size)
// At this point no exceptions can be thrown. // 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); Resize_Policy::notify_resized(new_size);
...@@ -142,7 +142,7 @@ resize_imp(size_type new_size) ...@@ -142,7 +142,7 @@ resize_imp(size_type new_size)
m_a_entries = a_entries_resized; m_a_entries = a_entries_resized;
PB_DS_DBG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
...@@ -73,12 +73,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash ...@@ -73,12 +73,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
return; return;
case erased_entry_status: case erased_entry_status:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
break; break;
case valid_entry_status: case valid_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
} }
......
...@@ -76,12 +76,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash ...@@ -76,12 +76,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
return; return;
case erased_entry_status: case erased_entry_status:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
break; break;
case valid_entry_status: case valid_entry_status:
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
} }
......
...@@ -70,7 +70,7 @@ trace() const ...@@ -70,7 +70,7 @@ trace() const
std::cerr << PB_DS_V2F(m_a_entries[i].m_value); std::cerr << PB_DS_V2F(m_a_entries[i].m_value);
break; break;
default: default:
PB_DS_DBG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
std::cerr << std::endl; std::cerr << std::endl;
......
...@@ -51,48 +51,15 @@ ...@@ -51,48 +51,15 @@
namespace pb_ds namespace pb_ds
{ {
namespace detail 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<typename Allocator>
#define PB_DS_CLASS_C_DEC \
probe_fn_base< \
Allocator>
template<typename Allocator> template<typename Allocator>
class probe_fn_base class probe_fn_base
{ {
protected: protected:
~probe_fn_base(); ~probe_fn_base() { }
}; };
} // namespace detail
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 pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_PROBE_FN_BASE_HPP #endif
...@@ -50,22 +50,13 @@ ...@@ -50,22 +50,13 @@
#include <ext/pb_ds/detail/basic_types.hpp> #include <ext/pb_ds/detail/basic_types.hpp>
#include <utility> #include <utility>
#include <debug/debug.h>
namespace pb_ds namespace pb_ds
{ {
namespace detail 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<typename Key, template<typename Key,
class Hash_Fn, class Hash_Fn,
class Allocator, class Allocator,
...@@ -254,26 +245,20 @@ namespace pb_ds ...@@ -254,26 +245,20 @@ namespace pb_ds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size) ranged_hash_fn(size_type size)
{ { Comb_Hash_Fn::notify_resized(size); }
Comb_Hash_Fn::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) :
Hash_Fn(r_hash_fn) Hash_Fn(r_hash_fn)
{ { Comb_Hash_Fn::notify_resized(size); }
Comb_Hash_Fn::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) :
Hash_Fn(r_hash_fn), Hash_Fn(r_hash_fn),
Comb_Hash_Fn(r_comb_hash_fn) Comb_Hash_Fn(r_comb_hash_fn)
{ { comb_hash_fn_base::notify_resized(size); }
comb_hash_fn_base::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -281,7 +266,6 @@ namespace pb_ds ...@@ -281,7 +266,6 @@ namespace pb_ds
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
comb_hash_fn_base::swap(other); comb_hash_fn_base::swap(other);
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
} }
...@@ -289,9 +273,7 @@ namespace pb_ds ...@@ -289,9 +273,7 @@ namespace pb_ds
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_resized(size_type size) notify_resized(size_type size)
{ { comb_hash_fn_base::notify_resized(size); }
comb_hash_fn_base::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash inline typename PB_DS_CLASS_C_DEC::comp_hash
...@@ -299,23 +281,21 @@ namespace pb_ds ...@@ -299,23 +281,21 @@ namespace pb_ds
operator()(const_key_reference r_key) const operator()(const_key_reference r_key) const
{ {
const size_type hash = hash_fn_base::operator()(r_key); const size_type hash = hash_fn_base::operator()(r_key);
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
return (std::make_pair(comb_hash_fn_base::operator()(hash), hash));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator() operator()
#ifdef PB_DS_RANGED_HASH_FN_DEBUG #ifdef _GLIBCXX_DEBUG
(const_key_reference r_key, size_type hash) const (const_key_reference r_key, size_type hash) const
#else // #ifdef PB_DS_RANGED_HASH_FN_DEBUG #else
(const_key_reference /*r_key*/, size_type hash) const (const_key_reference /*r_key*/, size_type hash) const
#endif // #ifdef PB_DS_RANGED_HASH_FN_DEBUG #endif
{ {
PB_DS_DBG_ASSERT(hash == hash_fn_base::operator()(r_key)); _GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
return (std::make_pair(comb_hash_fn_base::operator()(hash), hash));
} }
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
...@@ -359,7 +339,7 @@ namespace pb_ds ...@@ -359,7 +339,7 @@ namespace pb_ds
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn); ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn);
ranged_hash_fn(size_type size, const null_hash_fn & r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
void void
swap(PB_DS_CLASS_C_DEC& other); swap(PB_DS_CLASS_C_DEC& other);
...@@ -368,9 +348,7 @@ namespace pb_ds ...@@ -368,9 +348,7 @@ namespace pb_ds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size) ranged_hash_fn(size_type size)
{ { Comb_Hash_Fn::notify_resized(size); }
Comb_Hash_Fn::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -388,9 +366,7 @@ namespace pb_ds ...@@ -388,9 +366,7 @@ namespace pb_ds
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ { comb_hash_fn_base::swap(other); }
comb_hash_fn_base::swap(other);
}
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
...@@ -432,7 +408,7 @@ namespace pb_ds ...@@ -432,7 +408,7 @@ namespace pb_ds
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn); ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn);
ranged_hash_fn(size_type size, const null_hash_fn & r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
void void
swap(PB_DS_CLASS_C_DEC& other); swap(PB_DS_CLASS_C_DEC& other);
...@@ -441,9 +417,7 @@ namespace pb_ds ...@@ -441,9 +417,7 @@ namespace pb_ds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
ranged_hash_fn(size_type size) ranged_hash_fn(size_type size)
{ { Comb_Hash_Fn::notify_resized(size); }
Comb_Hash_Fn::notify_resized(size);
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -461,18 +435,12 @@ namespace pb_ds ...@@ -461,18 +435,12 @@ namespace pb_ds
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ { comb_hash_fn_base::swap(other); }
comb_hash_fn_base::swap(other);
}
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_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 } // namespace pb_ds
#endif // #ifndef PB_DS_RANGED_HASH_FN_HPP #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment