+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
* 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
#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
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>
#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
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
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
m_size(0)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
{
initialize();
m_size = other.m_size;
- _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
__try
{
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
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
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
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
- structure_only_assert_valid();
- assert_consistent_with_debug_base();
- assert_size();
- assert_iterators();
+ structure_only_assert_valid(__file, __line);
+ assert_consistent_with_debug_base(__file, __line);
+ assert_size(__file, __line);
+ assert_iterators(__file, __line);
if (m_p_head->m_p_parent == 0)
{
- _GLIBCXX_DEBUG_ASSERT(m_size == 0);
+ PB_DS_DEBUG_VERIFY(m_size == 0);
}
else
{
- _GLIBCXX_DEBUG_ASSERT(m_size > 0);
+ PB_DS_DEBUG_VERIFY(m_size > 0);
}
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-structure_only_assert_valid() const
+structure_only_assert_valid(const char* __file, int __line) const
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head != 0);
+ PB_DS_DEBUG_VERIFY(m_p_head != 0);
if (m_p_head->m_p_parent == 0)
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head);
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
}
else
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head);
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left != m_p_head);
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head);
}
if (m_p_head->m_p_parent != 0)
- assert_node_consistent(m_p_head->m_p_parent);
- assert_min();
- assert_max();
+ assert_node_consistent(m_p_head->m_p_parent, __file, __line);
+ assert_min(__file, __line);
+ assert_max(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_node_consistent(const node_pointer p_nd) const
+assert_node_consistent(const node_pointer p_nd,
+ const char* __file, int __line) const
{
- assert_node_consistent_(p_nd);
+ assert_node_consistent_(p_nd, __file, __line);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_consistent_t
PB_DS_CLASS_C_DEC::
-assert_node_consistent_(const node_pointer p_nd) const
+assert_node_consistent_(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd == 0)
return (std::make_pair((const_pointer)0,(const_pointer)0));
- assert_node_consistent_with_left(p_nd);
- assert_node_consistent_with_right(p_nd);
+ assert_node_consistent_with_left(p_nd, __file, __line);
+ assert_node_consistent_with_right(p_nd, __file, __line);
const std::pair<const_pointer, const_pointer>
- l_range = assert_node_consistent_(p_nd->m_p_left);
+ l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line);
if (l_range.second != 0)
- _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
- PB_DS_V2F(p_nd->m_value)));
+ PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
+ PB_DS_V2F(p_nd->m_value)));
const std::pair<const_pointer, const_pointer>
- r_range = assert_node_consistent_(p_nd->m_p_right);
+ r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line);
if (r_range.first != 0)
- _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
+ PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(*r_range.first)));
- return (std::make_pair((l_range.first != 0)? l_range.first :& p_nd->m_value,(r_range.second != 0)? r_range.second :& p_nd->m_value));
+ return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value,
+ (r_range.second != 0)? r_range.second : &p_nd->m_value);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_node_consistent_with_left(const node_pointer p_nd) const
+assert_node_consistent_with_left(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd->m_p_left == 0)
return;
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd);
- _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
- PB_DS_V2F(p_nd->m_p_left->m_value)));
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd);
+ PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
+ PB_DS_V2F(p_nd->m_p_left->m_value)));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_node_consistent_with_right(const node_pointer p_nd) const
+assert_node_consistent_with_right(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd->m_p_right == 0)
return;
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd);
- _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
- PB_DS_V2F(p_nd->m_value)));
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd);
+ PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
+ PB_DS_V2F(p_nd->m_value)));
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_min() const
+assert_min(const char* __file, int __line) const
{
- assert_min_imp(m_p_head->m_p_parent);
+ assert_min_imp(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_min_imp(const node_pointer p_nd) const
+assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const
{
if (p_nd == 0)
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
return;
}
if (p_nd->m_p_left == 0)
{
- _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_left);
+ PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left);
return;
}
- assert_min_imp(p_nd->m_p_left);
+ assert_min_imp(p_nd->m_p_left, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_max() const
+assert_max(const char* __file, int __line) const
{
- assert_max_imp(m_p_head->m_p_parent);
+ assert_max_imp(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_max_imp(const node_pointer p_nd) const
+assert_max_imp(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd == 0)
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
return;
}
if (p_nd->m_p_right == 0)
{
- _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_right);
+ PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right);
return;
}
- assert_max_imp(p_nd->m_p_right);
+ assert_max_imp(p_nd->m_p_right, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_iterators() const
+assert_iterators(const char* __file, int __line) const
{
size_type iterated_num = 0;
const_iterator prev_it = end();
for (const_iterator it = begin(); it != end(); ++it)
{
++iterated_num;
- _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
+ PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
--upper_bound_it;
- _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd);
+ PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd);
if (prev_it != end())
- _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);
size_type reverse_iterated_num = 0;
const_reverse_iterator reverse_prev_it = rend();
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
++reverse_it)
{
++reverse_iterated_num;
- _GLIBCXX_DEBUG_ASSERT(lower_bound(
+ PB_DS_DEBUG_VERIFY(lower_bound(
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
--upper_bound_it;
- _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
+ PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
if (reverse_prev_it != rend())
- _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
- PB_DS_V2F(*reverse_it)));
+ PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
+ PB_DS_V2F(*reverse_it)));
reverse_prev_it = reverse_it;
}
- _GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size);
+ PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_consistent_with_debug_base() const
+assert_consistent_with_debug_base(const char* __file, int __line) const
{
- debug_base::check_size(m_size);
- assert_consistent_with_debug_base(m_p_head->m_p_parent);
+ debug_base::check_size(m_size, __file, __line);
+ assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_consistent_with_debug_base(const node_pointer p_nd) const
+assert_consistent_with_debug_base(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd == 0)
return;
- debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value));
- assert_consistent_with_debug_base(p_nd->m_p_left);
- assert_consistent_with_debug_base(p_nd->m_p_right);
+ debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line);
+ assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line);
+ assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_size() const
+assert_size(const char* __file, int __line) const
{
- _GLIBCXX_DEBUG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size);
+ PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size);
}
-#endif
+#endif
// -*- C++ -*-
-// 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
_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();
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;
_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
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)
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
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)
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
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;
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
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)
{
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
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;
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
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();
++m_size;
- return (p_new_nd);
+ return p_new_nd;
}
PB_DS_CLASS_T_DEC
{
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
_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();
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);
_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
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);
}
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);
}
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
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;
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();
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;
}
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
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
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>
#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
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
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
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
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();
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
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
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
#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);
}
}
m_size = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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);
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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;
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;
}
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;
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
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
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);
}
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
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
#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
{
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
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
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
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
{
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
}
#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
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,
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);
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
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
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
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
#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:
#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>
#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
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::
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::
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
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
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();
m_p_max = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
- }
+ PB_DS_ASSERT_VALID((*this),true)
+}
PB_DS_CLASS_T_DEC
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);
m_p_max = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
- }
+ PB_DS_ASSERT_VALID((*this),true)
+}
PB_DS_CLASS_T_DEC
template<typename Pred>
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();
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
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
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
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;
m_p_max = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid(true);)
+ PB_DS_ASSERT_VALID((*this),true)
return;
}
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
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();
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;
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
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
#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,
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
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();
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();
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;
}
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;
}
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;
}
#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;
}
#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;
}
#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_
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>
#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
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
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
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
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
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());
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
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);
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
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)
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
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
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
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));
}
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;
}
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
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;
}
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;
}
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;
}
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
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);
}
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
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];
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
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];
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
__catch(...)
{ }
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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;
// 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
}
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
#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
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);
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;
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())
{
std::abort();
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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())
{
std::abort();
}
m_key_set.erase(it);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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();
}
}
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
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
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))
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())
{
++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())
++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;
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
} // 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
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
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
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
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
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
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
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
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);
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
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
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)
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
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;
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
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)
{
}
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
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();
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
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
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
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
#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,
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);
}
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_HT_MAP_TRACE_
_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;
}
_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;
}
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);
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);
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
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;
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;
}
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;
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;
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;
}
#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;
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>
#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
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;
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;
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
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;
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) :
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;
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
__catch(...)
{ }
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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;
}
// 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
m_p_root(0),
m_size(0)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
m_p_root(0),
m_size(0)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
: 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
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
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;
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
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
#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);
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);
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>
#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
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>
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
deallocate_all();
__throw_exception_again;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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
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
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;
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))
{
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;
}
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
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;
}
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
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
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);
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);
}
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);
}
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_LU_MAP_TRACE_
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>
#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
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::
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::
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
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
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
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
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
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
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
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
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
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
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);
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
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))
{
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;
}
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);
--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
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
#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,
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);
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);
}
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;
}
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();
}
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);
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>
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>
#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
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;
}
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
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;
}
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
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
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
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
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
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;
}
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;
}
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
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;
}
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;
}
{
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;
}
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();
push_imp(p_cur);
p_cur = p_next;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return 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
PB_DS_CLASS_C_DEC::
top() const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
return base_type::m_p_root->m_value;
}
// -*- 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
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
+ node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
push_imp(p_new_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return point_iterator(p_new_nd);
+ return point_iterator(p_new_nd);
}
PB_DS_CLASS_T_DEC
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
base_type::make_child_of(base_type::m_p_root, p_nd);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false));
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
base_type::m_p_root = p_nd;
}
else
{
base_type::make_child_of(p_nd, base_type::m_p_root);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
+ PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
}
}
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- remove_node(it.m_p_nd);
+ remove_node(it.m_p_nd);
it.m_p_nd->m_value = r_new_val;
push_imp(it.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
// -*- 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
{
#define PB_DS_CLASS_T_DEC \
- template<typename Value_Type, class Cmp_Fn, class Allocator>
+ template<typename Value_Type, class Cmp_Fn, class Allocator>
#define PB_DS_CLASS_C_DEC \
- pairing_heap_<Value_Type, Cmp_Fn, Allocator>
+ pairing_heap_<Value_Type, Cmp_Fn, Allocator>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_< \
- Value_Type, \
- Cmp_Fn, \
- null_left_child_next_sibling_heap_node_metadata, \
- Allocator, \
- false>
+ left_child_next_sibling_heap_<Value_Type, \
+ Cmp_Fn, \
+ null_left_child_next_sibling_heap_node_metadata, \
+ Allocator, \
+ false>
#else
#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_< \
- Value_Type, \
- Cmp_Fn, \
- null_left_child_next_sibling_heap_node_metadata, \
- Allocator>
+ left_child_next_sibling_heap_<Value_Type, \
+ Cmp_Fn, \
+ null_left_child_next_sibling_heap_node_metadata, \
+ Allocator>
#endif
/**
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
private:
void
remove_node(node_pointer p_nd);
-
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
+ _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
+ __FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp>
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_ASSERT_NODE_CONSISTENT
+#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_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
PB_DS_CLASS_C_DEC::
split(Pred pred, 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();
+ other.clear();
if (base_type::empty())
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
- return;
+ return;
}
base_type::to_linked_list();
p_out = p_next;
}
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID(other)
- node_pointer p_cur = base_type::m_p_root;
+ node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
p_cur = p_next;
}
- _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)
- if (other.m_p_root == 0)
- {
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ if (other.m_p_root == 0)
+ {
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
- return;
- }
+ return;
+ }
if (base_type::m_p_root == 0)
base_type::m_p_root = other.m_p_root;
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
{
base_type::make_child_of(base_type::m_p_root, other.m_p_root);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(other.m_p_root, false));
+ PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false)
base_type::m_p_root = other.m_p_root;
}
else
{
base_type::make_child_of(other.m_p_root, base_type::m_p_root);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
+ PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
}
base_type::m_size += other.m_size;
other.m_p_root = 0;
other.m_size = 0;
- _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, 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
m_size(0)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
m_size(0)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
{
initialize();
m_size = other.m_size;
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID(other)
if (other.m_p_head->m_p_parent == 0)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return;
}
__try
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_parent->m_p_parent = m_p_head;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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((e_access_traits& )(*this), (e_access_traits& )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
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
if (m_p_head->m_p_parent != 0)
- m_p_head->m_p_parent->assert_valid(this);
- assert_iterators();
- assert_reverse_iterators();
+ m_p_head->m_p_parent->assert_valid(this, __file, __line);
+ assert_iterators(__file, __line);
+ assert_reverse_iterators(__file, __line);
if (m_p_head->m_p_parent == 0)
{
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min == m_p_head);
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max == m_p_head);
- _GLIBCXX_DEBUG_ASSERT(empty());
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head);
+ PB_DS_DEBUG_VERIFY(empty());
return;
}
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type);
- _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type);
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type);
+ PB_DS_DEBUG_VERIFY(!empty());
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_iterators() const
+assert_iterators(const char* __file, int __line) const
{
size_type calc_size = 0;
for (const_iterator it = begin(); it != end(); ++it)
{
++calc_size;
- debug_base::check_key_exists(PB_DS_V2F(*it));
- _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it);
- _GLIBCXX_DEBUG_ASSERT(--upper_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);
+ PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it);
}
- _GLIBCXX_DEBUG_ASSERT(calc_size == m_size);
+ PB_DS_DEBUG_VERIFY(calc_size == m_size);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_reverse_iterators() const
+assert_reverse_iterators(const char* __file, int __line) const
{
size_type calc_size = 0;
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
++calc_size;
const_node_pointer p_nd =
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(PB_DS_V2F(*it));
- _GLIBCXX_DEBUG_ASSERT(p_nd == it.m_p_nd);
+ PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd);
}
- _GLIBCXX_DEBUG_ASSERT(calc_size == m_size);
+ PB_DS_DEBUG_VERIFY(calc_size == m_size);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-recursive_count_leafs(const_node_pointer p_nd)
+recursive_count_leafs(const_node_pointer p_nd,
+ const char* __file, int __line)
{
if (p_nd == 0)
return (0);
if (p_nd->m_type == pat_trie_leaf_node_type)
return (1);
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
+ PB_DS_DEBUG_VERIFY(p_nd->m_type == pat_trie_internal_node_type);
size_type ret = 0;
for (typename internal_node::const_iterator it =
static_cast<const_internal_node_pointer>(p_nd)->begin();
it != static_cast<const_internal_node_pointer>(p_nd)->end();
++it)
- ret += recursive_count_leafs(*it);
+ ret += recursive_count_leafs(*it, __file, __line);
return 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
node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type == pat_trie_internal_node_type)
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key));
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key));
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key));
+ PB_DS_CHECK_KEY_EXISTS(r_key)
erase_leaf(static_cast<leaf_pointer>(p_nd));
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return true;
}
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1);
p_nd->update_prefixes(this);
apply_update(p_nd, (node_update* )this);
- _GLIBCXX_DEBUG_ONLY(p_nd->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(p_nd)
if (p_nd->m_p_parent->m_type == pat_trie_head_node_type)
return;
PB_DS_CLASS_C_DEC::
clear()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
if (empty())
return;
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
erase(const_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it == end())
return it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it == end())
return it;
++ret_it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_CLASS_C_DEC::
erase(const_reverse_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head)
return it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == m_p_head)
return it;
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
erase_if(Pred pred)
{
size_type num_ersd = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
iterator it = begin();
while (it != end())
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- if (pred(*it))
- {
- ++num_ersd;
- it = erase(it);
- }
- else
- ++it;
+ PB_DS_ASSERT_VALID((*this))
+ if (pred(*it))
+ {
+ ++num_ersd;
+ it = erase(it);
+ }
+ else
+ ++it;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return num_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
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key));
+ PB_DS_CHECK_KEY_EXISTS(r_key)
return iterator(p_nd);
}
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
const_node_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key));
+ PB_DS_CHECK_KEY_EXISTS(r_key)
return const_iterator(const_cast<node_pointer>(p_nd));
}
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);)
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
// -*- 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
#ifdef _GLIBCXX_DEBUG
virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits) const;
+ assert_valid_imp(const_e_access_traits_pointer p_traits,
+ const char* file, int line) const;
#endif
public:
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer /*p_traits*/) const
+ assert_valid_imp(const_e_access_traits_pointer /*p_traits*/,
+ const char* __file, int __line) const
{
- _GLIBCXX_DEBUG_ASSERT(false);
+ _GLIBCXX_DEBUG_VERIFY_AT(false,
+ _M_message("Assertion from %1;:%2;")
+ ._M_string(__FILE__)._M_integer(__LINE__),
+ __file, __line);
return subtree_debug_info();
}
#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
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)
split_join_branch_bag bag;
if (!join_prep(other, bag))
{
- _GLIBCXX_DEBUG_ONLY(assert_valid(););
- _GLIBCXX_DEBUG_ONLY(other.assert_valid(););
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return;
}
m_p_head->m_p_parent->m_p_parent = m_p_head;
m_size += other.m_size;
other.initialize();
- _GLIBCXX_DEBUG_ONLY(other.assert_valid(););
+ PB_DS_ASSERT_VALID(other)
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
- _GLIBCXX_DEBUG_ONLY(assert_valid(););
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
{
- _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;
return false;
}
- const bool greater = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(
- m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>(
- other.m_p_head->m_p_min)->value()));
+ const bool greater =
+ synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value()),
+ PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_min)->value()));
- const bool lesser = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(
- other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value()));
+ const bool lesser =
+ synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_max)->value()),
+ PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value()));
if (!greater && !lesser)
__throw_join_error();
rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag);
- _GLIBCXX_DEBUG_ONLY(debug_base::join(other);)
+ _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
return true;
}
if (p_l == 0)
return (p_r);
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == 2);
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2);
return p_ret;
}
split_join_branch_bag& r_bag)
{
#ifdef _GLIBCXX_DEBUG
- const size_type lhs_leafs = recursive_count_leafs(p_l);
- const size_type rhs_leafs = recursive_count_leafs(p_r);
+ const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
+ const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag);
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs);
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret;
}
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
- const size_type lhs_leafs = recursive_count_leafs(p_l);
- const size_type rhs_leafs = recursive_count_leafs(p_r);
+ const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
+ const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this))
{
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
- _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);)
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) ==
+ PB_DS_ASSERT_NODE_VALID(p_ret)
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) ==
lhs_leafs + rhs_leafs);
return p_ret;
}
pref_end(p_new_child), this);
}
- _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this));
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs);
+ PB_DS_ASSERT_NODE_VALID(p_l)
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l;
}
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
- const size_type lhs_leafs = recursive_count_leafs(p_l);
- const size_type rhs_leafs = recursive_count_leafs(p_r);
+ const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
+ const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
#endif
if (p_l->get_e_ind() == p_r->get_e_ind() &&
p_r->~internal_node();
s_internal_node_allocator.deallocate(p_r, 1);
- _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);)
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs);
+ PB_DS_ASSERT_NODE_VALID(p_l)
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l;
}
p_r, 0, r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
- _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(p_l)
return p_l;
}
p_r->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
- _GLIBCXX_DEBUG_ONLY(p_r->assert_valid(this);)
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_r) == lhs_leafs + rhs_leafs);
+ PB_DS_ASSERT_NODE_VALID(p_r)
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs);
return p_r;
}
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
- _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);)
- _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs);
+ PB_DS_ASSERT_NODE_VALID(p_ret)
+ _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs);
return p_ret;
}
if (p_lf != 0 && p_lf->m_type == pat_trie_leaf_node_type &&
synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val)))
{
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(r_val)));
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
+ PB_DS_ASSERT_VALID((*this))
return std::make_pair(iterator(p_lf), false);
}
- _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_val)));
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val))
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1);
cond_dealtor cond(p_new_lf);
++m_size;
update_min_max_for_inserted_leaf(p_new_lf);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(p_new_lf), true);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-keys_diff_ind(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r)
+keys_diff_ind(typename e_access_traits::const_iterator b_l,
+ typename e_access_traits::const_iterator e_l,
+ typename e_access_traits::const_iterator b_r,
+ typename e_access_traits::const_iterator e_r)
{
size_type diff_pos = 0;
while (b_l != e_l)
p_new_nd->add_child(p_r, right_b_it, right_e_it, this);
p_l->m_p_parent = p_new_nd;
p_r->m_p_parent = p_new_nd;
- _GLIBCXX_DEBUG_ONLY(p_new_nd->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(p_new_nd)
return (p_new_nd);
}
// -*- 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
typedef typename base_type::subtree_debug_info subtree_debug_info;
virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer) const;
+ assert_valid_imp(const_e_access_traits_pointer,
+ const char* file, int line) const;
#endif
inline size_type
}
#ifdef _GLIBCXX_DEBUG
+# define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer p_traits) const
+ assert_valid_imp(const_e_access_traits_pointer p_traits,
+ const char* __file, int __line) const
{
- _GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_internal_node_type);
- _GLIBCXX_DEBUG_ASSERT(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
- _GLIBCXX_DEBUG_ASSERT(std::distance(begin(), end()) >= 2);
+ PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_internal_node_type);
+ PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
+ PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2);
for (typename pat_trie_internal_node::const_iterator it = begin();
it != end(); ++it)
{
const_node_pointer p_nd =* it;
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent == this);
- subtree_debug_info child_ret = p_nd->assert_valid_imp(p_traits);
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this);
+ subtree_debug_info child_ret =
+ p_nd->assert_valid_imp(p_traits, __file, __line);
- _GLIBCXX_DEBUG_ASSERT(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
- _GLIBCXX_DEBUG_ASSERT(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
- _GLIBCXX_DEBUG_ASSERT(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
+ PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
+ PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
+ PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
}
return std::make_pair(pref_b_it(), pref_e_it());
}
+# undef PB_DS_DEBUG_VERIFY
#endif
#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
{
#define PB_DS_CLASS_T_DEC \
- template< \
- class Type_Traits, \
- class E_Access_Traits, \
- class Metadata, \
- class Allocator>
+ template<class Type_Traits, \
+ class E_Access_Traits, \
+ class Metadata, \
+ class Allocator>
#define PB_DS_CLASS_C_DEC \
- pat_trie_leaf< \
- Type_Traits, \
- E_Access_Traits, \
- Metadata, \
- Allocator>
-
-#define PB_DS_BASE_C_DEC \
- pat_trie_node_base< \
- Type_Traits, \
- E_Access_Traits, \
- Metadata, \
- Allocator>
+ pat_trie_leaf<Type_Traits, \
+ E_Access_Traits, \
+ Metadata, \
+ Allocator>
+
+#define PB_DS_BASE_C_DEC \
+ pat_trie_node_base<Type_Traits, \
+ E_Access_Traits, \
+ Metadata, \
+ Allocator>
#define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \
- pat_trie_subtree_debug_info< \
- Type_Traits, \
- E_Access_Traits, \
- Allocator>
+ pat_trie_subtree_debug_info<Type_Traits, \
+ E_Access_Traits, \
+ Allocator>
template<typename Type_Traits,
class E_Access_Traits,
#ifdef _GLIBCXX_DEBUG
virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits) const;
+ assert_valid_imp(const_e_access_traits_pointer p_traits,
+ const char* file, int line) const;
virtual
~pat_trie_leaf();
{ return m_value; }
#ifdef _GLIBCXX_DEBUG
+# define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::subtree_debug_info
PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer p_traits) const
+ assert_valid_imp(const_e_access_traits_pointer p_traits,
+ const char* __file, int __line) const
{
- _GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_leaf_node_type);
+ PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_leaf_node_type);
subtree_debug_info ret;
const_reference r_val = value();
return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~pat_trie_leaf() { }
+# undef PB_DS_DEBUG_VERIFY
#endif
#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
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const_e_access_traits_pointer p_traits) const;
+ assert_valid(const_e_access_traits_pointer p_traits,
+ const char* file, int line) const;
virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits) const = 0;
+ assert_valid_imp(const_e_access_traits_pointer p_traits,
+ const char* file, int line) const = 0;
#endif
node_pointer m_p_parent;
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- assert_valid(const_e_access_traits_pointer p_traits) const
- { assert_valid_imp(p_traits); }
+ assert_valid(const_e_access_traits_pointer p_traits,
+ const char* __file, int __line) const
+ { assert_valid_imp(p_traits, __file, __line); }
#endif
#undef PB_DS_CLASS_T_DEC
// -*- 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
split_join_branch_bag&);
size_type
- keys_diff_ind(typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator);
+ keys_diff_ind(typename e_access_traits::const_iterator,
+ typename e_access_traits::const_iterator,
+ typename e_access_traits::const_iterator,
+ typename e_access_traits::const_iterator);
internal_node_pointer
insert_branch(node_pointer, node_pointer, split_join_branch_bag&);
#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;
void
- assert_reverse_iterators() const;
+ assert_reverse_iterators(const char* file, int line) const;
static size_type
- recursive_count_leafs(const_node_pointer);
+ recursive_count_leafs(const_node_pointer,
+ const char* file, int line);
#endif
#ifdef PB_DS_PAT_TRIE_TRACE_
size_type m_size;
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_ASSERT_NODE_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);)
+
+#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
+ recursive_count_leafs(X, __FILE__, __LINE__)
+
+#define PB_DS_CHECK_KEY_EXISTS(_Key) \
+ _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
+
+#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
+ _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
+ __FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp>
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
+#undef PB_DS_CHECK_KEY_EXISTS
+#undef PB_DS_RECURSIVE_COUNT_LEAFS
+#undef PB_DS_ASSERT_NODE_VALID
+#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_NAME
// -*- 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
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)
split_join_branch_bag bag;
leaf_pointer p_split_lf = split_prep(r_key, other, bag);
if (p_split_lf == 0)
{
_GLIBCXX_DEBUG_ASSERT(bag.empty());
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return;
}
other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(),
other.PB_DS_CLASS_C_DEC::end());
m_size -= other.m_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
if (m_size == 0)
{
other.clear();
- _GLIBCXX_DEBUG_ONLY(assert_valid(););
- _GLIBCXX_DEBUG_ONLY(other.assert_valid(););
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return (0);
}
{
other.clear();
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 (0);
}
if (!synth_e_access_traits::cmp_keys(r_key,
PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value())))
{
- _GLIBCXX_DEBUG_ONLY(assert_valid(););
- _GLIBCXX_DEBUG_ONLY(other.assert_valid(););
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return (0);
}
node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag);
- _GLIBCXX_DEBUG_ONLY(p_child_ret->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(p_child_ret)
p_internal_nd->replace_child(p_child_ret, b_it, e_it, this);
apply_update(p_internal_nd, (node_update* )this);
if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1)
{
p_internal_nd->update_prefixes(this);
- _GLIBCXX_DEBUG_ONLY(p_internal_nd->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(p_internal_nd)
apply_update(p_internal_nd, (node_update* )this);
return (p_internal_nd);
}
{
#ifdef _GLIBCXX_DEBUG
if (m_p_head->m_p_parent != 0)
- m_p_head->m_p_parent->assert_valid(this);
+ PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
#endif
const size_type total_num_children =((m_p_head->m_p_parent == 0)? 0 : 1) + num_children;
{
if (m_p_head->m_p_parent != 0)
{
- _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return;
}
m_p_head->m_p_parent =* child_b_it;
m_p_head->m_p_parent->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update* )this);
- _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return;
}
size_type num_inserted = 0;
while (num_inserted++ < num_children)
{
- _GLIBCXX_DEBUG_ONLY((*child_b_it)->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID((*child_b_it))
p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
pref_end(*child_b_it), this);
++child_b_it;
m_p_head->m_p_parent = p_new_root;
p_new_root->m_p_parent = m_p_head;
apply_update(m_p_head->m_p_parent, (node_update* )this);
- _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);)
+ PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
}
// -*- 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
PB_DS_CLASS_NAME()
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(r_cmp_fn)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(r_cmp_fn, r_node_update)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(other)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
base_type::swap(other);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
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
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-assert_node_consistent(const node_pointer p_nd) const
+assert_node_consistent(const node_pointer p_nd, const char* __file,
+ int __line) const
{
if (p_nd == 0)
return 1;
- const size_type l_height = assert_node_consistent(p_nd->m_p_left);
- const size_type r_height = assert_node_consistent(p_nd->m_p_right);
+ const size_type l_height =
+ assert_node_consistent(p_nd->m_p_left, __file, __line);
+ const size_type r_height =
+ assert_node_consistent(p_nd->m_p_right, __file, __line);
if (p_nd->m_red)
{
- _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_left));
- _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_right));
+ PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left));
+ PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right));
}
- _GLIBCXX_DEBUG_ASSERT(l_height == r_height);
+ PB_DS_DEBUG_VERIFY(l_height == r_height);
return (p_nd->m_red ? 0 : 1) + l_height;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
- base_type::assert_valid();
+ base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head;
- _GLIBCXX_DEBUG_ASSERT(p_head->m_red);
+ PB_DS_DEBUG_VERIFY(p_head->m_red);
if (p_head->m_p_parent != 0)
{
- _GLIBCXX_DEBUG_ASSERT(!p_head->m_p_parent->m_red);
- assert_node_consistent(p_head->m_p_parent);
+ PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red);
+ assert_node_consistent(p_head->m_p_parent, __file, __line);
}
}
// -*- 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
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it == base_type::end())
return it;
iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head)
return it;
reverse_iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
iterator it = base_type::begin();
while (it != base_type::end())
++it;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
{
remove_node(p_nd);
base_type::actual_erase_node(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
// -*- 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
PB_DS_CLASS_C_DEC::
insert(const_reference r_value)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = base_type::insert_leaf(r_value);
if (ins_pair.second == true)
{
ins_pair.first.m_p_nd->m_red = true;
- _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
insert_fixup(ins_pair.first.m_p_nd);
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return ins_pair;
}
// -*- 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
operator[](const_key_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair =
base_type::insert_leaf(value_type(r_key, mapped_type()));
if (ins_pair.second == true)
{
ins_pair.first.m_p_nd->m_red = true;
- _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);)
insert_fixup(ins_pair.first.m_p_nd);
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
#else
insert(r_key);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
size_type
- assert_node_consistent(const node_pointer) const;
+ assert_node_consistent(const node_pointer, const char* file,
+ int line) const;
#endif
inline static bool
split_at_node(node_pointer, PB_DS_CLASS_C_DEC&);
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp>
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
+#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_NAME
// -*- 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
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
if (base_type::join_prep(other) == false)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return;
}
const node_pointer p_x = other.split_min();
join_imp(p_x, other.m_p_head->m_p_parent);
base_type::join_finish(other);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(base_type::assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
p_x->m_red = true;
base_type::initialize_min_max();
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
base_type::update_to_top(p_x, (node_update* )this);
insert_fixup(p_x);
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid());
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
- _GLIBCXX_DEBUG_ONLY(base_type::assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid());
- _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();)
-
- if (base_type::split_prep(r_key, other) == false)
- {
- _GLIBCXX_DEBUG_ONLY(assert_valid());
- _GLIBCXX_DEBUG_ONLY(other.assert_valid());
- return;
- }
+ if (base_type::split_prep(r_key, other) == false)
+ {
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+ return;
+ }
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
+ PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
node_pointer p_nd = upper_bound(r_key).m_p_nd;
do
{
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
split_at_node(p_nd, other);
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();)
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
+ PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
p_nd = p_next_nd;
}
while (p_nd != base_type::m_p_head);
base_type::split_finish(other);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type::initialize_min_max();
other.join_imp(p_nd, p_r);
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid());
- _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid());
+ PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
+ PB_DS_STRUCT_ONLY_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
PB_DS_CLASS_C_DEC::
rc_binomial_heap_()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc_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::
base_type::find_max();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
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)
- base_type::swap(other);
+ base_type::swap(other);
m_rc.swap(other.m_rc);
- _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, 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
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
- base_type::assert_valid(false);
+ base_type::assert_valid(false, __file, __line);
if (!base_type::empty())
{
- _GLIBCXX_DEBUG_ASSERT(base_type::m_p_max != 0);
- base_type::assert_max();
+ PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0);
+ base_type::assert_max(__file, __line);
}
- m_rc.assert_valid();
+ m_rc.assert_valid(__file, __line);
if (m_rc.empty())
{
- base_type::assert_valid(true);
- _GLIBCXX_DEBUG_ASSERT(next_2_pointer(base_type::m_p_root) == 0);
+ base_type::assert_valid(true, __file, __line);
+ PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0);
return;
}
while (p_nd != 0)
{
- _GLIBCXX_DEBUG_ASSERT(*it == p_nd);
+ PB_DS_DEBUG_VERIFY(*it == p_nd);
const_node_pointer p_next = p_nd->m_p_next_sibling;
- _GLIBCXX_DEBUG_ASSERT(p_next != 0);
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_next->m_metadata);
- _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0 ||
+ PB_DS_DEBUG_VERIFY(p_next != 0);
+ PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata);
+ PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 ||
p_next->m_metadata < p_next->m_p_next_sibling->m_metadata);
--it;
p_nd = next_2_pointer(next_after_0_pointer(p_nd));
}
- _GLIBCXX_DEBUG_ASSERT(it + 1 == m_rc.begin());
+ PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin());
}
PB_DS_CLASS_T_DEC
// -*- 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
make_binomial_heap();
const size_type ersd = base_type::erase_if(pred);
base_type::find_max();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
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
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- make_0_exposed();
+ make_0_exposed();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
+ node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
p_nd->m_p_l_child = p_nd->m_p_prev_or_parent = 0;
p_nd->m_metadata = 0;
if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0)
m_rc.push(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return point_iterator(p_nd);
+ return point_iterator(p_nd);
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
modify(point_iterator it, const_reference r_new_val)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- make_binomial_heap();
+ make_binomial_heap();
base_type::modify(it, r_new_val);
base_type::find_max();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
// -*- 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
#ifndef PB_DS_RC_HPP
#define PB_DS_RC_HPP
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
namespace __gnu_pbds
{
namespace detail
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc() : m_over_top(0)
- { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+ { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0)
- { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+ { PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline 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)
const size_type over_top = std::max(m_over_top, other.m_over_top);
std::swap(m_a_entries[i], other.m_a_entries[i]);
std::swap(m_over_top, other.m_over_top);
- _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
PB_DS_CLASS_C_DEC::
push(entry p_nd)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries);
m_a_entries[m_over_top++] = p_nd;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
pop()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
--m_over_top;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
top() const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
return *(m_a_entries + m_over_top - 1);
}
PB_DS_CLASS_C_DEC::
empty() const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return m_over_top == 0;
}
PB_DS_CLASS_C_DEC::
clear()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
m_over_top = 0;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- assert_valid() const
- { _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); }
+ assert_valid(const char* __file, int __line) const
+ { PB_DS_DEBUG_VERIFY(m_over_top < max_entries); }
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
} // namespace detail
} // namespace __gnu_pbds
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_ASSERT_VALID
#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
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
rc_t m_rc;
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp>
+#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_BASE_C_DEC
-
#undef PB_DS_RC_C_DEC
} // namespace detail
} // namespace __gnu_pbds
// -*- 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
PB_DS_CLASS_C_DEC::
split(Pred pred, 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)
make_binomial_heap();
other.make_binomial_heap();
base_type::find_max();
other.find_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
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)
- make_binomial_heap();
+ make_binomial_heap();
other.make_binomial_heap();
base_type::join(other);
base_type::find_max();
other.find_max();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+}
* Contains a resize trigger implementation.
*/
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
hash_load_check_resize_trigger(float load_min, float load_max)
: m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0),
m_next_grow_size(0), m_resize_needed(false)
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_start()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_collision()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_find_search_end()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_start()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_collision()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_insert_search_end()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_start()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_collision()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
notify_erase_search_end()
-{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
inline void
{
m_resize_needed = (num_entries >= m_next_grow_size);
size_base::set_size(num_entries);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
{
size_base::set_size(num_entries);
m_resize_needed = num_entries <= m_next_shrink_size;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
is_resize_needed() const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return m_resize_needed;
}
<< "5 " << m_next_grow_size << std::endl;
#endif
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
m_next_shrink_size = new_shrink_size;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
notify_cleared()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
size_base::set_size(0);
m_resize_needed = (0 < m_next_shrink_size);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_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)
size_base::swap(other);
std::swap(m_load_min, other.m_load_min);
std::swap(m_next_grow_size, other.m_next_grow_size);
std::swap(m_next_shrink_size, other.m_next_shrink_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
{ std::abort(); }
#ifdef _GLIBCXX_DEBUG
+# define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
_GLIBCXX_DEBUG_ASSERT(m_load_max > m_load_min);
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= m_next_shrink_size);
}
+# undef PB_DS_DEBUG_VERIFY
#endif
+#undef PB_DS_ASSERT_VALID
// -*- 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
PB_DS_CLASS_NAME()
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(r_cmp_fn)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(r_cmp_fn, r_node_update)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
base_type(other)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
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)
base_type::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
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
- base_type::assert_valid();
+ base_type::assert_valid(__file, __line);
const node_pointer p_head = base_type::m_p_head;
- assert_special_imp(p_head);
+ assert_special_imp(p_head, __file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_special_imp(const node_pointer p_nd) const
+assert_special_imp(const node_pointer p_nd,
+ const char* __file, int __line) const
{
if (p_nd == 0)
return;
if (p_nd == base_type::m_p_head)
{
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_special);
- assert_special_imp(p_nd->m_p_parent);
+ PB_DS_DEBUG_VERIFY(p_nd->m_special);
+ assert_special_imp(p_nd->m_p_parent, __file, __line);
return;
}
- _GLIBCXX_DEBUG_ASSERT(!p_nd->m_special);
- assert_special_imp(p_nd->m_p_left);
- assert_special_imp(p_nd->m_p_right);
+ PB_DS_DEBUG_VERIFY(!p_nd->m_special);
+ assert_special_imp(p_nd->m_p_left, __file, __line);
+ assert_special_imp(p_nd->m_p_right, __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
PB_DS_CLASS_C_DEC::
erase(iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it == base_type::end())
return it;
iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase(reverse_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
if (it.m_p_nd == base_type::m_p_head)
return (it);
reverse_iterator ret_it = it;
++ret_it;
erase_node(it.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ret_it;
}
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
size_type num_ersd = 0;
iterator it = base_type::begin();
while (it != base_type::end())
else
++it;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return num_ersd;
}
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
splay(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
node_pointer p_l = p_nd->m_p_left;
base_type::m_p_head->m_p_parent = p_l;
if (p_l != 0)
p_l->m_p_parent = base_type::m_p_head;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
return;
}
p_target_r->m_p_left = p_l;
if (p_l != 0)
p_l->m_p_parent = p_target_r;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
apply_update(p_target_r, (node_update* )this);
}
// -*- 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
PB_DS_CLASS_C_DEC::
find_imp(const_key_reference r_key)
{
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
+ __LINE__);)
node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
PB_DS_CLASS_C_DEC::
find_imp(const_key_reference r_key) const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::m_p_head->m_p_parent;
while (p_nd != 0)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2010i, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
PB_DS_CLASS_C_DEC::
insert(const_reference r_value)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
std::pair<point_iterator, bool> ins_pair = insert_leaf_imp(r_value);
ins_pair.first.m_p_nd->m_special = false;
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
splay(ins_pair.first.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid());
+ PB_DS_ASSERT_VALID((*this))
return ins_pair;
}
PB_DS_CLASS_C_DEC::
insert_leaf_imp(const_reference r_value)
{
- _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
+ __LINE__);)
if (base_type::m_size == 0)
return std::make_pair(base_type::insert_imp_empty(r_value), true);
if (p_pot == base_type::m_p_head)
return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true);
- _GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(PB_DS_V2F(r_value)));
+ PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
p_nd = p_pot->m_p_left;
if (p_nd == 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
#ifdef _GLIBCXX_DEBUG
{
node_pointer p_head = base_type::m_p_head;
- assert_special_imp(p_head);
+ assert_special_imp(p_head, __FILE__, __LINE__);
}
#endif
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
- if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head)
- {
- base_type::rotate_parent(p_nd);
- _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
- }
- else
- {
- const node_pointer p_parent = p_nd->m_p_parent;
- const node_pointer p_grandparent = p_parent->m_p_parent;
+ if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head)
+ {
+ base_type::rotate_parent(p_nd);
+ _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
+ }
+ else
+ {
+ const node_pointer p_parent = p_nd->m_p_parent;
+ const node_pointer p_grandparent = p_parent->m_p_parent;
#ifdef _GLIBCXX_DEBUG
- const size_type total =
- base_type::recursive_count(p_grandparent);
- _GLIBCXX_DEBUG_ASSERT(total >= 3);
+ const size_type total =
+ base_type::recursive_count(p_grandparent);
+ _GLIBCXX_DEBUG_ASSERT(total >= 3);
#endif
- if (p_parent->m_p_left == p_nd &&
- p_grandparent->m_p_right == p_parent)
- splay_zig_zag_left(p_nd, p_parent, p_grandparent);
- else if (p_parent->m_p_right == p_nd &&
- p_grandparent->m_p_left == p_parent)
- splay_zig_zag_right(p_nd, p_parent, p_grandparent);
- else if (p_parent->m_p_left == p_nd &&
- p_grandparent->m_p_left == p_parent)
- splay_zig_zig_left(p_nd, p_parent, p_grandparent);
- else
- splay_zig_zig_right(p_nd, p_parent, p_grandparent);
- _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
- }
-
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);)
- }
+ if (p_parent->m_p_left == p_nd &&
+ p_grandparent->m_p_right == p_parent)
+ splay_zig_zag_left(p_nd, p_parent, p_grandparent);
+ else if (p_parent->m_p_right == p_nd &&
+ p_grandparent->m_p_left == p_parent)
+ splay_zig_zag_right(p_nd, p_parent, p_grandparent);
+ else if (p_parent->m_p_left == p_nd &&
+ p_grandparent->m_p_left == p_parent)
+ splay_zig_zig_left(p_nd, p_parent, p_grandparent);
+ else
+ splay_zig_zig_right(p_nd, p_parent, p_grandparent);
+ _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
+ }
+
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
+ }
}
PB_DS_CLASS_T_DEC
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_grandparent->m_p_right == p_parent);
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_grandparent->m_p_left == p_parent);
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent);
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent);
apply_update(p_parent, (node_update* )this);
apply_update(p_nd, (node_update* )this);
- _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);)
+ PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
}
// -*- C++ -*-
-// 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
operator[](const_key_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
- _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
std::pair<point_iterator, bool> ins_pair =
insert_leaf_imp(value_type(r_key, mapped_type()));
ins_pair.first.m_p_nd->m_special = false;
- _GLIBCXX_DEBUG_ONLY(base_type::assert_valid());
+ _GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__));
splay(ins_pair.first.m_p_nd);
- _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
#else
insert(r_key);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
void
- assert_special_imp(const node_pointer) const;
+ assert_special_imp(const node_pointer, const char* file, int line) const;
#endif
void
erase_node(node_pointer);
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \
+ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \
+ __FILE__, __LINE__);)
+
+#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
+ _GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(_Key, \
+ __FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp>
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
+#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
+#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_NAME
// -*- 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
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 (base_type::join_prep(other) == false)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return;
}
base_type::join_finish(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
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 (base_type::split_prep(r_key, other) == false)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid());
- _GLIBCXX_DEBUG_ONLY(other.assert_valid());
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
return;
}
apply_update(p_upper_bound, (node_update* )this);
base_type::split_finish(other);
- _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, 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
{
while (first_it != last_it)
push(*(first_it++));
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
m_p_max(0)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
m_p_max(0)
{
initialize();
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))
m_p_max = p_nd;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
base_type::swap(other);
std::swap(m_p_max, other.m_p_max);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
}
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
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_valid() const
+assert_valid(const char* __file, int __line) const
{
- base_type::assert_valid();
- assert_node_consistent(base_type::m_p_root, true);
- assert_max();
- assert_aux_null();
+ base_type::assert_valid(__file, __line);
+ assert_node_consistent(base_type::m_p_root, true, __file, __line);
+ assert_max(__file, __line);
+ assert_aux_null(__file, __line);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_aux_null() const
+assert_aux_null(const char* __file, int __line) const
{
for (size_type i = 0; i < max_rank; ++i)
- _GLIBCXX_DEBUG_ASSERT(m_a_aux[i] == 0);
+ PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0);
}
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)
{
- _GLIBCXX_DEBUG_ASSERT(base_type::empty());
+ PB_DS_DEBUG_VERIFY(base_type::empty());
return;
}
- _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
- _GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == 0);
- _GLIBCXX_DEBUG_ASSERT(m_p_max->m_p_prev_or_parent == 0);
+ PB_DS_DEBUG_VERIFY(!base_type::empty());
+ PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
+ PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 0);
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
- _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 root) const
+assert_node_consistent(const_node_pointer p_nd, bool root,
+ const char* __file, int __line) const
{
- base_type::assert_node_consistent(p_nd, root);
+ base_type::assert_node_consistent(p_nd, root, __file, __line);
if (p_nd == 0)
return;
- assert_node_consistent(p_nd->m_p_next_sibling, root);
- assert_node_consistent(p_nd->m_p_l_child, false);
+ assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line);
+ assert_node_consistent(p_nd->m_p_l_child, false, __file, __line);
if (!root)
{
if (p_nd->m_metadata == 0)
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == 0);
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0);
else
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1);
+ PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1);
}
if (p_nd->m_p_l_child != 0)
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd));
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd));
- const bool unmarked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 0) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1);
+ const bool unmarked_valid =
+ (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0)
+ || (p_nd->m_p_l_child != 0
+ && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1);
- const bool marked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 1) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2);
+ const bool marked_valid =
+ (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1)
+ || (p_nd->m_p_l_child != 0
+ && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2);
- _GLIBCXX_DEBUG_ASSERT(unmarked_valid || marked_valid);
+ PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid);
if (root)
- _GLIBCXX_DEBUG_ASSERT(unmarked_valid);
+ PB_DS_DEBUG_VERIFY(unmarked_valid);
}
#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
PB_DS_CLASS_C_DEC::
pop()
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
base_type::actual_erase_node(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
inline void
++i;
}
- _GLIBCXX_DEBUG_ONLY(assert_aux_null();)
- }
+ PB_DS_ASSERT_AUX_NULL((*this))
+}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
erase(point_iterator it)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_nd = it.m_p_nd;
base_type::actual_erase_node(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
template<typename Pred>
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();)
+ if (base_type::empty())
+ {
+ PB_DS_ASSERT_VALID((*this))
- return 0;
- }
+ return 0;
+ }
base_type::to_linked_list();
p_cur = p_next;
}
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return ersd;
+ return ersd;
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rank_bound()
{
- const std::size_t* const p_upper =
- std::upper_bound( g_a_rank_bounds, g_a_rank_bounds + num_distinct_rank_bounds, base_type::m_size);
+ using namespace std;
+ const size_t* const p_upper =
+ _GLIBCXX_STD_A::upper_bound(g_a_rank_bounds,
+ g_a_rank_bounds + num_distinct_rank_bounds,
+ base_type::m_size);
if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds)
return max_rank;
// -*- 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
PB_DS_CLASS_C_DEC::
top() const
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
return m_p_max->m_value;
// -*- 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
PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
+ node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
p_nd->m_metadata = 0;
m_p_max = base_type::m_p_root = p_nd;
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return point_iterator(p_nd);
+ return point_iterator(p_nd);
}
p_nd->m_p_next_sibling = base_type::m_p_root;
update_max(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return point_iterator(p_nd);
+ return point_iterator(p_nd);
}
PB_DS_CLASS_T_DEC
make_root(node_pointer p_nd)
{
p_nd->m_metadata =
- p_nd->m_p_l_child == 0?
+ p_nd->m_p_l_child == 0 ?
0 :
1 + p_nd->m_p_l_child->m_metadata;
}
make_root(p_y);
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, true);)
- }
+ PB_DS_ASSERT_NODE_CONSISTENT(p_y, true)
+}
PB_DS_CLASS_T_DEC
inline void
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
_GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;)
- _GLIBCXX_DEBUG_ASSERT(p_w != 0);
+ _GLIBCXX_DEBUG_ASSERT(p_w != 0);
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0);
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0);
p_y->m_p_l_child = 0;
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);)
- }
+ PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
+}
PB_DS_CLASS_T_DEC
inline void
p_y->m_metadata = 0;
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);)
- }
+ PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
+}
PB_DS_CLASS_T_DEC
inline void
p_y->m_p_next_sibling = p_w;
p_w->m_p_prev_or_parent = p_y;
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);)
- }
+ PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
+}
PB_DS_CLASS_T_DEC
inline void
--p_y->m_metadata;
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);)
- }
+ PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
+}
PB_DS_CLASS_T_DEC
inline 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))
node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
make_root_and_link(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return;
+ return;
}
if (p_nd->m_p_prev_or_parent == 0)
{
update_max(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
- return;
+ return;
}
node_pointer p_y = p_nd->m_p_prev_or_parent;
make_root_and_link(p_nd);
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+ PB_DS_ASSERT_VALID((*this))
+}
PB_DS_CLASS_T_DEC
inline 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
PB_DS_CLASS_C_DEC::
split(Pred pred, 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();
+ other.clear();
if (base_type::empty())
{
- _GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
- return;
+ return;
}
base_type::to_linked_list();
p_out = p_next;
}
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ PB_DS_ASSERT_VALID(other)
- node_pointer p_cur = base_type::m_p_root;
+ node_pointer p_cur = base_type::m_p_root;
m_p_max = 0;
p_cur = p_next;
}
- _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)
- node_pointer p_other = other.m_p_root;
+ node_pointer p_other = other.m_p_root;
while (p_other != 0)
{
other.m_size = 0;
other.m_p_max = 0;
- _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
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
void
- assert_max() const;
+ assert_max(const char* file, int line) const;
#endif
#ifdef PB_DS_THIN_HEAP_TRACE_
#ifdef _GLIBCXX_DEBUG
void
- assert_node_consistent(const_node_pointer p_nd, bool root) const;
+ assert_node_consistent(const_node_pointer p_nd, bool root,
+ const char* file, int line) const;
void
- assert_aux_null() const;
+ assert_aux_null(const char* file, int line) const;
#endif
private:
/* Pot's good, let's play */
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
+ _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
+ __FILE__, __LINE__);)
+
+#define PB_DS_ASSERT_AUX_NULL(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp>
#include <ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp>
+#undef PB_DS_DEBUG_VERIFY
+#undef PB_DS_ASSERT_AUX_NULL
+#undef PB_DS_ASSERT_NODE_CONSISTENT
+#undef PB_DS_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_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
#ifdef _GLIBCXX_DEBUG
void
- assert_valid() const;
+ assert_valid(const char* file, int line) const;
#endif
float m_load_min;