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