Commit f5886803 by François Dumont Committed by François Dumont

macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New.

2011-05-07  François Dumont  <francois.cppdevs@free.fr>

	* include/debug/macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New.
	(_GLICXX_DEBUG_VERIFY): Use latter.
	* include/ext/pb_ds/detail/resize_policy/
	hash_load_check_resize_trigger_imp.hpp: Emit assertion on the line
	containing the original assert call.
	* include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp,
	find_fn_imps.hpp, insert_fn_imps.hpp, binomial_heap_base_.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp,
	find_fn_imps.hpp, insert_store_hash_fn_imps.hpp, debug_fn_imps.hpp,
	debug_no_store_hash_fn_imps.hpp, cc_ht_map_.hpp, resize_fn_imps.hpp,
	constructor_destructor_fn_imps.hpp, debug_store_hash_fn_imps.hpp,
	erase_no_store_hash_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp,
	insert_join_fn_imps.hpp, pat_trie_/head.hpp, debug_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, pat_trie_.hpp, split_fn_imps.hpp,
	leaf.hpp, erase_fn_imps.hpp, node_base.hpp, internal_node.hpp:
	Likewise.
	* include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp,
	r_erase_fn_imps.hpp, constructors_destructor_fn_imps.hpp,
	debug_fn_imps.hpp, rotate_fn_imps.hpp, erase_fn_imps.hpp,
	bin_search_tree_.hpp, insert_fn_imps.hpp, split_join_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp,
	find_fn_imps.hpp, gp_ht_map_.hpp, insert_store_hash_fn_imps.hpp,
	debug_fn_imps.hpp, erase_fn_imps.hpp, debug_no_store_hash_fn_imps.hpp,
	resize_fn_imps.hpp, constructor_destructor_fn_imps.hpp,
	debug_store_hash_fn_imps.hpp, erase_no_store_hash_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	erase_fn_imps.hpp, insert_fn_imps.hpp, binary_heap_.hpp,
	resize_policy.hpp, split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp,
	find_fn_imps.hpp, insert_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	pairing_heap_.hpp, split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/binomial_heap_/
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	binomial_heap_.hpp: Likewise.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	erase_fn_imps.hpp, left_child_next_sibling_heap_.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp,
	find_fn_imps.hpp, thin_heap_.hpp, insert_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp,
	ov_tree_map_.hpp, constructors_destructor_fn_imps.hpp,
	debug_fn_imps.hpp, split_join_fn_imps.hpp, info_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/debug_map_base.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp,
	find_fn_imps.hpp, insert_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
	splay_fn_imps.hpp, split_join_fn_imps.hpp, splay_tree_.hpp: Likewise.
	* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp,
	find_fn_imps.hpp, lu_map_.hpp, constructor_destructor_fn_imps.hpp,
	insert_fn_imps.hpp, debug_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp,
	rc_binomial_heap_.hpp, insert_fn_imps.hpp,
	constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rc.hpp,
	split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp,
	insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp,
	debug_fn_imps.hpp, rb_tree_.hpp, split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/hash_policy.hpp: Likewise.

From-SVN: r173529
parent 6f4d39bb
2011-05-07 François Dumont <francois.cppdevs@free.fr>
* include/debug/macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New.
(_GLICXX_DEBUG_VERIFY): Use latter.
* include/ext/pb_ds/detail/resize_policy/
hash_load_check_resize_trigger_imp.hpp: Emit assertion on the line
containing the original assert call.
* include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp,
find_fn_imps.hpp, insert_fn_imps.hpp, binomial_heap_base_.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/cc_hash_table_map_/
erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp,
find_fn_imps.hpp, insert_store_hash_fn_imps.hpp, debug_fn_imps.hpp,
debug_no_store_hash_fn_imps.hpp, cc_ht_map_.hpp, resize_fn_imps.hpp,
constructor_destructor_fn_imps.hpp, debug_store_hash_fn_imps.hpp,
erase_no_store_hash_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp,
insert_join_fn_imps.hpp, pat_trie_/head.hpp, debug_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, pat_trie_.hpp, split_fn_imps.hpp,
leaf.hpp, erase_fn_imps.hpp, node_base.hpp, internal_node.hpp:
Likewise.
* include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp,
r_erase_fn_imps.hpp, constructors_destructor_fn_imps.hpp,
debug_fn_imps.hpp, rotate_fn_imps.hpp, erase_fn_imps.hpp,
bin_search_tree_.hpp, insert_fn_imps.hpp, split_join_fn_imps.hpp:
Likewise.
* include/ext/pb_ds/detail/gp_hash_table_map_/
erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp,
find_fn_imps.hpp, gp_ht_map_.hpp, insert_store_hash_fn_imps.hpp,
debug_fn_imps.hpp, erase_fn_imps.hpp, debug_no_store_hash_fn_imps.hpp,
resize_fn_imps.hpp, constructor_destructor_fn_imps.hpp,
debug_store_hash_fn_imps.hpp, erase_no_store_hash_fn_imps.hpp:
Likewise.
* include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
erase_fn_imps.hpp, insert_fn_imps.hpp, binary_heap_.hpp,
resize_policy.hpp, split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp,
find_fn_imps.hpp, insert_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
pairing_heap_.hpp, split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/binomial_heap_/
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
binomial_heap_.hpp: Likewise.
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
erase_fn_imps.hpp, left_child_next_sibling_heap_.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp,
find_fn_imps.hpp, thin_heap_.hpp, insert_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp,
ov_tree_map_.hpp, constructors_destructor_fn_imps.hpp,
debug_fn_imps.hpp, split_join_fn_imps.hpp, info_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/debug_map_base.hpp: Likewise.
* include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp,
find_fn_imps.hpp, insert_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp,
splay_fn_imps.hpp, split_join_fn_imps.hpp, splay_tree_.hpp: Likewise.
* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp,
find_fn_imps.hpp, lu_map_.hpp, constructor_destructor_fn_imps.hpp,
insert_fn_imps.hpp, debug_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp,
rc_binomial_heap_.hpp, insert_fn_imps.hpp,
constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rc.hpp,
split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp,
insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp,
debug_fn_imps.hpp, rb_tree_.hpp, split_join_fn_imps.hpp: Likewise.
* include/ext/pb_ds/hash_policy.hpp: Likewise.
2011-05-06 Paolo Carlini <paolo.carlini@oracle.com> 2011-05-06 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/22_locale/messages_byname/named_equivalence.cc: Fix. * testsuite/22_locale/messages_byname/named_equivalence.cc: Fix.
......
// Debugging support implementation -*- C++ -*- // Debugging support implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -39,14 +39,17 @@ ...@@ -39,14 +39,17 @@
* the user error and where the error is reported. * the user error and where the error is reported.
* *
*/ */
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ #define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \
do \ do \
{ \ { \
if (! (_Condition)) \ if (! (_Condition)) \
__gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ __gnu_debug::_Error_formatter::_M_at(_File, _Line) \
._ErrorMessage._M_error(); \ ._ErrorMessage._M_error(); \
} while (false) } while (false)
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
_GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__)
// Verify that [_First, _Last) forms a valid iterator range. // Verify that [_First, _Last) forms a valid iterator range.
#define __glibcxx_check_valid_range(_First,_Last) \ #define __glibcxx_check_valid_range(_First,_Last) \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -403,51 +403,58 @@ namespace __gnu_pbds ...@@ -403,51 +403,58 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
structure_only_assert_valid() const; structure_only_assert_valid(const char* file, int line) const;
void void
assert_node_consistent(const node_pointer p_nd) const; assert_node_consistent(const node_pointer p_nd,
const char* file, int line) const;
#endif #endif
private: private:
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_iterators() const; assert_iterators(const char* file, int line) const;
void void
assert_consistent_with_debug_base() const; assert_consistent_with_debug_base(const char* file, int line) const;
void void
assert_node_consistent_with_left(const node_pointer p_nd) const; assert_node_consistent_with_left(const node_pointer p_nd,
const char* file, int line) const;
void void
assert_node_consistent_with_right(const node_pointer p_nd) const; assert_node_consistent_with_right(const node_pointer p_nd,
const char* file, int line) const;
void void
assert_consistent_with_debug_base(const node_pointer p_nd) const; assert_consistent_with_debug_base(const node_pointer p_nd,
const char* file, int line) const;
void void
assert_min() const; assert_min(const char* file, int line) const;
void void
assert_min_imp(const node_pointer p_nd) const; assert_min_imp(const node_pointer p_nd,
const char* file, int line) const;
void void
assert_max() const; assert_max(const char* file, int line) const;
void void
assert_max_imp(const node_pointer p_nd) const; assert_max_imp(const node_pointer p_nd,
const char* file, int line) const;
void void
assert_size() const; assert_size(const char* file, int line) const;
typedef std::pair< const_pointer, const_pointer> node_consistent_t; typedef std::pair< const_pointer, const_pointer> node_consistent_t;
node_consistent_t node_consistent_t
assert_node_consistent_(const node_pointer p_nd) const; assert_node_consistent_(const node_pointer p_nd,
const char* file, int line) const;
#endif #endif
void void
...@@ -464,6 +471,28 @@ namespace __gnu_pbds ...@@ -464,6 +471,28 @@ namespace __gnu_pbds
static node_allocator s_node_allocator; static node_allocator s_node_allocator;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node) \
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp>
...@@ -475,14 +504,16 @@ namespace __gnu_pbds ...@@ -475,14 +504,16 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_NAME #undef PB_DS_CLASS_NAME
#undef PB_DS_TYPES_TRAITS_C_DEC #undef PB_DS_TYPES_TRAITS_C_DEC
#undef PB_DS_DEBUG_MAP_BASE_C_DEC #undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -48,7 +48,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -48,7 +48,7 @@ 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(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -57,7 +57,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : ...@@ -57,7 +57,7 @@ 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(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : ...@@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
m_size(0) m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -88,7 +88,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -88,7 +88,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
{ {
initialize(); initialize();
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
__try __try
{ {
...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
s_node_allocator.deallocate(m_p_head, 1); s_node_allocator.deallocate(m_p_head, 1);
__throw_exception_again; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -112,12 +112,12 @@ void ...@@ -112,12 +112,12 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
value_swap(other); value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -187,7 +187,7 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -187,7 +187,7 @@ recursive_copy_node(const node_pointer p_nd)
if (p_ret->m_p_right != 0) if (p_ret->m_p_right != 0)
p_ret->m_p_right->m_p_parent = p_ret; p_ret->m_p_right->m_p_parent = p_ret;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret);) PB_DS_ASSERT_NODE_CONSISTENT(p_ret)
return p_ret; return p_ret;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,230 +43,237 @@ ...@@ -43,230 +43,237 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
structure_only_assert_valid(); structure_only_assert_valid(__file, __line);
assert_consistent_with_debug_base(); assert_consistent_with_debug_base(__file, __line);
assert_size(); assert_size(__file, __line);
assert_iterators(); assert_iterators(__file, __line);
if (m_p_head->m_p_parent == 0) if (m_p_head->m_p_parent == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(m_size == 0); PB_DS_DEBUG_VERIFY(m_size == 0);
} }
else else
{ {
_GLIBCXX_DEBUG_ASSERT(m_size > 0); PB_DS_DEBUG_VERIFY(m_size > 0);
} }
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
structure_only_assert_valid() const structure_only_assert_valid(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head != 0); PB_DS_DEBUG_VERIFY(m_p_head != 0);
if (m_p_head->m_p_parent == 0) if (m_p_head->m_p_parent == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
} }
else else
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head);
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left != m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head);
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head);
} }
if (m_p_head->m_p_parent != 0) if (m_p_head->m_p_parent != 0)
assert_node_consistent(m_p_head->m_p_parent); assert_node_consistent(m_p_head->m_p_parent, __file, __line);
assert_min(); assert_min(__file, __line);
assert_max(); assert_max(__file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const node_pointer p_nd) const assert_node_consistent(const node_pointer p_nd,
const char* __file, int __line) const
{ {
assert_node_consistent_(p_nd); assert_node_consistent_(p_nd, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_consistent_t typename PB_DS_CLASS_C_DEC::node_consistent_t
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent_(const node_pointer p_nd) const assert_node_consistent_(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
return (std::make_pair((const_pointer)0,(const_pointer)0)); return (std::make_pair((const_pointer)0,(const_pointer)0));
assert_node_consistent_with_left(p_nd); assert_node_consistent_with_left(p_nd, __file, __line);
assert_node_consistent_with_right(p_nd); assert_node_consistent_with_right(p_nd, __file, __line);
const std::pair<const_pointer, const_pointer> 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, __file, __line);
if (l_range.second != 0) if (l_range.second != 0)
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second), PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
PB_DS_V2F(p_nd->m_value))); PB_DS_V2F(p_nd->m_value)));
const std::pair<const_pointer, const_pointer> const std::pair<const_pointer, const_pointer>
r_range = assert_node_consistent_(p_nd->m_p_right); r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line);
if (r_range.first != 0) if (r_range.first != 0)
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(*r_range.first))); PB_DS_V2F(*r_range.first)));
return (std::make_pair((l_range.first != 0)? l_range.first :& p_nd->m_value,(r_range.second != 0)? r_range.second :& p_nd->m_value)); return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value,
(r_range.second != 0)? r_range.second : &p_nd->m_value);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent_with_left(const node_pointer p_nd) const assert_node_consistent_with_left(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd->m_p_left == 0) if (p_nd->m_p_left == 0)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd); PB_DS_DEBUG_VERIFY(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_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(p_nd->m_p_left->m_value))); PB_DS_V2F(p_nd->m_p_left->m_value)));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent_with_right(const node_pointer p_nd) const assert_node_consistent_with_right(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd->m_p_right == 0) if (p_nd->m_p_right == 0)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd); PB_DS_DEBUG_VERIFY(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_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
PB_DS_V2F(p_nd->m_value))); PB_DS_V2F(p_nd->m_value)));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_min() const assert_min(const char* __file, int __line) const
{ {
assert_min_imp(m_p_head->m_p_parent); assert_min_imp(m_p_head->m_p_parent, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_min_imp(const node_pointer p_nd) const assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
return; return;
} }
if (p_nd->m_p_left == 0) if (p_nd->m_p_left == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_left); PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left);
return; return;
} }
assert_min_imp(p_nd->m_p_left); assert_min_imp(p_nd->m_p_left, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_max() const assert_max(const char* __file, int __line) const
{ {
assert_max_imp(m_p_head->m_p_parent); assert_max_imp(m_p_head->m_p_parent, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_max_imp(const node_pointer p_nd) const assert_max_imp(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
return; return;
} }
if (p_nd->m_p_right == 0) if (p_nd->m_p_right == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_right); PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right);
return; return;
} }
assert_max_imp(p_nd->m_p_right); assert_max_imp(p_nd->m_p_right, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_iterators() const assert_iterators(const char* __file, int __line) const
{ {
size_type iterated_num = 0; size_type iterated_num = 0;
const_iterator prev_it = end(); const_iterator prev_it = end();
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
++iterated_num; ++iterated_num;
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it; --upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd); PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd);
if (prev_it != end()) if (prev_it != end())
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it))); PB_DS_V2F(*it)));
prev_it = it; prev_it = it;
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); PB_DS_DEBUG_VERIFY(iterated_num == m_size);
size_type reverse_iterated_num = 0; size_type reverse_iterated_num = 0;
const_reverse_iterator reverse_prev_it = rend(); const_reverse_iterator reverse_prev_it = rend();
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
++reverse_it) ++reverse_it)
{ {
++reverse_iterated_num; ++reverse_iterated_num;
_GLIBCXX_DEBUG_ASSERT(lower_bound( PB_DS_DEBUG_VERIFY(lower_bound(
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it)); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
--upper_bound_it; --upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd); PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
if (reverse_prev_it != rend()) if (reverse_prev_it != rend())
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it), PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
PB_DS_V2F(*reverse_it))); PB_DS_V2F(*reverse_it)));
reverse_prev_it = reverse_it; reverse_prev_it = reverse_it;
} }
_GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size); PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_consistent_with_debug_base() const assert_consistent_with_debug_base(const char* __file, int __line) const
{ {
debug_base::check_size(m_size); debug_base::check_size(m_size, __file, __line);
assert_consistent_with_debug_base(m_p_head->m_p_parent); assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_consistent_with_debug_base(const node_pointer p_nd) const assert_consistent_with_debug_base(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
return; return;
debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value)); debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line);
assert_consistent_with_debug_base(p_nd->m_p_left); assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line);
assert_consistent_with_debug_base(p_nd->m_p_right); assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_size() const assert_size(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size); PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z) ...@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z)
_GLIBCXX_DEBUG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node(); p_z->~node();
...@@ -88,7 +88,7 @@ void ...@@ -88,7 +88,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent); clear_imp(m_p_head->m_p_parent);
...@@ -98,8 +98,8 @@ clear() ...@@ -98,8 +98,8 @@ clear()
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -133,7 +133,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -133,7 +133,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head; node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_nd = m_p_head->m_p_parent;
...@@ -148,10 +148,10 @@ find(const_key_reference r_key) ...@@ -148,10 +148,10 @@ find(const_key_reference r_key)
else else
p_nd = p_nd->m_p_right; p_nd = p_nd->m_p_right;
return point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( return point_iterator((p_pot != m_p_head
r_key, && Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))? PB_DS_V2F(p_pot->m_value)))
m_p_head : p_pot); ? m_p_head : p_pot);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -159,7 +159,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator ...@@ -159,7 +159,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head; node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_nd = m_p_head->m_p_parent;
...@@ -174,9 +174,9 @@ find(const_key_reference r_key) const ...@@ -174,9 +174,9 @@ find(const_key_reference r_key) const
else else
p_nd = p_nd->m_p_right; p_nd = p_nd->m_p_right;
return const_point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( return const_point_iterator((p_pot != m_p_head
r_key, && Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))? PB_DS_V2F(p_pot->m_value)))
m_p_head : p_pot); ? m_p_head : p_pot);
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,19 +43,17 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -43,19 +43,17 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_leaf(const_reference r_value) insert_leaf(const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
if (m_size == 0) if (m_size == 0)
return (std::make_pair( return std::make_pair(insert_imp_empty(r_value),
insert_imp_empty(r_value), true);
true));
node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_nd = m_p_head->m_p_parent;
node_pointer p_pot = m_p_head; node_pointer p_pot = m_p_head;
while (p_nd != 0) while (p_nd != 0)
if (!Cmp_Fn::operator()( if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value))) PB_DS_V2F(r_value)))
{ {
p_pot = p_nd; p_pot = p_nd;
...@@ -66,37 +64,29 @@ insert_leaf(const_reference r_value) ...@@ -66,37 +64,29 @@ insert_leaf(const_reference r_value)
p_nd = p_nd->m_p_right; p_nd = p_nd->m_p_right;
if (p_pot == m_p_head) if (p_pot == m_p_head)
return (std::make_pair( return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false),
insert_leaf_new(r_value, m_p_head->m_p_right, false), true);
true));
if (!Cmp_Fn::operator()( if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
PB_DS_V2F(r_value),
PB_DS_V2F(p_pot->m_value))) PB_DS_V2F(p_pot->m_value)))
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists( return std::make_pair(p_pot, false);
PB_DS_V2F(r_value)));
return (std::make_pair(p_pot, false));
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
PB_DS_V2F(r_value)));
p_nd = p_pot->m_p_left; p_nd = p_pot->m_p_left;
if (p_nd == 0) if (p_nd == 0)
return (std::make_pair( return std::make_pair(insert_leaf_new(r_value, p_pot, true),
insert_leaf_new(r_value, p_pot, true), true);
true));
while (p_nd->m_p_right != 0) while (p_nd->m_p_right != 0)
p_nd = p_nd->m_p_right; p_nd = p_nd->m_p_right;
return (std::make_pair( return std::make_pair(insert_leaf_new(r_value, p_nd, false),
insert_leaf_new(r_value, p_nd, false), true);
true));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -105,7 +95,8 @@ PB_DS_CLASS_C_DEC:: ...@@ -105,7 +95,8 @@ PB_DS_CLASS_C_DEC::
insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
{ {
node_pointer p_new_nd = node_pointer p_new_nd =
get_new_node_for_leaf_insert( r_value, traits_base::m_no_throw_copies_indicator); get_new_node_for_leaf_insert(r_value,
traits_base::m_no_throw_copies_indicator);
if (left_nd) if (left_nd)
{ {
...@@ -136,14 +127,13 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) ...@@ -136,14 +127,13 @@ 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 = 0; p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_nd)); PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
update_to_top(p_new_nd, (node_update* )this); update_to_top(p_new_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new( _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
PB_DS_V2F(r_value)));
return (iterator(p_new_nd)); return iterator(p_new_nd);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -152,7 +142,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -152,7 +142,7 @@ PB_DS_CLASS_C_DEC::
insert_imp_empty(const_reference r_value) insert_imp_empty(const_reference r_value)
{ {
node_pointer p_new_node = node_pointer p_new_node =
get_new_node_for_leaf_insert( r_value, traits_base::m_no_throw_copies_indicator); get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator);
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head->m_p_left = m_p_head->m_p_right =
m_p_head->m_p_parent = p_new_node; m_p_head->m_p_parent = p_new_node;
...@@ -161,12 +151,11 @@ insert_imp_empty(const_reference r_value) ...@@ -161,12 +151,11 @@ insert_imp_empty(const_reference r_value)
p_new_node->m_p_left = p_new_node->m_p_right = 0; p_new_node->m_p_left = p_new_node->m_p_right = 0;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new( _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
PB_DS_V2F(r_value)));
update_to_top(m_p_head->m_p_parent, (node_update* )this); update_to_top(m_p_head->m_p_parent, (node_update*)this);
return (iterator(p_new_node)); return iterator(p_new_node);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -178,8 +167,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type) ...@@ -178,8 +167,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type)
cond_dealtor_t cond(p_new_nd); cond_dealtor_t cond(p_new_nd);
new (const_cast<void* >( new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val); typename node::value_type(r_val);
cond.set_no_action(); cond.set_no_action();
...@@ -188,7 +176,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type) ...@@ -188,7 +176,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type)
++m_size; ++m_size;
return (p_new_nd); return p_new_nd;
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -198,14 +186,13 @@ get_new_node_for_leaf_insert(const_reference r_val, true_type) ...@@ -198,14 +186,13 @@ get_new_node_for_leaf_insert(const_reference r_val, true_type)
{ {
node_pointer p_new_nd = s_node_allocator.allocate(1); node_pointer p_new_nd = s_node_allocator.allocate(1);
new (const_cast<void* >( new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val); typename node::value_type(r_val);
p_new_nd->m_p_left = p_new_nd->m_p_right = 0; p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size; ++m_size;
return (p_new_nd); return p_new_nd;
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z) ...@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z)
_GLIBCXX_DEBUG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node(); p_z->~node();
...@@ -88,7 +88,7 @@ void ...@@ -88,7 +88,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent); clear_imp(m_p_head->m_p_parent);
...@@ -98,8 +98,8 @@ clear() ...@@ -98,8 +98,8 @@ clear()
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -62,8 +62,8 @@ rotate_left(node_pointer p_x) ...@@ -62,8 +62,8 @@ rotate_left(node_pointer p_x)
p_y->m_p_left = p_x; p_y->m_p_left = p_x;
p_x->m_p_parent = p_y; p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) PB_DS_ASSERT_NODE_CONSISTENT(p_x)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) PB_DS_ASSERT_NODE_CONSISTENT(p_y)
apply_update(p_x, (node_update* )this); apply_update(p_x, (node_update* )this);
apply_update(p_x->m_p_parent, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this);
...@@ -93,8 +93,8 @@ rotate_right(node_pointer p_x) ...@@ -93,8 +93,8 @@ rotate_right(node_pointer p_x)
p_y->m_p_right = p_x; p_y->m_p_right = p_x;
p_x->m_p_parent = p_y; p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) PB_DS_ASSERT_NODE_CONSISTENT(p_x)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) PB_DS_ASSERT_NODE_CONSISTENT(p_y)
apply_update(p_x, (node_update* )this); apply_update(p_x, (node_update* )this);
apply_update(p_x->m_p_parent, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this);
...@@ -129,8 +129,7 @@ inline void ...@@ -129,8 +129,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_* /*p_update*/) apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
{ {
node_update::operator()( node_update::operator()(node_iterator(p_nd),
node_iterator(p_nd),
const_node_iterator(static_cast<node_pointer>(0))); const_node_iterator(static_cast<node_pointer>(0)));
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,8 +43,8 @@ bool ...@@ -43,8 +43,8 @@ bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other) join_prep(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (other.m_size == 0) if (other.m_size == 0)
return false; return false;
...@@ -54,9 +54,13 @@ join_prep(PB_DS_CLASS_C_DEC& other) ...@@ -54,9 +54,13 @@ join_prep(PB_DS_CLASS_C_DEC& other)
return false; return false;
} }
const bool greater = Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value), PB_DS_V2F(other.m_p_head->m_p_left->m_value)); const bool greater =
Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value),
PB_DS_V2F(other.m_p_head->m_p_left->m_value));
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value), PB_DS_V2F(m_p_head->m_p_left->m_value)); const bool lesser =
Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value),
PB_DS_V2F(m_p_head->m_p_left->m_value));
if (!greater && !lesser) if (!greater && !lesser)
__throw_join_error(); __throw_join_error();
...@@ -83,37 +87,37 @@ bool ...@@ -83,37 +87,37 @@ bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
other.clear(); other.clear();
if (m_size == 0) if (m_size == 0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return false; return false;
} }
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value))) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return false; return false;
} }
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value))) if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return false; return false;
} }
if (m_size == 1) if (m_size == 1)
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return false; return false;
} }
...@@ -130,8 +134,8 @@ split_finish(PB_DS_CLASS_C_DEC& other) ...@@ -130,8 +134,8 @@ split_finish(PB_DS_CLASS_C_DEC& other)
other.m_size = std::distance(other.begin(), other.end()); other.m_size = std::distance(other.begin(), other.end());
m_size -= other.m_size; m_size -= other.m_size;
initialize_min_max(); initialize_min_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -310,7 +310,7 @@ namespace __gnu_pbds ...@@ -310,7 +310,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
...@@ -335,6 +335,15 @@ namespace __gnu_pbds ...@@ -335,6 +335,15 @@ namespace __gnu_pbds
entry_pointer m_a_entries; entry_pointer m_a_entries;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp>
...@@ -346,6 +355,8 @@ namespace __gnu_pbds ...@@ -346,6 +355,8 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp> #include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_ENTRY_CMP_DEC #undef PB_DS_ENTRY_CMP_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -64,7 +65,7 @@ copy_from_range(It first_it, It last_it) ...@@ -64,7 +65,7 @@ copy_from_range(It first_it, It last_it)
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this)); std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -74,7 +75,7 @@ binary_heap_() : ...@@ -74,7 +75,7 @@ binary_heap_() :
m_actual_size(resize_policy::min_size), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -85,7 +86,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -85,7 +86,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) :
m_actual_size(resize_policy::min_size), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -97,7 +98,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -97,7 +98,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
m_actual_size(other.m_actual_size), m_actual_size(other.m_actual_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
const_iterator first_it = other.begin(); const_iterator first_it = other.begin();
...@@ -119,7 +120,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -119,7 +120,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
s_entry_allocator.deallocate(m_a_entries, m_actual_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size);
__throw_exception_again; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -127,14 +128,14 @@ void ...@@ -127,14 +128,14 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other); value_swap(other);
std::swap((entry_cmp& )(*this), (entry_cmp& )other); std::swap((entry_cmp& )(*this), (entry_cmp& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,14 +43,14 @@ ...@@ -43,14 +43,14 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
s_entry_allocator.check_allocated(m_a_entries, m_actual_size); s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
#endif #endif
resize_policy::assert_valid(); resize_policy::assert_valid(__file, __line);
_GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size); PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
for (size_type i = 0; i < m_size; ++i) for (size_type i = 0; i < m_size; ++i)
{ {
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
...@@ -58,14 +58,14 @@ assert_valid() const ...@@ -58,14 +58,14 @@ assert_valid() const
#endif #endif
if (left_child(i) < m_size) if (left_child(i) < m_size)
_GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
_GLIBCXX_DEBUG_ASSERT(parent(left_child(i)) == i); PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i);
if (right_child(i) < m_size) if (right_child(i) < m_size)
_GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
_GLIBCXX_DEBUG_ASSERT(parent(right_child(i)) == i); PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i);
} }
} }
......
...@@ -66,7 +66,7 @@ clear() ...@@ -66,7 +66,7 @@ clear()
m_size = 0; m_size = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -89,7 +89,7 @@ inline void ...@@ -89,7 +89,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
erase_at(m_a_entries, 0, s_no_throw_copies_ind); erase_at(m_a_entries, 0, s_no_throw_copies_ind);
...@@ -102,7 +102,7 @@ pop() ...@@ -102,7 +102,7 @@ pop()
_GLIBCXX_DEBUG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size; --m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -111,7 +111,7 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -111,7 +111,7 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
typedef typename entry_pred<value_type, Pred, simple_value, Allocator>::type typedef typename entry_pred<value_type, Pred, simple_value, Allocator>::type
pred_t; pred_t;
...@@ -148,7 +148,7 @@ erase_if(Pred pred) ...@@ -148,7 +148,7 @@ erase_if(Pred pred)
std::make_heap(m_a_entries, m_a_entries + m_size, std::make_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp& >(*this)); static_cast<entry_cmp& >(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return ersd; return ersd;
} }
...@@ -158,7 +158,7 @@ inline void ...@@ -158,7 +158,7 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
const size_type fix_pos = it.m_p_e - m_a_entries; const size_type fix_pos = it.m_p_e - m_a_entries;
...@@ -177,7 +177,7 @@ erase(point_iterator it) ...@@ -177,7 +177,7 @@ erase(point_iterator it)
if (fix_pos != m_size) if (fix_pos != m_size)
fix(m_a_entries + fix_pos); fix(m_a_entries + fix_pos);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
return top_imp(s_no_throw_copies_ind); return top_imp(s_no_throw_copies_ind);
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,11 +43,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,11 +43,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) push(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
insert_value(r_val, s_no_throw_copies_ind); insert_value(r_val, s_no_throw_copies_ind);
std::push_heap(m_a_entries, m_a_entries + m_size, std::push_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp&>(*this)); static_cast<entry_cmp&>(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return point_iterator(m_a_entries); return point_iterator(m_a_entries);
} }
...@@ -108,10 +108,10 @@ void ...@@ -108,10 +108,10 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) modify(point_iterator it, const_reference r_new_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
fix(it.m_p_e); fix(it.m_p_e);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -131,7 +131,7 @@ fix(entry_pointer p_e) ...@@ -131,7 +131,7 @@ fix(entry_pointer p_e)
parent_i = parent(i); parent_i = parent(i);
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return; return;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -52,6 +52,15 @@ namespace __gnu_pbds ...@@ -52,6 +52,15 @@ namespace __gnu_pbds
#define PB_DS_CLASS_C_DEC resize_policy<Size_Type> #define PB_DS_CLASS_C_DEC resize_policy<Size_Type>
#define PB_DS_ASSERT_VALID(X)\
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
template<typename Size_Type> template<typename Size_Type>
class resize_policy class resize_policy
{ {
...@@ -102,7 +111,7 @@ namespace __gnu_pbds ...@@ -102,7 +111,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_BINARY_HEAP_TRACE_ #ifdef PB_DS_BINARY_HEAP_TRACE_
...@@ -128,7 +137,7 @@ namespace __gnu_pbds ...@@ -128,7 +137,7 @@ namespace __gnu_pbds
resize_policy() : resize_policy() :
m_next_shrink_size(0), m_next_shrink_size(0),
m_next_grow_size(min_size) m_next_grow_size(min_size)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -188,11 +197,11 @@ namespace __gnu_pbds ...@@ -188,11 +197,11 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_grow_resize() notify_grow_resize()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
m_next_grow_size *= factor; m_next_grow_size *= factor;
m_next_shrink_size = m_next_grow_size / ratio; m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -200,14 +209,14 @@ namespace __gnu_pbds ...@@ -200,14 +209,14 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_shrink_resize() notify_shrink_resize()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
m_next_shrink_size /= factor; m_next_shrink_size /= factor;
if (m_next_shrink_size == 1) if (m_next_shrink_size == 1)
m_next_shrink_size = 0; m_next_shrink_size = 0;
m_next_grow_size = m_next_grow_size =
std::max(m_next_grow_size / factor, static_cast<size_type>(min_size)); std::max(m_next_grow_size / factor, static_cast<size_type>(min_size));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -217,19 +226,19 @@ namespace __gnu_pbds ...@@ -217,19 +226,19 @@ namespace __gnu_pbds
{ {
m_next_grow_size = actual_size; m_next_grow_size = actual_size;
m_next_shrink_size = m_next_grow_size / ratio; m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(m_next_shrink_size == 0 || PB_DS_DEBUG_VERIFY(m_next_shrink_size == 0 ||
m_next_shrink_size* ratio == m_next_grow_size); m_next_shrink_size* ratio == m_next_grow_size);
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); PB_DS_DEBUG_VERIFY(m_next_grow_size >= min_size);
} }
#endif #endif
...@@ -244,6 +253,8 @@ namespace __gnu_pbds ...@@ -244,6 +253,8 @@ namespace __gnu_pbds
} }
#endif #endif
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -45,7 +45,7 @@ void ...@@ -45,7 +45,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
typedef typedef
typename entry_pred< typename entry_pred<
...@@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
resize_policy::notify_arbitrary(m_actual_size); resize_policy::notify_arbitrary(m_actual_size);
other.notify_arbitrary(other.m_actual_size); other.notify_arbitrary(other.m_actual_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
const size_type len = m_size + other.m_size; const size_type len = m_size + other.m_size;
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(len); const size_type actual_size = resize_policy::get_new_size_for_arbitrary(len);
...@@ -167,7 +167,7 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -167,7 +167,7 @@ join(PB_DS_CLASS_C_DEC& other)
other.notify_arbitrary(resize_policy::min_size); other.notify_arbitrary(resize_policy::min_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -100,13 +100,17 @@ namespace __gnu_pbds ...@@ -100,13 +100,17 @@ namespace __gnu_pbds
protected: protected:
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp>
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -41,19 +41,19 @@ ...@@ -41,19 +41,19 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_() binomial_heap_()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_(const Cmp_Fn& r_cmp_fn) : binomial_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn) PB_DS_BASE_C_DEC(r_cmp_fn)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_(const PB_DS_CLASS_C_DEC& other) : binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other) PB_DS_BASE_C_DEC(other)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ base_type::assert_valid(true); } { base_type::assert_valid(true, __file, __line); }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -187,10 +187,10 @@ namespace __gnu_pbds ...@@ -187,10 +187,10 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid(bool strictly_binomial) const; assert_valid(bool strictly_binomial, const char* file, int line) const;
void void
assert_max() const; assert_max(const char* file, int line) const;
#endif #endif
private: private:
...@@ -209,13 +209,27 @@ namespace __gnu_pbds ...@@ -209,13 +209,27 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_node_consistent(const_node_pointer, bool, bool) const; assert_node_consistent(const_node_pointer, bool, bool,
const char*, int) const;
#endif #endif
protected: protected:
node_pointer m_p_max; node_pointer m_p_max;
}; };
#define PB_DS_ASSERT_VALID(X, _StrictlyBinomial) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(_StrictlyBinomial,__FILE__, __LINE__);)
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp>
...@@ -223,6 +237,9 @@ namespace __gnu_pbds ...@@ -223,6 +237,9 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC #undef PB_DS_BASE_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -47,16 +47,16 @@ copy_from_range(It first_it, It last_it) ...@@ -47,16 +47,16 @@ copy_from_range(It first_it, It last_it)
while (first_it != last_it) while (first_it != last_it)
push(*(first_it++)); push(*(first_it++));
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
binomial_heap_base_() : binomial_heap_base_() :
m_p_max(0) m_p_max(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -64,8 +64,8 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) : ...@@ -64,8 +64,8 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn), PB_DS_BASE_C_DEC(r_cmp_fn),
m_p_max(0) m_p_max(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -73,22 +73,22 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) : ...@@ -73,22 +73,22 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other), PB_DS_BASE_C_DEC(other),
m_p_max(0) m_p_max(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
base_type::swap(other); base_type::swap(other);
std::swap(m_p_max, other.m_p_max); std::swap(m_p_max, other.m_p_max);
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -44,23 +44,24 @@ ...@@ -44,23 +44,24 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid(bool strictly_binomial) const assert_valid(bool strictly_binomial, const char* __file, int __line) const
{ {
base_type::assert_valid(); base_type::assert_valid(__file, __line);
assert_node_consistent(base_type::m_p_root, strictly_binomial, true); assert_node_consistent(base_type::m_p_root, strictly_binomial, true,
assert_max(); __file, __line);
assert_max(__file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_max() const assert_max(const char* __file, int __line) const
{ {
if (m_p_max == 0) if (m_p_max == 0)
return; return;
_GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == 0); PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value,
it.m_p_nd->m_value)); it.m_p_nd->m_value));
} }
...@@ -68,30 +69,31 @@ PB_DS_CLASS_T_DEC ...@@ -68,30 +69,31 @@ PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial,
bool increasing) const bool increasing, const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(increasing || strictly_binomial); PB_DS_DEBUG_VERIFY(increasing || strictly_binomial);
base_type::assert_node_consistent(p_nd, false); base_type::assert_node_consistent(p_nd, false, __file, __line);
if (p_nd == 0) if (p_nd == 0)
return; return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd)); PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd));
_GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) == PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) ==
static_cast<size_type>(1 << p_nd->m_metadata)); static_cast<size_type>(1 << p_nd->m_metadata));
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing); assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing,
assert_node_consistent(p_nd->m_p_l_child, true, false); __file, __line);
assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line);
if (p_nd->m_p_next_sibling != 0) if (p_nd->m_p_next_sibling != 0)
{ {
if (increasing) if (increasing)
{ {
if (strictly_binomial) if (strictly_binomial)
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata PB_DS_DEBUG_VERIFY(p_nd->m_metadata
< p_nd->m_p_next_sibling->m_metadata); < p_nd->m_p_next_sibling->m_metadata);
else else
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata PB_DS_DEBUG_VERIFY(p_nd->m_metadata
<= p_nd->m_p_next_sibling->m_metadata); <= p_nd->m_p_next_sibling->m_metadata);
} }
else else
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata PB_DS_DEBUG_VERIFY(p_nd->m_metadata
> p_nd->m_p_next_sibling->m_metadata); > p_nd->m_p_next_sibling->m_metadata);
} }
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ void ...@@ -43,7 +43,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0) if (m_p_max == 0)
...@@ -59,8 +59,8 @@ pop() ...@@ -59,8 +59,8 @@ pop()
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -113,7 +113,7 @@ void ...@@ -113,7 +113,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::bubble_to_top(it.m_p_nd); base_type::bubble_to_top(it.m_p_nd);
...@@ -124,8 +124,8 @@ erase(point_iterator it) ...@@ -124,8 +124,8 @@ erase(point_iterator it)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
template<typename Pred> template<typename Pred>
...@@ -133,11 +133,11 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -133,11 +133,11 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
return 0; return 0;
} }
...@@ -185,7 +185,7 @@ erase_if(Pred pred) ...@@ -185,7 +185,7 @@ erase_if(Pred pred)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
return ersd; return ersd;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(false);) PB_DS_ASSERT_VALID((*this),false)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0) if (m_p_max == 0)
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) push(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
node_pointer p_nd = base_type::get_new_node_for_insert(r_val); node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
...@@ -51,7 +51,7 @@ push(const_reference r_val) ...@@ -51,7 +51,7 @@ push(const_reference r_val)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
return point_iterator(p_nd); return point_iterator(p_nd);
} }
...@@ -171,11 +171,11 @@ void ...@@ -171,11 +171,11 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) modify(point_iterator it, const_reference r_new_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
node_pointer p_nd = it.m_p_nd; node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val); const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
...@@ -198,7 +198,7 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -198,7 +198,7 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
return; return;
} }
...@@ -211,6 +211,6 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -211,6 +211,6 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,15 +44,15 @@ void ...@@ -44,15 +44,15 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
other.clear(); other.clear();
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
return; return;
} }
...@@ -86,7 +86,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -86,7 +86,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_out = p_next; p_out = p_next;
} }
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
node_pointer p_cur = base_type::m_p_root; node_pointer p_cur = base_type::m_p_root;
...@@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
m_p_max = 0; m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
node_pointer p_other = other.m_p_root; node_pointer p_other = other.m_p_root;
...@@ -147,9 +147,9 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -147,9 +147,9 @@ join(PB_DS_CLASS_C_DEC& other)
other.m_size = 0; other.m_size = 0;
other.m_p_max = 0; other.m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);) PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) PB_DS_ASSERT_VALID(other,true)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer inline typename PB_DS_CLASS_C_DEC::node_pointer
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -100,6 +101,14 @@ namespace __gnu_pbds ...@@ -100,6 +101,14 @@ namespace __gnu_pbds
#define PB_DS_V2S(X) Mapped_Data() #define PB_DS_V2S(X) Mapped_Data()
#endif #endif
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
// <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813. // <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813.
template<typename Key, template<typename Key,
typename Mapped, typename Mapped,
...@@ -320,7 +329,7 @@ namespace __gnu_pbds ...@@ -320,7 +329,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_HT_MAP_TRACE_ #ifdef PB_DS_HT_MAP_TRACE_
...@@ -369,7 +378,7 @@ namespace __gnu_pbds ...@@ -369,7 +378,7 @@ namespace __gnu_pbds
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference r_key, false_type) subscript_imp(const_key_reference r_key, false_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
const size_type pos = ranged_hash_fn_base::operator()(r_key); const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos]; entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start(); resize_base::notify_insert_search_start();
...@@ -384,18 +393,18 @@ namespace __gnu_pbds ...@@ -384,18 +393,18 @@ namespace __gnu_pbds
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (p_e != 0) if (p_e != 0)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return (p_e->m_value.second); return (p_e->m_value.second);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return insert_new_imp(value_type(r_key, mapped_type()), pos)->second; return insert_new_imp(value_type(r_key, mapped_type()), pos)->second;
} }
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference r_key, true_type) subscript_imp(const_key_reference r_key, true_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos_hash_pair.first]; entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start(); resize_base::notify_insert_search_start();
...@@ -409,11 +418,11 @@ namespace __gnu_pbds ...@@ -409,11 +418,11 @@ namespace __gnu_pbds
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (p_e != 0) if (p_e != 0)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return p_e->m_value.second; return p_e->m_value.second;
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return insert_new_imp(value_type(r_key, mapped_type()), return insert_new_imp(value_type(r_key, mapped_type()),
pos_hash_pair)->second; pos_hash_pair)->second;
} }
...@@ -440,7 +449,7 @@ namespace __gnu_pbds ...@@ -440,7 +449,7 @@ namespace __gnu_pbds
resize_base::notify_inserted(++m_num_used_e); resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -459,7 +468,7 @@ namespace __gnu_pbds ...@@ -459,7 +468,7 @@ namespace __gnu_pbds
m_entries[r_pos_hash_pair.first] = p_e; m_entries[r_pos_hash_pair.first] = p_e;
resize_base::notify_inserted(++m_num_used_e); resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -479,9 +488,9 @@ namespace __gnu_pbds ...@@ -479,9 +488,9 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
if (p_e == 0) if (p_e == 0)
debug_base::check_key_does_not_exist(r_key); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else else
debug_base::check_key_exists(r_key); PB_DS_CHECK_KEY_EXISTS(r_key)
#endif #endif
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -505,9 +514,9 @@ namespace __gnu_pbds ...@@ -505,9 +514,9 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
if (p_e == 0) if (p_e == 0)
debug_base::check_key_does_not_exist(r_key); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else else
debug_base::check_key_exists(r_key); PB_DS_CHECK_KEY_EXISTS(r_key)
#endif #endif
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -568,13 +577,16 @@ namespace __gnu_pbds ...@@ -568,13 +577,16 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_entry_pointer_array_valid(const entry_pointer_array) const; assert_entry_pointer_array_valid(const entry_pointer_array,
const char* file, int line) const;
void void
assert_entry_pointer_valid(const entry_pointer, true_type) const; assert_entry_pointer_valid(const entry_pointer, true_type,
const char* file, int line) const;
void void
assert_entry_pointer_valid(const entry_pointer, false_type) const; assert_entry_pointer_valid(const entry_pointer, false_type,
const char* file, int line) const;
#endif #endif
#ifdef PB_DS_HT_MAP_TRACE_ #ifdef PB_DS_HT_MAP_TRACE_
...@@ -609,6 +621,15 @@ namespace __gnu_pbds ...@@ -609,6 +621,15 @@ namespace __gnu_pbds
PB_DS_STATIC_ASSERT(sth, store_hash_ok); PB_DS_STATIC_ASSERT(sth, store_hash_ok);
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp>
...@@ -621,6 +642,10 @@ namespace __gnu_pbds ...@@ -621,6 +642,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -66,7 +66,7 @@ PB_DS_CLASS_NAME() : ...@@ -66,7 +66,7 @@ PB_DS_CLASS_NAME() :
m_entries(s_entry_pointer_allocator.allocate(m_num_e)) m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -77,7 +77,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : ...@@ -77,7 +77,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
m_entries(s_entry_pointer_allocator.allocate(m_num_e)) m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -91,7 +91,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : ...@@ -91,7 +91,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0); std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0);
Resize_Policy::notify_cleared(); Resize_Policy::notify_cleared();
ranged_hash_fn_base::notify_resized(m_num_e); ranged_hash_fn_base::notify_resized(m_num_e);
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash ...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash
m_entries(s_entry_pointer_allocator.allocate(m_num_e)) m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -118,22 +118,19 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash ...@@ -118,22 +118,19 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash
m_entries(s_entry_pointer_allocator.allocate(m_num_e)) m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
PB_DS_HASH_EQ_FN_C_DEC(other), PB_DS_HASH_EQ_FN_C_DEC(other),
resize_base(other), ranged_hash_fn_base(other), resize_base(other), ranged_hash_fn_base(other),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e)) m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
__try __try
{ {
copy_from_range(other.begin(), other.end()); copy_from_range(other.begin(), other.end());
...@@ -143,7 +140,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -143,7 +140,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
deallocate_all(); deallocate_all();
__throw_exception_again; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -156,8 +153,8 @@ void ...@@ -156,8 +153,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
std::swap(m_entries, other.m_entries); std::swap(m_entries, other.m_entries);
std::swap(m_num_e, other.m_num_e); std::swap(m_num_e, other.m_num_e);
...@@ -167,8 +164,8 @@ swap(PB_DS_CLASS_C_DEC& other) ...@@ -167,8 +164,8 @@ swap(PB_DS_CLASS_C_DEC& other)
resize_base::swap(other); resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,16 +43,17 @@ ...@@ -43,16 +43,17 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
debug_base::check_size(m_num_used_e); debug_base::check_size(m_num_used_e, __file, __line);
assert_entry_pointer_array_valid(m_entries); assert_entry_pointer_array_valid(m_entries, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries,
const char* __file, int __line) const
{ {
size_type iterated_num_used_e = 0; size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos) for (size_type pos = 0; pos < m_num_e; ++pos)
...@@ -61,11 +62,12 @@ assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const ...@@ -61,11 +62,12 @@ assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const
while (p_e != 0) while (p_e != 0)
{ {
++iterated_num_used_e; ++iterated_num_used_e;
assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator); assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator,
__file, __line);
p_e = p_e->m_p_next; p_e = p_e->m_p_next;
} }
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
} }
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp>
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p, false_type) const assert_entry_pointer_valid(const entry_pointer p, false_type,
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value)); } const char* __file, int __line) const
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,11 +43,12 @@ ...@@ -43,11 +43,12 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e, true_type) const assert_entry_pointer_valid(const entry_pointer p_e, true_type,
const char* __file, int __line) const
{ {
debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); debug_base::check_key_exists(PB_DS_V2F(p_e->m_value), __file, __line);
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));
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,7 +44,7 @@ inline bool ...@@ -44,7 +44,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key) erase(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key)); return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
} }
...@@ -53,24 +53,24 @@ inline bool ...@@ -53,24 +53,24 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_in_pos_imp(const_key_reference r_key, size_type pos) erase_in_pos_imp(const_key_reference r_key, size_type pos)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[pos]; entry_pointer p_e = m_entries[pos];
resize_base::notify_erase_search_start(); resize_base::notify_erase_search_start();
if (p_e == 0) if (p_e == 0)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return false; return false;
} }
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base:: check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(m_entries[pos]); erase_entry_pointer(m_entries[pos]);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return true; return true;
} }
...@@ -80,18 +80,18 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) ...@@ -80,18 +80,18 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
if (p_next_e == 0) if (p_next_e == 0)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return false; return false;
} }
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key)) if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(p_e->m_p_next); erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return true; return true;
} }
resize_base::notify_erase_search_collision(); resize_base::notify_erase_search_collision();
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,14 +44,14 @@ inline bool ...@@ -44,14 +44,14 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[r_pos_hash_pair.first]; entry_pointer p_e = m_entries[r_pos_hash_pair.first];
resize_base::notify_erase_search_start(); resize_base::notify_erase_search_start();
if (p_e == 0) if (p_e == 0)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base:: check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return false; return false;
} }
...@@ -59,10 +59,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -59,10 +59,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
r_key, r_pos_hash_pair.second)) r_key, r_pos_hash_pair.second))
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(m_entries[r_pos_hash_pair.first]); erase_entry_pointer(m_entries[r_pos_hash_pair.first]);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return true; return true;
} }
...@@ -72,8 +72,8 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -72,8 +72,8 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
if (p_next_e == 0) if (p_next_e == 0)
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return false; return false;
} }
...@@ -82,10 +82,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) ...@@ -82,10 +82,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
r_pos_hash_pair.second)) r_pos_hash_pair.second))
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
erase_entry_pointer(p_e->m_p_next); erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return true; return true;
} }
resize_base::notify_erase_search_collision(); resize_base::notify_erase_search_collision();
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator); return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
} }
...@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator ...@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key, return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key,
traits_base::m_store_extra_indicator); traits_base::m_store_extra_indicator);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,7 +44,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -44,7 +44,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, false_type) insert_imp(const_reference r_val, false_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
const_key_reference r_key = PB_DS_V2F(r_val); const_key_reference r_key = PB_DS_V2F(r_val);
const size_type pos = ranged_hash_fn_base::operator()(r_key); const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos]; entry_pointer p_e = m_entries[pos];
...@@ -60,11 +60,11 @@ insert_imp(const_reference r_val, false_type) ...@@ -60,11 +60,11 @@ insert_imp(const_reference r_val, false_type)
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (p_e != 0) if (p_e != 0)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&p_e->m_value, false); return std::make_pair(&p_e->m_value, false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos), true); return std::make_pair(insert_new_imp(r_val, pos), true);
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,7 +44,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -44,7 +44,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, true_type) insert_imp(const_reference r_val, true_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
const_key_reference key = PB_DS_V2F(r_val); const_key_reference key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key);
entry_pointer p_e = m_entries[pos_hash_pair.first]; entry_pointer p_e = m_entries[pos_hash_pair.first];
...@@ -61,11 +61,11 @@ insert_imp(const_reference r_val, true_type) ...@@ -61,11 +61,11 @@ insert_imp(const_reference r_val, true_type)
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (p_e != 0) if (p_e != 0)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) PB_DS_CHECK_KEY_EXISTS(key)
return std::make_pair(&p_e->m_value, false); return std::make_pair(&p_e->m_value, false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw() ...@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw()
__catch(...) __catch(...)
{ } { }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -79,7 +79,7 @@ void ...@@ -79,7 +79,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size) resize_imp(size_type new_size)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (new_size == m_num_e) if (new_size == m_num_e)
return; return;
...@@ -104,7 +104,7 @@ resize_imp(size_type new_size) ...@@ -104,7 +104,7 @@ resize_imp(size_type new_size)
// At this point no exceptions can be thrown. // At this point no exceptions can be thrown.
resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size); resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size);
Resize_Policy::notify_resized(new_size); Resize_Policy::notify_resized(new_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -123,10 +123,11 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res ...@@ -123,10 +123,11 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res
} }
m_num_e = new_size; m_num_e = new_size;
_GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);) _GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized,
__FILE__, __LINE__);)
s_entry_pointer_allocator.deallocate(m_entries, old_size); s_entry_pointer_allocator.deallocate(m_entries, old_size);
m_entries = a_p_entries_resized; m_entries = a_p_entries_resized;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -51,6 +51,15 @@ ...@@ -51,6 +51,15 @@
#include <ext/throw_allocator.h> #include <ext/throw_allocator.h>
#include <debug/debug.h> #include <debug/debug.h>
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
namespace __gnu_pbds namespace __gnu_pbds
{ {
namespace detail namespace detail
...@@ -98,13 +107,15 @@ namespace __gnu_pbds ...@@ -98,13 +107,15 @@ namespace __gnu_pbds
clear(); clear();
inline void inline void
check_key_exists(const_key_reference r_key) const; check_key_exists(const_key_reference r_key,
const char* file, int line) const;
inline void inline void
check_key_does_not_exist(const_key_reference r_key) const; check_key_does_not_exist(const_key_reference r_key,
const char* file, int line) const;
inline void inline void
check_size(size_type size) const; check_size(size_type size, const char* file, int line) const;
void void
swap(PB_DS_CLASS_C_DEC& other); swap(PB_DS_CLASS_C_DEC& other);
...@@ -114,11 +125,11 @@ namespace __gnu_pbds ...@@ -114,11 +125,11 @@ namespace __gnu_pbds
split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&); split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
void void
join(PB_DS_CLASS_C_DEC& other); join(PB_DS_CLASS_C_DEC& other, bool with_cleanup = true);
private: private:
void void
assert_valid() const; assert_valid(const char* file, int line) const;
const_key_set_iterator const_key_set_iterator
find(const_key_reference r_key) const; find(const_key_reference r_key) const;
...@@ -133,24 +144,24 @@ namespace __gnu_pbds ...@@ -133,24 +144,24 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
debug_map_base() debug_map_base()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
debug_map_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set) debug_map_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
~debug_map_base() ~debug_map_base()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_new(const_key_reference r_key) insert_new(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (find(r_key) != m_key_set.end()) if (find(r_key) != m_key_set.end())
{ {
...@@ -169,7 +180,7 @@ namespace __gnu_pbds ...@@ -169,7 +180,7 @@ namespace __gnu_pbds
std::abort(); std::abort();
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -177,7 +188,7 @@ namespace __gnu_pbds ...@@ -177,7 +188,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_existing(const_key_reference r_key) erase_existing(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
key_set_iterator it = find(r_key); key_set_iterator it = find(r_key);
if (it == m_key_set.end()) if (it == m_key_set.end())
{ {
...@@ -185,7 +196,7 @@ namespace __gnu_pbds ...@@ -185,7 +196,7 @@ namespace __gnu_pbds
std::abort(); std::abort();
} }
m_key_set.erase(it); m_key_set.erase(it);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -193,36 +204,39 @@ namespace __gnu_pbds ...@@ -193,36 +204,39 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
m_key_set.clear(); m_key_set.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
check_key_exists(const_key_reference r_key) const check_key_exists(const_key_reference r_key,
const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) assert_valid(__file, __line);
if (find(r_key) == m_key_set.end()) if (find(r_key) == m_key_set.end())
{ {
std::cerr << "check_key_exists " << r_key << std::endl; std::cerr << __file << ':' << __line << ": check_key_exists "
<< r_key << std::endl;
std::abort(); std::abort();
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
check_key_does_not_exist(const_key_reference r_key) const check_key_does_not_exist(const_key_reference r_key,
const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) assert_valid(__file, __line);
if (find(r_key) != m_key_set.end()) if (find(r_key) != m_key_set.end())
{ {
using std::cerr; using std::cerr;
using std::endl; using std::endl;
cerr << "check_key_does_not_exist " << r_key << endl; cerr << __file << ':' << __line << ": check_key_does_not_exist "
<< r_key << endl;
std::abort(); std::abort();
} }
} }
...@@ -230,17 +244,16 @@ namespace __gnu_pbds ...@@ -230,17 +244,16 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
check_size(size_type size) const check_size(size_type size, const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) assert_valid(__file, __line);
const size_type key_set_size = m_key_set.size(); const size_type key_set_size = m_key_set.size();
if (size != key_set_size) if (size != key_set_size)
{ {
std::cerr << "check_size " << size std::cerr << __file << ':' << __line << ": check_size " << size
<< " " << key_set_size << std::endl; << " != " << key_set_size << std::endl;
std::abort(); std::abort();
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -248,9 +261,9 @@ namespace __gnu_pbds ...@@ -248,9 +261,9 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
m_key_set.swap(other.m_key_set); m_key_set.swap(other.m_key_set);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -258,7 +271,7 @@ namespace __gnu_pbds ...@@ -258,7 +271,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
typedef const_key_set_iterator iterator_type; typedef const_key_set_iterator iterator_type;
for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it) for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it)
if (m_eq(*it, r_key)) if (m_eq(*it, r_key))
...@@ -271,7 +284,7 @@ namespace __gnu_pbds ...@@ -271,7 +284,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
key_set_iterator it = m_key_set.begin(); key_set_iterator it = m_key_set.begin();
while (it != m_key_set.end()) while (it != m_key_set.end())
{ {
...@@ -280,13 +293,12 @@ namespace __gnu_pbds ...@@ -280,13 +293,12 @@ namespace __gnu_pbds
++it; ++it;
} }
return it; return it;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
const_key_set_iterator prime_it = m_key_set.begin(); const_key_set_iterator prime_it = m_key_set.begin();
while (prime_it != m_key_set.end()) while (prime_it != m_key_set.end())
...@@ -295,8 +307,8 @@ namespace __gnu_pbds ...@@ -295,8 +307,8 @@ namespace __gnu_pbds
++sec_it; ++sec_it;
while (sec_it != m_key_set.end()) while (sec_it != m_key_set.end())
{ {
_GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it)); PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it));
_GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it)); PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it));
++sec_it; ++sec_it;
} }
++prime_it; ++prime_it;
...@@ -324,15 +336,18 @@ namespace __gnu_pbds ...@@ -324,15 +336,18 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other, bool with_cleanup)
{ {
key_set_iterator it = other.m_key_set.begin(); key_set_iterator it = other.m_key_set.begin();
while (it != other.m_key_set.end()) while (it != other.m_key_set.end())
{ {
insert_new(*it); insert_new(*it);
if (with_cleanup)
it = other.m_key_set.erase(it); it = other.m_key_set.erase(it);
else
++it;
} }
_GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty()); _GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_key_set.empty());
} }
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
...@@ -341,6 +356,9 @@ namespace __gnu_pbds ...@@ -341,6 +356,9 @@ namespace __gnu_pbds
} // namespace detail } // namespace detail
} // namespace __gnu_pbds } // namespace __gnu_pbds
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#endif #endif
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -61,7 +62,7 @@ PB_DS_CLASS_NAME() ...@@ -61,7 +62,7 @@ PB_DS_CLASS_NAME()
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -72,7 +73,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) ...@@ -72,7 +73,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn)
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -84,7 +85,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) ...@@ -84,7 +85,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn)
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -98,7 +99,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, ...@@ -98,7 +99,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -112,7 +113,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, ...@@ -112,7 +113,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -127,7 +128,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, ...@@ -127,7 +128,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
m_entries(s_entry_allocator.allocate(m_num_e)) m_entries(s_entry_allocator.allocate(m_num_e))
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -160,7 +161,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -160,7 +161,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
deallocate_all(); deallocate_all();
__throw_exception_again; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -173,8 +174,8 @@ void ...@@ -173,8 +174,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
std::swap(m_num_e, other.m_num_e); std::swap(m_num_e, other.m_num_e);
std::swap(m_num_used_e, other.m_num_used_e); std::swap(m_num_used_e, other.m_num_used_e);
std::swap(m_entries, other.m_entries); std::swap(m_entries, other.m_entries);
...@@ -182,8 +183,8 @@ swap(PB_DS_CLASS_C_DEC& other) ...@@ -182,8 +183,8 @@ swap(PB_DS_CLASS_C_DEC& other)
hash_eq_fn_base::swap(other); hash_eq_fn_base::swap(other);
resize_base::swap(other); resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
debug_base::check_size(m_num_used_e); debug_base::check_size(m_num_used_e, __file, __line);
assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator); assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator,
__file, __line);
} }
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_array_valid(const entry_array a_entries, false_type) const assert_entry_array_valid(const entry_array a_entries, false_type,
const char* __file, int __line) const
{ {
size_type iterated_num_used_e = 0; size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos) for (size_type pos = 0; pos < m_num_e; ++pos)
...@@ -57,15 +58,15 @@ assert_entry_array_valid(const entry_array a_entries, false_type) const ...@@ -57,15 +58,15 @@ assert_entry_array_valid(const entry_array a_entries, false_type) const
case valid_entry_status: 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);
debug_base::check_key_exists(r_key); debug_base::check_key_exists(r_key, __file, __line);
++iterated_num_used_e; ++iterated_num_used_e;
break; break;
} }
default: default:
_GLIBCXX_DEBUG_ASSERT(0); PB_DS_DEBUG_VERIFY(0);
}; };
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_entry_array_valid(const entry_array a_entries, true_type) const assert_entry_array_valid(const entry_array a_entries, true_type,
const char* __file, int __line) const
{ {
size_type iterated_num_used_e = 0; size_type iterated_num_used_e = 0;
...@@ -58,20 +59,20 @@ assert_entry_array_valid(const entry_array a_entries, true_type) const ...@@ -58,20 +59,20 @@ assert_entry_array_valid(const entry_array a_entries, true_type) const
case valid_entry_status: 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);
debug_base::check_key_exists(r_key); debug_base::check_key_exists(r_key, __file, __line);
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
++iterated_num_used_e; ++iterated_num_used_e;
break; break;
} }
default: default:
_GLIBCXX_DEBUG_ASSERT(0); PB_DS_DEBUG_VERIFY(0);
}; };
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -72,7 +72,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -72,7 +72,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0; size_type num_ersd = 0;
for (size_type pos = 0; pos < m_num_e; ++pos) for (size_type pos = 0; pos < m_num_e; ++pos)
{ {
...@@ -86,7 +86,7 @@ erase_if(Pred pred) ...@@ -86,7 +86,7 @@ erase_if(Pred pred)
} }
do_resize_if_needed_no_throw(); do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_ersd; return num_ersd;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,7 +44,7 @@ inline bool ...@@ -44,7 +44,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_imp(const_key_reference r_key, false_type) erase_imp(const_key_reference r_key, false_type)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
size_type hash = ranged_probe_fn_base::operator()(r_key); size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i; size_type i;
resize_base::notify_erase_search_start(); resize_base::notify_erase_search_start();
...@@ -58,8 +58,7 @@ erase_imp(const_key_reference r_key, false_type) ...@@ -58,8 +58,7 @@ erase_imp(const_key_reference r_key, false_type)
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
r_key));
return false; return false;
} }
break; break;
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -57,8 +57,7 @@ erase_imp(const_key_reference r_key, true_type) ...@@ -57,8 +57,7 @@ erase_imp(const_key_reference r_key, true_type)
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_erase_search_end(); resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
r_key));
return false; return false;
} }
break; break;
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator); return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
} }
...@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator ...@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC&>(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator); return const_cast<PB_DS_CLASS_C_DEC&>(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -97,6 +98,13 @@ namespace __gnu_pbds ...@@ -97,6 +98,13 @@ namespace __gnu_pbds
#define PB_DS_V2S(X) Mapped() #define PB_DS_V2S(X) Mapped()
#endif #endif
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
template<typename Key, template<typename Key,
typename Mapped, typename Mapped,
typename Hash_Fn, typename Hash_Fn,
...@@ -280,7 +288,7 @@ namespace __gnu_pbds ...@@ -280,7 +288,7 @@ namespace __gnu_pbds
inline std::pair<point_iterator, bool> inline std::pair<point_iterator, bool>
insert(const_reference r_val) insert(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);)
return insert_imp(r_val, traits_base::m_store_extra_indicator); return insert_imp(r_val, traits_base::m_store_extra_indicator);
} }
...@@ -331,7 +339,7 @@ namespace __gnu_pbds ...@@ -331,7 +339,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_HT_MAP_TRACE_ #ifdef PB_DS_HT_MAP_TRACE_
...@@ -406,7 +414,7 @@ namespace __gnu_pbds ...@@ -406,7 +414,7 @@ namespace __gnu_pbds
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -432,7 +440,7 @@ namespace __gnu_pbds ...@@ -432,7 +440,7 @@ namespace __gnu_pbds
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value; return &p_e->m_value;
} }
...@@ -440,7 +448,7 @@ namespace __gnu_pbds ...@@ -440,7 +448,7 @@ namespace __gnu_pbds
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference key, false_type) subscript_imp(const_key_reference key, false_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
const size_type pos = find_ins_pos(key, const size_type pos = find_ins_pos(key,
traits_base::m_store_extra_indicator); traits_base::m_store_extra_indicator);
...@@ -449,14 +457,14 @@ namespace __gnu_pbds ...@@ -449,14 +457,14 @@ namespace __gnu_pbds
if (p_e->m_stat != valid_entry_status) if (p_e->m_stat != valid_entry_status)
return insert_new_imp(value_type(key, mapped_type()), pos)->second; return insert_new_imp(value_type(key, mapped_type()), pos)->second;
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) PB_DS_CHECK_KEY_EXISTS(key)
return p_e->m_value.second; return p_e->m_value.second;
} }
inline mapped_reference inline mapped_reference
subscript_imp(const_key_reference key, true_type) subscript_imp(const_key_reference key, true_type)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
comp_hash pos_hash_pair = comp_hash pos_hash_pair =
find_ins_pos(key, traits_base::m_store_extra_indicator); find_ins_pos(key, traits_base::m_store_extra_indicator);
...@@ -465,7 +473,7 @@ namespace __gnu_pbds ...@@ -465,7 +473,7 @@ namespace __gnu_pbds
return insert_new_imp(value_type(key, mapped_type()), return insert_new_imp(value_type(key, mapped_type()),
pos_hash_pair)->second; pos_hash_pair)->second;
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key)); PB_DS_CHECK_KEY_EXISTS(key)
return (m_entries + pos_hash_pair.first)->m_value.second; return (m_entries + pos_hash_pair.first)->m_value.second;
} }
#endif #endif
...@@ -488,8 +496,7 @@ namespace __gnu_pbds ...@@ -488,8 +496,7 @@ namespace __gnu_pbds
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return 0; return 0;
} }
break; break;
...@@ -497,8 +504,7 @@ namespace __gnu_pbds ...@@ -497,8 +504,7 @@ namespace __gnu_pbds
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key)) if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key))
{ {
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) PB_DS_CHECK_KEY_EXISTS(key)
return pointer(&p_e->m_value); return pointer(&p_e->m_value);
} }
break; break;
...@@ -511,7 +517,7 @@ namespace __gnu_pbds ...@@ -511,7 +517,7 @@ namespace __gnu_pbds
resize_base::notify_find_search_collision(); resize_base::notify_find_search_collision();
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
return 0; return 0;
} }
...@@ -536,8 +542,7 @@ namespace __gnu_pbds ...@@ -536,8 +542,7 @@ namespace __gnu_pbds
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return 0; return 0;
} }
break; break;
...@@ -547,7 +552,7 @@ namespace __gnu_pbds ...@@ -547,7 +552,7 @@ namespace __gnu_pbds
key, pos_hash_pair.second)) key, pos_hash_pair.second))
{ {
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) PB_DS_CHECK_KEY_EXISTS(key)
return pointer(&p_e->m_value); return pointer(&p_e->m_value);
} }
break; break;
...@@ -560,7 +565,7 @@ namespace __gnu_pbds ...@@ -560,7 +565,7 @@ namespace __gnu_pbds
resize_base::notify_find_search_collision(); resize_base::notify_find_search_collision();
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
resize_base::notify_find_search_end(); resize_base::notify_find_search_end();
return 0; return 0;
} }
...@@ -628,10 +633,12 @@ namespace __gnu_pbds ...@@ -628,10 +633,12 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_entry_array_valid(const entry_array, false_type) const; assert_entry_array_valid(const entry_array, false_type,
const char* file, int line) const;
void void
assert_entry_array_valid(const entry_array, true_type) const; assert_entry_array_valid(const entry_array, true_type,
const char* file, int line) const;
#endif #endif
static entry_allocator s_entry_allocator; static entry_allocator s_entry_allocator;
...@@ -651,6 +658,15 @@ namespace __gnu_pbds ...@@ -651,6 +658,15 @@ namespace __gnu_pbds
PB_DS_STATIC_ASSERT(sth, store_hash_ok); PB_DS_STATIC_ASSERT(sth, store_hash_ok);
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp>
...@@ -662,6 +678,10 @@ namespace __gnu_pbds ...@@ -662,6 +678,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp> #include <ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -62,7 +62,7 @@ find_ins_pos(const_key_reference r_key, false_type) ...@@ -62,7 +62,7 @@ find_ins_pos(const_key_reference r_key, false_type)
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return (ins_pos == m_num_e) ? pos : ins_pos; return (ins_pos == m_num_e) ? pos : ins_pos;
} }
break; break;
...@@ -74,7 +74,7 @@ find_ins_pos(const_key_reference r_key, false_type) ...@@ -74,7 +74,7 @@ find_ins_pos(const_key_reference r_key, false_type)
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return pos; return pos;
} }
break; break;
...@@ -101,11 +101,11 @@ insert_imp(const_reference r_val, false_type) ...@@ -101,11 +101,11 @@ insert_imp(const_reference r_val, false_type)
if (m_entries[pos].m_stat == valid_entry_status) if (m_entries[pos].m_stat == valid_entry_status)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&(m_entries + pos)->m_value, false); return std::make_pair(&(m_entries + pos)->m_value, false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos), true); return std::make_pair(insert_new_imp(r_val, pos), true);
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,7 +44,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash ...@@ -44,7 +44,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find_ins_pos(const_key_reference r_key, true_type) find_ins_pos(const_key_reference r_key, true_type)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
size_type i; size_type i;
...@@ -64,7 +64,7 @@ find_ins_pos(const_key_reference r_key, true_type) ...@@ -64,7 +64,7 @@ find_ins_pos(const_key_reference r_key, true_type)
case empty_entry_status: case empty_entry_status:
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return ((ins_pos == m_num_e) ? return ((ins_pos == m_num_e) ?
std::make_pair(pos, pos_hash_pair.second) : std::make_pair(pos, pos_hash_pair.second) :
...@@ -80,7 +80,7 @@ find_ins_pos(const_key_reference r_key, true_type) ...@@ -80,7 +80,7 @@ find_ins_pos(const_key_reference r_key, true_type)
r_key, pos_hash_pair.second)) r_key, pos_hash_pair.second))
{ {
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(pos, pos_hash_pair.second); return std::make_pair(pos, pos_hash_pair.second);
} }
break; break;
...@@ -108,11 +108,11 @@ insert_imp(const_reference r_val, true_type) ...@@ -108,11 +108,11 @@ insert_imp(const_reference r_val, true_type)
entry_pointer p_e =& m_entries[pos_hash_pair.first]; entry_pointer p_e =& m_entries[pos_hash_pair.first];
if (p_e->m_stat == valid_entry_status) if (p_e->m_stat == valid_entry_status)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(&p_e->m_value, false); return std::make_pair(&p_e->m_value, false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw() ...@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw()
__catch(...) __catch(...)
{ } { }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -86,7 +86,7 @@ resize_imp(size_type new_size) ...@@ -86,7 +86,7 @@ resize_imp(size_type new_size)
if (new_size == m_num_e) if (new_size == m_num_e)
return; return;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
const size_type old_size = m_num_e; const size_type old_size = m_num_e;
entry_array a_entries_resized = 0; entry_array a_entries_resized = 0;
...@@ -113,13 +113,15 @@ resize_imp(size_type new_size) ...@@ -113,13 +113,15 @@ resize_imp(size_type new_size)
} }
// At this point no exceptions can be thrown. // At this point no exceptions can be thrown.
_GLIBCXX_DEBUG_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,
__FILE__, __LINE__);)
Resize_Policy::notify_resized(new_size); Resize_Policy::notify_resized(new_size);
erase_all_valid_entries(m_entries, old_size); erase_all_valid_entries(m_entries, old_size);
s_entry_allocator.deallocate(m_entries, old_size); s_entry_allocator.deallocate(m_entries, old_size);
m_entries = a_entries_resized; m_entries = a_entries_resized;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -53,7 +53,7 @@ left_child_next_sibling_heap_() : ...@@ -53,7 +53,7 @@ left_child_next_sibling_heap_() :
m_p_root(0), m_p_root(0),
m_size(0) m_size(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -63,7 +63,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -63,7 +63,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
m_p_root(0), m_p_root(0),
m_size(0) m_size(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -72,10 +72,10 @@ left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) ...@@ -72,10 +72,10 @@ left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other)
: Cmp_Fn(other), m_p_root(0), m_size(0) : Cmp_Fn(other), m_p_root(0), m_size(0)
{ {
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
m_p_root = recursive_copy_node(other.m_p_root); m_p_root = recursive_copy_node(other.m_p_root);
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -83,12 +83,12 @@ void ...@@ -83,12 +83,12 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
value_swap(other); value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,31 +43,32 @@ ...@@ -43,31 +43,32 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0); PB_DS_DEBUG_VERIFY(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0);
if (m_p_root != 0) if (m_p_root != 0)
assert_node_consistent(m_p_root, Single_Link_Roots); assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line);
assert_size(); assert_size(__file, __line);
assert_iterators(); assert_iterators(__file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const_node_pointer p_nd, bool single_link) const assert_node_consistent(const_node_pointer p_nd, bool single_link,
const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
return; return;
assert_node_consistent(p_nd->m_p_l_child, false); assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
assert_node_consistent(p_nd->m_p_next_sibling, single_link); assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line);
if (single_link) if (single_link)
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent == 0); PB_DS_DEBUG_VERIFY(p_nd->m_p_prev_or_parent == 0);
else if (p_nd->m_p_next_sibling != 0) else if (p_nd->m_p_next_sibling != 0)
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd);
if (p_nd->m_p_l_child == 0) if (p_nd->m_p_l_child == 0)
return; return;
...@@ -76,31 +77,26 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const ...@@ -76,31 +77,26 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const
while (p_child != 0) while (p_child != 0)
{ {
const_node_pointer p_next_child = p_child->m_p_next_sibling; const_node_pointer p_next_child = p_child->m_p_next_sibling;
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value));
p_child = p_next_child; p_child = p_next_child;
} }
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_iterators() const assert_iterators(const char* __file, int __line) const
{ {
const size_type calc_size = std::distance(begin(), end()); PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size());
if (calc_size == size())
return;
_GLIBCXX_DEBUG_ASSERT(0);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_size() const assert_size(const char* __file, int __line) const
{ {
if (size_from_node(m_p_root) == m_size) PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size);
return;
_GLIBCXX_DEBUG_ASSERT(0);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -78,7 +78,7 @@ void ...@@ -78,7 +78,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
to_linked_list() to_linked_list()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_cur = m_p_root; node_pointer p_cur = m_p_root;
while (p_cur != 0) while (p_cur != 0)
if (p_cur->m_p_l_child != 0) if (p_cur->m_p_l_child != 0)
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -273,10 +273,11 @@ namespace __gnu_pbds ...@@ -273,10 +273,11 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
assert_node_consistent(const_node_pointer p_nd, bool single_link) const; assert_node_consistent(const_node_pointer p_nd, bool single_link,
const char* file, int line) const;
static size_type static size_type
size_under_node(const_node_pointer p_nd); size_under_node(const_node_pointer p_nd);
...@@ -298,10 +299,10 @@ namespace __gnu_pbds ...@@ -298,10 +299,10 @@ namespace __gnu_pbds
private: private:
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_iterators() const; assert_iterators(const char* file, int line) const;
void void
assert_size() const; assert_size(const char* file, int line) const;
static size_type static size_type
size_from_node(const_node_pointer p_nd); size_from_node(const_node_pointer p_nd);
...@@ -331,6 +332,15 @@ namespace __gnu_pbds ...@@ -331,6 +332,15 @@ namespace __gnu_pbds
static no_throw_copies_t s_no_throw_copies_ind; static no_throw_copies_t s_no_throw_copies_ind;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp>
...@@ -340,6 +350,8 @@ namespace __gnu_pbds ...@@ -340,6 +350,8 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp> #include <ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -69,7 +69,7 @@ copy_from_range(It first_it, It last_it) ...@@ -69,7 +69,7 @@ copy_from_range(It first_it, It last_it)
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : m_p_l(0) PB_DS_CLASS_NAME() : m_p_l(0)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
template<typename It> template<typename It>
...@@ -77,15 +77,12 @@ PB_DS_CLASS_C_DEC:: ...@@ -77,15 +77,12 @@ PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0) PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0)
{ {
copy_from_range(first_it, last_it); copy_from_range(first_it, last_it);
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(),
#endif
m_p_l(0) m_p_l(0)
{ {
__try __try
...@@ -104,7 +101,7 @@ m_p_l(0) ...@@ -104,7 +101,7 @@ m_p_l(0)
deallocate_all(); deallocate_all();
__throw_exception_again; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -112,12 +109,12 @@ void ...@@ -112,12 +109,12 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_p_l, other.m_p_l); std::swap(m_p_l, other.m_p_l);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,15 +43,15 @@ ...@@ -43,15 +43,15 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
size_type calc_size = 0; size_type calc_size = 0;
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
debug_base::check_key_exists(PB_DS_V2F(*it)); debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
++calc_size; ++calc_size;
} }
debug_base::check_size(calc_size); debug_base::check_size(calc_size, __file, __line);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline bool ...@@ -43,7 +43,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key) erase(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
if (m_p_l == 0) if (m_p_l == 0)
return false; return false;
...@@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0; size_type num_ersd = 0;
while (m_p_l != 0 && pred(m_p_l->m_value)) while (m_p_l != 0 && pred(m_p_l->m_value))
{ {
...@@ -106,7 +106,7 @@ erase_if(Pred pred) ...@@ -106,7 +106,7 @@ erase_if(Pred pred)
p_l = p_l->m_p_next; p_l = p_l->m_p_next;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_ersd; return num_ersd;
} }
...@@ -116,7 +116,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -116,7 +116,6 @@ PB_DS_CLASS_C_DEC::
erase_next(entry_pointer p_l) erase_next(entry_pointer p_l)
{ {
_GLIBCXX_DEBUG_ASSERT(p_l != 0); _GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_l != m_p_l);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0); _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0);
entry_pointer p_next_l = p_l->m_p_next->m_p_next; entry_pointer p_next_l = p_l->m_p_next->m_p_next;
actual_erase_entry(p_l->m_p_next); actual_erase_entry(p_l->m_p_next);
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -48,7 +48,7 @@ find_imp(const_key_reference r_key) const ...@@ -48,7 +48,7 @@ find_imp(const_key_reference r_key) const
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value)))
{ {
apply_update(m_p_l, s_metadata_type_indicator); apply_update(m_p_l, s_metadata_type_indicator);
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) PB_DS_CHECK_KEY_EXISTS(r_key)
return m_p_l; return m_p_l;
} }
...@@ -71,7 +71,7 @@ find_imp(const_key_reference r_key) const ...@@ -71,7 +71,7 @@ find_imp(const_key_reference r_key) const
p_l = p_next; p_l = p_next;
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return 0; return 0;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -45,21 +45,21 @@ inline std::pair< ...@@ -45,21 +45,21 @@ inline std::pair<
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert(const_reference r_val) insert(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); entry_pointer p_l = find_imp(PB_DS_V2F(r_val));
if (p_l != 0) if (p_l != 0)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(r_val));) PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
return std::make_pair(point_iterator(&p_l->m_value), false); return std::make_pair(point_iterator(&p_l->m_value), false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_val));) PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val))
p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator); p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator);
p_l->m_p_next = m_p_l; p_l->m_p_next = m_p_l;
m_p_l = p_l; m_p_l = p_l;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(&p_l->m_value), true); return std::make_pair(point_iterator(&p_l->m_value), true);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -217,7 +217,7 @@ namespace __gnu_pbds ...@@ -217,7 +217,7 @@ namespace __gnu_pbds
operator[](const_key_reference r_key) operator[](const_key_reference r_key)
{ {
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return insert(std::make_pair(r_key, mapped_type())).first->second; return insert(std::make_pair(r_key, mapped_type())).first->second;
#else #else
insert(r_key); insert(r_key);
...@@ -231,7 +231,7 @@ namespace __gnu_pbds ...@@ -231,7 +231,7 @@ namespace __gnu_pbds
inline point_iterator inline point_iterator
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key); entry_pointer p_e = find_imp(r_key);
return point_iterator(p_e == 0 ? 0: &p_e->m_value); return point_iterator(p_e == 0 ? 0: &p_e->m_value);
} }
...@@ -239,7 +239,7 @@ namespace __gnu_pbds ...@@ -239,7 +239,7 @@ namespace __gnu_pbds
inline const_point_iterator inline const_point_iterator
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key); entry_pointer p_e = find_imp(r_key);
return const_point_iterator(p_e == 0 ? 0: &p_e->m_value); return const_point_iterator(p_e == 0 ? 0: &p_e->m_value);
} }
...@@ -268,7 +268,7 @@ namespace __gnu_pbds ...@@ -268,7 +268,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_LU_MAP_TRACE_ #ifdef PB_DS_LU_MAP_TRACE_
...@@ -337,6 +337,22 @@ namespace __gnu_pbds ...@@ -337,6 +337,22 @@ namespace __gnu_pbds
mutable entry_pointer m_p_l; mutable entry_pointer m_p_l;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp> #include <ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp>
...@@ -346,6 +362,10 @@ namespace __gnu_pbds ...@@ -346,6 +362,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp> #include <ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_TYPES_TRAITS_C_DEC #undef PB_DS_TYPES_TRAITS_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -53,7 +53,7 @@ PB_DS_OV_TREE_CLASS_NAME() : ...@@ -53,7 +53,7 @@ PB_DS_OV_TREE_CLASS_NAME() :
m_a_metadata(0), m_a_metadata(0),
m_end_it(0), m_end_it(0),
m_size(0) m_size(0)
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -63,7 +63,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : ...@@ -63,7 +63,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
m_a_metadata(0), m_a_metadata(0),
m_end_it(0), m_end_it(0),
m_size(0) m_size(0)
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -74,14 +74,11 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_updat ...@@ -74,14 +74,11 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_updat
m_a_metadata(0), m_a_metadata(0),
m_end_it(0), m_end_it(0),
m_size(0) m_size(0)
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
#ifdef PB_DS_TREE_TRACE #ifdef PB_DS_TREE_TRACE
PB_DS_TREE_TRACE_BASE_C_DEC(other), PB_DS_TREE_TRACE_BASE_C_DEC(other),
#endif #endif
...@@ -93,7 +90,7 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -93,7 +90,7 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
m_size(0) m_size(0)
{ {
copy_from_ordered_range(other.begin(), other.end()); copy_from_ordered_range(other.begin(), other.end());
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -123,6 +120,7 @@ copy_from_range(It first_it, It last_it) ...@@ -123,6 +120,7 @@ copy_from_range(It first_it, It last_it)
map_type m(first_it, last_it); map_type m(first_it, last_it);
copy_from_ordered_range(m.begin(), m.end()); copy_from_ordered_range(m.begin(), m.end());
PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -157,13 +155,10 @@ copy_from_ordered_range(It first_it, It last_it) ...@@ -157,13 +155,10 @@ copy_from_ordered_range(It first_it, It last_it)
update(PB_DS_node_begin_imp(), (node_update* )this); update(PB_DS_node_begin_imp(), (node_update* )this);
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
const_iterator dbg_it = m_a_values; for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
while (dbg_it != m_end_it)
{ {
debug_base::insert_new(PB_DS_V2F(*dbg_it)); debug_base::insert_new(PB_DS_V2F(*dbg_it));
dbg_it++;
} }
PB_DS_CLASS_C_DEC::assert_valid();
#endif #endif
} }
...@@ -210,13 +205,10 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, ...@@ -210,13 +205,10 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it,
update(PB_DS_node_begin_imp(), (node_update* )this); update(PB_DS_node_begin_imp(), (node_update* )this);
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
const_iterator dbg_it = m_a_values; for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
while (dbg_it != m_end_it)
{ {
debug_base::insert_new(PB_DS_V2F(*dbg_it)); debug_base::insert_new(PB_DS_V2F(*dbg_it));
dbg_it++;
} }
PB_DS_CLASS_C_DEC::assert_valid();
#endif #endif
} }
...@@ -225,10 +217,12 @@ void ...@@ -225,10 +217,12 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other); value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID(other)
PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -247,9 +241,9 @@ PB_DS_CLASS_T_DEC ...@@ -247,9 +241,9 @@ PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
~PB_DS_OV_TREE_CLASS_NAME() ~PB_DS_OV_TREE_CLASS_NAME()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) //PB_DS_ASSERT_VALID((*this))
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size); cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
reallocate_metadata((node_update* )this, 0); reallocate_metadata((node_update*)this, 0);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
...@@ -43,40 +43,37 @@ ...@@ -43,40 +43,37 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
std::cout << "av1" << std::endl;
if (m_a_values == 0 || m_end_it == 0 || m_size == 0) if (m_a_values == 0 || m_end_it == 0 || m_size == 0)
_GLIBCXX_DEBUG_ASSERT(m_a_values == 0 && m_end_it == 0 && m_size == 0); PB_DS_DEBUG_VERIFY(m_a_values == 0 && m_end_it == 0 && m_size == 0);
std::cout << "av2" << std::endl; assert_iterators(__file, __line);
assert_iterators();
std::cout << "av3" << std::endl;
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_iterators() const assert_iterators(const char* __file, int __line) const
{ {
debug_base::check_size(m_size); debug_base::check_size(m_size, __file, __line);
size_type iterated_num = 0; size_type iterated_num = 0;
const_iterator prev_it = end(); const_iterator prev_it = end();
_GLIBCXX_DEBUG_ASSERT(m_end_it == m_a_values + m_size); PB_DS_DEBUG_VERIFY(m_end_it == m_a_values + m_size);
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
++iterated_num; ++iterated_num;
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(*it));) debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it; --upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it == it); PB_DS_DEBUG_VERIFY(upper_bound_it == it);
if (prev_it != end()) if (prev_it != end())
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it))); PB_DS_V2F(*it)));
prev_it = it; prev_it = it;
} }
_GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); PB_DS_DEBUG_VERIFY(iterated_num == m_size);
} }
#endif #endif
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,10 +43,9 @@ void ...@@ -43,10 +43,9 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (m_size == 0) if (m_size == 0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return; return;
} }
else else
...@@ -59,7 +58,7 @@ clear() ...@@ -59,7 +58,7 @@ clear()
m_a_values = 0; m_a_values = 0;
m_size = 0; m_size = 0;
m_end_it = m_a_values; m_end_it = m_a_values;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -68,7 +67,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -68,7 +67,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
...@@ -76,8 +75,7 @@ erase_if(Pred pred) ...@@ -76,8 +75,7 @@ erase_if(Pred pred)
size_type new_size = 0; size_type new_size = 0;
size_type num_val_ersd = 0; size_type num_val_ersd = 0;
iterator source_it = m_a_values; for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
for (source_it = begin(); source_it != m_end_it; ++source_it)
if (!pred(*source_it)) if (!pred(*source_it))
++new_size; ++new_size;
else else
...@@ -93,7 +91,7 @@ erase_if(Pred pred) ...@@ -93,7 +91,7 @@ erase_if(Pred pred)
iterator target_it = a_new_values; iterator target_it = a_new_values;
cond_dtor<size_type> cd(a_new_values, target_it, new_size); cond_dtor<size_type> cd(a_new_values, target_it, new_size);
_GLIBCXX_DEBUG_ONLY(debug_base::clear()); _GLIBCXX_DEBUG_ONLY(debug_base::clear());
for (source_it = begin(); source_it != m_end_it; ++source_it) for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
{ {
if (!pred(*source_it)) if (!pred(*source_it))
{ {
...@@ -116,7 +114,7 @@ erase_if(Pred pred) ...@@ -116,7 +114,7 @@ erase_if(Pred pred)
m_size = new_size; m_size = new_size;
m_end_it = target_it; m_end_it = target_it;
update(node_begin(), (node_update* )this); update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_val_ersd; return num_val_ersd;
} }
...@@ -126,11 +124,11 @@ It ...@@ -126,11 +124,11 @@ It
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_imp(It it) erase_imp(It it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (it == end()) if (it == end())
return end(); return end();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));) PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it))
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
...@@ -175,7 +173,7 @@ erase_imp(It it) ...@@ -175,7 +173,7 @@ erase_imp(It it)
--m_size; --m_size;
m_end_it = m_a_values + m_size; m_end_it = m_a_values + m_size;
update(node_begin(), (node_update* )this); update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return It(ret_it); return It(ret_it);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
size() const size() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return m_size; return m_size;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -107,6 +107,16 @@ namespace __gnu_pbds ...@@ -107,6 +107,16 @@ namespace __gnu_pbds
Cmp_Fn, false, Allocator> Cmp_Fn, false, Allocator>
#endif #endif
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
// Ordered-vector tree associative-container. // Ordered-vector tree associative-container.
template<typename Key, typename Mapped, class Cmp_Fn, template<typename Key, typename Mapped, class Cmp_Fn,
class Node_And_It_Traits, class Allocator> class Node_And_It_Traits, class Allocator>
...@@ -234,16 +244,15 @@ namespace __gnu_pbds ...@@ -234,16 +244,15 @@ namespace __gnu_pbds
operator[](const_key_reference r_key) operator[](const_key_reference r_key)
{ {
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
point_iterator it = lower_bound(r_key); point_iterator it = lower_bound(r_key);
if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return it->second; return it->second;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second); return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second);
#else #else
insert(r_key); insert(r_key);
...@@ -254,18 +263,17 @@ namespace __gnu_pbds ...@@ -254,18 +263,17 @@ namespace __gnu_pbds
inline std::pair<point_iterator, bool> inline std::pair<point_iterator, bool>
insert(const_reference r_value) insert(const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
const_key_reference r_key = PB_DS_V2F(r_value); const_key_reference r_key = PB_DS_V2F(r_value);
point_iterator it = lower_bound(r_key); point_iterator it = lower_bound(r_key);
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(it, false); return std::make_pair(it, false);
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return std::make_pair(insert_new_val(it, r_value), true); return std::make_pair(insert_new_val(it, r_value), true);
} }
...@@ -295,11 +303,11 @@ namespace __gnu_pbds ...@@ -295,11 +303,11 @@ namespace __gnu_pbds
iterator pot_it = lower_bound(r_key); iterator pot_it = lower_bound(r_key);
if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return ++pot_it; return ++pot_it;
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return pot_it; return pot_it;
} }
...@@ -310,15 +318,15 @@ namespace __gnu_pbds ...@@ -310,15 +318,15 @@ namespace __gnu_pbds
inline point_iterator inline point_iterator
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
iterator pot_it = lower_bound(r_key); iterator pot_it = lower_bound(r_key);
if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return pot_it; return pot_it;
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end(); return end();
} }
...@@ -412,12 +420,11 @@ namespace __gnu_pbds ...@@ -412,12 +420,11 @@ namespace __gnu_pbds
inline iterator inline iterator
insert_new_val(iterator it, const_reference r_value) insert_new_val(iterator it, const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();)
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
#endif #endif
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_value))); PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
value_vector a_values = s_value_alloc.allocate(m_size + 1); value_vector a_values = s_value_alloc.allocate(m_size + 1);
...@@ -457,16 +464,16 @@ namespace __gnu_pbds ...@@ -457,16 +464,16 @@ namespace __gnu_pbds
m_end_it = m_a_values + m_size; m_end_it = m_a_values + m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value))); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value)));
update(node_begin(), (node_update* )this); update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
assert_iterators() const; assert_iterators(const char* file, int line) const;
#endif #endif
template<typename It> template<typename It>
...@@ -495,6 +502,12 @@ namespace __gnu_pbds ...@@ -495,6 +502,12 @@ namespace __gnu_pbds
size_type m_size; size_type m_size;
}; };
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp> #include <ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp>
...@@ -504,6 +517,10 @@ namespace __gnu_pbds ...@@ -504,6 +517,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp> #include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_OV_TREE_CLASS_NAME #undef PB_DS_OV_TREE_CLASS_NAME
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,37 +43,33 @@ void ...@@ -43,37 +43,33 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (m_size == 0) if (m_size == 0)
{ {
other.clear(); other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return; return;
} }
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin()))) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin())))
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1)))) if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1))))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return; return;
} }
if (m_size == 1) if (m_size == 1)
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -90,8 +86,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -90,8 +86,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
update(node_begin(), (node_update* )this); update(node_begin(), (node_update* )this);
other.value_swap(new_other); other.value_swap(new_other);
value_swap(new_this); value_swap(new_this);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -99,14 +95,16 @@ void ...@@ -99,14 +95,16 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (other.m_size == 0) if (other.m_size == 0)
return; return;
if (m_size == 0) if (m_size == 0)
{ {
value_swap(other); value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -129,9 +127,9 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -129,9 +127,9 @@ join(PB_DS_CLASS_C_DEC& other)
begin(), end()); begin(), end());
// No exceptions from this point. // No exceptions from this point.
_GLIBCXX_DEBUG_ONLY(debug_base::join(other);) _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
value_swap(new_this); value_swap(new_this);
other.clear(); other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -47,43 +47,43 @@ copy_from_range(It first_it, It last_it) ...@@ -47,43 +47,43 @@ copy_from_range(It first_it, It last_it)
while (first_it != last_it) while (first_it != last_it)
push(*(first_it++)); push(*(first_it++));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pairing_heap_() pairing_heap_()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pairing_heap_(const Cmp_Fn& r_cmp_fn) : pairing_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn) PB_DS_BASE_C_DEC(r_cmp_fn)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pairing_heap_(const PB_DS_CLASS_C_DEC& other) : pairing_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other) PB_DS_BASE_C_DEC(other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
PB_DS_BASE_C_DEC::swap(other); PB_DS_BASE_C_DEC::swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_root == 0 PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0
|| base_type::m_p_root->m_p_next_sibling == 0); || base_type::m_p_root->m_p_next_sibling == 0);
base_type::assert_valid(); base_type::assert_valid(__file, __line);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,17 +43,17 @@ void ...@@ -43,17 +43,17 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_new_root = join_node_children(base_type::m_p_root); node_pointer p_new_root = join_node_children(base_type::m_p_root);
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_new_root, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false)
if (p_new_root != 0) if (p_new_root != 0)
p_new_root->m_p_prev_or_parent = 0; p_new_root->m_p_prev_or_parent = 0;
base_type::actual_erase_node(base_type::m_p_root); base_type::actual_erase_node(base_type::m_p_root);
base_type::m_p_root = p_new_root; base_type::m_p_root = p_new_root;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -61,11 +61,11 @@ void ...@@ -61,11 +61,11 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
remove_node(it.m_p_nd); remove_node(it.m_p_nd);
base_type::actual_erase_node(it.m_p_nd); base_type::actual_erase_node(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -73,21 +73,18 @@ void ...@@ -73,21 +73,18 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
remove_node(node_pointer p_nd) remove_node(node_pointer p_nd)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_new_child = join_node_children(p_nd); node_pointer p_new_child = join_node_children(p_nd);
#ifdef _GLIBCXX_DEBUG PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false)
if (p_new_child != 0)
base_type::assert_node_consistent(p_new_child, false);
#endif
if (p_nd == base_type::m_p_root) if (p_nd == base_type::m_p_root)
{ {
if (p_new_child != 0) if (p_new_child != 0)
p_new_child->m_p_prev_or_parent = 0; p_new_child->m_p_prev_or_parent = 0;
base_type::m_p_root = p_new_child; base_type::m_p_root = p_new_child;
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);) PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
return; return;
} }
...@@ -101,14 +98,14 @@ remove_node(node_pointer p_nd) ...@@ -101,14 +98,14 @@ remove_node(node_pointer p_nd)
if (p_new_child->m_p_next_sibling != 0) if (p_new_child->m_p_next_sibling != 0)
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child; p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child;
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return; return;
} }
p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling; p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0) if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return; return;
} }
...@@ -119,14 +116,14 @@ remove_node(node_pointer p_nd) ...@@ -119,14 +116,14 @@ remove_node(node_pointer p_nd)
if (p_new_child->m_p_next_sibling != 0) if (p_new_child->m_p_next_sibling != 0)
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child; p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child;
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
return; return;
} }
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling; p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0) if (p_nd->m_p_next_sibling != 0)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -142,7 +139,7 @@ join_node_children(node_pointer p_nd) ...@@ -142,7 +139,7 @@ join_node_children(node_pointer p_nd)
p_ret = forward_join(p_ret, p_ret->m_p_next_sibling); p_ret = forward_join(p_ret, p_ret->m_p_next_sibling);
while (p_ret->m_p_prev_or_parent != p_nd) while (p_ret->m_p_prev_or_parent != p_nd)
p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret); p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret);
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false)
return p_ret; return p_ret;
} }
...@@ -171,7 +168,7 @@ forward_join(node_pointer p_nd, node_pointer p_next) ...@@ -171,7 +168,7 @@ forward_join(node_pointer p_nd, node_pointer p_next)
p_nd->m_p_next_sibling = 0; p_nd->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd); base_type::make_child_of(p_next, p_nd);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
return p_nd; return p_nd;
} }
...@@ -187,13 +184,13 @@ back_join(node_pointer p_nd, node_pointer p_next) ...@@ -187,13 +184,13 @@ back_join(node_pointer p_nd, node_pointer p_next)
{ {
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
base_type::make_child_of(p_nd, p_next); base_type::make_child_of(p_nd, p_next);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_next, false)); PB_DS_ASSERT_NODE_CONSISTENT(p_next, false)
return p_next; return p_next;
} }
p_nd->m_p_next_sibling = 0; p_nd->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd); base_type::make_child_of(p_next, p_nd);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
return p_nd; return p_nd;
} }
...@@ -203,10 +200,10 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -203,10 +200,10 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return 0; return 0;
} }
base_type::to_linked_list(); base_type::to_linked_list();
...@@ -230,7 +227,7 @@ erase_if(Pred pred) ...@@ -230,7 +227,7 @@ erase_if(Pred pred)
push_imp(p_cur); push_imp(p_cur);
p_cur = p_next; p_cur = p_next;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return ersd; return ersd;
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
return base_type::m_p_root->m_value; return base_type::m_p_root->m_value;
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,13 +43,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,13 +43,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) push(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
push_imp(p_new_nd); push_imp(p_new_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return point_iterator(p_new_nd); return point_iterator(p_new_nd);
} }
...@@ -72,14 +72,14 @@ push_imp(node_pointer p_nd) ...@@ -72,14 +72,14 @@ push_imp(node_pointer p_nd)
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
base_type::make_child_of(base_type::m_p_root, p_nd); base_type::make_child_of(base_type::m_p_root, p_nd);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
base_type::m_p_root = p_nd; base_type::m_p_root = p_nd;
} }
else else
{ {
base_type::make_child_of(p_nd, base_type::m_p_root); base_type::make_child_of(p_nd, base_type::m_p_root);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
} }
} }
...@@ -88,7 +88,7 @@ void ...@@ -88,7 +88,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) modify(point_iterator it, const_reference r_new_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
remove_node(it.m_p_nd); remove_node(it.m_p_nd);
...@@ -96,6 +96,6 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -96,6 +96,6 @@ modify(point_iterator it, const_reference r_new_val)
push_imp(it.m_p_nd); push_imp(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -64,16 +64,14 @@ namespace __gnu_pbds ...@@ -64,16 +64,14 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
#define PB_DS_BASE_C_DEC \ #define PB_DS_BASE_C_DEC \
left_child_next_sibling_heap_< \ left_child_next_sibling_heap_<Value_Type, \
Value_Type, \
Cmp_Fn, \ Cmp_Fn, \
null_left_child_next_sibling_heap_node_metadata, \ null_left_child_next_sibling_heap_node_metadata, \
Allocator, \ Allocator, \
false> false>
#else #else
#define PB_DS_BASE_C_DEC \ #define PB_DS_BASE_C_DEC \
left_child_next_sibling_heap_< \ left_child_next_sibling_heap_<Value_Type, \
Value_Type, \
Cmp_Fn, \ Cmp_Fn, \
null_left_child_next_sibling_heap_node_metadata, \ null_left_child_next_sibling_heap_node_metadata, \
Allocator> Allocator>
...@@ -179,7 +177,7 @@ namespace __gnu_pbds ...@@ -179,7 +177,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
private: private:
...@@ -198,9 +196,21 @@ namespace __gnu_pbds ...@@ -198,9 +196,21 @@ namespace __gnu_pbds
void void
remove_node(node_pointer p_nd); remove_node(node_pointer p_nd);
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp> #include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp>
...@@ -208,6 +218,9 @@ namespace __gnu_pbds ...@@ -208,6 +218,9 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp> #include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC #undef PB_DS_BASE_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,15 +44,15 @@ void ...@@ -44,15 +44,15 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
other.clear(); other.clear();
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -77,7 +77,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -77,7 +77,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_out = p_next; p_out = p_next;
} }
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
node_pointer p_cur = base_type::m_p_root; node_pointer p_cur = base_type::m_p_root;
...@@ -94,22 +94,22 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -94,22 +94,22 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_cur = p_next; p_cur = p_next;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (other.m_p_root == 0) if (other.m_p_root == 0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -119,14 +119,14 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -119,14 +119,14 @@ join(PB_DS_CLASS_C_DEC& other)
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value)) else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
{ {
base_type::make_child_of(base_type::m_p_root, other.m_p_root); base_type::make_child_of(base_type::m_p_root, other.m_p_root);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(other.m_p_root, false)); PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false)
base_type::m_p_root = other.m_p_root; base_type::m_p_root = other.m_p_root;
} }
else else
{ {
base_type::make_child_of(other.m_p_root, base_type::m_p_root); base_type::make_child_of(other.m_p_root, base_type::m_p_root);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
} }
base_type::m_size += other.m_size; base_type::m_size += other.m_size;
...@@ -134,7 +134,7 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -134,7 +134,7 @@ join(PB_DS_CLASS_C_DEC& other)
other.m_p_root = 0; other.m_p_root = 0;
other.m_size = 0; other.m_size = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -58,7 +58,7 @@ PB_DS_CLASS_NAME() : ...@@ -58,7 +58,7 @@ PB_DS_CLASS_NAME() :
m_size(0) m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) : ...@@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) :
m_size(0) m_size(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -85,10 +85,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -85,10 +85,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
{ {
initialize(); initialize();
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (other.m_p_head->m_p_parent == 0) if (other.m_p_head->m_p_parent == 0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return; return;
} }
__try __try
...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_parent->m_p_parent = m_p_head; m_p_head->m_p_parent->m_p_parent = m_p_head;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -112,12 +112,12 @@ void ...@@ -112,12 +112,12 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
value_swap(other); value_swap(other);
std::swap((e_access_traits& )(*this), (e_access_traits& )other); std::swap((e_access_traits& )(*this), (e_access_traits& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,45 +43,45 @@ ...@@ -43,45 +43,45 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
if (m_p_head->m_p_parent != 0) if (m_p_head->m_p_parent != 0)
m_p_head->m_p_parent->assert_valid(this); m_p_head->m_p_parent->assert_valid(this, __file, __line);
assert_iterators(); assert_iterators(__file, __line);
assert_reverse_iterators(); assert_reverse_iterators(__file, __line);
if (m_p_head->m_p_parent == 0) if (m_p_head->m_p_parent == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head);
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max == m_p_head); PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head);
_GLIBCXX_DEBUG_ASSERT(empty()); PB_DS_DEBUG_VERIFY(empty());
return; return;
} }
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type); PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type);
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type); PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type);
_GLIBCXX_DEBUG_ASSERT(!empty()); PB_DS_DEBUG_VERIFY(!empty());
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_iterators() const assert_iterators(const char* __file, int __line) const
{ {
size_type calc_size = 0; size_type calc_size = 0;
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
++calc_size; ++calc_size;
debug_base::check_key_exists(PB_DS_V2F(*it)); debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it);
_GLIBCXX_DEBUG_ASSERT(--upper_bound(PB_DS_V2F(*it)) == it); PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it);
} }
_GLIBCXX_DEBUG_ASSERT(calc_size == m_size); PB_DS_DEBUG_VERIFY(calc_size == m_size);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_reverse_iterators() const assert_reverse_iterators(const char* __file, int __line) const
{ {
size_type calc_size = 0; size_type calc_size = 0;
for (const_reverse_iterator it = rbegin(); it != rend(); ++it) for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
...@@ -89,27 +89,28 @@ assert_reverse_iterators() const ...@@ -89,27 +89,28 @@ assert_reverse_iterators() const
++calc_size; ++calc_size;
const_node_pointer p_nd = const_node_pointer p_nd =
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(PB_DS_V2F(*it)); const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(PB_DS_V2F(*it));
_GLIBCXX_DEBUG_ASSERT(p_nd == it.m_p_nd); PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd);
} }
_GLIBCXX_DEBUG_ASSERT(calc_size == m_size); PB_DS_DEBUG_VERIFY(calc_size == m_size);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
recursive_count_leafs(const_node_pointer p_nd) recursive_count_leafs(const_node_pointer p_nd,
const char* __file, int __line)
{ {
if (p_nd == 0) if (p_nd == 0)
return (0); return (0);
if (p_nd->m_type == pat_trie_leaf_node_type) if (p_nd->m_type == pat_trie_leaf_node_type)
return (1); return (1);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); PB_DS_DEBUG_VERIFY(p_nd->m_type == pat_trie_internal_node_type);
size_type ret = 0; size_type ret = 0;
for (typename internal_node::const_iterator it = for (typename internal_node::const_iterator it =
static_cast<const_internal_node_pointer>(p_nd)->begin(); static_cast<const_internal_node_pointer>(p_nd)->begin();
it != static_cast<const_internal_node_pointer>(p_nd)->end(); it != static_cast<const_internal_node_pointer>(p_nd)->end();
++it) ++it)
ret += recursive_count_leafs(*it); ret += recursive_count_leafs(*it, __file, __line);
return ret; return ret;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -46,20 +46,20 @@ erase(const_key_reference r_key) ...@@ -46,20 +46,20 @@ erase(const_key_reference r_key)
node_pointer p_nd = find_imp(r_key); node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type == pat_trie_internal_node_type) if (p_nd == 0 || p_nd->m_type == pat_trie_internal_node_type)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false; return false;
} }
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key)) if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false; return false;
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
erase_leaf(static_cast<leaf_pointer>(p_nd)); erase_leaf(static_cast<leaf_pointer>(p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return true; return true;
} }
...@@ -100,7 +100,7 @@ erase_fixup(internal_node_pointer p_nd) ...@@ -100,7 +100,7 @@ erase_fixup(internal_node_pointer p_nd)
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1);
p_nd->update_prefixes(this); p_nd->update_prefixes(this);
apply_update(p_nd, (node_update* )this); apply_update(p_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(p_nd->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_nd)
if (p_nd->m_p_parent->m_type == pat_trie_head_node_type) if (p_nd->m_p_parent->m_type == pat_trie_head_node_type)
return; return;
...@@ -128,7 +128,7 @@ void ...@@ -128,7 +128,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (empty()) if (empty())
return; return;
...@@ -136,7 +136,7 @@ clear() ...@@ -136,7 +136,7 @@ clear()
m_size = 0; m_size = 0;
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -169,7 +169,7 @@ inline typename PB_DS_CLASS_C_DEC::const_iterator ...@@ -169,7 +169,7 @@ inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(const_iterator it) erase(const_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it == end()) if (it == end())
return it; return it;
...@@ -178,7 +178,7 @@ erase(const_iterator it) ...@@ -178,7 +178,7 @@ erase(const_iterator it)
++ret_it; ++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -188,7 +188,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator ...@@ -188,7 +188,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(iterator it) erase(iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it == end()) if (it == end())
return it; return it;
...@@ -196,7 +196,7 @@ erase(iterator it) ...@@ -196,7 +196,7 @@ erase(iterator it)
++ret_it; ++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
...@@ -206,7 +206,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator ...@@ -206,7 +206,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(const_reverse_iterator it) erase(const_reverse_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head) if (it.m_p_nd == m_p_head)
return it; return it;
...@@ -215,7 +215,7 @@ erase(const_reverse_iterator it) ...@@ -215,7 +215,7 @@ erase(const_reverse_iterator it)
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -225,7 +225,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator ...@@ -225,7 +225,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(reverse_iterator it) erase(reverse_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head) if (it.m_p_nd == m_p_head)
return it; return it;
...@@ -234,7 +234,7 @@ erase(reverse_iterator it) ...@@ -234,7 +234,7 @@ erase(reverse_iterator it)
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
...@@ -246,12 +246,12 @@ PB_DS_CLASS_C_DEC:: ...@@ -246,12 +246,12 @@ PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
size_type num_ersd = 0; size_type num_ersd = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
iterator it = begin(); iterator it = begin();
while (it != end()) while (it != end())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (pred(*it)) if (pred(*it))
{ {
++num_ersd; ++num_ersd;
...@@ -261,7 +261,7 @@ erase_if(Pred pred) ...@@ -261,7 +261,7 @@ erase_if(Pred pred)
++it; ++it;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_ersd; return num_ersd;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,22 +43,22 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,22 +43,22 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) find(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = find_imp(r_key); node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type) if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end(); return end();
} }
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key)) if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return iterator(p_nd); return iterator(p_nd);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end(); return end();
} }
...@@ -67,23 +67,23 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator ...@@ -67,23 +67,23 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const find(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
const_node_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key); const_node_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type) if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end(); return end();
} }
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key)) if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); PB_DS_CHECK_KEY_EXISTS(r_key)
return const_iterator(const_cast<node_pointer>(p_nd)); return const_iterator(const_cast<node_pointer>(p_nd));
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end(); return end();
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -88,7 +88,8 @@ namespace __gnu_pbds ...@@ -88,7 +88,8 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
virtual subtree_debug_info virtual subtree_debug_info
assert_valid_imp(const_e_access_traits_pointer p_traits) const; assert_valid_imp(const_e_access_traits_pointer p_traits,
const char* file, int line) const;
#endif #endif
public: public:
...@@ -106,9 +107,13 @@ namespace __gnu_pbds ...@@ -106,9 +107,13 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid_imp(const_e_access_traits_pointer /*p_traits*/) const assert_valid_imp(const_e_access_traits_pointer /*p_traits*/,
const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(false); _GLIBCXX_DEBUG_VERIFY_AT(false,
_M_message("Assertion from %1;:%2;")
._M_string(__FILE__)._M_integer(__LINE__),
__file, __line);
return subtree_debug_info(); return subtree_debug_info();
} }
#endif #endif
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,13 +43,13 @@ void ...@@ -43,13 +43,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
split_join_branch_bag bag; split_join_branch_bag bag;
if (!join_prep(other, bag)) if (!join_prep(other, bag))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -59,10 +59,10 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -59,10 +59,10 @@ join(PB_DS_CLASS_C_DEC& other)
m_p_head->m_p_parent->m_p_parent = m_p_head; m_p_head->m_p_parent->m_p_parent = m_p_head;
m_size += other.m_size; m_size += other.m_size;
other.initialize(); other.initialize();
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -70,8 +70,8 @@ bool ...@@ -70,8 +70,8 @@ bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (other.m_size == 0) if (other.m_size == 0)
return false; return false;
...@@ -81,18 +81,19 @@ join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) ...@@ -81,18 +81,19 @@ join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
return false; return false;
} }
const bool greater = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>( const bool greater =
m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>( synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value()),
other.m_p_head->m_p_min)->value())); PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_min)->value()));
const bool lesser = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>( const bool lesser =
other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value())); synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_max)->value()),
PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value()));
if (!greater && !lesser) if (!greater && !lesser)
__throw_join_error(); __throw_join_error();
rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag);
_GLIBCXX_DEBUG_ONLY(debug_base::join(other);) _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
return true; return true;
} }
...@@ -249,7 +250,7 @@ rec_join(leaf_pointer p_l, leaf_pointer p_r, split_join_branch_bag& r_bag) ...@@ -249,7 +250,7 @@ rec_join(leaf_pointer p_l, leaf_pointer p_r, split_join_branch_bag& r_bag)
if (p_l == 0) if (p_l == 0)
return (p_r); return (p_r);
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == 2); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2);
return p_ret; return p_ret;
} }
...@@ -260,13 +261,13 @@ rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind, ...@@ -260,13 +261,13 @@ rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind,
split_join_branch_bag& r_bag) split_join_branch_bag& r_bag)
{ {
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = recursive_count_leafs(p_l); const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = recursive_count_leafs(p_r); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif #endif
_GLIBCXX_DEBUG_ASSERT(p_r != 0); _GLIBCXX_DEBUG_ASSERT(p_r != 0);
node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag); node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag);
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret; return p_ret;
} }
...@@ -279,15 +280,15 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl ...@@ -279,15 +280,15 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl
_GLIBCXX_DEBUG_ASSERT(p_r != 0); _GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = recursive_count_leafs(p_l); const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = recursive_count_leafs(p_r); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif #endif
if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this)) if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this))
{ {
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
_GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_ret)
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) ==
lhs_leafs + rhs_leafs); lhs_leafs + rhs_leafs);
return p_ret; return p_ret;
} }
...@@ -303,8 +304,8 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl ...@@ -303,8 +304,8 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl
pref_end(p_new_child), this); pref_end(p_new_child), this);
} }
_GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this)); PB_DS_ASSERT_NODE_VALID(p_l)
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l; return p_l;
} }
...@@ -317,8 +318,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch ...@@ -317,8 +318,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch
_GLIBCXX_DEBUG_ASSERT(p_r != 0); _GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = recursive_count_leafs(p_l); const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = recursive_count_leafs(p_r); const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif #endif
if (p_l->get_e_ind() == p_r->get_e_ind() && if (p_l->get_e_ind() == p_r->get_e_ind() &&
...@@ -336,8 +337,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch ...@@ -336,8 +337,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch
p_r->~internal_node(); p_r->~internal_node();
s_internal_node_allocator.deallocate(p_r, 1); s_internal_node_allocator.deallocate(p_r, 1);
_GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_l)
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l; return p_l;
} }
...@@ -348,7 +349,7 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch ...@@ -348,7 +349,7 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch
p_r, 0, r_bag); p_r, 0, r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child), p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this); pref_end(p_new_child), this);
_GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_l)
return p_l; return p_l;
} }
...@@ -361,14 +362,14 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch ...@@ -361,14 +362,14 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch
p_r->replace_child(p_new_child, pref_begin(p_new_child), p_r->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this); pref_end(p_new_child), this);
_GLIBCXX_DEBUG_ONLY(p_r->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_r)
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_r) == lhs_leafs + rhs_leafs); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs);
return p_r; return p_r;
} }
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
_GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_ret)
_GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret; return p_ret;
} }
...@@ -381,12 +382,12 @@ insert(const_reference r_val) ...@@ -381,12 +382,12 @@ insert(const_reference r_val)
if (p_lf != 0 && p_lf->m_type == pat_trie_leaf_node_type && if (p_lf != 0 && p_lf->m_type == pat_trie_leaf_node_type &&
synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val))) synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val)))
{ {
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(r_val))); PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return std::make_pair(iterator(p_lf), false); return std::make_pair(iterator(p_lf), false);
} }
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_val))); PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val))
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); leaf_pointer p_new_lf = s_leaf_allocator.allocate(1);
cond_dealtor cond(p_new_lf); cond_dealtor cond(p_new_lf);
...@@ -402,14 +403,17 @@ insert(const_reference r_val) ...@@ -402,14 +403,17 @@ insert(const_reference r_val)
++m_size; ++m_size;
update_min_max_for_inserted_leaf(p_new_lf); update_min_max_for_inserted_leaf(p_new_lf);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(p_new_lf), true); return std::make_pair(point_iterator(p_new_lf), true);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
keys_diff_ind(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r) keys_diff_ind(typename e_access_traits::const_iterator b_l,
typename e_access_traits::const_iterator e_l,
typename e_access_traits::const_iterator b_r,
typename e_access_traits::const_iterator e_r)
{ {
size_type diff_pos = 0; size_type diff_pos = 0;
while (b_l != e_l) while (b_l != e_l)
...@@ -445,7 +449,7 @@ insert_branch(node_pointer p_l, node_pointer p_r, split_join_branch_bag& r_bag) ...@@ -445,7 +449,7 @@ insert_branch(node_pointer p_l, node_pointer p_r, split_join_branch_bag& r_bag)
p_new_nd->add_child(p_r, right_b_it, right_e_it, this); p_new_nd->add_child(p_r, right_b_it, right_e_it, this);
p_l->m_p_parent = p_new_nd; p_l->m_p_parent = p_new_nd;
p_r->m_p_parent = p_new_nd; p_r->m_p_parent = p_new_nd;
_GLIBCXX_DEBUG_ONLY(p_new_nd->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_new_nd)
return (p_new_nd); return (p_new_nd);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -94,7 +95,8 @@ namespace __gnu_pbds ...@@ -94,7 +95,8 @@ namespace __gnu_pbds
typedef typename base_type::subtree_debug_info subtree_debug_info; typedef typename base_type::subtree_debug_info subtree_debug_info;
virtual subtree_debug_info virtual subtree_debug_info
assert_valid_imp(const_e_access_traits_pointer) const; assert_valid_imp(const_e_access_traits_pointer,
const char* file, int line) const;
#endif #endif
inline size_type inline size_type
...@@ -564,28 +566,37 @@ namespace __gnu_pbds ...@@ -564,28 +566,37 @@ namespace __gnu_pbds
} }
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
# define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid_imp(const_e_access_traits_pointer p_traits) const assert_valid_imp(const_e_access_traits_pointer p_traits,
const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_internal_node_type); PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_internal_node_type);
_GLIBCXX_DEBUG_ASSERT(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
_GLIBCXX_DEBUG_ASSERT(std::distance(begin(), end()) >= 2); PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2);
for (typename pat_trie_internal_node::const_iterator it = begin(); for (typename pat_trie_internal_node::const_iterator it = begin();
it != end(); ++it) it != end(); ++it)
{ {
const_node_pointer p_nd =* it; const_node_pointer p_nd =* it;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent == this); PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this);
subtree_debug_info child_ret = p_nd->assert_valid_imp(p_traits); subtree_debug_info child_ret =
p_nd->assert_valid_imp(p_traits, __file, __line);
_GLIBCXX_DEBUG_ASSERT(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
_GLIBCXX_DEBUG_ASSERT(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
_GLIBCXX_DEBUG_ASSERT(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children)); PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
} }
return std::make_pair(pref_b_it(), pref_e_it()); return std::make_pair(pref_b_it(), pref_e_it());
} }
# undef PB_DS_DEBUG_VERIFY
#endif #endif
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -49,29 +49,25 @@ namespace __gnu_pbds ...@@ -49,29 +49,25 @@ namespace __gnu_pbds
{ {
#define PB_DS_CLASS_T_DEC \ #define PB_DS_CLASS_T_DEC \
template< \ template<class Type_Traits, \
class Type_Traits, \
class E_Access_Traits, \ class E_Access_Traits, \
class Metadata, \ class Metadata, \
class Allocator> class Allocator>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
pat_trie_leaf< \ pat_trie_leaf<Type_Traits, \
Type_Traits, \
E_Access_Traits, \ E_Access_Traits, \
Metadata, \ Metadata, \
Allocator> Allocator>
#define PB_DS_BASE_C_DEC \ #define PB_DS_BASE_C_DEC \
pat_trie_node_base< \ pat_trie_node_base<Type_Traits, \
Type_Traits, \
E_Access_Traits, \ E_Access_Traits, \
Metadata, \ Metadata, \
Allocator> Allocator>
#define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \ #define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \
pat_trie_subtree_debug_info< \ pat_trie_subtree_debug_info<Type_Traits, \
Type_Traits, \
E_Access_Traits, \ E_Access_Traits, \
Allocator> Allocator>
...@@ -112,7 +108,8 @@ namespace __gnu_pbds ...@@ -112,7 +108,8 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
virtual subtree_debug_info virtual subtree_debug_info
assert_valid_imp(const_e_access_traits_pointer p_traits) const; assert_valid_imp(const_e_access_traits_pointer p_traits,
const char* file, int line) const;
virtual virtual
~pat_trie_leaf(); ~pat_trie_leaf();
...@@ -143,12 +140,19 @@ namespace __gnu_pbds ...@@ -143,12 +140,19 @@ namespace __gnu_pbds
{ return m_value; } { return m_value; }
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
# define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid_imp(const_e_access_traits_pointer p_traits) const assert_valid_imp(const_e_access_traits_pointer p_traits,
const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_leaf_node_type); PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_leaf_node_type);
subtree_debug_info ret; subtree_debug_info ret;
const_reference r_val = value(); const_reference r_val = value();
return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)), return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
...@@ -158,6 +162,7 @@ namespace __gnu_pbds ...@@ -158,6 +162,7 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
~pat_trie_leaf() { } ~pat_trie_leaf() { }
# undef PB_DS_DEBUG_VERIFY
#endif #endif
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -95,10 +95,12 @@ namespace __gnu_pbds ...@@ -95,10 +95,12 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid(const_e_access_traits_pointer p_traits) const; assert_valid(const_e_access_traits_pointer p_traits,
const char* file, int line) const;
virtual subtree_debug_info virtual subtree_debug_info
assert_valid_imp(const_e_access_traits_pointer p_traits) const = 0; assert_valid_imp(const_e_access_traits_pointer p_traits,
const char* file, int line) const = 0;
#endif #endif
node_pointer m_p_parent; node_pointer m_p_parent;
...@@ -114,8 +116,9 @@ namespace __gnu_pbds ...@@ -114,8 +116,9 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid(const_e_access_traits_pointer p_traits) const assert_valid(const_e_access_traits_pointer p_traits,
{ assert_valid_imp(p_traits); } const char* __file, int __line) const
{ assert_valid_imp(p_traits, __file, __line); }
#endif #endif
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -393,7 +394,10 @@ namespace __gnu_pbds ...@@ -393,7 +394,10 @@ namespace __gnu_pbds
split_join_branch_bag&); split_join_branch_bag&);
size_type size_type
keys_diff_ind(typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator); keys_diff_ind(typename e_access_traits::const_iterator,
typename e_access_traits::const_iterator,
typename e_access_traits::const_iterator,
typename e_access_traits::const_iterator);
internal_node_pointer internal_node_pointer
insert_branch(node_pointer, node_pointer, split_join_branch_bag&); insert_branch(node_pointer, node_pointer, split_join_branch_bag&);
...@@ -445,16 +449,17 @@ namespace __gnu_pbds ...@@ -445,16 +449,17 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
assert_iterators() const; assert_iterators(const char* file, int line) const;
void void
assert_reverse_iterators() const; assert_reverse_iterators(const char* file, int line) const;
static size_type static size_type
recursive_count_leafs(const_node_pointer); recursive_count_leafs(const_node_pointer,
const char* file, int line);
#endif #endif
#ifdef PB_DS_PAT_TRIE_TRACE_ #ifdef PB_DS_PAT_TRIE_TRACE_
...@@ -490,6 +495,28 @@ namespace __gnu_pbds ...@@ -490,6 +495,28 @@ namespace __gnu_pbds
size_type m_size; size_type m_size;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_NODE_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);)
#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
recursive_count_leafs(X, __FILE__, __LINE__)
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp> #include <ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp> #include <ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp>
...@@ -502,6 +529,12 @@ namespace __gnu_pbds ...@@ -502,6 +529,12 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp> #include <ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp> #include <ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
#undef PB_DS_RECURSIVE_COUNT_LEAFS
#undef PB_DS_ASSERT_NODE_VALID
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_NAME #undef PB_DS_CLASS_NAME
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,15 +43,15 @@ void ...@@ -43,15 +43,15 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
split_join_branch_bag bag; split_join_branch_bag bag;
leaf_pointer p_split_lf = split_prep(r_key, other, bag); leaf_pointer p_split_lf = split_prep(r_key, other, bag);
if (p_split_lf == 0) if (p_split_lf == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(bag.empty()); _GLIBCXX_DEBUG_ASSERT(bag.empty());
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -73,8 +73,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -73,8 +73,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(), other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(),
other.PB_DS_CLASS_C_DEC::end()); other.PB_DS_CLASS_C_DEC::end());
m_size -= other.m_size; m_size -= other.m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -86,8 +86,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc ...@@ -86,8 +86,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc
if (m_size == 0) if (m_size == 0)
{ {
other.clear(); other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
return (0); return (0);
} }
...@@ -96,16 +96,16 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc ...@@ -96,16 +96,16 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc
{ {
other.clear(); other.clear();
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
return (0); return (0);
} }
if (!synth_e_access_traits::cmp_keys(r_key, if (!synth_e_access_traits::cmp_keys(r_key,
PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value()))) PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value())))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();); PB_DS_ASSERT_VALID(other)
return (0); return (0);
} }
...@@ -143,7 +143,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS ...@@ -143,7 +143,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS
node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag); node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag);
_GLIBCXX_DEBUG_ONLY(p_child_ret->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_child_ret)
p_internal_nd->replace_child(p_child_ret, b_it, e_it, this); p_internal_nd->replace_child(p_child_ret, b_it, e_it, this);
apply_update(p_internal_nd, (node_update* )this); apply_update(p_internal_nd, (node_update* )this);
...@@ -184,7 +184,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS ...@@ -184,7 +184,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS
if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1) if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1)
{ {
p_internal_nd->update_prefixes(this); p_internal_nd->update_prefixes(this);
_GLIBCXX_DEBUG_ONLY(p_internal_nd->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(p_internal_nd)
apply_update(p_internal_nd, (node_update* )this); apply_update(p_internal_nd, (node_update* )this);
return (p_internal_nd); return (p_internal_nd);
} }
...@@ -203,7 +203,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no ...@@ -203,7 +203,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no
{ {
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
if (m_p_head->m_p_parent != 0) if (m_p_head->m_p_parent != 0)
m_p_head->m_p_parent->assert_valid(this); PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
#endif #endif
const size_type total_num_children =((m_p_head->m_p_parent == 0)? 0 : 1) + num_children; const size_type total_num_children =((m_p_head->m_p_parent == 0)? 0 : 1) + num_children;
...@@ -218,7 +218,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no ...@@ -218,7 +218,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no
{ {
if (m_p_head->m_p_parent != 0) if (m_p_head->m_p_parent != 0)
{ {
_GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return; return;
} }
...@@ -226,7 +226,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no ...@@ -226,7 +226,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no
m_p_head->m_p_parent =* child_b_it; m_p_head->m_p_parent =* child_b_it;
m_p_head->m_p_parent->m_p_parent = m_p_head; m_p_head->m_p_parent->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update* )this); apply_update(m_p_head->m_p_parent, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return; return;
} }
...@@ -236,7 +236,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no ...@@ -236,7 +236,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no
size_type num_inserted = 0; size_type num_inserted = 0;
while (num_inserted++ < num_children) while (num_inserted++ < num_children)
{ {
_GLIBCXX_DEBUG_ONLY((*child_b_it)->assert_valid(this);) PB_DS_ASSERT_NODE_VALID((*child_b_it))
p_new_root->add_child(*child_b_it, pref_begin(*child_b_it), p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
pref_end(*child_b_it), this); pref_end(*child_b_it), this);
++child_b_it; ++child_b_it;
...@@ -250,5 +250,5 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no ...@@ -250,5 +250,5 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no
m_p_head->m_p_parent = p_new_root; m_p_head->m_p_parent = p_new_root;
p_new_root->m_p_parent = m_p_head; p_new_root->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update* )this); apply_update(m_p_head->m_p_parent, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() PB_DS_CLASS_NAME()
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : ...@@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn) base_type(r_cmp_fn)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : ...@@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update) base_type(r_cmp_fn, r_node_update)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other) base_type(other)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -88,9 +88,9 @@ void ...@@ -88,9 +88,9 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
base_type::swap(other); base_type::swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,34 +43,37 @@ ...@@ -43,34 +43,37 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const node_pointer p_nd) const assert_node_consistent(const node_pointer p_nd, const char* __file,
int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
return 1; return 1;
const size_type l_height = assert_node_consistent(p_nd->m_p_left); const size_type l_height =
const size_type r_height = assert_node_consistent(p_nd->m_p_right); assert_node_consistent(p_nd->m_p_left, __file, __line);
const size_type r_height =
assert_node_consistent(p_nd->m_p_right, __file, __line);
if (p_nd->m_red) if (p_nd->m_red)
{ {
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_left)); PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left));
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_right)); PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right));
} }
_GLIBCXX_DEBUG_ASSERT(l_height == r_height); PB_DS_DEBUG_VERIFY(l_height == r_height);
return (p_nd->m_red ? 0 : 1) + l_height; return (p_nd->m_red ? 0 : 1) + l_height;
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
base_type::assert_valid(); base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head; const node_pointer p_head = base_type::m_p_head;
_GLIBCXX_DEBUG_ASSERT(p_head->m_red); PB_DS_DEBUG_VERIFY(p_head->m_red);
if (p_head->m_p_parent != 0) if (p_head->m_p_parent != 0)
{ {
_GLIBCXX_DEBUG_ASSERT(!p_head->m_p_parent->m_red); PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red);
assert_node_consistent(p_head->m_p_parent); assert_node_consistent(p_head->m_p_parent, __file, __line);
} }
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -55,14 +55,14 @@ inline typename PB_DS_CLASS_C_DEC::iterator ...@@ -55,14 +55,14 @@ inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(iterator it) erase(iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it == base_type::end()) if (it == base_type::end())
return it; return it;
iterator ret_it = it; iterator ret_it = it;
++ret_it; ++ret_it;
erase_node(it.m_p_nd); erase_node(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -71,14 +71,14 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator ...@@ -71,14 +71,14 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(reverse_iterator it) erase(reverse_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head) if (it.m_p_nd == base_type::m_p_head)
return it; return it;
reverse_iterator ret_it = it; reverse_iterator ret_it = it;
++ret_it; ++ret_it;
erase_node(it.m_p_nd); erase_node(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -88,7 +88,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -88,7 +88,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0; size_type num_ersd = 0;
iterator it = base_type::begin(); iterator it = base_type::begin();
while (it != base_type::end()) while (it != base_type::end())
...@@ -102,7 +102,7 @@ erase_if(Pred pred) ...@@ -102,7 +102,7 @@ erase_if(Pred pred)
++it; ++it;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_ersd; return num_ersd;
} }
...@@ -113,7 +113,7 @@ erase_node(node_pointer p_nd) ...@@ -113,7 +113,7 @@ erase_node(node_pointer p_nd)
{ {
remove_node(p_nd); remove_node(p_nd);
base_type::actual_erase_node(p_nd); base_type::actual_erase_node(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,16 +43,16 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -43,16 +43,16 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert(const_reference r_value) insert(const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = base_type::insert_leaf(r_value); std::pair<point_iterator, bool> ins_pair = base_type::insert_leaf(r_value);
if (ins_pair.second == true) if (ins_pair.second == true)
{ {
ins_pair.first.m_p_nd->m_red = true; ins_pair.first.m_p_nd->m_red = true;
_GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
insert_fixup(ins_pair.first.m_p_nd); insert_fixup(ins_pair.first.m_p_nd);
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return ins_pair; return ins_pair;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -167,17 +167,17 @@ namespace __gnu_pbds ...@@ -167,17 +167,17 @@ namespace __gnu_pbds
operator[](const_key_reference r_key) operator[](const_key_reference r_key)
{ {
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair = std::pair<point_iterator, bool> ins_pair =
base_type::insert_leaf(value_type(r_key, mapped_type())); base_type::insert_leaf(value_type(r_key, mapped_type()));
if (ins_pair.second == true) if (ins_pair.second == true)
{ {
ins_pair.first.m_p_nd->m_red = true; ins_pair.first.m_p_nd->m_red = true;
_GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);)
insert_fixup(ins_pair.first.m_p_nd); insert_fixup(ins_pair.first.m_p_nd);
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second; return ins_pair.first.m_p_nd->m_value.second;
#else #else
insert(r_key); insert(r_key);
...@@ -210,10 +210,11 @@ namespace __gnu_pbds ...@@ -210,10 +210,11 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
size_type size_type
assert_node_consistent(const node_pointer) const; assert_node_consistent(const node_pointer, const char* file,
int line) const;
#endif #endif
inline static bool inline static bool
...@@ -259,6 +260,18 @@ namespace __gnu_pbds ...@@ -259,6 +260,18 @@ namespace __gnu_pbds
split_at_node(node_pointer, PB_DS_CLASS_C_DEC&); split_at_node(node_pointer, PB_DS_CLASS_C_DEC&);
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp> #include <ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp>
...@@ -266,6 +279,9 @@ namespace __gnu_pbds ...@@ -266,6 +279,9 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp> #include <ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_NAME #undef PB_DS_CLASS_NAME
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,23 +43,20 @@ inline void ...@@ -43,23 +43,20 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
if (base_type::join_prep(other) == false) if (base_type::join_prep(other) == false)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
const node_pointer p_x = other.split_min(); const node_pointer p_x = other.split_min();
join_imp(p_x, other.m_p_head->m_p_parent); join_imp(p_x, other.m_p_head->m_p_parent);
base_type::join_finish(other); base_type::join_finish(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(base_type::assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -122,10 +119,10 @@ join_imp(node_pointer p_x, node_pointer p_r) ...@@ -122,10 +119,10 @@ join_imp(node_pointer p_x, node_pointer p_r)
p_x->m_red = true; p_x->m_red = true;
base_type::initialize_min_max(); base_type::initialize_min_max();
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
base_type::update_to_top(p_x, (node_update* )this); base_type::update_to_top(p_x, (node_update* )this);
insert_fixup(p_x); insert_fixup(p_x);
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid()); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -237,21 +234,18 @@ void ...@@ -237,21 +234,18 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(base_type::assert_valid();) PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
_GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
if (base_type::split_prep(r_key, other) == false) if (base_type::split_prep(r_key, other) == false)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
return; return;
} }
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
node_pointer p_nd = upper_bound(r_key).m_p_nd; node_pointer p_nd = upper_bound(r_key).m_p_nd;
do do
{ {
...@@ -259,15 +253,14 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -259,15 +253,14 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
split_at_node(p_nd, other); split_at_node(p_nd, other);
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();) PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
p_nd = p_next_nd; p_nd = p_next_nd;
} }
while (p_nd != base_type::m_p_head); while (p_nd != base_type::m_p_head);
base_type::split_finish(other); base_type::split_finish(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -307,7 +300,7 @@ split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) ...@@ -307,7 +300,7 @@ split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other)
base_type::initialize_min_max(); base_type::initialize_min_max();
other.join_imp(p_nd, p_r); other.join_imp(p_nd, p_r);
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid()); PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid()); PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -42,16 +42,16 @@ PB_DS_CLASS_T_DEC ...@@ -42,16 +42,16 @@ PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
rc_binomial_heap_() rc_binomial_heap_()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
rc_binomial_heap_(const Cmp_Fn& r_cmp_fn) : rc_binomial_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn) PB_DS_BASE_C_DEC(r_cmp_fn)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -62,8 +62,8 @@ rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -62,8 +62,8 @@ rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
base_type::find_max(); base_type::find_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -75,14 +75,13 @@ void ...@@ -75,14 +75,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
base_type::swap(other); base_type::swap(other);
m_rc.swap(other.m_rc); m_rc.swap(other.m_rc);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,21 +43,21 @@ ...@@ -43,21 +43,21 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
base_type::assert_valid(false); base_type::assert_valid(false, __file, __line);
if (!base_type::empty()) if (!base_type::empty())
{ {
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_max != 0); PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0);
base_type::assert_max(); base_type::assert_max(__file, __line);
} }
m_rc.assert_valid(); m_rc.assert_valid(__file, __line);
if (m_rc.empty()) if (m_rc.empty())
{ {
base_type::assert_valid(true); base_type::assert_valid(true, __file, __line);
_GLIBCXX_DEBUG_ASSERT(next_2_pointer(base_type::m_p_root) == 0); PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0);
return; return;
} }
...@@ -67,17 +67,17 @@ assert_valid() const ...@@ -67,17 +67,17 @@ assert_valid() const
while (p_nd != 0) while (p_nd != 0)
{ {
_GLIBCXX_DEBUG_ASSERT(*it == p_nd); PB_DS_DEBUG_VERIFY(*it == p_nd);
const_node_pointer p_next = p_nd->m_p_next_sibling; const_node_pointer p_next = p_nd->m_p_next_sibling;
_GLIBCXX_DEBUG_ASSERT(p_next != 0); PB_DS_DEBUG_VERIFY(p_next != 0);
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_next->m_metadata); PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata);
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0 || PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 ||
p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); p_next->m_metadata < p_next->m_p_next_sibling->m_metadata);
--it; --it;
p_nd = next_2_pointer(next_after_0_pointer(p_nd)); p_nd = next_2_pointer(next_after_0_pointer(p_nd));
} }
_GLIBCXX_DEBUG_ASSERT(it + 1 == m_rc.begin()); PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin());
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -91,7 +91,7 @@ erase_if(Pred pred) ...@@ -91,7 +91,7 @@ erase_if(Pred pred)
make_binomial_heap(); make_binomial_heap();
const size_type ersd = base_type::erase_if(pred); const size_type ersd = base_type::erase_if(pred);
base_type::find_max(); base_type::find_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return ersd; return ersd;
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,11 +43,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,11 +43,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) push(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
make_0_exposed(); make_0_exposed();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::get_new_node_for_insert(r_val); node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
...@@ -67,7 +67,7 @@ push(const_reference r_val) ...@@ -67,7 +67,7 @@ push(const_reference r_val)
if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0) if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0)
m_rc.push(p_nd); m_rc.push(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd); return point_iterator(p_nd);
} }
...@@ -77,7 +77,7 @@ void ...@@ -77,7 +77,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) modify(point_iterator it, const_reference r_new_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
make_binomial_heap(); make_binomial_heap();
...@@ -85,8 +85,8 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -85,8 +85,8 @@ modify(point_iterator it, const_reference r_new_val)
base_type::find_max(); base_type::find_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer inline typename PB_DS_CLASS_C_DEC::node_pointer
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -41,6 +41,15 @@ ...@@ -41,6 +41,15 @@
#ifndef PB_DS_RC_HPP #ifndef PB_DS_RC_HPP
#define PB_DS_RC_HPP #define PB_DS_RC_HPP
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
namespace __gnu_pbds namespace __gnu_pbds
{ {
namespace detail namespace detail
...@@ -121,7 +130,7 @@ namespace __gnu_pbds ...@@ -121,7 +130,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
...@@ -138,20 +147,20 @@ namespace __gnu_pbds ...@@ -138,20 +147,20 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
rc() : m_over_top(0) rc() : m_over_top(0)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0) rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
const size_type over_top = std::max(m_over_top, other.m_over_top); const size_type over_top = std::max(m_over_top, other.m_over_top);
...@@ -159,8 +168,8 @@ namespace __gnu_pbds ...@@ -159,8 +168,8 @@ namespace __gnu_pbds
std::swap(m_a_entries[i], other.m_a_entries[i]); std::swap(m_a_entries[i], other.m_a_entries[i]);
std::swap(m_over_top, other.m_over_top); std::swap(m_over_top, other.m_over_top);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -168,10 +177,10 @@ namespace __gnu_pbds ...@@ -168,10 +177,10 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(entry p_nd) push(entry p_nd)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries);
m_a_entries[m_over_top++] = p_nd; m_a_entries[m_over_top++] = p_nd;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -179,10 +188,10 @@ namespace __gnu_pbds ...@@ -179,10 +188,10 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
--m_over_top; --m_over_top;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -190,7 +199,7 @@ namespace __gnu_pbds ...@@ -190,7 +199,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty()); _GLIBCXX_DEBUG_ASSERT(!empty());
return *(m_a_entries + m_over_top - 1); return *(m_a_entries + m_over_top - 1);
} }
...@@ -200,7 +209,7 @@ namespace __gnu_pbds ...@@ -200,7 +209,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
empty() const empty() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return m_over_top == 0; return m_over_top == 0;
} }
...@@ -215,9 +224,9 @@ namespace __gnu_pbds ...@@ -215,9 +224,9 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
clear() clear()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
m_over_top = 0; m_over_top = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -236,8 +245,8 @@ namespace __gnu_pbds ...@@ -236,8 +245,8 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); } { PB_DS_DEBUG_VERIFY(m_over_top < max_entries); }
#endif #endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
...@@ -259,4 +268,6 @@ namespace __gnu_pbds ...@@ -259,4 +268,6 @@ namespace __gnu_pbds
} // namespace detail } // namespace detail
} // namespace __gnu_pbds } // namespace __gnu_pbds
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -149,7 +149,7 @@ namespace __gnu_pbds ...@@ -149,7 +149,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
...@@ -180,6 +180,15 @@ namespace __gnu_pbds ...@@ -180,6 +180,15 @@ namespace __gnu_pbds
rc_t m_rc; rc_t m_rc;
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp> #include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp>
...@@ -187,12 +196,11 @@ namespace __gnu_pbds ...@@ -187,12 +196,11 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC #undef PB_DS_BASE_C_DEC
#undef PB_DS_RC_C_DEC #undef PB_DS_RC_C_DEC
} // namespace detail } // namespace detail
} // namespace __gnu_pbds } // namespace __gnu_pbds
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,8 +44,8 @@ void ...@@ -44,8 +44,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
make_binomial_heap(); make_binomial_heap();
other.make_binomial_heap(); other.make_binomial_heap();
...@@ -55,17 +55,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -55,17 +55,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
base_type::find_max(); base_type::find_max();
other.find_max(); other.find_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
make_binomial_heap(); make_binomial_heap();
other.make_binomial_heap(); other.make_binomial_heap();
...@@ -75,7 +75,7 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -75,7 +75,7 @@ join(PB_DS_CLASS_C_DEC& other)
base_type::find_max(); base_type::find_max();
other.find_max(); other.find_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
...@@ -39,66 +39,69 @@ ...@@ -39,66 +39,69 @@
* Contains a resize trigger implementation. * Contains a resize trigger implementation.
*/ */
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
hash_load_check_resize_trigger(float load_min, float load_max) hash_load_check_resize_trigger(float load_min, float load_max)
: m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0), : m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0),
m_next_grow_size(0), m_resize_needed(false) m_next_grow_size(0), m_resize_needed(false)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_find_search_start() notify_find_search_start()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_find_search_collision() notify_find_search_collision()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_find_search_end() notify_find_search_end()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_insert_search_start() notify_insert_search_start()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_insert_search_collision() notify_insert_search_collision()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_insert_search_end() notify_insert_search_end()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_erase_search_start() notify_erase_search_start()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_erase_search_collision() notify_erase_search_collision()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_erase_search_end() notify_erase_search_end()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -107,7 +110,7 @@ notify_inserted(size_type num_entries) ...@@ -107,7 +110,7 @@ notify_inserted(size_type num_entries)
{ {
m_resize_needed = (num_entries >= m_next_grow_size); m_resize_needed = (num_entries >= m_next_grow_size);
size_base::set_size(num_entries); size_base::set_size(num_entries);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -117,7 +120,7 @@ notify_erased(size_type num_entries) ...@@ -117,7 +120,7 @@ notify_erased(size_type num_entries)
{ {
size_base::set_size(num_entries); size_base::set_size(num_entries);
m_resize_needed = num_entries <= m_next_shrink_size; m_resize_needed = num_entries <= m_next_shrink_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -125,7 +128,7 @@ inline bool ...@@ -125,7 +128,7 @@ inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
is_resize_needed() const is_resize_needed() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return m_resize_needed; return m_resize_needed;
} }
...@@ -160,7 +163,7 @@ notify_resized(size_type new_size) ...@@ -160,7 +163,7 @@ notify_resized(size_type new_size)
<< "5 " << m_next_grow_size << std::endl; << "5 " << m_next_grow_size << std::endl;
#endif #endif
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -194,7 +197,7 @@ notify_externally_resized(size_type new_size) ...@@ -194,7 +197,7 @@ notify_externally_resized(size_type new_size)
m_next_shrink_size = new_shrink_size; m_next_shrink_size = new_shrink_size;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -202,10 +205,10 @@ void ...@@ -202,10 +205,10 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
notify_cleared() notify_cleared()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
size_base::set_size(0); size_base::set_size(0);
m_resize_needed = (0 < m_next_shrink_size); m_resize_needed = (0 < m_next_shrink_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -213,8 +216,8 @@ void ...@@ -213,8 +216,8 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
size_base::swap(other); size_base::swap(other);
std::swap(m_load_min, other.m_load_min); std::swap(m_load_min, other.m_load_min);
...@@ -223,8 +226,8 @@ swap(PB_DS_CLASS_C_DEC& other) ...@@ -223,8 +226,8 @@ swap(PB_DS_CLASS_C_DEC& other)
std::swap(m_next_grow_size, other.m_next_grow_size); std::swap(m_next_grow_size, other.m_next_grow_size);
std::swap(m_next_shrink_size, other.m_next_shrink_size); std::swap(m_next_shrink_size, other.m_next_shrink_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -272,12 +275,20 @@ do_resize(size_type) ...@@ -272,12 +275,20 @@ do_resize(size_type)
{ std::abort(); } { std::abort(); }
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
# define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
_GLIBCXX_DEBUG_ASSERT(m_load_max > m_load_min); _GLIBCXX_DEBUG_ASSERT(m_load_max > m_load_min);
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= m_next_shrink_size); _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= m_next_shrink_size);
} }
# undef PB_DS_DEBUG_VERIFY
#endif #endif
#undef PB_DS_ASSERT_VALID
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() PB_DS_CLASS_NAME()
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : ...@@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn) base_type(r_cmp_fn)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : ...@@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update) base_type(r_cmp_fn, r_node_update)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other) base_type(other)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -88,11 +88,11 @@ void ...@@ -88,11 +88,11 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
base_type::swap(other); base_type::swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,31 +43,32 @@ ...@@ -43,31 +43,32 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
base_type::assert_valid(); base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head; const node_pointer p_head = base_type::m_p_head;
assert_special_imp(p_head); assert_special_imp(p_head, __file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_special_imp(const node_pointer p_nd) const assert_special_imp(const node_pointer p_nd,
const char* __file, int __line) const
{ {
if (p_nd == 0) if (p_nd == 0)
return; return;
if (p_nd == base_type::m_p_head) if (p_nd == base_type::m_p_head)
{ {
_GLIBCXX_DEBUG_ASSERT(p_nd->m_special); PB_DS_DEBUG_VERIFY(p_nd->m_special);
assert_special_imp(p_nd->m_p_parent); assert_special_imp(p_nd->m_p_parent, __file, __line);
return; return;
} }
_GLIBCXX_DEBUG_ASSERT(!p_nd->m_special); PB_DS_DEBUG_VERIFY(!p_nd->m_special);
assert_special_imp(p_nd->m_p_left); assert_special_imp(p_nd->m_p_left, __file, __line);
assert_special_imp(p_nd->m_p_right); assert_special_imp(p_nd->m_p_right, __file, __line);
} }
#endif #endif
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -55,13 +55,13 @@ inline typename PB_DS_CLASS_C_DEC::iterator ...@@ -55,13 +55,13 @@ inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(iterator it) erase(iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it == base_type::end()) if (it == base_type::end())
return it; return it;
iterator ret_it = it; iterator ret_it = it;
++ret_it; ++ret_it;
erase_node(it.m_p_nd); erase_node(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -70,13 +70,13 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator ...@@ -70,13 +70,13 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(reverse_iterator it) erase(reverse_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head) if (it.m_p_nd == base_type::m_p_head)
return (it); return (it);
reverse_iterator ret_it = it; reverse_iterator ret_it = it;
++ret_it; ++ret_it;
erase_node(it.m_p_nd); erase_node(it.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ret_it; return ret_it;
} }
...@@ -86,7 +86,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -86,7 +86,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0; size_type num_ersd = 0;
iterator it = base_type::begin(); iterator it = base_type::begin();
while (it != base_type::end()) while (it != base_type::end())
...@@ -99,7 +99,7 @@ erase_if(Pred pred) ...@@ -99,7 +99,7 @@ erase_if(Pred pred)
else else
++it; ++it;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return num_ersd; return num_ersd;
} }
...@@ -111,7 +111,7 @@ erase_node(node_pointer p_nd) ...@@ -111,7 +111,7 @@ erase_node(node_pointer p_nd)
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
splay(p_nd); splay(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
node_pointer p_l = p_nd->m_p_left; node_pointer p_l = p_nd->m_p_left;
...@@ -124,7 +124,7 @@ erase_node(node_pointer p_nd) ...@@ -124,7 +124,7 @@ erase_node(node_pointer p_nd)
base_type::m_p_head->m_p_parent = p_l; base_type::m_p_head->m_p_parent = p_l;
if (p_l != 0) if (p_l != 0)
p_l->m_p_parent = base_type::m_p_head; p_l->m_p_parent = base_type::m_p_head;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return; return;
} }
...@@ -141,7 +141,7 @@ erase_node(node_pointer p_nd) ...@@ -141,7 +141,7 @@ erase_node(node_pointer p_nd)
p_target_r->m_p_left = p_l; p_target_r->m_p_left = p_l;
if (p_l != 0) if (p_l != 0)
p_l->m_p_parent = p_target_r; p_l->m_p_parent = p_target_r;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
apply_update(p_target_r, (node_update* )this); apply_update(p_target_r, (node_update* )this);
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -65,7 +65,8 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer ...@@ -65,7 +65,8 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find_imp(const_key_reference r_key) find_imp(const_key_reference r_key)
{ {
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
__LINE__);)
node_pointer p_nd = base_type::m_p_head->m_p_parent; node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0) while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
...@@ -84,7 +85,7 @@ inline const typename PB_DS_CLASS_C_DEC::node_pointer ...@@ -84,7 +85,7 @@ inline const typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
find_imp(const_key_reference r_key) const find_imp(const_key_reference r_key) const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::m_p_head->m_p_parent; node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0) while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010i, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,12 +43,12 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -43,12 +43,12 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert(const_reference r_value) insert(const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = insert_leaf_imp(r_value); std::pair<point_iterator, bool> ins_pair = insert_leaf_imp(r_value);
ins_pair.first.m_p_nd->m_special = false; ins_pair.first.m_p_nd->m_special = false;
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
splay(ins_pair.first.m_p_nd); splay(ins_pair.first.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
return ins_pair; return ins_pair;
} }
...@@ -57,7 +57,8 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> ...@@ -57,7 +57,8 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
insert_leaf_imp(const_reference r_value) insert_leaf_imp(const_reference r_value)
{ {
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
__LINE__);)
if (base_type::m_size == 0) if (base_type::m_size == 0)
return std::make_pair(base_type::insert_imp_empty(r_value), true); return std::make_pair(base_type::insert_imp_empty(r_value), true);
...@@ -80,7 +81,7 @@ insert_leaf_imp(const_reference r_value) ...@@ -80,7 +81,7 @@ insert_leaf_imp(const_reference r_value)
if (p_pot == base_type::m_p_head) if (p_pot == base_type::m_p_head)
return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true); return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true);
_GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(PB_DS_V2F(r_value))); PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
p_nd = p_pot->m_p_left; p_nd = p_pot->m_p_left;
if (p_nd == 0) if (p_nd == 0)
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -48,11 +48,11 @@ splay(node_pointer p_nd) ...@@ -48,11 +48,11 @@ splay(node_pointer p_nd)
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
{ {
node_pointer p_head = base_type::m_p_head; node_pointer p_head = base_type::m_p_head;
assert_special_imp(p_head); assert_special_imp(p_head, __FILE__, __LINE__);
} }
#endif #endif
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head)
{ {
...@@ -84,7 +84,7 @@ splay(node_pointer p_nd) ...@@ -84,7 +84,7 @@ splay(node_pointer p_nd)
_GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
} }
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
} }
} }
...@@ -97,7 +97,7 @@ splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, ...@@ -97,7 +97,7 @@ splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent,
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_grandparent->m_p_right == p_parent); p_grandparent->m_p_right == p_parent);
...@@ -133,7 +133,7 @@ splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, ...@@ -133,7 +133,7 @@ splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent,
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_grandparent->m_p_left == p_parent); p_grandparent->m_p_left == p_parent);
...@@ -169,7 +169,7 @@ splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, ...@@ -169,7 +169,7 @@ splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent,
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent);
...@@ -204,7 +204,7 @@ splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, ...@@ -204,7 +204,7 @@ splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent,
{ {
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent);
...@@ -278,6 +278,6 @@ splay_zz_end(node_pointer p_nd, node_pointer p_parent, ...@@ -278,6 +278,6 @@ splay_zz_end(node_pointer p_nd, node_pointer p_parent,
apply_update(p_parent, (node_update* )this); apply_update(p_parent, (node_update* )this);
apply_update(p_nd, (node_update* )this); apply_update(p_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -191,14 +191,14 @@ namespace __gnu_pbds ...@@ -191,14 +191,14 @@ namespace __gnu_pbds
operator[](const_key_reference r_key) operator[](const_key_reference r_key)
{ {
#ifdef PB_DS_DATA_TRUE_INDICATOR #ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair = std::pair<point_iterator, bool> ins_pair =
insert_leaf_imp(value_type(r_key, mapped_type())); insert_leaf_imp(value_type(r_key, mapped_type()));
ins_pair.first.m_p_nd->m_special = false; ins_pair.first.m_p_nd->m_special = false;
_GLIBCXX_DEBUG_ONLY(base_type::assert_valid()); _GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__));
splay(ins_pair.first.m_p_nd); splay(ins_pair.first.m_p_nd);
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second; return ins_pair.first.m_p_nd->m_value.second;
#else #else
insert(r_key); insert(r_key);
...@@ -243,10 +243,10 @@ namespace __gnu_pbds ...@@ -243,10 +243,10 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
assert_special_imp(const node_pointer) const; assert_special_imp(const node_pointer, const char* file, int line) const;
#endif #endif
void void
...@@ -277,6 +277,23 @@ namespace __gnu_pbds ...@@ -277,6 +277,23 @@ namespace __gnu_pbds
erase_node(node_pointer); erase_node(node_pointer);
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \
__FILE__, __LINE__);)
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
_GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(_Key, \
__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp> #include <ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp> #include <ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp>
...@@ -285,6 +302,10 @@ namespace __gnu_pbds ...@@ -285,6 +302,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_NAME #undef PB_DS_CLASS_NAME
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,12 +43,12 @@ inline void ...@@ -43,12 +43,12 @@ inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
if (base_type::join_prep(other) == false) if (base_type::join_prep(other) == false)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -70,8 +70,8 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -70,8 +70,8 @@ join(PB_DS_CLASS_C_DEC& other)
base_type::join_finish(other); base_type::join_finish(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -79,13 +79,13 @@ void ...@@ -79,13 +79,13 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
if (base_type::split_prep(r_key, other) == false) if (base_type::split_prep(r_key, other) == false)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -106,7 +106,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -106,7 +106,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
apply_update(p_upper_bound, (node_update* )this); apply_update(p_upper_bound, (node_update* )this);
base_type::split_finish(other); base_type::split_finish(other);
_GLIBCXX_DEBUG_ONLY(assert_valid()); PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid()); PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -46,7 +46,7 @@ copy_from_range(It first_it, It last_it) ...@@ -46,7 +46,7 @@ copy_from_range(It first_it, It last_it)
{ {
while (first_it != last_it) while (first_it != last_it)
push(*(first_it++)); push(*(first_it++));
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -55,7 +55,7 @@ thin_heap_() : ...@@ -55,7 +55,7 @@ thin_heap_() :
m_p_max(0) m_p_max(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -65,7 +65,7 @@ thin_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -65,7 +65,7 @@ thin_heap_(const Cmp_Fn& r_cmp_fn) :
m_p_max(0) m_p_max(0)
{ {
initialize(); initialize();
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -79,7 +79,7 @@ thin_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -79,7 +79,7 @@ thin_heap_(const PB_DS_CLASS_C_DEC& other) :
if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))
m_p_max = p_nd; m_p_max = p_nd;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -87,10 +87,10 @@ void ...@@ -87,10 +87,10 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other) swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
base_type::swap(other); base_type::swap(other);
std::swap(m_p_max, other.m_p_max); std::swap(m_p_max, other.m_p_max);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,70 +43,77 @@ ...@@ -43,70 +43,77 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_valid() const assert_valid(const char* __file, int __line) const
{ {
base_type::assert_valid(); base_type::assert_valid(__file, __line);
assert_node_consistent(base_type::m_p_root, true); assert_node_consistent(base_type::m_p_root, true, __file, __line);
assert_max(); assert_max(__file, __line);
assert_aux_null(); assert_aux_null(__file, __line);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_aux_null() const assert_aux_null(const char* __file, int __line) const
{ {
for (size_type i = 0; i < max_rank; ++i) for (size_type i = 0; i < max_rank; ++i)
_GLIBCXX_DEBUG_ASSERT(m_a_aux[i] == 0); PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_max() const assert_max(const char* __file, int __line) const
{ {
if (m_p_max == 0) if (m_p_max == 0)
{ {
_GLIBCXX_DEBUG_ASSERT(base_type::empty()); PB_DS_DEBUG_VERIFY(base_type::empty());
return; return;
} }
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); PB_DS_DEBUG_VERIFY(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == 0); PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
_GLIBCXX_DEBUG_ASSERT(m_p_max->m_p_prev_or_parent == 0); PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 0);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value));
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
assert_node_consistent(const_node_pointer p_nd, bool root) const assert_node_consistent(const_node_pointer p_nd, bool root,
const char* __file, int __line) const
{ {
base_type::assert_node_consistent(p_nd, root); base_type::assert_node_consistent(p_nd, root, __file, __line);
if (p_nd == 0) if (p_nd == 0)
return; return;
assert_node_consistent(p_nd->m_p_next_sibling, root); assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line);
assert_node_consistent(p_nd->m_p_l_child, false); assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
if (!root) if (!root)
{ {
if (p_nd->m_metadata == 0) if (p_nd->m_metadata == 0)
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == 0); PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0);
else else
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1);
} }
if (p_nd->m_p_l_child != 0) if (p_nd->m_p_l_child != 0)
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd));
const bool unmarked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 0) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); const bool unmarked_valid =
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0)
|| (p_nd->m_p_l_child != 0
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1);
const bool marked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 1) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); const bool marked_valid =
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1)
|| (p_nd->m_p_l_child != 0
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2);
_GLIBCXX_DEBUG_ASSERT(unmarked_valid || marked_valid); PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid);
if (root) if (root)
_GLIBCXX_DEBUG_ASSERT(unmarked_valid); PB_DS_DEBUG_VERIFY(unmarked_valid);
} }
#endif #endif
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ void ...@@ -43,7 +43,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
pop() pop()
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
...@@ -54,8 +54,8 @@ pop() ...@@ -54,8 +54,8 @@ pop()
base_type::actual_erase_node(p_nd); base_type::actual_erase_node(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -177,8 +177,8 @@ make_from_aux() ...@@ -177,8 +177,8 @@ make_from_aux()
++i; ++i;
} }
_GLIBCXX_DEBUG_ONLY(assert_aux_null();) PB_DS_ASSERT_AUX_NULL((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -218,7 +218,7 @@ void ...@@ -218,7 +218,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase(point_iterator it) erase(point_iterator it)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_nd = it.m_p_nd; node_pointer p_nd = it.m_p_nd;
...@@ -227,8 +227,8 @@ erase(point_iterator it) ...@@ -227,8 +227,8 @@ erase(point_iterator it)
base_type::actual_erase_node(p_nd); base_type::actual_erase_node(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
template<typename Pred> template<typename Pred>
...@@ -236,11 +236,11 @@ typename PB_DS_CLASS_C_DEC::size_type ...@@ -236,11 +236,11 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
erase_if(Pred pred) erase_if(Pred pred)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return 0; return 0;
} }
...@@ -275,7 +275,7 @@ erase_if(Pred pred) ...@@ -275,7 +275,7 @@ erase_if(Pred pred)
p_cur = p_next; p_cur = p_next;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return ersd; return ersd;
} }
...@@ -285,8 +285,11 @@ inline typename PB_DS_CLASS_C_DEC::size_type ...@@ -285,8 +285,11 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
rank_bound() rank_bound()
{ {
const std::size_t* const p_upper = using namespace std;
std::upper_bound( g_a_rank_bounds, g_a_rank_bounds + num_distinct_rank_bounds, base_type::m_size); const size_t* const p_upper =
_GLIBCXX_STD_A::upper_bound(g_a_rank_bounds,
g_a_rank_bounds + num_distinct_rank_bounds,
base_type::m_size);
if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds) if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds)
return max_rank; return max_rank;
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
top() const top() const
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator ...@@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
push(const_reference r_val) push(const_reference r_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::get_new_node_for_insert(r_val); node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
...@@ -57,7 +57,7 @@ push(const_reference r_val) ...@@ -57,7 +57,7 @@ push(const_reference r_val)
m_p_max = base_type::m_p_root = p_nd; m_p_max = base_type::m_p_root = p_nd;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd); return point_iterator(p_nd);
} }
...@@ -70,7 +70,7 @@ push(const_reference r_val) ...@@ -70,7 +70,7 @@ push(const_reference r_val)
update_max(p_nd); update_max(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return point_iterator(p_nd); return point_iterator(p_nd);
} }
...@@ -81,7 +81,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -81,7 +81,7 @@ PB_DS_CLASS_C_DEC::
make_root(node_pointer p_nd) make_root(node_pointer p_nd)
{ {
p_nd->m_metadata = p_nd->m_metadata =
p_nd->m_p_l_child == 0? p_nd->m_p_l_child == 0 ?
0 : 0 :
1 + p_nd->m_p_l_child->m_metadata; 1 + p_nd->m_p_l_child->m_metadata;
} }
...@@ -170,8 +170,8 @@ fix_root(node_pointer p_y) ...@@ -170,8 +170,8 @@ fix_root(node_pointer p_y)
make_root(p_y); make_root(p_y);
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, true);) PB_DS_ASSERT_NODE_CONSISTENT(p_y, true)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -191,8 +191,8 @@ fix_sibling_rank_1_unmarked(node_pointer p_y) ...@@ -191,8 +191,8 @@ fix_sibling_rank_1_unmarked(node_pointer p_y)
p_y->m_p_l_child = 0; p_y->m_p_l_child = 0;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -204,8 +204,8 @@ fix_sibling_rank_1_marked(node_pointer p_y) ...@@ -204,8 +204,8 @@ fix_sibling_rank_1_marked(node_pointer p_y)
p_y->m_metadata = 0; p_y->m_metadata = 0;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -228,8 +228,8 @@ fix_sibling_general_unmarked(node_pointer p_y) ...@@ -228,8 +228,8 @@ fix_sibling_general_unmarked(node_pointer p_y)
p_y->m_p_next_sibling = p_w; p_y->m_p_next_sibling = p_w;
p_w->m_p_prev_or_parent = p_y; p_w->m_p_prev_or_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -240,8 +240,8 @@ fix_sibling_general_marked(node_pointer p_y) ...@@ -240,8 +240,8 @@ fix_sibling_general_marked(node_pointer p_y)
--p_y->m_metadata; --p_y->m_metadata;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
...@@ -266,7 +266,7 @@ void ...@@ -266,7 +266,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val) modify(point_iterator it, const_reference r_new_val)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = it.m_p_nd; node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
...@@ -283,7 +283,7 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -283,7 +283,7 @@ modify(point_iterator it, const_reference r_new_val)
make_root_and_link(p_nd); make_root_and_link(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return; return;
} }
...@@ -292,7 +292,7 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -292,7 +292,7 @@ modify(point_iterator it, const_reference r_new_val)
{ {
update_max(p_nd); update_max(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
return; return;
} }
...@@ -312,8 +312,8 @@ modify(point_iterator it, const_reference r_new_val) ...@@ -312,8 +312,8 @@ modify(point_iterator it, const_reference r_new_val)
make_root_and_link(p_nd); make_root_and_link(p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -44,15 +44,15 @@ void ...@@ -44,15 +44,15 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other) split(Pred pred, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
other.clear(); other.clear();
if (base_type::empty()) if (base_type::empty())
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
return; return;
} }
...@@ -75,7 +75,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -75,7 +75,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_out = p_next; p_out = p_next;
} }
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
node_pointer p_cur = base_type::m_p_root; node_pointer p_cur = base_type::m_p_root;
...@@ -92,17 +92,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -92,17 +92,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
p_cur = p_next; p_cur = p_next;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
node_pointer p_other = other.m_p_root; node_pointer p_other = other.m_p_root;
...@@ -121,6 +121,6 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -121,6 +121,6 @@ join(PB_DS_CLASS_C_DEC& other)
other.m_size = 0; other.m_size = 0;
other.m_p_max = 0; other.m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();) PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) PB_DS_ASSERT_VALID(other)
} }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -183,10 +183,10 @@ namespace __gnu_pbds ...@@ -183,10 +183,10 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
void void
assert_max() const; assert_max(const char* file, int line) const;
#endif #endif
#ifdef PB_DS_THIN_HEAP_TRACE_ #ifdef PB_DS_THIN_HEAP_TRACE_
...@@ -261,10 +261,11 @@ namespace __gnu_pbds ...@@ -261,10 +261,11 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_node_consistent(const_node_pointer p_nd, bool root) const; assert_node_consistent(const_node_pointer p_nd, bool root,
const char* file, int line) const;
void void
assert_aux_null() const; assert_aux_null(const char* file, int line) const;
#endif #endif
private: private:
...@@ -333,6 +334,22 @@ namespace __gnu_pbds ...@@ -333,6 +334,22 @@ namespace __gnu_pbds
/* Pot's good, let's play */ /* Pot's good, let's play */
}; };
#define PB_DS_ASSERT_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
#define PB_DS_ASSERT_AUX_NULL(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);)
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
#include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp> #include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp> #include <ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp> #include <ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp>
...@@ -341,6 +358,10 @@ namespace __gnu_pbds ...@@ -341,6 +358,10 @@ namespace __gnu_pbds
#include <ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp> #include <ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp> #include <ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp>
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_AUX_NULL
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC #undef PB_DS_BASE_C_DEC
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -275,7 +275,7 @@ namespace __gnu_pbds ...@@ -275,7 +275,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
void void
assert_valid() const; assert_valid(const char* file, int line) const;
#endif #endif
float m_load_min; float m_load_min;
......
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