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>
* testsuite/22_locale/messages_byname/named_equivalence.cc: Fix.
......
// 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.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -39,14 +39,17 @@
* the user error and where the error is reported.
*
*/
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
do \
#define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \
do \
{ \
if (! (_Condition)) \
__gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \
__gnu_debug::_Error_formatter::_M_at(_File, _Line) \
._ErrorMessage._M_error(); \
} 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.
#define __glibcxx_check_valid_range(_First,_Last) \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -403,51 +403,58 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
void
structure_only_assert_valid() const;
structure_only_assert_valid(const char* file, int line) const;
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
private:
#ifdef _GLIBCXX_DEBUG
void
assert_iterators() const;
assert_iterators(const char* file, int line) const;
void
assert_consistent_with_debug_base() const;
assert_consistent_with_debug_base(const char* file, int line) const;
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
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
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
assert_min() const;
assert_min(const char* file, int line) const;
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
assert_max() const;
assert_max(const char* file, int line) const;
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
assert_size() const;
assert_size(const char* file, int line) const;
typedef std::pair< const_pointer, const_pointer> 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
void
......@@ -464,6 +471,28 @@ namespace __gnu_pbds
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_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp>
......@@ -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_/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_T_DEC
#undef PB_DS_CLASS_NAME
#undef PB_DS_TYPES_TRAITS_C_DEC
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -48,7 +48,7 @@ PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
{
initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -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)
{
initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
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) :
m_size(0)
{
initialize();
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -88,7 +88,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
{
initialize();
m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
__try
{
......@@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
s_node_allocator.deallocate(m_p_head, 1);
__throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -112,12 +112,12 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......@@ -187,7 +187,7 @@ recursive_copy_node(const node_pointer p_nd)
if (p_ret->m_p_right != 0)
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;
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z)
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--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();
......@@ -88,9 +88,9 @@ void
PB_DS_CLASS_C_DEC::
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);
m_size = 0;
......@@ -98,8 +98,8 @@ 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
void
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -133,9 +133,9 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
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;
while (p_nd != 0)
......@@ -148,10 +148,10 @@ find(const_key_reference r_key)
else
p_nd = p_nd->m_p_right;
return point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()(
r_key,
PB_DS_V2F(p_pot->m_value)))?
m_p_head : p_pot);
return point_iterator((p_pot != m_p_head
&& Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))
? m_p_head : p_pot);
}
PB_DS_CLASS_T_DEC
......@@ -159,9 +159,9 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC::
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;
while (p_nd != 0)
......@@ -174,9 +174,9 @@ find(const_key_reference r_key) const
else
p_nd = p_nd->m_p_right;
return const_point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()(
r_key,
PB_DS_V2F(p_pot->m_value)))?
m_p_head : p_pot);
return const_point_iterator((p_pot != m_p_head
&& Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))
? m_p_head : p_pot);
}
// -*- 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
// 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>
PB_DS_CLASS_C_DEC::
insert_leaf(const_reference r_value)
{
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
if (m_size == 0)
return (std::make_pair(
insert_imp_empty(r_value),
true));
if (m_size == 0)
return std::make_pair(insert_imp_empty(r_value),
true);
node_pointer p_nd = m_p_head->m_p_parent;
node_pointer p_pot = m_p_head;
while (p_nd != 0)
if (!Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_value),
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value)))
{
p_pot = p_nd;
......@@ -66,37 +64,29 @@ insert_leaf(const_reference r_value)
p_nd = p_nd->m_p_right;
if (p_pot == m_p_head)
return (std::make_pair(
insert_leaf_new(r_value, m_p_head->m_p_right, false),
true));
return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false),
true);
if (!Cmp_Fn::operator()(
PB_DS_V2F(r_value),
if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
PB_DS_V2F(p_pot->m_value)))
{
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(
PB_DS_V2F(r_value)));
return (std::make_pair(p_pot, false));
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
return std::make_pair(p_pot, false);
}
_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))
p_nd = p_pot->m_p_left;
if (p_nd == 0)
return (std::make_pair(
insert_leaf_new(r_value, p_pot, true),
true));
return std::make_pair(insert_leaf_new(r_value, p_pot, true),
true);
while (p_nd->m_p_right != 0)
p_nd = p_nd->m_p_right;
return (std::make_pair(
insert_leaf_new(r_value, p_nd, false),
true));
return std::make_pair(insert_leaf_new(r_value, p_nd, false),
true);
}
PB_DS_CLASS_T_DEC
......@@ -105,7 +95,8 @@ PB_DS_CLASS_C_DEC::
insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_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)
{
......@@ -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;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_nd));
PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
update_to_top(p_new_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(
PB_DS_V2F(r_value)));
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
return (iterator(p_new_nd));
return iterator(p_new_nd);
}
PB_DS_CLASS_T_DEC
......@@ -152,7 +142,7 @@ PB_DS_CLASS_C_DEC::
insert_imp_empty(const_reference r_value)
{
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_parent = p_new_node;
......@@ -161,12 +151,11 @@ insert_imp_empty(const_reference r_value)
p_new_node->m_p_left = p_new_node->m_p_right = 0;
_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_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
......@@ -178,8 +167,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type)
cond_dealtor_t cond(p_new_nd);
new (const_cast<void* >(
static_cast<const void* >(&p_new_nd->m_value)))
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
cond.set_no_action();
......@@ -188,7 +176,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type)
++m_size;
return (p_new_nd);
return p_new_nd;
}
PB_DS_CLASS_T_DEC
......@@ -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);
new (const_cast<void* >(
static_cast<const void* >(&p_new_nd->m_value)))
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size;
return (p_new_nd);
return p_new_nd;
}
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z)
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--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();
......@@ -88,7 +88,7 @@ void
PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent);
......@@ -98,8 +98,8 @@ 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
void
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -62,10 +62,10 @@ rotate_left(node_pointer p_x)
p_y->m_p_left = p_x;
p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
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);
}
......@@ -93,10 +93,10 @@ rotate_right(node_pointer p_x)
p_y->m_p_right = p_x;
p_x->m_p_parent = p_y;
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
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);
}
......@@ -129,9 +129,8 @@ inline void
PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
{
node_update::operator()(
node_iterator(p_nd),
const_node_iterator(static_cast<node_pointer>(0)));
node_update::operator()(node_iterator(p_nd),
const_node_iterator(static_cast<node_pointer>(0)));
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,8 +43,8 @@ bool
PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_size == 0)
return false;
......@@ -54,9 +54,13 @@ join_prep(PB_DS_CLASS_C_DEC& other)
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)
__throw_join_error();
......@@ -83,37 +87,37 @@ bool
PB_DS_CLASS_C_DEC::
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
other.clear();
if (m_size == 0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
{
value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
if (m_size == 1)
{
value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return false;
}
......@@ -130,8 +134,8 @@ split_finish(PB_DS_CLASS_C_DEC& other)
other.m_size = std::distance(other.begin(), other.end());
m_size -= other.m_size;
initialize_min_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -310,7 +310,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
......@@ -335,6 +335,15 @@ namespace __gnu_pbds
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_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp>
......@@ -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_/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_T_DEC
#undef PB_DS_ENTRY_CMP_DEC
......
// -*- 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
// 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)
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
......@@ -74,7 +75,7 @@ binary_heap_() :
m_actual_size(resize_policy::min_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
......@@ -85,7 +86,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) :
m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -97,7 +98,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
m_actual_size(other.m_actual_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
const_iterator first_it = other.begin();
......@@ -119,7 +120,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
__throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -127,14 +128,14 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other);
std::swap((entry_cmp& )(*this), (entry_cmp& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,14 +43,14 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid() const
assert_valid(const char* __file, int __line) const
{
#ifdef PB_DS_REGRESSION
s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
#endif
resize_policy::assert_valid();
_GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size);
resize_policy::assert_valid(__file, __line);
PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
for (size_type i = 0; i < m_size; ++i)
{
#ifdef PB_DS_REGRESSION
......@@ -58,14 +58,14 @@ assert_valid() const
#endif
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)
_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()
m_size = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -89,7 +89,7 @@ inline void
PB_DS_CLASS_C_DEC::
pop()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
erase_at(m_a_entries, 0, s_no_throw_copies_ind);
......@@ -102,7 +102,7 @@ pop()
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -111,7 +111,7 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
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
pred_t;
......@@ -148,7 +148,7 @@ erase_if(Pred pred)
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))
return ersd;
}
......@@ -158,7 +158,7 @@ inline void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
const size_type fix_pos = it.m_p_e - m_a_entries;
......@@ -177,7 +177,7 @@ erase(point_iterator it)
if (fix_pos != m_size)
fix(m_a_entries + fix_pos);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ASSERT(!empty());
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
return top_imp(s_no_throw_copies_ind);
}
......
// -*- 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
// 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
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
insert_value(r_val, s_no_throw_copies_ind);
std::push_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp&>(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return point_iterator(m_a_entries);
}
......@@ -108,10 +108,10 @@ void
PB_DS_CLASS_C_DEC::
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);
fix(it.m_p_e);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -131,7 +131,7 @@ fix(entry_pointer p_e)
parent_i = parent(i);
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return;
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -52,6 +52,15 @@ namespace __gnu_pbds
#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>
class resize_policy
{
......@@ -102,7 +111,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
......@@ -128,7 +137,7 @@ namespace __gnu_pbds
resize_policy() :
m_next_shrink_size(0),
m_next_grow_size(min_size)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
......@@ -188,11 +197,11 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
notify_grow_resize()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
m_next_grow_size *= factor;
m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -200,14 +209,14 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
notify_shrink_resize()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
m_next_shrink_size /= factor;
if (m_next_shrink_size == 1)
m_next_shrink_size = 0;
m_next_grow_size =
std::max(m_next_grow_size / factor, static_cast<size_type>(min_size));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -217,19 +226,19 @@ namespace __gnu_pbds
{
m_next_grow_size = actual_size;
m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
void
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);
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
PB_DS_DEBUG_VERIFY(m_next_grow_size >= min_size);
}
#endif
......@@ -244,6 +253,8 @@ namespace __gnu_pbds
}
#endif
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -45,9 +45,9 @@ void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
typedef
typedef
typename entry_pred<
value_type,
Pred,
......@@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
resize_policy::notify_arbitrary(m_actual_size);
other.notify_arbitrary(other.m_actual_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
}
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
const size_type len = m_size + other.m_size;
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(len);
......@@ -167,7 +167,7 @@ join(PB_DS_CLASS_C_DEC& other)
other.notify_arbitrary(resize_policy::min_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -100,13 +100,17 @@ namespace __gnu_pbds
protected:
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#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_/debug_fn_imps.hpp>
#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -41,19 +41,19 @@
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,7 +43,7 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid() const
{ base_type::assert_valid(true); }
assert_valid(const char* __file, int __line) const
{ base_type::assert_valid(true, __file, __line); }
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -187,10 +187,10 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid(bool strictly_binomial) const;
assert_valid(bool strictly_binomial, const char* file, int line) const;
void
assert_max() const;
assert_max(const char* file, int line) const;
#endif
private:
......@@ -209,13 +209,27 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_node_consistent(const_node_pointer, bool, bool) const;
assert_node_consistent(const_node_pointer, bool, bool,
const char*, int) const;
#endif
protected:
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_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp>
......@@ -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_/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_T_DEC
#undef PB_DS_BASE_C_DEC
......
// -*- 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
// 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)
while (first_it != last_it)
push(*(first_it++));
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
}
PB_DS_ASSERT_VALID((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base_() :
m_p_max(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
}
PB_DS_ASSERT_VALID((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
......@@ -64,8 +64,8 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn),
m_p_max(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
}
PB_DS_ASSERT_VALID((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
......@@ -73,22 +73,22 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other),
m_p_max(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
}
PB_DS_ASSERT_VALID((*this),false)
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
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);
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
}
PB_DS_ASSERT_VALID((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -44,54 +44,56 @@
PB_DS_CLASS_T_DEC
void
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();
assert_node_consistent(base_type::m_p_root, strictly_binomial, true);
assert_max();
base_type::assert_valid(__file, __line);
assert_node_consistent(base_type::m_p_root, strictly_binomial, true,
__file, __line);
assert_max(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_max() const
assert_max(const char* __file, int __line) const
{
if (m_p_max == 0)
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)
_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
void
PB_DS_CLASS_C_DEC::
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);
base_type::assert_node_consistent(p_nd, false);
PB_DS_DEBUG_VERIFY(increasing || strictly_binomial);
base_type::assert_node_consistent(p_nd, false, __file, __line);
if (p_nd == 0)
return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd));
_GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) ==
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd));
PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) ==
static_cast<size_type>(1 << p_nd->m_metadata));
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing);
assert_node_consistent(p_nd->m_p_l_child, true, false);
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing,
__file, __line);
assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line);
if (p_nd->m_p_next_sibling != 0)
{
if (increasing)
{
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);
else
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
<= p_nd->m_p_next_sibling->m_metadata);
}
else
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
> p_nd->m_p_next_sibling->m_metadata);
}
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,8 +43,8 @@ void
PB_DS_CLASS_C_DEC::
pop()
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0)
find_max();
......@@ -59,8 +59,8 @@ pop()
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
}
PB_DS_ASSERT_VALID((*this),true)
}
PB_DS_CLASS_T_DEC
void
......@@ -113,8 +113,8 @@ void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
PB_DS_ASSERT_VALID((*this),true)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::bubble_to_top(it.m_p_nd);
......@@ -124,8 +124,8 @@ erase(point_iterator it)
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
}
PB_DS_ASSERT_VALID((*this),true)
}
PB_DS_CLASS_T_DEC
template<typename Pred>
......@@ -133,14 +133,14 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
if (base_type::empty())
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this),true)
return 0;
}
return 0;
}
base_type::to_linked_list();
......@@ -185,8 +185,8 @@ erase_if(Pred pred)
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
return ersd;
return ersd;
}
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top() const
{
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
PB_DS_ASSERT_VALID((*this),false)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
if (m_p_max == 0)
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max();
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,17 +43,17 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
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);
insert_node(p_nd);
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);
}
PB_DS_CLASS_T_DEC
......@@ -171,13 +171,13 @@ void
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
node_pointer p_nd = it.m_p_nd;
PB_DS_ASSERT_VALID((*this),true)
node_pointer p_nd = it.m_p_nd;
_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);
p_nd->m_value = r_new_val;
......@@ -198,7 +198,7 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
return;
}
......@@ -211,6 +211,6 @@ modify(point_iterator it, const_reference r_new_val)
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
}
PB_DS_ASSERT_VALID((*this),true)
}
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -44,17 +44,17 @@ void
PB_DS_CLASS_C_DEC::
split(Pred pred, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
PB_DS_ASSERT_VALID(other,true)
other.clear();
other.clear();
if (base_type::empty())
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
PB_DS_ASSERT_VALID(other,true)
return;
return;
}
base_type::to_linked_list();
......@@ -86,9 +86,9 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
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;
base_type::m_p_root = 0;
......@@ -114,19 +114,19 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
}
PB_DS_ASSERT_VALID((*this),true)
PB_DS_ASSERT_VALID(other,true)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
PB_DS_ASSERT_VALID((*this),true)
PB_DS_ASSERT_VALID(other,true)
node_pointer p_other = other.m_p_root;
node_pointer p_other = other.m_p_root;
if (p_other != 0)
do
......@@ -147,9 +147,9 @@ join(PB_DS_CLASS_C_DEC& other)
other.m_size = 0;
other.m_p_max = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
}
PB_DS_ASSERT_VALID((*this),true)
PB_DS_ASSERT_VALID(other,true)
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -98,7 +99,15 @@ namespace __gnu_pbds
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_V2F(X) (X)
#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.
template<typename Key,
......@@ -320,7 +329,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
......@@ -369,7 +378,7 @@ namespace __gnu_pbds
inline mapped_reference
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);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
......@@ -384,18 +393,18 @@ namespace __gnu_pbds
resize_base::notify_insert_search_end();
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);
}
_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;
}
inline mapped_reference
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);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start();
......@@ -409,11 +418,11 @@ namespace __gnu_pbds
resize_base::notify_insert_search_end();
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;
}
_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_hash_pair)->second;
}
......@@ -440,7 +449,7 @@ namespace __gnu_pbds
resize_base::notify_inserted(++m_num_used_e);
_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;
}
......@@ -459,7 +468,7 @@ namespace __gnu_pbds
m_entries[r_pos_hash_pair.first] = p_e;
resize_base::notify_inserted(++m_num_used_e);
_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;
}
......@@ -479,9 +488,9 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
if (p_e == 0)
debug_base::check_key_does_not_exist(r_key);
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
debug_base::check_key_exists(r_key);
PB_DS_CHECK_KEY_EXISTS(r_key)
#endif
return &p_e->m_value;
}
......@@ -505,9 +514,9 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
if (p_e == 0)
debug_base::check_key_does_not_exist(r_key);
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
debug_base::check_key_exists(r_key);
PB_DS_CHECK_KEY_EXISTS(r_key)
#endif
return &p_e->m_value;
}
......@@ -568,13 +577,16 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
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
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
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
#ifdef PB_DS_HT_MAP_TRACE_
......@@ -609,6 +621,15 @@ namespace __gnu_pbds
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_/entry_list_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp>
......@@ -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_/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_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -66,7 +66,7 @@ PB_DS_CLASS_NAME() :
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -77,7 +77,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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) :
std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0);
Resize_Policy::notify_cleared();
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
......@@ -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))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
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),
resize_base(other), ranged_hash_fn_base(other),
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))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
__try
{
copy_from_range(other.begin(), other.end());
......@@ -143,7 +140,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
deallocate_all();
__throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -156,8 +153,8 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid());
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
std::swap(m_entries, other.m_entries);
std::swap(m_num_e, other.m_num_e);
......@@ -167,8 +164,8 @@ swap(PB_DS_CLASS_C_DEC& other)
resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
_GLIBCXX_DEBUG_ONLY(assert_valid());
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,16 +43,17 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid() const
assert_valid(const char* __file, int __line) const
{
debug_base::check_size(m_num_used_e);
assert_entry_pointer_array_valid(m_entries);
debug_base::check_size(m_num_used_e, __file, __line);
assert_entry_pointer_array_valid(m_entries, __file, __line);
}
PB_DS_CLASS_T_DEC
void
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;
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
while (p_e != 0)
{
++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;
}
}
_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>
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p, false_type) const
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value)); }
assert_entry_pointer_valid(const entry_pointer p, false_type,
const char* __file, int __line) const
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); }
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,11 +43,12 @@
PB_DS_CLASS_T_DEC
void
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));
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second);
PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
}
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -44,7 +44,7 @@ inline bool
PB_DS_CLASS_C_DEC::
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));
}
......@@ -53,24 +53,24 @@ inline bool
PB_DS_CLASS_C_DEC::
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];
resize_base::notify_erase_search_start();
if (p_e == 0)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
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]);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return true;
}
......@@ -80,18 +80,18 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
if (p_next_e == 0)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
{
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);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return true;
}
resize_base::notify_erase_search_collision();
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -44,14 +44,14 @@ inline bool
PB_DS_CLASS_C_DEC::
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];
resize_base::notify_erase_search_start();
if (p_e == 0)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base:: check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
......@@ -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))
{
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]);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return true;
}
......@@ -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)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
PB_DS_ASSERT_VALID((*this))
return false;
}
......@@ -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))
{
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);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return true;
}
resize_base::notify_erase_search_collision();
......
// -*- 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
// 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
PB_DS_CLASS_C_DEC::
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);
}
......@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC::
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);
}
......
// -*- 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
// 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>
PB_DS_CLASS_C_DEC::
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 size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
......@@ -60,11 +60,11 @@ insert_imp(const_reference r_val, false_type)
resize_base::notify_insert_search_end();
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);
}
_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);
}
// -*- 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
// 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>
PB_DS_CLASS_C_DEC::
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);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
......@@ -61,11 +61,11 @@ insert_imp(const_reference r_val, true_type)
resize_base::notify_insert_search_end();
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);
}
_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);
}
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw()
__catch(...)
{ }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -79,7 +79,7 @@ void
PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
if (new_size == m_num_e)
return;
......@@ -104,7 +104,7 @@ resize_imp(size_type new_size)
// At this point no exceptions can be thrown.
resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size);
Resize_Policy::notify_resized(new_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -123,10 +123,11 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res
}
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);
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>
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -51,6 +51,15 @@
#include <ext/throw_allocator.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 detail
......@@ -98,13 +107,15 @@ namespace __gnu_pbds
clear();
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
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
check_size(size_type size) const;
check_size(size_type size, const char* file, int line) const;
void
swap(PB_DS_CLASS_C_DEC& other);
......@@ -114,11 +125,11 @@ namespace __gnu_pbds
split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC& other);
join(PB_DS_CLASS_C_DEC& other, bool with_cleanup = true);
private:
void
assert_valid() const;
assert_valid(const char* file, int line) const;
const_key_set_iterator
find(const_key_reference r_key) const;
......@@ -133,24 +144,24 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
debug_map_base()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
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_C_DEC::
~debug_map_base()
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
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())
{
......@@ -169,7 +180,7 @@ namespace __gnu_pbds
std::abort();
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -177,7 +188,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
erase_existing(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
key_set_iterator it = find(r_key);
if (it == m_key_set.end())
{
......@@ -185,7 +196,7 @@ namespace __gnu_pbds
std::abort();
}
m_key_set.erase(it);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -193,36 +204,39 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
m_key_set.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
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())
{
std::cerr << "check_key_exists " << r_key << std::endl;
std::cerr << __file << ':' << __line << ": check_key_exists "
<< r_key << std::endl;
std::abort();
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
check_key_does_not_exist(const_key_reference r_key) const
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())
{
using std::cerr;
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();
}
}
......@@ -230,17 +244,16 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC
inline void
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();
if (size != key_set_size)
{
std::cerr << "check_size " << size
<< " " << key_set_size << std::endl;
std::cerr << __file << ':' << __line << ": check_size " << size
<< " != " << key_set_size << std::endl;
std::abort();
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC
......@@ -248,9 +261,9 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
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);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -258,7 +271,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
typedef const_key_set_iterator iterator_type;
for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it)
if (m_eq(*it, r_key))
......@@ -271,7 +284,7 @@ namespace __gnu_pbds
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
key_set_iterator it = m_key_set.begin();
while (it != m_key_set.end())
{
......@@ -280,13 +293,12 @@ namespace __gnu_pbds
++it;
}
return it;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC
void
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();
while (prime_it != m_key_set.end())
......@@ -295,8 +307,8 @@ namespace __gnu_pbds
++sec_it;
while (sec_it != m_key_set.end())
{
_GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it));
_GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it));
PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it));
PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it));
++sec_it;
}
++prime_it;
......@@ -324,15 +336,18 @@ namespace __gnu_pbds
PB_DS_CLASS_T_DEC
void
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();
while (it != other.m_key_set.end())
{
insert_new(*it);
it = other.m_key_set.erase(it);
if (with_cleanup)
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
......@@ -341,6 +356,9 @@ namespace __gnu_pbds
} // namespace detail
} // namespace __gnu_pbds
#undef PB_DS_DEBUG_VERIFY
#undef PB_DS_ASSERT_VALID
#endif
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -61,7 +62,7 @@ PB_DS_CLASS_NAME()
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -72,7 +73,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn)
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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)
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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,
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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,
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
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,
m_entries(s_entry_allocator.allocate(m_num_e))
{
initialize();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -160,7 +161,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
deallocate_all();
__throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -173,8 +174,8 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid());
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
std::swap(m_num_e, other.m_num_e);
std::swap(m_num_used_e, other.m_num_used_e);
std::swap(m_entries, other.m_entries);
......@@ -182,8 +183,8 @@ swap(PB_DS_CLASS_C_DEC& other)
hash_eq_fn_base::swap(other);
resize_base::swap(other);
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
_GLIBCXX_DEBUG_ONLY(assert_valid());
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,10 +43,11 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid() const
assert_valid(const char* __file, int __line) const
{
debug_base::check_size(m_num_used_e);
assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator);
debug_base::check_size(m_num_used_e, __file, __line);
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>
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC
void
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;
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
case valid_entry_status:
{
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;
break;
}
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
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,7 +43,8 @@
PB_DS_CLASS_T_DEC
void
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;
......@@ -58,20 +59,20 @@ assert_entry_array_valid(const entry_array a_entries, true_type) const
case valid_entry_status:
{
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);
_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;
break;
}
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
// -*- 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
// 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
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
......@@ -86,7 +86,7 @@ erase_if(Pred pred)
}
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -44,7 +44,7 @@ inline bool
PB_DS_CLASS_C_DEC::
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 i;
resize_base::notify_erase_search_start();
......@@ -58,8 +58,7 @@ erase_imp(const_key_reference r_key, false_type)
case empty_entry_status:
{
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)
return false;
}
break;
......
// -*- 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
// 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)
case empty_entry_status:
{
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)
return false;
}
break;
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
PB_DS_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
......@@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC::
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);
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -95,7 +96,14 @@ namespace __gnu_pbds
#ifdef PB_DS_DATA_FALSE_INDICATOR
#define PB_DS_V2F(X) (X)
#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,
typename Mapped,
......@@ -280,7 +288,7 @@ namespace __gnu_pbds
inline std::pair<point_iterator, bool>
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);
}
......@@ -331,7 +339,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
......@@ -406,7 +414,7 @@ namespace __gnu_pbds
_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;
}
......@@ -432,7 +440,7 @@ namespace __gnu_pbds
_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;
}
......@@ -440,7 +448,7 @@ namespace __gnu_pbds
inline mapped_reference
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,
traits_base::m_store_extra_indicator);
......@@ -449,14 +457,14 @@ namespace __gnu_pbds
if (p_e->m_stat != valid_entry_status)
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;
}
inline mapped_reference
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 =
find_ins_pos(key, traits_base::m_store_extra_indicator);
......@@ -465,7 +473,7 @@ namespace __gnu_pbds
return insert_new_imp(value_type(key, mapped_type()),
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;
}
#endif
......@@ -488,17 +496,15 @@ namespace __gnu_pbds
case empty_entry_status:
{
resize_base::notify_find_search_end();
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);)
return 0;
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
return 0;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key))
{
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);
}
break;
......@@ -511,7 +517,7 @@ namespace __gnu_pbds
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();
return 0;
}
......@@ -536,8 +542,7 @@ namespace __gnu_pbds
case empty_entry_status:
{
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;
}
break;
......@@ -547,7 +552,7 @@ namespace __gnu_pbds
key, pos_hash_pair.second))
{
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);
}
break;
......@@ -560,7 +565,7 @@ namespace __gnu_pbds
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();
return 0;
}
......@@ -628,10 +633,12 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
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
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
static entry_allocator s_entry_allocator;
......@@ -651,6 +658,15 @@ namespace __gnu_pbds
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_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp>
......@@ -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_/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_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
......
// -*- 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
// 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)
case empty_entry_status:
{
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;
}
break;
......@@ -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))
{
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;
}
break;
......@@ -101,11 +101,11 @@ insert_imp(const_reference r_val, false_type)
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);
}
_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);
}
// -*- 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
// 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
PB_DS_CLASS_C_DEC::
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);
size_type i;
......@@ -64,7 +64,7 @@ find_ins_pos(const_key_reference r_key, true_type)
case empty_entry_status:
{
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) ?
std::make_pair(pos, pos_hash_pair.second) :
......@@ -80,7 +80,7 @@ find_ins_pos(const_key_reference r_key, true_type)
r_key, pos_hash_pair.second))
{
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);
}
break;
......@@ -108,11 +108,11 @@ insert_imp(const_reference r_val, true_type)
entry_pointer p_e =& m_entries[pos_hash_pair.first];
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);
}
_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);
}
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -71,7 +71,7 @@ do_resize_if_needed_no_throw()
__catch(...)
{ }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -86,7 +86,7 @@ resize_imp(size_type new_size)
if (new_size == m_num_e)
return;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
const size_type old_size = m_num_e;
entry_array a_entries_resized = 0;
......@@ -113,13 +113,15 @@ resize_imp(size_type new_size)
}
// 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);
erase_all_valid_entries(m_entries, old_size);
s_entry_allocator.deallocate(m_entries, old_size);
m_entries = a_entries_resized;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -53,7 +53,7 @@ left_child_next_sibling_heap_() :
m_p_root(0),
m_size(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -63,7 +63,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
m_p_root(0),
m_size(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -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)
{
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_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -83,12 +83,12 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,31 +43,32 @@
PB_DS_CLASS_T_DEC
void
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)
assert_node_consistent(m_p_root, Single_Link_Roots);
assert_size();
assert_iterators();
assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line);
assert_size(__file, __line);
assert_iterators(__file, __line);
}
PB_DS_CLASS_T_DEC
void
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)
return;
assert_node_consistent(p_nd->m_p_l_child, false);
assert_node_consistent(p_nd->m_p_next_sibling, single_link);
assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line);
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)
_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)
return;
......@@ -76,31 +77,26 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const
while (p_child != 0)
{
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;
}
_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
void
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());
if (calc_size == size())
return;
_GLIBCXX_DEBUG_ASSERT(0);
PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size());
}
PB_DS_CLASS_T_DEC
void
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)
return;
_GLIBCXX_DEBUG_ASSERT(0);
PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size);
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -78,7 +78,7 @@ void
PB_DS_CLASS_C_DEC::
to_linked_list()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
node_pointer p_cur = m_p_root;
while (p_cur != 0)
if (p_cur->m_p_l_child != 0)
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -273,10 +273,11 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
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
size_under_node(const_node_pointer p_nd);
......@@ -298,10 +299,10 @@ namespace __gnu_pbds
private:
#ifdef _GLIBCXX_DEBUG
void
assert_iterators() const;
assert_iterators(const char* file, int line) const;
void
assert_size() const;
assert_size(const char* file, int line) const;
static size_type
size_from_node(const_node_pointer p_nd);
......@@ -331,6 +332,15 @@ namespace __gnu_pbds
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_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp>
......@@ -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_/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_T_DEC
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// 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)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME() : m_p_l(0)
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
template<typename It>
......@@ -77,15 +77,12 @@ PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0)
{
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_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(),
#endif
m_p_l(0)
{
__try
......@@ -104,7 +101,7 @@ m_p_l(0)
deallocate_all();
__throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -112,12 +109,12 @@ void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_p_l, other.m_p_l);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,15 +43,15 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_valid() const
assert_valid(const char* __file, int __line) const
{
size_type calc_size = 0;
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;
}
debug_base::check_size(calc_size);
debug_base::check_size(calc_size, __file, __line);
}
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,7 +43,7 @@ inline bool
PB_DS_CLASS_C_DEC::
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)
return false;
......@@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
while (m_p_l != 0 && pred(m_p_l->m_value))
{
......@@ -106,7 +106,7 @@ erase_if(Pred pred)
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;
}
......@@ -116,7 +116,6 @@ PB_DS_CLASS_C_DEC::
erase_next(entry_pointer p_l)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_l != m_p_l);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0);
entry_pointer p_next_l = p_l->m_p_next->m_p_next;
actual_erase_entry(p_l->m_p_next);
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -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)))
{
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;
}
......@@ -71,7 +71,7 @@ find_imp(const_key_reference r_key) const
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;
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -45,21 +45,21 @@ inline std::pair<
PB_DS_CLASS_C_DEC::
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));
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);
}
_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->m_p_next = m_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);
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -217,7 +217,7 @@ namespace __gnu_pbds
operator[](const_key_reference r_key)
{
#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;
#else
insert(r_key);
......@@ -231,7 +231,7 @@ namespace __gnu_pbds
inline point_iterator
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);
return point_iterator(p_e == 0 ? 0: &p_e->m_value);
}
......@@ -239,7 +239,7 @@ namespace __gnu_pbds
inline const_point_iterator
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);
return const_point_iterator(p_e == 0 ? 0: &p_e->m_value);
}
......@@ -268,7 +268,7 @@ namespace __gnu_pbds
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_LU_MAP_TRACE_
......@@ -337,6 +337,22 @@ namespace __gnu_pbds
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_/info_fn_imps.hpp>
#include <ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp>
......@@ -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_/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_C_DEC
#undef PB_DS_TYPES_TRAITS_C_DEC
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -53,7 +53,7 @@ PB_DS_OV_TREE_CLASS_NAME() :
m_a_metadata(0),
m_end_it(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_C_DEC::
......@@ -63,7 +63,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
m_a_metadata(0),
m_end_it(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_C_DEC::
......@@ -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_end_it(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_C_DEC::
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
PB_DS_TREE_TRACE_BASE_C_DEC(other),
#endif
......@@ -93,7 +90,7 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
m_size(0)
{
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
......@@ -123,6 +120,7 @@ copy_from_range(It first_it, It last_it)
map_type m(first_it, last_it);
copy_from_ordered_range(m.begin(), m.end());
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -157,14 +155,11 @@ copy_from_ordered_range(It first_it, It last_it)
update(PB_DS_node_begin_imp(), (node_update* )this);
#ifdef _GLIBCXX_DEBUG
const_iterator dbg_it = m_a_values;
while (dbg_it != m_end_it)
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
{
debug_base::insert_new(PB_DS_V2F(*dbg_it));
dbg_it++;
}
PB_DS_CLASS_C_DEC::assert_valid();
#endif
#endif
}
PB_DS_CLASS_T_DEC
......@@ -210,14 +205,11 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it,
update(PB_DS_node_begin_imp(), (node_update* )this);
#ifdef _GLIBCXX_DEBUG
const_iterator dbg_it = m_a_values;
while (dbg_it != m_end_it)
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
{
debug_base::insert_new(PB_DS_V2F(*dbg_it));
dbg_it++;
}
PB_DS_CLASS_C_DEC::assert_valid();
#endif
#endif
}
PB_DS_CLASS_T_DEC
......@@ -225,10 +217,12 @@ void
PB_DS_CLASS_C_DEC::
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);
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
......@@ -247,9 +241,9 @@ PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~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);
reallocate_metadata((node_update* )this, 0);
reallocate_metadata((node_update*)this, 0);
}
PB_DS_CLASS_T_DEC
......
......@@ -43,40 +43,37 @@
PB_DS_CLASS_T_DEC
void
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)
_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();
std::cout << "av3" << std::endl;
assert_iterators(__file, __line);
}
PB_DS_CLASS_T_DEC
void
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;
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)
{
++iterated_num;
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(*it));)
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it);
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line);
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it;
_GLIBCXX_DEBUG_ASSERT(upper_bound_it == it);
PB_DS_DEBUG_VERIFY(upper_bound_it == it);
if (prev_it != end())
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it)));
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
PB_DS_V2F(*it)));
prev_it = it;
}
_GLIBCXX_DEBUG_ASSERT(iterated_num == m_size);
PB_DS_DEBUG_VERIFY(iterated_num == m_size);
}
#endif
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,10 +43,9 @@ void
PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
if (m_size == 0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return;
}
else
......@@ -59,7 +58,7 @@ clear()
m_a_values = 0;
m_size = 0;
m_end_it = m_a_values;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -68,7 +67,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
#ifdef PB_DS_REGRESSION
typename Allocator::group_adjustor adjust(m_size);
......@@ -76,8 +75,7 @@ erase_if(Pred pred)
size_type new_size = 0;
size_type num_val_ersd = 0;
iterator source_it = m_a_values;
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))
++new_size;
else
......@@ -93,7 +91,7 @@ erase_if(Pred pred)
iterator target_it = a_new_values;
cond_dtor<size_type> cd(a_new_values, target_it, new_size);
_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))
{
......@@ -116,7 +114,7 @@ erase_if(Pred pred)
m_size = new_size;
m_end_it = target_it;
update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return num_val_ersd;
}
......@@ -126,11 +124,11 @@ It
PB_DS_CLASS_C_DEC::
erase_imp(It it)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
if (it == 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
typename Allocator::group_adjustor adjust(m_size);
......@@ -175,7 +173,7 @@ erase_imp(It it)
--m_size;
m_end_it = m_a_values + m_size;
update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return It(ret_it);
}
......
// -*- 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
// 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
PB_DS_CLASS_C_DEC::
size() const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return m_size;
}
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -102,10 +102,20 @@ namespace __gnu_pbds
#ifdef PB_DS_TREE_TRACE
#define PB_DS_TREE_TRACE_BASE_C_DEC \
tree_trace_base<typename Node_And_It_Traits::const_node_iterator, \
typename Node_And_It_Traits::node_iterator, \
tree_trace_base<typename Node_And_It_Traits::const_node_iterator, \
typename Node_And_It_Traits::node_iterator, \
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.
template<typename Key, typename Mapped, class Cmp_Fn,
......@@ -234,16 +244,15 @@ namespace __gnu_pbds
operator[](const_key_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
point_iterator it = lower_bound(r_key);
if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_CHECK_KEY_EXISTS(r_key)
PB_DS_ASSERT_VALID((*this))
return it->second;
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second);
#else
insert(r_key);
......@@ -254,18 +263,17 @@ namespace __gnu_pbds
inline std::pair<point_iterator, bool>
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);
point_iterator it = lower_bound(r_key);
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key));
PB_DS_ASSERT_VALID((*this))
PB_DS_CHECK_KEY_EXISTS(r_key)
return std::make_pair(it, false);
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return std::make_pair(insert_new_val(it, r_value), true);
}
......@@ -295,11 +303,11 @@ namespace __gnu_pbds
iterator pot_it = lower_bound(r_key);
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;
}
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key));
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return pot_it;
}
......@@ -310,15 +318,15 @@ namespace __gnu_pbds
inline point_iterator
find(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
iterator pot_it = lower_bound(r_key);
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;
}
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key));
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
......@@ -412,12 +420,11 @@ namespace __gnu_pbds
inline iterator
insert_new_val(iterator it, const_reference r_value)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
#ifdef PB_DS_REGRESSION
typename Allocator::group_adjustor adjust(m_size);
#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);
......@@ -457,16 +464,16 @@ namespace __gnu_pbds
m_end_it = m_a_values + m_size;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value)));
update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#ifdef _GLIBCXX_DEBUG
void
assert_valid() const;
assert_valid(const char* file, int line) const;
void
assert_iterators() const;
assert_iterators(const char* file, int line) const;
#endif
template<typename It>
......@@ -495,6 +502,12 @@ namespace __gnu_pbds
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_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp>
......@@ -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/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_T_DEC
#undef PB_DS_OV_TREE_CLASS_NAME
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,37 +43,33 @@ void
PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (m_size == 0)
{
other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
}
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin())))
{
value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1))))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
}
if (m_size == 1)
{
value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
......@@ -90,8 +86,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
update(node_begin(), (node_update* )this);
other.value_swap(new_other);
value_swap(new_this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
......@@ -99,14 +95,16 @@ void
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
if (other.m_size == 0)
return;
if (m_size == 0)
{
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
......@@ -129,9 +127,9 @@ join(PB_DS_CLASS_C_DEC& other)
begin(), end());
// No exceptions from this point.
_GLIBCXX_DEBUG_ONLY(debug_base::join(other);)
_GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
value_swap(new_this);
other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
// -*- 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
// 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)
while (first_it != last_it)
push(*(first_it++));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pairing_heap_()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pairing_heap_(const Cmp_Fn& 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_C_DEC::
pairing_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
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_C_DEC::
......
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,11 +43,11 @@
PB_DS_CLASS_T_DEC
void
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::assert_valid();
base_type::assert_valid(__file, __line);
}
#endif
// -*- 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
// software; you can redistribute it and/or modify it under the terms
......@@ -43,17 +43,17 @@ void
PB_DS_CLASS_C_DEC::
pop()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
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)
p_new_root->m_p_prev_or_parent = 0;
base_type::actual_erase_node(base_type::m_p_root);
base_type::m_p_root = p_new_root;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
......@@ -61,11 +61,11 @@ void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
remove_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
......@@ -73,21 +73,18 @@ void
PB_DS_CLASS_C_DEC::
remove_node(node_pointer p_nd)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_new_child = join_node_children(p_nd);
#ifdef _GLIBCXX_DEBUG
if (p_new_child != 0)
base_type::assert_node_consistent(p_new_child, false);
#endif
PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false)
if (p_nd == base_type::m_p_root)
{
if (p_new_child != 0)
p_new_child->m_p_prev_or_parent = 0;
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;
}
......@@ -101,14 +98,14 @@ remove_node(node_pointer p_nd)
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_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;
}
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)
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;
}
......@@ -119,14 +116,14 @@ remove_node(node_pointer p_nd)
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_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;
}
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)
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
......@@ -142,7 +139,7 @@ join_node_children(node_pointer p_nd)
p_ret = forward_join(p_ret, p_ret->m_p_next_sibling);
while (p_ret->m_p_prev_or_parent != p_nd)
p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret);
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret, false);)
PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false)
return p_ret;
}
......@@ -171,7 +168,7 @@ forward_join(node_pointer p_nd, node_pointer p_next)
p_nd->m_p_next_sibling = 0;
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;
}
......@@ -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;
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;
}
p_nd->m_p_next_sibling = 0;
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;
}
......@@ -203,10 +200,10 @@ typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
if (base_type::empty())
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return 0;
}
base_type::to_linked_list();
......@@ -230,7 +227,7 @@ erase_if(Pred pred)
push_imp(p_cur);
p_cur = p_next;
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
PB_DS_ASSERT_VALID((*this))
return ersd;
}
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