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