Commit 1b24692f by Benjamin Kosnik Committed by Benjamin Kosnik

erase_store_hash_fn_imps.hpp: Formatting fixes.

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

	* include/ext/pb_ds/detail/cc_hash_table_map_/
	erase_store_hash_fn_imps.hpp: Formatting fixes.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	constructor_destructor_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	insert_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	resize_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	constructor_destructor_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	insert_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	entry_list_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	find_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	debug_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	cond_key_dtor_entry_dealtor.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	debug_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	erase_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	resize_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/head.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/leaf.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/node_base.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	erase_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	constructor_destructor_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	insert_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	resize_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	constructor_destructor_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	insert_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	iterator_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	find_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	find_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	debug_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	erase_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	resize_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/
	policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/node.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/traits.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/
	entry_metadata_base.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/
	iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/node.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/traits.hpp: Same.

From-SVN: r117281
parent 45538136
2006-09-28 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/pb_ds/detail/cc_hash_table_map_/
erase_store_hash_fn_imps.hpp: Formatting fixes.
* include/ext/pb_ds/detail/cc_hash_table_map_/
constructor_destructor_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
insert_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
policy_access_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
resize_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
constructor_destructor_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
insert_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
entry_list_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
find_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
debug_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
constructor_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
cond_key_dtor_entry_dealtor.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
debug_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
erase_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
iterators_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/
resize_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/head.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/leaf.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/node_base.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
erase_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
constructor_destructor_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
insert_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
policy_access_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
resize_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
constructor_destructor_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
insert_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
iterator_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
find_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
find_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
debug_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
constructor_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
erase_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
resize_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/
policy_access_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/node.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same.
* include/ext/pb_ds/detail/splay_tree_/traits.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/
entry_metadata_base.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/
iterators_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/node.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/rb_tree_map_/traits.hpp: Same.
2006-09-28 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h: Use __atomic_add_dispatch and
......
......@@ -75,44 +75,26 @@ namespace pb_ds
template<typename Value_Type, class Cmp_Fn, class Allocator>
class binomial_heap_ : public PB_DS_BASE_C_DEC
{
private:
typedef PB_DS_BASE_C_DEC base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::const_node_pointer const_node_pointer;
public:
typedef Value_Type value_type;
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef Value_Type value_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::const_point_iterator const_point_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::cmp_fn cmp_fn;
typedef typename base_type::allocator allocator;
public:
binomial_heap_();
binomial_heap_(const Cmp_Fn& r_cmp_fn);
......
......@@ -50,9 +50,7 @@ template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator==(const Other_HT_Map_Type& other) const
{
return (cmp_with_other(other));
}
{ return cmp_with_other(other); }
PB_DS_CLASS_T_DEC
template<typename Other_Map_Type>
......@@ -61,27 +59,26 @@ PB_DS_CLASS_C_DEC::
cmp_with_other(const Other_Map_Type& other) const
{
if (size() != other.size())
return (false);
return false;
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
const_key_reference r_key =(const_key_reference)PB_DS_V2F(*it);
const_key_reference r_key = const_key_reference(PB_DS_V2F(*it));
const_mapped_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_hash_indicator);
if (p_mapped_value == NULL)
return (false);
return false;
#ifdef PB_DS_DATA_TRUE_INDICATOR
if (p_mapped_value->second != it->second)
return (false);
return false;
#endif
}
return (true);
return true;
}
PB_DS_CLASS_T_DEC
......@@ -89,6 +86,4 @@ template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator!=(const Other_HT_Map_Type& other) const
{
return (!operator==(other));
}
{ return !operator==(other); }
......@@ -49,12 +49,8 @@ namespace pb_ds
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename HT_Map>
#define PB_DS_CLASS_C_DEC \
PB_DS_CKDED_CLASS_NAME< \
HT_Map>
#define PB_DS_CLASS_T_DEC template<typename HT_Map>
#define PB_DS_CLASS_C_DEC PB_DS_CKDED_CLASS_NAME<HT_Map>
/**
* A conditional key destructor, used for exception handling.
......@@ -64,12 +60,9 @@ namespace pb_ds
{
public:
typedef typename HT_Map::entry entry;
typedef typename HT_Map::entry_allocator entry_allocator;
typedef typename HT_Map::key_type key_type;
public:
inline
PB_DS_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e);
......@@ -93,10 +86,8 @@ namespace pb_ds
PB_DS_CLASS_T_DEC
inline
PB_DS_CLASS_C_DEC::
PB_DS_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e) :
m_p_a(p_a),
m_p_e(p_e),
m_key_destruct(false),
PB_DS_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e)
: m_p_a(p_a), m_p_e(p_e), m_key_destruct(false),
m_no_action_destructor(false)
{ }
......@@ -104,17 +95,13 @@ namespace pb_ds
inline void
PB_DS_CLASS_C_DEC::
set_key_destruct()
{
m_key_destruct = true;
}
{ m_key_destruct = true; }
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
set_no_action_destructor()
{
m_no_action_destructor = true;
}
{ m_no_action_destructor = true; }
PB_DS_CLASS_T_DEC
inline
......@@ -123,10 +110,8 @@ namespace pb_ds
{
if (m_no_action_destructor)
return;
if (m_key_destruct)
m_p_e->m_value.first.~key_type();
m_p_a->deallocate(m_p_e, 1);
}
......
......@@ -143,7 +143,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
{
copy_from_range(other.begin(), other.end());
}
catch (...)
catch(...)
{
deallocate_all();
throw;
......
......@@ -51,11 +51,10 @@ PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>)
{
// Following lines might throw an exception.
entry_pointer p_e = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_p_next = m_entries[pos];
m_entries[pos] = p_e;
p->m_p_next = m_entries[pos];
m_entries[pos] = p;
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
}
......@@ -51,13 +51,12 @@ PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_reference r_val, size_type pos, true_type)
{
// Following lines might throw an exception.
entry_pointer p_e = get_entry(r_val,
traits_base::s_no_throw_copies_indicator);
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_p_next = m_entries[pos];
p_e->m_hash = ranged_hash_fn_base::operator()((const_key_reference)(PB_DS_V2F(p_e->m_value))).second;
p->m_p_next = m_entries[pos];
p->m_hash = ranged_hash_fn_base::operator()((const_key_reference)(PB_DS_V2F(p->m_value))).second;
m_entries[pos] = p_e;
m_entries[pos] = p;
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
}
......@@ -49,8 +49,7 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e,
store_hash_false_type) const
{ map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); }
assert_entry_pointer_valid(const entry_pointer p, store_hash_false_type) const
{ map_debug_base::check_key_exists(PB_DS_V2F(p->m_value)); }
#endif
......@@ -49,11 +49,10 @@
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const
{
map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value));
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);
}
......
......@@ -52,9 +52,7 @@ deallocate_links_in_list(entry_pointer p_e)
while (p_e != NULL)
{
entry_pointer p_dealloc_e = p_e;
p_e = p_e->m_p_next;
s_entry_allocator.deallocate(p_dealloc_e, 1);
}
}
......@@ -65,14 +63,11 @@ PB_DS_CLASS_C_DEC::
get_entry(const_reference r_val, no_throw_copies_true_type)
{
// Following line might throw an exception.
entry_pointer p_e = s_entry_allocator.allocate(1);
// Following lines* cannot* throw an exception.
new (&p_e->m_value) value_type(r_val);
return (p_e);
return p_e;
}
PB_DS_CLASS_T_DEC
......@@ -81,18 +76,13 @@ PB_DS_CLASS_C_DEC::
get_entry(const_reference r_val, no_throw_copies_false_type)
{
// Following line might throw an exception.
entry_pointer p_e = s_entry_allocator.allocate(1);
cond_dealtor_t cond(p_e);
// Following lines might throw an exception.
new (&p_e->m_value) value_type(r_val);
cond.set_no_action();
return (p_e);
return p_e;
}
PB_DS_CLASS_T_DEC
......@@ -100,11 +90,8 @@ inline void
PB_DS_CLASS_C_DEC::
rels_entry(entry_pointer p_e)
{
/* The following lines cannot throw exceptions
* (unless if key-data dtors do). */
// The following lines cannot throw exceptions (unless if key-data dtors do).
p_e->m_value.~value_type();
s_entry_allocator.deallocate(p_e, 1);
}
......@@ -49,15 +49,11 @@ inline void
PB_DS_CLASS_C_DEC::
erase_entry_pointer(entry_pointer& r_p_e)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(
PB_DS_V2F(r_p_e->m_value)));
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(PB_DS_V2F(r_p_e->m_value)));
entry_pointer p_e = r_p_e;
r_p_e = r_p_e->m_p_next;
rels_entry(p_e);
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
resize_base::notify_erased(--m_num_used_e);
}
......@@ -68,34 +64,24 @@ inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
typedef typename PB_DS_TYPES_TRAITS_C_DEC::const_reference const_reference;
size_type num_ersd = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
const_reference;
while (m_entries[pos] != NULL&&
pred(m_entries[pos]->m_value))
while (m_entries[pos] != NULL && pred(m_entries[pos]->m_value))
{
++num_ersd;
entry_pointer p_next_e = m_entries[pos]->m_p_next;
erase_entry_pointer(m_entries[pos]);
m_entries[pos] = p_next_e;
}
entry_pointer p_e = m_entries[pos];
while (p_e != NULL&& p_e->m_p_next != NULL)
while (p_e != NULL && p_e->m_p_next != NULL)
{
if (pred(p_e->m_p_next->m_value))
{
++num_ersd;
erase_entry_pointer(p_e->m_p_next);
}
else
......@@ -104,8 +90,7 @@ erase_if(Pred pred)
}
do_resize_if_needed_no_throw();
return (num_ersd);
return num_ersd;
}
PB_DS_CLASS_T_DEC
......@@ -116,9 +101,7 @@ clear()
for (size_type pos = 0; pos < m_num_e; ++pos)
while (m_entries[pos] != NULL)
erase_entry_pointer(m_entries[pos]);
do_resize_if_needed_no_throw();
resize_base::notify_cleared();
}
......
......@@ -41,8 +41,8 @@
/**
* @file erase_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions, when the hash
* value is not stored.
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
......@@ -51,9 +51,7 @@ PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (erase_in_pos_imp(r_key,
ranged_hash_fn_base::operator()(r_key)));
return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
}
PB_DS_CLASS_T_DEC
......@@ -62,77 +60,47 @@ PB_DS_CLASS_C_DEC::
erase_in_pos_imp(const_key_reference r_key, size_type pos)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
entry_pointer p_e = m_entries[pos];
entry_pointer p_e = m_entries[pos];
resize_base::notify_erase_search_start();
if (p_e == NULL)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return false;
}
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
r_key))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists(r_key);)
erase_entry_pointer(m_entries[pos]);
_GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_exists(r_key);)
erase_entry_pointer(m_entries[pos]);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true);
return true;
}
while (true)
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == NULL)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return false;
}
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_next_e->m_value),
r_key))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists(r_key);)
erase_entry_pointer(p_e->m_p_next);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true);
return true;
}
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
......
......@@ -41,8 +41,8 @@
/**
* @file erase_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions, when the hash
* value is stored.
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
......@@ -51,83 +51,50 @@ 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();)
entry_pointer p_e = m_entries[r_pos_hash_pair.first];
entry_pointer p_e = m_entries[r_pos_hash_pair.first];
resize_base::notify_erase_search_start();
if (p_e == NULL)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_does_not_exist(
r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return false;
}
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
p_e->m_hash,
r_key,
r_pos_hash_pair.second))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
r_key, r_pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
r_key);)
erase_entry_pointer(m_entries[r_pos_hash_pair.first]);
_GLIBCXX_DEBUG_ONLY(map_debug_base::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();)
return (true);
return true;
}
while (true)
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == NULL)
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return false;
}
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_next_e->m_value),
p_next_e->m_hash,
r_key,
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value),
p_next_e->m_hash, r_key,
r_pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::
check_key_exists(
r_key);)
erase_entry_pointer(p_e->m_p_next);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true);
return true;
}
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
......
......@@ -50,8 +50,7 @@ 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));
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
......@@ -60,23 +59,19 @@ PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer( r_key, traits_base::m_store_extra_indicator));
return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key,
traits_base::m_store_extra_indicator);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find_end()
{
return (NULL);
}
{ return NULL; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC::
find_end() const
{
return (NULL);
}
{ return NULL; }
......@@ -41,7 +41,7 @@
/**
* @file find_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s find related functions, when the hash
* value is stored.
* Contains implementations of cc_ht_map_'s find related functions,
* when the hash value is stored.
*/
......@@ -42,41 +42,33 @@
/**
* @file info_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container info related
* functions.
* functions.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_num_used_e);
}
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (m_entry_allocator.max_size());
}
{ return m_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (size() == 0);
}
{ return (size() == 0); }
PB_DS_CLASS_T_DEC
template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator==(const Other_HT_Map_Type& other) const
{
return (cmp_with_other(other));
}
{ return cmp_with_other(other); }
PB_DS_CLASS_T_DEC
template<typename Other_Map_Type>
......@@ -85,27 +77,25 @@ PB_DS_CLASS_C_DEC::
cmp_with_other(const Other_Map_Type& other) const
{
if (size() != other.size())
return (false);
return false;
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
const_key_reference r_key =(const_key_reference)PB_DS_V2F(*it);
const_mapped_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_hash_indicator);
if (p_mapped_value == NULL)
return (false);
return false;
#ifdef PB_DS_DATA_TRUE_INDICATOR
if (p_mapped_value->second != it->second)
return (false);
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
return false;
#endif
}
return (true);
return true;
}
PB_DS_CLASS_T_DEC
......@@ -113,6 +103,4 @@ template<typename Other_HT_Map_Type>
bool
PB_DS_CLASS_C_DEC::
operator!=(const Other_HT_Map_Type& other) const
{
return (!operator==(other));
}
{ return !operator==(other); }
......@@ -41,49 +41,36 @@
/**
* @file insert_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions, when the hash
* value is not stored.
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline std::pair<
typename PB_DS_CLASS_C_DEC::point_iterator,
bool>
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, store_hash_false_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
const_key_reference r_key = PB_DS_V2F(r_val);
const_key_reference r_key = PB_DS_V2F(r_val);
const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
while (p_e != NULL&&
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
while (p_e != NULL && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
r_key))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != NULL)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
return (
std::make_pair( & p_e->m_value, false));
return std::make_pair(&p_e->m_value, false);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (std::make_pair(
insert_new_imp(r_val, pos),
true));
return std::make_pair(insert_new_imp(r_val, pos), true);
}
......@@ -41,51 +41,37 @@
/**
* @file insert_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions, when the hash
* value is stored.
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline std::pair<
typename PB_DS_CLASS_C_DEC::point_iterator,
bool>
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, store_hash_true_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
const_key_reference r_key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
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_start();
while (p_e != NULL&&
!hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
p_e->m_hash,
r_key, pos_hash_pair.second))
while (p_e != NULL && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
p_e->m_hash,
key, pos_hash_pair.second))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
resize_base::notify_insert_search_end();
if (p_e != NULL)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
return (std::make_pair( & p_e->m_value, false));
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(key);)
return std::make_pair(&p_e->m_value, false);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (std::make_pair(
insert_new_imp(r_val, pos_hash_pair),
true));
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(key);)
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
}
......@@ -42,7 +42,7 @@
/**
* @file iterators_fn_imps.hpp
* Contains implementations of cc_ht_map_'s iterators related functions, e.g.,
* begin().
* begin().
*/
PB_DS_CLASS_T_DEC
......@@ -60,19 +60,15 @@ begin()
{
pointer p_value;
std::pair<entry_pointer, size_type> pos;
get_start_it_state(p_value, pos);
return (iterator(p_value, pos, this));
return iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (s_end_it);
}
{ return s_end_it; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
......@@ -81,17 +77,13 @@ begin() const
{
pointer p_value;
std::pair<entry_pointer, size_type> pos;
get_start_it_state(p_value, pos);
return (const_iterator(p_value, pos, this));
return const_iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (s_const_end_it);
}
{ return s_const_end_it; }
......@@ -49,62 +49,46 @@ PB_DS_CLASS_T_DEC
Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Comb_Hash_Fn&
PB_DS_CLASS_C_DEC::
get_comb_hash_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Comb_Hash_Fn&
PB_DS_CLASS_C_DEC::
get_comb_hash_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy() const
{
return (*this);
}
{ return *this; }
......@@ -50,21 +50,16 @@ PB_DS_CLASS_C_DEC::
do_resize_if_needed()
{
if (!resize_base::is_resize_needed())
return (false);
resize_imp(resize_base::get_new_size( m_num_e, m_num_used_e));
return (true);
return false;
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
return true;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
do_resize(size_type size)
{
resize_imp(resize_base::get_nearest_larger_size(
size));
}
{ resize_imp(resize_base::get_nearest_larger_size(size)); }
PB_DS_CLASS_T_DEC
inline void
......@@ -76,13 +71,13 @@ do_resize_if_needed_no_throw()
try
{
resize_imp(resize_base::get_new_size( m_num_e, m_num_used_e));
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
}
catch(...)
{ }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
}
PB_DS_CLASS_T_DEC
void
......@@ -90,67 +85,54 @@ PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
if (new_size == m_num_e)
return;
if (new_size == m_num_e)
return;
const size_type old_size = m_num_e;
entry_pointer_array a_p_entries_resized;
// Following line might throw an exception.
ranged_hash_fn_base::notify_resized(new_size);
try
{
// Following line might throw an exception.
a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size);
m_num_e = new_size;
}
catch(...)
{
ranged_hash_fn_base::notify_resized(old_size);
throw;
}
// 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_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size)
{
std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e,(entry_pointer)NULL);
std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e,
entry_pointer(NULL));
for (size_type pos = 0; pos < old_size; ++pos)
{
entry_pointer p_e = m_entries[pos];
while (p_e != NULL)
p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, traits_base::m_store_extra_indicator);
p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, traits_base::m_store_extra_indicator);
}
m_num_e = new_size;
_GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);)
s_entry_pointer_allocator.deallocate(m_entries, old_size);
s_entry_pointer_allocator.deallocate(m_entries, old_size);
m_entries = a_p_entries_resized;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
}
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp>
......
......@@ -54,10 +54,7 @@ resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
entry_pointer const p_next_e = p_e->m_p_next;
p_e->m_p_next = a_p_entries_resized[hash_pos];
a_p_entries_resized[hash_pos] = p_e;
return (p_next_e);
return p_next_e;
}
......@@ -51,15 +51,10 @@ PB_DS_CLASS_C_DEC::
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, store_hash_true_type)
{
const comp_hash pos_hash_pair =
ranged_hash_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
p_e->m_hash);
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash);
entry_pointer const p_next_e = p_e->m_p_next;
p_e->m_p_next = a_p_entries_resized[pos_hash_pair.first];
a_p_entries_resized[pos_hash_pair.first] = p_e;
return (p_next_e);
return p_next_e;
}
......@@ -49,23 +49,17 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_num_used_e);
}
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (size() == 0);
}
{ return (size() == 0); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_entry_allocator.max_size());
}
{ return s_entry_allocator.max_size(); }
......@@ -51,15 +51,13 @@ void
PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << static_cast<unsigned long>(m_num_e) << " " <<
static_cast<unsigned long>(m_num_used_e) << std::endl;
std::cerr << static_cast<unsigned long>(m_num_e) << " "
<< static_cast<unsigned long>(m_num_used_e) << std::endl;
for (size_type i = 0; i < m_num_e; ++i)
{
std::cerr << static_cast<unsigned long>(i) << " ";
trace_list(m_entries[i]);
std::cerr << std::endl;
}
}
......@@ -70,13 +68,11 @@ PB_DS_CLASS_C_DEC::
trace_list(const_entry_pointer p_l) const
{
size_type iterated_num_used_e = 0;
while (p_l != NULL)
{
std::cerr << PB_DS_V2F(p_l->m_value) << " ";
p_l = p_l->m_p_next;
}
}
#endif // #ifdef PB_DS_HT_MAP_TRACE_
#endif
......@@ -161,7 +161,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
new (m_entries + i) entry(other.m_entries[i]);
}
}
catch (...)
catch(...)
{
deallocate_all();
throw;
......
......@@ -48,16 +48,12 @@
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>)
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
false_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status)k;
entry* const p_e = m_entries + pos;
new (&p_e->m_value) mapped_value_type(r_val);
p_e->m_stat = valid_entry_status;
_GLIBCXX_DEBUG_ONLY(map_debug_base::
insert_new(p_e->m_value.first);)
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(p_e->m_value.first);)
}
......@@ -42,25 +42,19 @@
/**
* @file constructor_destructor_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_type)
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
true_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
entry* const p_e = m_entries + pos;
new (&p_e->m_value) mapped_value_type(r_val);
p_e->m_hash = ranged_probe_fn_base::operator()(
PB_DS_V2F(r_val)).second;
p_e->m_hash = ranged_probe_fn_base::operator()(PB_DS_V2F(r_val)).second;
p_e->m_stat = valid_entry_status;
_GLIBCXX_DEBUG_ONLY(map_debug_base::
insert_new(p_e->m_value.first);)
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(p_e->m_value.first);)
}
......@@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC::
assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) const
{
size_type iterated_num_used_e = 0;
for (size_type pos = 0; pos < m_num_e; ++pos)
{
const_entry_pointer p_e =& a_entries[pos];
const_entry_pointer p_e = &a_entries[pos];
switch(p_e->m_stat)
{
case empty_entry_status:
......@@ -64,20 +62,15 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) con
break;
case valid_entry_status:
{
const_key_reference r_key =
PB_DS_V2F(p_e->m_value);
const_key_reference r_key = PB_DS_V2F(p_e->m_value);
map_debug_base::check_key_exists(r_key);
++iterated_num_used_e;
break;
}
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
}
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e);
}
......
......@@ -41,8 +41,8 @@
/**
* @file erase_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions, when the hash
* value is not stored.
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
......@@ -51,44 +51,31 @@ PB_DS_CLASS_C_DEC::
erase_imp(const_key_reference r_key, false_type)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
resize_base::notify_erase_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()( r_key, hash, i);
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
r_key));
return (false);
return false;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
r_key))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_erase_search_end();
erase_entry(p_e);
do_resize_if_needed_no_throw();
return (true);
return true;
}
break;
case erased_entry_status:
......@@ -96,12 +83,9 @@ erase_imp(const_key_reference r_key, false_type)
default:
_GLIBCXX_DEBUG_ASSERT(0);
};
resize_base::notify_erase_search_collision();
}
resize_base::notify_erase_search_end();
return (false);
return false;
}
......@@ -41,54 +41,41 @@
/**
* @file erase_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions, when the hash
* value is stored.
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
erase_imp(const_key_reference r_key, true_type)
erase_imp(const_key_reference r_key, true_type)
{
const comp_hash pos_hash_pair =
ranged_probe_fn_base::operator()(r_key);
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
size_type i;
resize_base::notify_erase_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos = ranged_probe_fn_base::operator()( r_key, pos_hash_pair.second, i);
const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_erase_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
r_key));
return (false);
return false;
}
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value),
p_e->m_hash,
r_key,
pos_hash_pair.second))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
r_key, pos_hash_pair.second))
{
resize_base::notify_erase_search_end();
erase_entry(p_e);
do_resize_if_needed_no_throw();
return (true);
return true;
}
break;
case erased_entry_status:
......@@ -99,9 +86,7 @@ erase_imp(const_key_reference r_key, true_type)
resize_base::notify_erase_search_collision();
}
resize_base::notify_erase_search_end();
return (false);
return false;
}
......@@ -41,8 +41,8 @@
/**
* @file find_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions, when the hash
* value is not stored.
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
......
......@@ -41,6 +41,6 @@
/**
* @file find_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions, when the hash
* value is stored.
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is stored.
*/
......@@ -457,8 +457,7 @@ namespace pb_ds
const size_type pos = find_ins_pos(key,
traits_base::m_store_extra_indicator);
entry_pointer p_e =& m_entries[pos];
entry_pointer p_e = &m_entries[pos];
if (p_e->m_stat != valid_entry_status)
return insert_new_imp(value_type(key, mapped_type()), pos)->second;
......
......@@ -49,22 +49,16 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_num_used_e);
}
{ return m_num_used_e; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_entry_allocator.max_size());
}
{ return s_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (size() == 0);
}
{ return (size() == 0); }
......@@ -41,8 +41,8 @@
/**
* @file insert_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions, when the hash
* value is not stored.
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
......@@ -51,35 +51,25 @@ PB_DS_CLASS_C_DEC::
find_ins_pos(const_key_reference r_key, store_hash_false_type)
{
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
/* The insertion position is initted to a non-legal value to indicate
* that it has not been initted yet.
*/
size_type ins_pos = m_num_e;
resize_base::notify_insert_search_start();
for (i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()(r_key, hash, i);
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
_GLIBCXX_DEBUG_ASSERT(pos < m_num_e);
entry* const p_e = m_entries + pos;
switch(p_e->m_stat)
{
case empty_entry_status:
{
resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(
map_debug_base::check_key_does_not_exist(r_key);)
return ((ins_pos == m_num_e)? pos : ins_pos);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (ins_pos == m_num_e) ? pos : ins_pos;
}
break;
case erased_entry_status:
......@@ -87,14 +77,11 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
ins_pos = pos;
break;
case valid_entry_status:
if (hash_eq_fn_base::operator()(
PB_DS_V2F(p_e->m_value), r_key))
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
return (pos);
return pos;
}
break;
default:
......@@ -103,13 +90,10 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
resize_base::notify_insert_search_collision();
}
resize_base::notify_insert_search_end();
if (ins_pos == m_num_e)
throw insert_error();
return (ins_pos);
return ins_pos;
}
PB_DS_CLASS_T_DEC
......@@ -118,23 +102,16 @@ PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, store_hash_false_type)
{
const_key_reference r_key = PB_DS_V2F(r_val);
const size_type pos =
find_ins_pos(r_key, traits_base::m_store_extra_indicator);
const size_type pos = find_ins_pos(r_key,
traits_base::m_store_extra_indicator);
if (m_entries[pos].m_stat == valid_entry_status)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
return (std::make_pair(
& (m_entries + pos)->m_value,
false));
return std::make_pair(&(m_entries + pos)->m_value, false);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
return (std::make_pair(
insert_new_imp(r_val, pos),
true));
return std::make_pair(insert_new_imp(r_val, pos), true);
}
......@@ -41,8 +41,8 @@
/**
* @file insert_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions, when the hash
* value is stored.
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
......@@ -70,12 +70,11 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type)
case empty_entry_status:
{
resize_base::notify_insert_search_end();
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return ((ins_pos == m_num_e) ?
std::make_pair(pos, pos_hash_pair.second) :
std::make_pair(ins_pos, pos_hash_pair.second));
return ((ins_pos == m_num_e) ?
std::make_pair(pos, pos_hash_pair.second) :
std::make_pair(ins_pos, pos_hash_pair.second));
}
break;
case erased_entry_status:
......
......@@ -60,19 +60,15 @@ begin()
{
pointer_ p_value;
size_type pos;
get_start_it_state(p_value, pos);
return (iterator(p_value, pos, this));
return iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (s_end_it);
}
{ return s_end_it; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
......@@ -81,17 +77,13 @@ begin() const
{
const_pointer_ p_value;
size_type pos;
get_start_it_state(p_value, pos);
return (const_iterator( p_value, pos, this));
return const_iterator(p_value, pos, this);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (s_const_end_it);
}
{ return s_const_end_it; }
......@@ -49,78 +49,58 @@ PB_DS_CLASS_T_DEC
Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Hash_Fn&
PB_DS_CLASS_C_DEC::
get_hash_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Eq_Fn&
PB_DS_CLASS_C_DEC::
get_eq_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Probe_Fn&
PB_DS_CLASS_C_DEC::
get_probe_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Probe_Fn&
PB_DS_CLASS_C_DEC::
get_probe_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Comb_Probe_Fn&
PB_DS_CLASS_C_DEC::
get_comb_probe_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Comb_Probe_Fn&
PB_DS_CLASS_C_DEC::
get_comb_probe_fn() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Resize_Policy&
PB_DS_CLASS_C_DEC::
get_resize_policy() const
{
return (*this);
}
{ return *this; }
......@@ -73,7 +73,7 @@ do_resize_if_needed_no_throw()
{
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
}
catch (...)
catch(...)
{ }
_GLIBCXX_DEBUG_ONLY(assert_valid();)
......@@ -108,7 +108,7 @@ resize_imp(size_type new_size)
{
resize_imp(a_entries_resized, old_size);
}
catch (...)
catch(...)
{
erase_all_valid_entries(a_entries_resized, new_size);
m_num_e = old_size;
......
......@@ -48,29 +48,21 @@
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash_false_type)
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
store_hash_false_type)
{
const_key_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
for (i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()(r_key, hash, i);
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry_pointer p_new_e = a_entries_resized + pos;
switch(p_new_e->m_stat)
{
case empty_entry_status:
new (&p_new_e->m_value) value_type(p_e->m_value);
p_new_e->m_stat = valid_entry_status;
return;
case erased_entry_status:
_GLIBCXX_DEBUG_ASSERT(0);
......@@ -81,7 +73,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
_GLIBCXX_DEBUG_ASSERT(0);
};
}
throw insert_error();
}
......@@ -48,32 +48,23 @@
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash_true_type)
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
store_hash_true_type)
{
const_key_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash =
ranged_probe_fn_base::operator()(r_key, p_e->m_hash);
size_type hash = ranged_probe_fn_base::operator()(r_key, p_e->m_hash);
size_type i;
for (i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()(r_key, hash, i);
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i);
entry_pointer p_new_e = a_entries_resized + pos;
switch(p_new_e->m_stat)
{
case empty_entry_status:
new (&p_new_e->m_value) value_type(p_e->m_value);
p_new_e->m_hash = hash;
p_new_e->m_stat = valid_entry_status;
return;
case erased_entry_status:
_GLIBCXX_DEBUG_ASSERT(0);
......@@ -84,7 +75,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
_GLIBCXX_DEBUG_ASSERT(0);
};
}
throw insert_error();
}
......@@ -63,4 +63,4 @@ namespace pb_ds
} // namespace detail
} // namespace pb_ds
#endif // #ifndef PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP
#endif
......@@ -50,33 +50,26 @@ PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
if (m_p_l == NULL)
return false;
if (m_p_l == NULL)
return false;
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value)))
{
entry_pointer p_next = m_p_l->m_p_next;
actual_erase_entry(m_p_l);
m_p_l = p_next;
return true;
}
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != NULL)
if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value)))
{
erase_next(p_l);
return true;
}
else
p_l = p_l->m_p_next;
return false;
}
......@@ -95,17 +88,12 @@ PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
size_type num_ersd = 0;
while (m_p_l != NULL&& pred(m_p_l->m_value))
size_type num_ersd = 0;
while (m_p_l != NULL && pred(m_p_l->m_value))
{
entry_pointer p_next = m_p_l->m_p_next;
++num_ersd;
actual_erase_entry(m_p_l);
m_p_l = p_next;
}
......@@ -113,13 +101,11 @@ erase_if(Pred pred)
return num_ersd;
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != NULL)
{
if (pred(p_l->m_p_next->m_value))
{
++num_ersd;
erase_next(p_l);
}
else
......@@ -127,8 +113,7 @@ erase_if(Pred pred)
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
return (num_ersd);
return num_ersd;
}
PB_DS_CLASS_T_DEC
......@@ -139,11 +124,8 @@ erase_next(entry_pointer p_l)
_GLIBCXX_DEBUG_ASSERT(p_l != NULL);
_GLIBCXX_DEBUG_ASSERT(p_l != m_p_l);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != NULL);
entry_pointer p_next_l = p_l->m_p_next->m_p_next;
actual_erase_entry(p_l->m_p_next);
p_l->m_p_next = p_next_l;
}
......@@ -152,11 +134,8 @@ void
PB_DS_CLASS_C_DEC::
actual_erase_entry(entry_pointer p_l)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(
PB_DS_V2F(p_l->m_value));)
p_l->~entry();
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(PB_DS_V2F(p_l->m_value));)
p_l->~entry();
s_entry_allocator.deallocate(p_l, 1);
}
......@@ -51,35 +51,26 @@ find_imp(const_key_reference r_key) const
{
if (m_p_l == NULL)
return NULL;
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(map_debug_base::check_key_exists(r_key);)
return m_p_l;
return m_p_l;
}
entry_pointer p_l = m_p_l;
while (p_l->m_p_next != NULL)
{
entry_pointer p_next = p_l->m_p_next;
if (s_eq_fn(r_key, PB_DS_V2F(p_next->m_value)))
{
if (apply_update(p_next, s_metadata_type_indicator))
{
p_l->m_p_next = p_next->m_p_next;
p_next->m_p_next = m_p_l;
m_p_l = p_next;
return m_p_l;
}
return p_next;
}
else
......@@ -87,8 +78,7 @@ find_imp(const_key_reference r_key) const
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return NULL;
return NULL;
}
PB_DS_CLASS_T_DEC
......@@ -96,15 +86,11 @@ template<typename Metadata>
inline bool
PB_DS_CLASS_C_DEC::
apply_update(entry_pointer p_l, type_to_type<Metadata>)
{
return s_update_policy(p_l->m_update_metadata);
}
{ return s_update_policy(p_l->m_update_metadata); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
apply_update(entry_pointer, type_to_type<null_lu_metadata>)
{
return s_update_policy(s_null_lu_metadata);
}
{ return s_update_policy(s_null_lu_metadata); }
......@@ -48,22 +48,16 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (std::distance(begin(), end()));
}
{ return std::distance(begin(), end()); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_entry_allocator.max_size());
}
{ return s_entry_allocator.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (m_p_l == NULL);
}
{ return (m_p_l == NULL); }
......@@ -52,29 +52,21 @@ PB_DS_CLASS_C_DEC::
insert(const_reference r_val)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
entry_pointer p_l = find_imp(PB_DS_V2F(r_val));
entry_pointer p_l = find_imp(PB_DS_V2F(r_val));
if (p_l != NULL)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
PB_DS_V2F(r_val));)
return std::make_pair(point_iterator(&p_l->m_value), false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(PB_DS_V2F(r_val));)
return std::make_pair(point_iterator(&p_l->m_value), false);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
PB_DS_V2F(r_val));)
p_l = allocate_new_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
_GLIBCXX_DEBUG_ONLY(map_debug_base::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();)
return std::make_pair(point_iterator(&p_l->m_value), true);
return std::make_pair(point_iterator(&p_l->m_value), true);
}
PB_DS_CLASS_T_DEC
......@@ -83,20 +75,13 @@ PB_DS_CLASS_C_DEC::
allocate_new_entry(const_reference r_val, false_type)
{
entry_pointer p_l = s_entry_allocator.allocate(1);
cond_dealtor_t cond(p_l);
new (const_cast<void* >(
static_cast<const void* >(&p_l->m_value)))
new (const_cast<void* >(static_cast<const void* >(&p_l->m_value)))
value_type(r_val);
cond.set_no_action();
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
return p_l;
}
......@@ -106,14 +91,9 @@ PB_DS_CLASS_C_DEC::
allocate_new_entry(const_reference r_val, true_type)
{
entry_pointer p_l = s_entry_allocator.allocate(1);
new (&p_l->m_value) value_type(r_val);
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));)
init_entry_metadata(p_l, s_metadata_type_indicator);
return p_l;
}
......@@ -122,9 +102,7 @@ template<typename Metadata>
inline void
PB_DS_CLASS_C_DEC::
init_entry_metadata(entry_pointer p_l, type_to_type<Metadata>)
{
new (&p_l->m_update_metadata) Metadata(s_update_policy());
}
{ new (&p_l->m_update_metadata) Metadata(s_update_policy()); }
PB_DS_CLASS_T_DEC
inline void
......
......@@ -52,11 +52,9 @@ begin()
if (m_p_l == NULL)
{
_GLIBCXX_DEBUG_ASSERT(empty());
return (end());
return end();
}
return (iterator(&m_p_l->m_value, m_p_l, this));
return iterator(&m_p_l->m_value, m_p_l, this);
}
PB_DS_CLASS_T_DEC
......@@ -67,28 +65,22 @@ begin() const
if (m_p_l == NULL)
{
_GLIBCXX_DEBUG_ASSERT(empty());
return (end());
return end();
}
return (iterator(&m_p_l->m_value, m_p_l,
const_cast<PB_DS_CLASS_C_DEC* >(this)));
return iterator(&m_p_l->m_value, m_p_l, const_cast<PB_DS_CLASS_C_DEC* >(this));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (iterator(NULL, NULL, this));
}
{ return iterator(NULL, NULL, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (const_iterator(NULL, NULL,
const_cast<PB_DS_CLASS_C_DEC* const>(this)));
return const_iterator(NULL, NULL, const_cast<PB_DS_CLASS_C_DEC* const>(this));
}
......@@ -113,47 +113,30 @@ namespace pb_ds
#endif
public PB_DS_TYPES_TRAITS_C_DEC
{
private:
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
struct entry : public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
struct entry
: public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
{
typename PB_DS_TYPES_TRAITS_C_DEC::value_type m_value;
typename traits_base::value_type m_value;
typename Allocator::template rebind<entry>::other::pointer m_p_next;
};
typedef
typename Allocator::template rebind<entry>::other
entry_allocator;
typedef typename Allocator::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
typedef
typename Allocator::template rebind<entry_pointer>::other
entry_pointer_allocator;
typedef typename Allocator::template rebind<entry_pointer>::other entry_pointer_allocator;
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type_;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer pointer_;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_pointer
const_pointer_;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::reference reference_;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
const_reference_;
typedef typename traits_base::value_type value_type_;
typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
#define PB_DS_GEN_POS entry_pointer
......@@ -164,63 +147,39 @@ namespace pb_ds
#undef PB_DS_GEN_POS
public:
typedef typename Allocator::size_type size_type;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
#endif
typedef typename Allocator::difference_type difference_type;
typedef typename traits_base:: no_throw_copies_false_type no_throw_copies_false_type;
typedef Eq_Fn eq_fn;
typedef typename traits_base:: no_throw_copies_true_type no_throw_copies_true_type;
typedef Allocator allocator;
typedef cond_dealtor<entry, Allocator> cond_dealtor_t;
public:
typedef Allocator allocator;
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef Eq_Fn eq_fn;
typedef Update_Policy update_policy;
typedef typename Update_Policy::metadata_type update_metadata;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_type key_type;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_pointer key_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_key_pointer
const_key_pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_reference key_reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_key_reference
const_key_reference;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::mapped_pointer
mapped_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_pointer
const_mapped_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::mapped_reference
mapped_reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference
const_mapped_reference;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::const_pointer const_pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::reference reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
const_reference;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::const_key_pointer const_key_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::const_key_reference const_key_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::const_mapped_reference const_mapped_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef point_iterator_ point_iterator;
......@@ -243,10 +202,9 @@ namespace pb_ds
typedef const_iterator_ const_iterator;
public:
PB_DS_CLASS_NAME();
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other);
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
virtual
~PB_DS_CLASS_NAME();
......@@ -255,7 +213,7 @@ namespace pb_ds
PB_DS_CLASS_NAME(It first_it, It last_it);
void
swap(PB_DS_CLASS_C_DEC& other);
swap(PB_DS_CLASS_C_DEC&);
inline size_type
size() const;
......@@ -279,7 +237,7 @@ namespace pb_ds
}
inline std::pair<point_iterator, bool>
insert(const_reference r_val);
insert(const_reference);
inline point_iterator
find(const_key_reference r_key)
......@@ -298,11 +256,11 @@ namespace pb_ds
}
inline bool
erase(const_key_reference r_key);
erase(const_key_reference);
template<typename Pred>
inline size_type
erase_if(Pred pred);
erase_if(Pred);
void
clear();
......@@ -329,90 +287,65 @@ namespace pb_ds
trace() const;
#endif
private:
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
#endif
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::
no_throw_copies_false_type
no_throw_copies_false_type;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::
no_throw_copies_true_type
no_throw_copies_true_type;
protected:
template<typename It>
void
copy_from_range(It first_it, It last_it);
copy_from_range(It, It);
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
#endif
friend class const_iterator_;
inline entry_pointer
allocate_new_entry(const_reference r_val, false_type);
allocate_new_entry(const_reference, false_type);
inline entry_pointer
allocate_new_entry(const_reference r_val, true_type);
allocate_new_entry(const_reference, true_type);
template<typename Metadata>
inline static void
init_entry_metadata(entry_pointer p_l, type_to_type<Metadata>);
init_entry_metadata(entry_pointer, type_to_type<Metadata>);
inline static void
init_entry_metadata(entry_pointer p_l, type_to_type<null_lu_metadata>);
init_entry_metadata(entry_pointer, type_to_type<null_lu_metadata>);
void
deallocate_all();
void
erase_next(entry_pointer p_l);
erase_next(entry_pointer);
void
actual_erase_entry(entry_pointer p_l);
actual_erase_entry(entry_pointer);
void
inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const
{
r_pos = r_pos->m_p_next;
r_p_value = (r_pos == NULL)? NULL :& r_pos->m_value;
r_p_value = (r_pos == NULL) ? NULL : &r_pos->m_value;
}
template<typename Metadata>
inline static bool
apply_update(entry_pointer p_l, type_to_type<Metadata>);
apply_update(entry_pointer, type_to_type<Metadata>);
inline static bool
apply_update(entry_pointer p_l, type_to_type<null_lu_metadata>);
apply_update(entry_pointer, type_to_type<null_lu_metadata>);
inline entry_pointer
find_imp(const_key_reference r_key) const;
private:
mutable entry_pointer m_p_l;
typedef cond_dealtor< entry, Allocator> cond_dealtor_t;
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
#endif
friend class const_iterator_;
find_imp(const_key_reference) const;
static entry_allocator s_entry_allocator;
static Eq_Fn s_eq_fn;
static Update_Policy s_update_policy;
static type_to_type<update_metadata> s_metadata_type_indicator;
static null_lu_metadata s_null_lu_metadata;
mutable entry_pointer m_p_l;
};
#include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp>
......@@ -426,10 +359,9 @@ namespace pb_ds
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_TYPES_TRAITS_C_DEC
#undef PB_DS_TYPES_TRAITS_C_DEC
#undef PB_DS_MAP_DEBUG_BASE_C_DEC
#undef PB_DS_CLASS_NAME
#undef PB_DS_V2F
#undef PB_DS_EP2VP
#undef PB_DS_V2S
......
......@@ -52,18 +52,14 @@ PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << m_p_l << std::endl << std::endl;
const_entry_pointer p_l = m_p_l;
while (p_l != NULL)
{
std::cerr << PB_DS_V2F(p_l->m_value) << std::endl;
p_l = p_l->m_p_next;
}
std::cerr << std::endl;
}
#endif // #ifdef PB_DS_LU_MAP_TRACE_
#endif
......@@ -54,7 +54,7 @@ assert_valid() const
std::cout << "av1" << std::endl;
if (m_a_values == NULL || m_end_it == NULL || m_size == 0)
_GLIBCXX_DEBUG_ASSERT(m_a_values == NULL&& m_end_it == NULL && m_size == 0);
_GLIBCXX_DEBUG_ASSERT(m_a_values == NULL && m_end_it == NULL && m_size == 0);
std::cout << "av2" << std::endl;
assert_iterators();
......
......@@ -50,30 +50,23 @@ PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
if (m_size == 0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return;
}
else
{
reallocate_metadata((node_update* )this, 0);
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
}
if (m_size == 0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return;
}
else
{
reallocate_metadata((node_update* )this, 0);
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
m_a_values = NULL;
m_a_values = NULL;
m_size = 0;
m_end_it = m_a_values;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
}
PB_DS_CLASS_T_DEC
template<typename Pred>
......@@ -85,14 +78,11 @@ erase_if(Pred pred)
#ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_size);
#endif // #ifdef PB_DS_REGRESSION
#endif
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)
if (!pred(*source_it))
++new_size;
......@@ -102,35 +92,26 @@ erase_if(Pred pred)
if (new_size == 0)
{
clear();
return (num_val_ersd);
return num_val_ersd;
}
value_vector a_new_values = s_value_alloc.allocate(new_size);
iterator target_it = a_new_values;
cond_dtor<size_type> cd(a_new_values, target_it, new_size);
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear());
for (source_it = begin(); source_it != m_end_it; ++source_it)
{
if (!pred(*source_it))
{
new (const_cast<void* >(
static_cast<const void* >(target_it)))
new (const_cast<void*>(static_cast<const void* >(target_it)))
value_type(*source_it);
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
PB_DS_V2F(*source_it)));
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(*source_it)));
++target_it;
}
}
reallocate_metadata((node_update* )this, new_size);
cd.set_no_action();
{
......@@ -138,16 +119,11 @@ erase_if(Pred pred)
}
m_a_values = a_new_values;
m_size = new_size;
m_end_it = target_it;
update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (num_val_ersd);
return num_val_ersd;
}
PB_DS_CLASS_T_DEC
......@@ -157,21 +133,17 @@ PB_DS_CLASS_C_DEC::
erase_imp(It it)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
if (it == end())
return end();
if (it == end())
return end();
_GLIBCXX_DEBUG_ONLY(
PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));)
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));)
#ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_size);
#endif // #ifdef PB_DS_REGRESSION
#endif
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
value_vector a_values = s_value_alloc.allocate(m_size - 1);
iterator source_it = begin();
iterator source_end_it = end();
iterator target_it = a_values;
......@@ -181,48 +153,36 @@ erase_imp(It it)
_GLIBCXX_DEBUG_ONLY(size_type cnt = 0;)
while (source_it != source_end_it)
{
if (source_it != it)
{
_GLIBCXX_DEBUG_ONLY(++cnt;)
_GLIBCXX_DEBUG_ASSERT(cnt != m_size);
new (const_cast<void* >(
static_cast<const void* >(target_it)))
while (source_it != source_end_it)
{
if (source_it != it)
{
_GLIBCXX_DEBUG_ONLY(++cnt;)
_GLIBCXX_DEBUG_ASSERT(cnt != m_size);
new (const_cast<void* >(static_cast<const void* >(target_it)))
value_type(*source_it);
++target_it;
}
else
ret_it = target_it;
++source_it;
}
++target_it;
}
else
ret_it = target_it;
++source_it;
}
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
reallocate_metadata((node_update* )this, m_size - 1);
cd.set_no_action();
_GLIBCXX_DEBUG_ONLY(
PB_DS_CLASS_C_DEC::erase_existing(PB_DS_V2F(*it));)
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::erase_existing(PB_DS_V2F(*it));)
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
m_a_values = a_values;
--m_size;
m_end_it = m_a_values + m_size;
update(node_begin(), (node_update* )this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (It(ret_it));
return It(ret_it);
}
PB_DS_CLASS_T_DEC
......@@ -231,12 +191,9 @@ PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key)
{
point_iterator it = find(r_key);
if (it == end())
return (false);
return false;
erase(it);
return (true);
return true;
}
......@@ -50,22 +50,17 @@ PB_DS_CLASS_C_DEC::
size() const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (m_size);
return m_size;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_value_alloc.max_size());
}
{ return s_value_alloc.max_size(); }
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (size() == 0);
}
{ return size() == 0; }
......@@ -56,16 +56,14 @@ void
PB_DS_CLASS_C_DEC::
reallocate_metadata(Node_Update_* , size_type new_size)
{
metadata_pointer a_new_metadata_vec =(new_size == 0)? NULL : s_metadata_alloc.allocate(new_size);
metadata_pointer a_new_metadata_vec =(new_size == 0) ? NULL : s_metadata_alloc.allocate(new_size);
if (m_a_metadata != NULL)
{
for (size_type i = 0; i < m_size; ++i)
m_a_metadata[i].~metadata_type();
s_metadata_alloc.deallocate(m_a_metadata, m_size);
}
std::swap(m_a_metadata, a_new_metadata_vec);
}
......@@ -48,45 +48,36 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{
return (PB_DS_node_begin_imp());
}
{ return PB_DS_node_begin_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{
return (PB_DS_node_end_imp());
}
{ return PB_DS_node_end_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_begin()
{
return (PB_DS_node_begin_imp());
}
{ return PB_DS_node_begin_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_end()
{
return (PB_DS_node_end_imp());
}
{ return PB_DS_node_end_imp(); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_begin_imp() const
{
return (const_node_iterator(
const_cast<pointer>(mid_pointer(begin(), end())),
return const_node_iterator(const_cast<pointer>(mid_pointer(begin(), end())),
const_cast<pointer>(begin()),
const_cast<pointer>(end()),(m_a_metadata == NULL)?
NULL :
mid_pointer(m_a_metadata, m_a_metadata + m_size)));
mid_pointer(m_a_metadata, m_a_metadata + m_size));
}
PB_DS_CLASS_T_DEC
......@@ -94,12 +85,8 @@ inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_end_imp() const
{
return (const_node_iterator(
end(),
end(),
end(),(m_a_metadata == NULL)?
NULL :
m_a_metadata + m_size));
return const_node_iterator(end(), end(), end(),
(m_a_metadata == NULL) ? NULL : m_a_metadata + m_size);
}
PB_DS_CLASS_T_DEC
......@@ -107,12 +94,8 @@ inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_begin_imp()
{
return (node_iterator(
mid_pointer(begin(), end()),
begin(),
end(),(m_a_metadata == NULL)?
NULL :
mid_pointer(m_a_metadata, m_a_metadata + m_size)));
return node_iterator(mid_pointer(begin(), end()), begin(), end(),
(m_a_metadata == NULL) ? NULL : mid_pointer(m_a_metadata, m_a_metadata + m_size));
}
PB_DS_CLASS_T_DEC
......@@ -120,11 +103,7 @@ inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_end_imp()
{
return (node_iterator(
end(),
end(),
end(),(m_a_metadata == NULL)?
NULL :
m_a_metadata + m_size));
return node_iterator(end(), end(),
end(),(m_a_metadata == NULL) ? NULL : m_a_metadata + m_size);
}
......@@ -55,7 +55,6 @@ namespace pb_ds
{
namespace detail
{
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
typedef \
static_assert_dumclass<sizeof(static_assert<(bool)(E)>)> \
......
......@@ -64,7 +64,6 @@ namespace pb_ds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, class Cmp_Fn, \
class Node_And_It_Traits, class Allocator>
......@@ -128,21 +127,14 @@ namespace pb_ds
public Node_And_It_Traits::node_update,
public PB_DS_TYPES_TRAITS_C_DEC
{
private:
typedef
typename remove_const<
typename PB_DS_TYPES_TRAITS_C_DEC::value_type>::type
non_const_value_type;
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
typedef
typename Allocator::template rebind<
non_const_value_type>::other
value_allocator;
typedef typename remove_const<typename traits_base::value_type>::type non_const_value_type;
typedef typename Allocator::template rebind<non_const_value_type>::other value_allocator;
typedef typename value_allocator::pointer value_vector;
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
typedef Cmp_Fn cmp_fn_base;
......@@ -150,25 +142,14 @@ namespace pb_ds
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
#endif
typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer mapped_pointer_;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_pointer
const_mapped_pointer_;
typedef typename traits_base::pointer mapped_pointer_;
typedef typename traits_base::const_pointer const_mapped_pointer_;
typedef typename Node_And_It_Traits::metadata_type metadata_type;
typedef
typename Allocator::template rebind<
metadata_type>::other
metadata_allocator;
typedef typename Allocator::template rebind<metadata_type>::other metadata_allocator;
typedef typename metadata_allocator::pointer metadata_pointer;
typedef
typename metadata_allocator::const_reference
const_metadata_reference;
typedef typename metadata_allocator::const_reference const_metadata_reference;
typedef typename metadata_allocator::reference metadata_reference;
typedef
......@@ -177,59 +158,29 @@ namespace pb_ds
public:
typedef Allocator allocator;
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef Cmp_Fn cmp_fn;
typedef typename Node_And_It_Traits::node_update node_update;
typedef Allocator allocator;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_type key_type;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_pointer key_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_key_pointer
const_key_pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_reference key_reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_key_reference
const_key_reference;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::mapped_pointer
mapped_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_pointer
const_mapped_pointer;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::mapped_reference
mapped_reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference
const_mapped_reference;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::const_pointer const_pointer;
typedef typename PB_DS_TYPES_TRAITS_C_DEC::reference reference;
typedef
typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
const_reference;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
typedef typename traits_base::const_key_pointer const_key_pointer;
typedef typename traits_base::key_reference key_reference;
typedef typename traits_base::const_key_reference const_key_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
typedef typename traits_base::const_mapped_reference const_mapped_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
typedef const_pointer const_point_iterator;
......@@ -255,20 +206,20 @@ namespace pb_ds
PB_DS_OV_TREE_CLASS_NAME();
PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn);
PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn&);
PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update);
PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn&, const node_update&);
PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other);
PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
~PB_DS_OV_TREE_CLASS_NAME();
void
swap(PB_DS_CLASS_C_DEC& other);
swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_range(It first_it, It last_it);
copy_from_range(It, It);
inline size_type
max_size() const;
......@@ -342,9 +293,7 @@ namespace pb_ds
inline const_point_iterator
lower_bound(const_key_reference r_key) const
{
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).lower_bound(r_key));
}
{ return const_cast<PB_DS_CLASS_C_DEC& >(*this).lower_bound(r_key); }
inline point_iterator
upper_bound(const_key_reference r_key)
......@@ -384,11 +333,11 @@ namespace pb_ds
{ return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find(r_key)); }
bool
erase(const_key_reference r_key);
erase(const_key_reference);
template<typename Pred>
inline size_type
erase_if(Pred pred);
erase_if(Pred);
inline iterator
erase(iterator it)
......@@ -398,10 +347,10 @@ namespace pb_ds
clear();
void
join(PB_DS_CLASS_C_DEC& other);
join(PB_DS_CLASS_C_DEC&);
void
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other);
split(const_key_reference, PB_DS_CLASS_C_DEC&);
inline iterator
begin()
......@@ -438,25 +387,25 @@ namespace pb_ds
template<typename Node_Update>
void
update(node_iterator it, Node_Update* p_update);
update(node_iterator, Node_Update*);
void
reallocate_metadata(null_node_update_pointer, size_type);
template<typename Node_Update_>
void
reallocate_metadata(Node_Update_* p_update, size_type new_size);
reallocate_metadata(Node_Update_*, size_type);
template<typename It>
void
copy_from_ordered_range(It first_it, It last_it);
copy_from_ordered_range(It, It);
void
value_swap(PB_DS_CLASS_C_DEC& other);
value_swap(PB_DS_CLASS_C_DEC&);
template<typename It>
void
copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it);
copy_from_ordered_range(It, It, It, It);
template<typename Ptr>
inline static Ptr
......@@ -543,16 +492,12 @@ namespace pb_ds
PB_DS_node_end_imp();
private:
value_vector m_a_values;
static value_allocator s_value_alloc;
metadata_pointer m_a_metadata;
static metadata_allocator s_metadata_alloc;
value_vector m_a_values;
metadata_pointer m_a_metadata;
iterator m_end_it;
size_type m_size;
};
......@@ -577,7 +522,6 @@ namespace pb_ds
#undef PB_DS_V2F
#undef PB_DS_EP2VP
#undef PB_DS_V2S
#undef PB_DS_CONST_NODE_ITERATOR_NAME
} // namespace detail
......
......@@ -48,14 +48,10 @@ PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{
return (*this);
}
{ return *this; }
......@@ -50,77 +50,55 @@ 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();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
if (m_size == 0)
{
other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
}
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();)
return;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
}
if (!Cmp_Fn::operator()(
r_key,
PB_DS_V2F(*(end() - 1))))
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1))))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
_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();)
return;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return;
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
iterator it = upper_bound(r_key);
iterator it = upper_bound(r_key);
PB_DS_CLASS_C_DEC new_other(other, other);
new_other.copy_from_ordered_range(it, end());
PB_DS_CLASS_C_DEC new_this(*this, * this);
new_this.copy_from_ordered_range(begin(), it);
// No exceptions from this point.
_GLIBCXX_DEBUG_ONLY(map_debug_base::split(
r_key,(Cmp_Fn& )(*this),
other);)
other.update(other.node_begin(), (node_update* )(&other));
_GLIBCXX_DEBUG_ONLY(map_debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
other.update(other.node_begin(), (node_update* )(&other));
update(node_begin(), (node_update* )this);
other.value_swap(new_other);
value_swap(new_this);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
}
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
}
PB_DS_CLASS_T_DEC
void
......@@ -128,52 +106,38 @@ PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
if (other.m_size == 0)
return;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
if (other.m_size == 0)
return;
if (m_size == 0)
{
value_swap(other);
return;
}
const bool greater = Cmp_Fn::operator()(
PB_DS_V2F(*(end() - 1)),
const bool greater = Cmp_Fn::operator()(PB_DS_V2F(*(end() - 1)),
PB_DS_V2F(*other.begin()));
const bool lesser = Cmp_Fn::operator()(
PB_DS_V2F(*(other.end() - 1)),
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)),
PB_DS_V2F(*begin()));
if (!greater&& !lesser)
throw join_error();
PB_DS_CLASS_C_DEC new_this(*this, * this);
PB_DS_CLASS_C_DEC new_this(*this, *this);
if (greater)
new_this.copy_from_ordered_range(
begin(),
end(),
other.begin(),
other.end());
new_this.copy_from_ordered_range(begin(), end(),
other.begin(), other.end());
else
new_this.copy_from_ordered_range(
other.begin(),
other.end(),
begin(),
end());
new_this.copy_from_ordered_range(other.begin(), other.end(),
begin(), end());
// No exceptions from this point.
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
value_swap(new_this);
value_swap(new_this);
other.clear();
_GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
}
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
}
......@@ -48,64 +48,52 @@ struct iterator : public const_iterator
{
public:
typedef std::forward_iterator_tag iterator_category;
typedef typename Allocator::difference_type difference_type;
typedef node_pointer value_type;
typedef node_pointer_pointer pointer;
typedef node_pointer_reference reference;
public:
inline
iterator(node_pointer_pointer p_p_cur = NULL, node_pointer_pointer p_p_end = NULL) : const_iterator(p_p_cur, p_p_end)
iterator(node_pointer_pointer p_p_cur = NULL,
node_pointer_pointer p_p_end = NULL)
: const_iterator(p_p_cur, p_p_end)
{ }
inline bool
operator==(const iterator& other) const
{
return (const_iterator::m_p_p_cur == other.m_p_p_cur);
}
{ return const_iterator::m_p_p_cur == other.m_p_p_cur; }
inline bool
operator!=(const iterator& other) const
{
return (const_iterator::m_p_p_cur != other.m_p_p_cur);
}
{ return const_iterator::m_p_p_cur != other.m_p_p_cur; }
inline iterator&
operator++()
{
const_iterator::operator++();
return (*this);
return *this;
}
inline iterator
operator++(int)
{
iterator ret_it(*this);
operator++();
return (ret_it);
return ret_it;
}
node_pointer_pointer
operator->()
{
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
return (const_iterator::m_p_p_cur);
return const_iterator::m_p_p_cur;
}
node_pointer
operator*()
{
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
return (*const_iterator::m_p_p_cur);
return *const_iterator::m_p_p_cur;
}
};
......@@ -79,9 +79,7 @@ public:
protected:
leaf_pointer m_p_nd;
bool m_no_action_dtor;
bool m_call_destructor;
};
......@@ -50,34 +50,23 @@ PB_DS_CLASS_C_DEC::
erase(const_key_reference r_key)
{
node_pointer p_nd = find_imp(r_key);
if (p_nd == NULL || p_nd->m_type == pat_trie_internal_node_type)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
r_key));
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::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))
if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
r_key));
return (false);
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
return false;
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
erase_leaf(static_cast<leaf_pointer>(p_nd));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (true);
return true;
}
PB_DS_CLASS_T_DEC
......@@ -86,19 +75,15 @@ PB_DS_CLASS_C_DEC::
erase_fixup(internal_node_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1);
if (std::distance(p_nd->begin(), p_nd->end()) == 1)
{
node_pointer p_parent = p_nd->m_p_parent;
if (p_parent == m_p_head)
m_p_head->m_p_parent =* p_nd->begin();
else
{
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type);
node_pointer p_new_child =* p_nd->begin();
static_cast<internal_node_pointer>(p_parent)->replace_child(
p_new_child,
pref_begin(p_new_child),
......@@ -106,31 +91,24 @@ erase_fixup(internal_node_pointer p_nd)
this);
}
(*p_nd->begin())->m_p_parent = p_nd->m_p_parent;
p_nd->~internal_node();
s_internal_node_allocator.deallocate(p_nd, 1);
if (p_parent == m_p_head)
return;
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type);
p_nd = static_cast<internal_node_pointer>(p_parent);
}
while (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);)
if (p_nd->m_p_parent->m_type == pat_trie_head_node_type)
return;
if (p_nd->m_p_parent->m_type == pat_trie_head_node_type)
return;
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type ==
pat_trie_internal_node_type);
......@@ -146,11 +124,8 @@ actual_erase_leaf(leaf_pointer p_l)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_l->value())));
p_l->~leaf();
s_leaf_allocator.deallocate(p_l, 1);
}
......@@ -160,20 +135,15 @@ PB_DS_CLASS_C_DEC::
clear()
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
if (empty())
return;
if (empty())
return;
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
PB_DS_CLASS_T_DEC
void
......@@ -183,29 +153,21 @@ clear_imp(node_pointer p_nd)
if (p_nd->m_type == pat_trie_internal_node_type)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
for (typename internal_node::iterator it =
static_cast<internal_node_pointer>(p_nd)->begin();
it != static_cast<internal_node_pointer>(p_nd)->end();
++it)
{
node_pointer p_child =* it;
clear_imp(p_child);
}
s_internal_node_allocator.deallocate(
static_cast<internal_node_pointer>(p_nd), 1);
s_internal_node_allocator.deallocate(static_cast<internal_node_pointer>(p_nd), 1);
return;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
static_cast<leaf_pointer>(p_nd)->~leaf();
s_leaf_allocator.deallocate(
static_cast<leaf_pointer>(p_nd), 1);
s_leaf_allocator.deallocate(static_cast<leaf_pointer>(p_nd), 1);
}
PB_DS_CLASS_T_DEC
......@@ -216,19 +178,14 @@ erase(const_iterator it)
_GLIBCXX_DEBUG_ONLY(assert_valid());
if (it == end())
return (it);
return it;
const_iterator ret_it = 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());
return (ret_it);
return ret_it;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
......@@ -240,19 +197,13 @@ erase(iterator it)
_GLIBCXX_DEBUG_ONLY(assert_valid());
if (it == end())
return (it);
return it;
iterator ret_it = 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());
return (ret_it);
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
......@@ -264,19 +215,14 @@ erase(const_reverse_iterator it)
_GLIBCXX_DEBUG_ONLY(assert_valid());
if (it.m_p_nd == m_p_head)
return (it);
return it;
const_reverse_iterator ret_it = 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());
return (ret_it);
return ret_it;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
......@@ -288,19 +234,14 @@ erase(reverse_iterator it)
_GLIBCXX_DEBUG_ONLY(assert_valid());
if (it.m_p_nd == m_p_head)
return (it);
return it;
reverse_iterator ret_it = 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());
return (ret_it);
return ret_it;
}
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
......@@ -311,19 +252,15 @@ PB_DS_CLASS_C_DEC::
erase_if(Pred pred)
{
size_type num_ersd = 0;
_GLIBCXX_DEBUG_ONLY(assert_valid();)
iterator it = begin();
iterator it = begin();
while (it != end())
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
if (pred(*it))
{
++num_ersd;
it = erase(it);
}
else
......@@ -331,8 +268,7 @@ erase_if(Pred pred)
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
return (num_ersd);
return num_ersd;
}
PB_DS_CLASS_T_DEC
......@@ -341,18 +277,14 @@ PB_DS_CLASS_C_DEC::
erase_leaf(leaf_pointer p_l)
{
update_min_max_for_erased_leaf(p_l);
if (p_l->m_p_parent->m_type == pat_trie_head_node_type)
{
_GLIBCXX_DEBUG_ASSERT(size() == 1);
clear();
return;
}
_GLIBCXX_DEBUG_ASSERT(size() > 1);
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type ==
pat_trie_internal_node_type);
......@@ -360,9 +292,7 @@ erase_leaf(leaf_pointer p_l)
static_cast<internal_node_pointer>(p_l->m_p_parent);
p_parent->remove_child(p_l);
erase_fixup(p_parent);
actual_erase_leaf(p_l);
}
......@@ -375,27 +305,21 @@ update_min_max_for_erased_leaf(leaf_pointer p_l)
{
m_p_head->m_p_min = m_p_head;
m_p_head->m_p_max = m_p_head;
return;
}
if (p_l == static_cast<const_leaf_pointer>(m_p_head->m_p_min))
{
iterator it(p_l);
++it;
m_p_head->m_p_min = it.m_p_nd;
return;
}
if (p_l == static_cast<const_leaf_pointer>(m_p_head->m_p_max))
{
iterator it(p_l);
--it;
m_p_head->m_p_max = it.m_p_nd;
}
}
......@@ -50,28 +50,22 @@ PB_DS_CLASS_C_DEC::
find(const_key_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
node_pointer p_nd = find_imp(r_key);
node_pointer p_nd = find_imp(r_key);
if (p_nd == NULL || p_nd->m_type != pat_trie_leaf_node_type)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (end());
return end();
}
if (synth_e_access_traits::equal_keys(
PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()),
r_key))
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
return (iterator(p_nd));
return iterator(p_nd);
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (end());
return end();
}
PB_DS_CLASS_T_DEC
......@@ -81,29 +75,22 @@ find(const_key_reference r_key) const
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
const_node_pointer p_nd =
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
const_node_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
if (p_nd == NULL || p_nd->m_type != pat_trie_leaf_node_type)
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (end());
return end();
}
if (synth_e_access_traits::equal_keys(
PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()),
r_key))
if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
r_key));
return (const_iterator(const_cast<node_pointer>(p_nd)));
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
return const_iterator(const_cast<node_pointer>(p_nd));
}
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
return (end());
return end();
}
PB_DS_CLASS_T_DEC
......@@ -125,17 +112,13 @@ find_imp(const_key_reference r_key)
while (p_nd->m_type != pat_trie_leaf_node_type)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
node_pointer p_next_nd =
static_cast<internal_node_pointer>(p_nd)->get_child_node( b_it, e_it, this);
node_pointer p_next_nd = static_cast<internal_node_pointer>(p_nd)->get_child_node(b_it, e_it, this);
if (p_next_nd == NULL)
return (p_nd);
return p_nd;
p_nd = p_next_nd;
}
return (p_nd);
return p_nd;
}
PB_DS_CLASS_T_DEC
......@@ -156,31 +139,23 @@ lower_bound_imp(const_key_reference r_key)
synth_e_access_traits::end(r_key);
size_type checked_ind = 0;
while (true)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
{
if (!synth_e_access_traits::cmp_keys(
PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()),
r_key))
return (p_nd);
if (!synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
return p_nd;
iterator it(p_nd);
++it;
return (it.m_p_nd);
return it.m_p_nd;
}
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
const size_type new_checked_ind =
static_cast<internal_node_pointer>(p_nd)->get_e_ind();
p_nd =
static_cast<internal_node_pointer>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this);
checked_ind = new_checked_ind;
}
}
......@@ -189,17 +164,14 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
lower_bound(const_key_reference r_key)
{
return (point_iterator(lower_bound_imp(r_key)));
}
{ return point_iterator(lower_bound_imp(r_key)); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_point_iterator
PB_DS_CLASS_C_DEC::
lower_bound(const_key_reference r_key) const
{
return (const_point_iterator(
const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key)));
return const_point_iterator(const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key));
}
PB_DS_CLASS_T_DEC
......@@ -210,17 +182,14 @@ upper_bound(const_key_reference r_key)
point_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
!synth_e_access_traits::cmp_keys(
PB_DS_V2F(*l_bound_it),
!synth_e_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
synth_e_access_traits::cmp_keys(
r_key,
PB_DS_V2F(*l_bound_it)))
return (l_bound_it);
synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return (++l_bound_it);
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
......@@ -231,17 +200,13 @@ upper_bound(const_key_reference r_key) const
const_point_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
!synth_e_access_traits::cmp_keys(
PB_DS_V2F(*l_bound_it),
!synth_e_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
synth_e_access_traits::cmp_keys(
r_key,
PB_DS_V2F(*l_bound_it)))
return (l_bound_it);
return (++l_bound_it);
synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
......@@ -250,12 +215,10 @@ PB_DS_CLASS_C_DEC::
pref_begin(const_node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (synth_e_access_traits::begin(
PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
return (synth_e_access_traits::begin(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
return (static_cast<const_internal_node_pointer>(p_nd)->pref_b_it());
return static_cast<const_internal_node_pointer>(p_nd)->pref_b_it();
}
PB_DS_CLASS_T_DEC
......@@ -264,12 +227,10 @@ PB_DS_CLASS_C_DEC::
pref_end(const_node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (synth_e_access_traits::end(
PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
return (synth_e_access_traits::end(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
return (static_cast<const_internal_node_pointer>(p_nd)->pref_e_it());
return static_cast<const_internal_node_pointer>(p_nd)->pref_e_it();
}
PB_DS_CLASS_T_DEC
......@@ -278,9 +239,8 @@ PB_DS_CLASS_C_DEC::
leftmost_descendant(const_node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<const_leaf_pointer>(p_nd));
return (static_cast<const_internal_node_pointer>(p_nd)->leftmost_descendant());
return static_cast<const_leaf_pointer>(p_nd);
return static_cast<const_internal_node_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
......@@ -289,9 +249,8 @@ PB_DS_CLASS_C_DEC::
leftmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<leaf_pointer>(p_nd));
return (static_cast<internal_node_pointer>(p_nd)->leftmost_descendant());
return static_cast<leaf_pointer>(p_nd);
return static_cast<internal_node_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
......@@ -300,9 +259,8 @@ PB_DS_CLASS_C_DEC::
rightmost_descendant(const_node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<const_leaf_pointer>(p_nd));
return (static_cast<const_internal_node_pointer>(p_nd)->rightmost_descendant());
return static_cast<const_leaf_pointer>(p_nd);
return static_cast<const_internal_node_pointer>(p_nd)->rightmost_descendant();
}
PB_DS_CLASS_T_DEC
......@@ -311,8 +269,7 @@ PB_DS_CLASS_C_DEC::
rightmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<leaf_pointer>(p_nd));
return (static_cast<internal_node_pointer>(p_nd)->rightmost_descendant());
return static_cast<leaf_pointer>(p_nd);
return static_cast<internal_node_pointer>(p_nd)->rightmost_descendant();
}
......@@ -54,32 +54,20 @@ namespace pb_ds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Type_Traits, typename E_Access_Traits, \
typename Metadata, typename Allocator>
#define PB_DS_CLASS_T_DEC \
template< \
class Type_Traits, \
class E_Access_Traits, \
class Metadata, \
class Allocator>
#define PB_DS_CLASS_C_DEC \
pat_trie_head< \
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_CLASS_C_DEC \
pat_trie_head<Type_Traits, E_Access_Traits, Metadata, Allocator>
#define PB_DS_BASE_C_DEC \
pat_trie_node_base<Type_Traits, E_Access_Traits, Metadata, Allocator>
template<typename Type_Traits,
class E_Access_Traits,
class Metadata,
class Allocator>
typename E_Access_Traits,
typename Metadata,
typename Allocator>
struct pat_trie_head : public PB_DS_BASE_C_DEC
{
private:
......
......@@ -48,23 +48,17 @@ PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (m_size == 0);
}
{ return (m_size == 0); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_size);
}
{ return m_size; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_internal_node_allocator.max_size());
}
{ return s_internal_node_allocator.max_size(); }
......@@ -48,33 +48,25 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
return (iterator(m_p_head->m_p_min));
}
{ return iterator(m_p_head->m_p_min); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
return (const_iterator(m_p_head->m_p_min));
}
{ return const_iterator(m_p_head->m_p_min); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (iterator(m_p_head));
}
{ return iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (const_iterator(m_p_head));
}
{ return const_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
......@@ -82,9 +74,8 @@ PB_DS_CLASS_C_DEC::
rbegin() const
{
if (empty())
return (rend());
return (--end());
return rend();
return --end();
}
PB_DS_CLASS_T_DEC
......@@ -93,56 +84,43 @@ PB_DS_CLASS_C_DEC::
rbegin()
{
if (empty())
return (rend());
return (--end());
return rend();
return --end();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
PB_DS_CLASS_C_DEC::
rend()
{
return (reverse_iterator(m_p_head));
}
{ return reverse_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
PB_DS_CLASS_C_DEC::
rend() const
{
return (const_reverse_iterator(m_p_head));
}
{ return const_reverse_iterator(m_p_head); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{
return (const_node_iterator(m_p_head->m_p_parent, this));
}
{ return const_node_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_begin()
{
return (node_iterator(m_p_head->m_p_parent, this));
}
{ return node_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{
return (const_node_iterator(NULL, this));
}
{ return const_node_iterator(NULL, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
node_end()
{
return (node_iterator(NULL, this));
}
{ return node_iterator(NULL, this); }
......@@ -127,7 +127,6 @@ namespace pb_ds
private:
pat_trie_leaf(const PB_DS_CLASS_C_DEC& other);
private:
value_type m_value;
};
......
......@@ -53,26 +53,15 @@ namespace pb_ds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Type_Traits, typename E_Access_Traits, \
typename Metadata, typename Allocator>
#define PB_DS_CLASS_T_DEC \
template< \
class Type_Traits, \
class E_Access_Traits, \
class Metadata, \
class Allocator>
#define PB_DS_CLASS_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>
#define PB_DS_CLASS_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>
enum pat_trie_node_type
{
......@@ -82,9 +71,9 @@ namespace pb_ds
};
template<typename Type_Traits,
class E_Access_Traits,
class Metadata,
class Allocator>
typename E_Access_Traits,
typename Metadata,
typename Allocator>
struct pat_trie_node_base : public pat_trie_node_metadata_base<
Metadata,
Allocator>
......@@ -108,7 +97,6 @@ namespace pb_ds
subtree_debug_info;
#endif
public:
pat_trie_node_base(pat_trie_node_type type);
#ifdef _GLIBCXX_DEBUG
......@@ -119,9 +107,7 @@ namespace pb_ds
assert_valid_imp(const_e_access_traits_pointer p_traits) const = 0;
#endif
public:
node_pointer m_p_parent;
const pat_trie_node_type m_type;
};
......
......@@ -87,7 +87,6 @@ namespace pb_ds
class Allocator>
class pat_trie_const_node_it_
{
protected:
typedef
typename Allocator::template rebind<
......@@ -181,14 +180,11 @@ namespace pb_ds
metadata_type>::other::const_reference
const_metadata_reference;
public:
// Default constructor.
/*
inline
pat_trie_const_node_it_()
*/
inline
pat_trie_const_node_it_(node_pointer p_nd = NULL,
const_e_access_traits_pointer p_traits = NULL)
......@@ -219,7 +215,7 @@ namespace pb_ds
num_children() const
{
if (m_p_nd->m_type == pat_trie_leaf_node_type)
return (0);
return 0;
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type);
return std::distance(static_cast<internal_node_pointer>(m_p_nd)->begin(), static_cast<internal_node_pointer>(m_p_nd)->end());
}
......@@ -270,7 +266,6 @@ namespace pb_ds
public PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC
{
private:
typedef
typename Allocator::template rebind<
......@@ -303,8 +298,6 @@ namespace pb_ds
// __Iterator's __const reference type.
typedef value_type const_reference;
public:
// Default constructor.
/*
inline
......@@ -328,8 +321,7 @@ namespace pb_ds
PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC
get_child(size_type i) const
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type ==
pat_trie_internal_node_type);
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == pat_trie_internal_node_type);
typename Internal_Node::iterator it =
static_cast<internal_node_pointer>(base_type::m_p_nd)->begin();
......
......@@ -164,7 +164,7 @@ namespace pb_ds
operator=(const PB_DS_CONST_IT_C_DEC& other)
{
m_p_nd = other.m_p_nd;
return (*this);
return *this;
}
inline
......@@ -172,52 +172,44 @@ namespace pb_ds
operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other)
{
m_p_nd = other.m_p_nd;
return (*this);
return *this;
}
inline const_pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type);
return (&static_cast<leaf_pointer>(m_p_nd)->value());
return &static_cast<leaf_pointer>(m_p_nd)->value();
}
inline const_reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type);
return (static_cast<leaf_pointer>(m_p_nd)->value());
return static_cast<leaf_pointer>(m_p_nd)->value();
}
inline bool
operator==(const PB_DS_CONST_IT_C_DEC& other) const
{
return (m_p_nd == other.m_p_nd);
}
{ return (m_p_nd == other.m_p_nd); }
inline bool
operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
{
return (m_p_nd == other.m_p_nd);
}
{ return (m_p_nd == other.m_p_nd); }
inline bool
operator!=(const PB_DS_CONST_IT_C_DEC& other) const
{
return (m_p_nd != other.m_p_nd);
}
{ return (m_p_nd != other.m_p_nd); }
inline bool
operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
{
return (m_p_nd != other.m_p_nd);
}
{ return (m_p_nd != other.m_p_nd); }
inline PB_DS_CONST_IT_C_DEC&
operator++()
{
inc(integral_constant<int,Is_Forward_Iterator>());
return (*this);
return *this;
}
inline PB_DS_CONST_IT_C_DEC
......@@ -225,14 +217,14 @@ namespace pb_ds
{
PB_DS_CONST_IT_C_DEC ret_it(m_p_nd);
operator++();
return (ret_it);
return ret_it;
}
inline PB_DS_CONST_IT_C_DEC&
operator--()
{
dec(integral_constant<int,Is_Forward_Iterator>());
return (*this);
return *this;
}
inline PB_DS_CONST_IT_C_DEC
......@@ -240,7 +232,7 @@ namespace pb_ds
{
PB_DS_CONST_IT_C_DEC ret_it(m_p_nd);
operator--();
return (ret_it);
return ret_it;
}
protected:
......@@ -345,17 +337,16 @@ namespace pb_ds
leftmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<leaf_pointer>(p_nd));
return (static_cast<internal_node_pointer>(p_nd)->leftmost_descendant());
return static_cast<leaf_pointer>(p_nd);
return static_cast<internal_node_pointer>(p_nd)->leftmost_descendant();
}
inline static leaf_pointer
rightmost_descendant(node_pointer p_nd)
{
if (p_nd->m_type == pat_trie_leaf_node_type)
return (static_cast<leaf_pointer>(p_nd));
return (static_cast<internal_node_pointer>(p_nd)->rightmost_descendant());
return static_cast<leaf_pointer>(p_nd);
return static_cast<internal_node_pointer>(p_nd)->rightmost_descendant();
}
public:
......@@ -374,7 +365,6 @@ namespace pb_ds
public PB_DS_CONST_IT_C_DEC
{
private:
typedef
typename Allocator::template rebind<
......@@ -412,8 +402,6 @@ namespace pb_ds
typedef typename Type_Traits::reference reference;
public:
inline
pat_trie_it_(node_pointer p_nd = NULL) : PB_DS_CONST_IT_C_DEC((node_pointer)p_nd)
{ }
......@@ -427,7 +415,7 @@ namespace pb_ds
operator=(const PB_DS_IT_C_DEC& other)
{
base_it_type::m_p_nd = other.m_p_nd;
return (*this);
return *this;
}
inline
......@@ -435,23 +423,22 @@ namespace pb_ds
operator=(const PB_DS_ODIR_IT_C_DEC& other)
{
base_it_type::m_p_nd = other.m_p_nd;
return (*this);
return *this;
}
inline pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type ==
pat_trie_leaf_node_type);
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type);
return (&static_cast<leaf_pointer>(base_it_type::m_p_nd)->value());
return &static_cast<leaf_pointer>(base_it_type::m_p_nd)->value();
}
inline reference
operator*() const
{
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type);
return (static_cast<leaf_pointer>(base_it_type::m_p_nd)->value());
return static_cast<leaf_pointer>(base_it_type::m_p_nd)->value();
}
inline PB_DS_IT_C_DEC&
......@@ -459,7 +446,7 @@ namespace pb_ds
{
PB_DS_CONST_IT_C_DEC::
operator++();
return (*this);
return *this;
}
inline PB_DS_IT_C_DEC
......@@ -467,14 +454,14 @@ namespace pb_ds
{
PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd);
operator++();
return (ret_it);
return ret_it;
}
inline PB_DS_IT_C_DEC&
operator--()
{
PB_DS_CONST_IT_C_DEC::operator--();
return (*this);
return *this;
}
inline PB_DS_IT_C_DEC
......@@ -482,7 +469,7 @@ namespace pb_ds
{
PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd);
operator--();
return (ret_it);
return ret_it;
}
protected:
......
......@@ -48,30 +48,22 @@ PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::e_access_traits&
PB_DS_CLASS_C_DEC::
get_e_access_traits()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const typename PB_DS_CLASS_C_DEC::e_access_traits&
PB_DS_CLASS_C_DEC::
get_e_access_traits() const
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_update&
PB_DS_CLASS_C_DEC::
get_node_update()
{
return (*this);
}
{ return *this; }
PB_DS_CLASS_T_DEC
const typename PB_DS_CLASS_C_DEC::node_update&
PB_DS_CLASS_C_DEC::
get_node_update() const
{
return (*this);
}
{ return *this; }
......@@ -60,7 +60,6 @@ public:
add_branch()
{
internal_node_pointer p_nd = s_internal_node_allocator.allocate(1);
try
{
m_bag.push_back(p_nd);
......@@ -68,7 +67,6 @@ public:
catch(...)
{
s_internal_node_allocator.deallocate(p_nd, 1);
throw;
}
}
......@@ -77,12 +75,9 @@ public:
get_branch()
{
_GLIBCXX_DEBUG_ASSERT(!m_bag.empty());
internal_node_pointer p_nd =* m_bag.begin();
m_bag.pop_front();
return (p_nd);
return p_nd;
}
~split_join_branch_bag()
......@@ -90,18 +85,14 @@ public:
while (!m_bag.empty())
{
internal_node_pointer p_nd =* m_bag.begin();
s_internal_node_allocator.deallocate(p_nd, 1);
m_bag.pop_front();
}
}
inline bool
empty() const
{
return (m_bag.empty());
}
{ return m_bag.empty(); }
private:
bag_t m_bag;
......
......@@ -52,12 +52,9 @@ PB_DS_CLASS_C_DEC::
trace() const
{
std::cerr << std::endl;
if (m_p_head->m_p_parent == NULL)
return;
trace_node(m_p_head->m_p_parent, 0);
std::cerr << std::endl;
}
......@@ -68,29 +65,20 @@ trace_node(const_node_pointer p_nd, size_type level)
{
for (size_type i = 0; i < level; ++i)
std::cerr << ' ';
std::cerr << p_nd << " ";
std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type)?
"l " :
"i ");
std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i ");
trace_node_metadata(p_nd, type_to_type<typename node::metadata_type>());
typename e_access_traits::const_iterator el_it =
pref_begin(p_nd);
typename e_access_traits::const_iterator el_it = pref_begin(p_nd);
while (el_it != pref_end(p_nd))
{
std::cerr <<* el_it;
++el_it;
}
if (p_nd->m_type == pat_trie_leaf_node_type)
{
std::cerr << std::endl;
return;
}
......@@ -100,8 +88,7 @@ trace_node(const_node_pointer p_nd, size_type level)
std::cerr << " " <<
static_cast<unsigned long>(p_internal->get_e_ind()) << std::endl;
const size_type num_children = std::distance(
p_internal->begin(),
const size_type num_children = std::distance(p_internal->begin(),
p_internal->end());
for (size_type child_i = 0; child_i < num_children; ++child_i)
......@@ -109,7 +96,6 @@ trace_node(const_node_pointer p_nd, size_type level)
typename internal_node::const_iterator child_it =
p_internal->begin();
std::advance(child_it, num_children - child_i - 1);
trace_node(*child_it, level + 1);
}
}
......@@ -120,8 +106,7 @@ void
PB_DS_CLASS_C_DEC::
trace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>)
{
std::cerr << "(" <<
static_cast<unsigned long>(p_nd->get_metadata()) << ") ";
std::cerr << "(" << static_cast<unsigned long>(p_nd->get_metadata()) << ") ";
}
PB_DS_CLASS_T_DEC
......@@ -130,5 +115,5 @@ PB_DS_CLASS_C_DEC::
trace_node_metadata(const_node_pointer, type_to_type<null_node_metadata>)
{ }
#endif // #ifdef PB_DS_PAT_TRIE_TRACE_
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment