debug.h (_GLIBCXX_DEBUG_ONLY): New.
2006-09-08 Benjamin Kosnik <bkoz@redhat.com> * include/debug/debug.h (_GLIBCXX_DEBUG_ONLY): New. * include/ext/bitmap_allocator.h (_BALLOC_SANITY_CHECK, _BALLOC_ASSERT): Remove. Use _GLIBCXX_DEBUG, _GLIBCXX_DEBUG_ASSERT. * include/ext/pb_ds/hash_policy.hpp (PB_DS_DBG_ASSERT): Convert to _GLIBCXX_DEBUG_ASSERT. Formatting corrections. (PB_DS_DBG_VERIFY): Remove, unused. (PB_DS_DBG_ONLY): Convert to _GLIBCXX_DEBUG blocks. * include/ext/pb_ds/detail/resize_policy/ hash_load_check_resize_trigger_imp.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/ insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/ binomial_heap_base_.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_base_/ split_join_fn_imps.hpp: Same. * 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_/ erase_store_hash_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_/cmp_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_/ 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_/debug_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_/cc_ht_map_.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_/ 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/unordered_iterator/iterator.hpp: Same. * include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp: Same. * include/ext/pb_ds/detail/unordered_iterator/ const_point_iterator.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/head.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/split_fn_imps.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_/rotate_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_/synth_e_access_traits.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/internal_node.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/ split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/point_iterators.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_/ erase_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_/ resize_store_hash_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.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_/gp_ht_map_.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_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/erase_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_/ debug_store_hash_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/types_traits.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp: Same. * include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp: Same. * include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ left_child_next_sibling_heap_.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ const_iterator.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ const_point_iterator.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp: Same. * include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same. * include/ext/pb_ds/detail/ov_tree_map_/ constructors_destructor_fn_imps.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/map_debug_base.hpp: Same. * include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Same. * include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp: Same. * include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.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_/split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same. * include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.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_/ constructor_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/list_update_map_/ iterators_fn_imps.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/ rc_binomial_heap_.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp: Same. * include/ext/pb_ds/detail/rc_binomial_heap_/ split_join_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_/split_join_fn_imps.hpp: Same. * testsuite/util/regression/res_mng/forced_exception.hpp: Same. * testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp: Same. * testsuite/util/regression/res_mng/dbg_ex_allocator.hpp: Same. * testsuite/util/rng/twister_rand_gen.cc * testsuite/util/native_type/assoc/native_multimap.hpp: Same. * testsuite/util/native_type/assoc/native_hash_multimap.hpp: Same. From-SVN: r116766
This commit is contained in:
parent
5de1a1eb07
commit
47bea7b87a
158 changed files with 2512 additions and 4699 deletions
|
@ -1,3 +1,216 @@
|
|||
2006-09-08 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/debug/debug.h (_GLIBCXX_DEBUG_ONLY): New.
|
||||
* include/ext/bitmap_allocator.h (_BALLOC_SANITY_CHECK,
|
||||
_BALLOC_ASSERT): Remove. Use _GLIBCXX_DEBUG,
|
||||
_GLIBCXX_DEBUG_ASSERT.
|
||||
* include/ext/pb_ds/hash_policy.hpp (PB_DS_DBG_ASSERT): Convert to
|
||||
_GLIBCXX_DEBUG_ASSERT. Formatting corrections.
|
||||
(PB_DS_DBG_VERIFY): Remove, unused.
|
||||
(PB_DS_DBG_ONLY): Convert to _GLIBCXX_DEBUG blocks.
|
||||
* include/ext/pb_ds/detail/resize_policy/
|
||||
hash_load_check_resize_trigger_imp.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/
|
||||
insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/
|
||||
binomial_heap_base_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_base_/
|
||||
split_join_fn_imps.hpp: Same.
|
||||
* 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_/
|
||||
erase_store_hash_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_/cmp_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_/
|
||||
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_/debug_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_/cc_ht_map_.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_/
|
||||
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/unordered_iterator/iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/unordered_iterator/
|
||||
const_point_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/head.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/split_fn_imps.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_/rotate_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_/synth_e_access_traits.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/internal_node.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/
|
||||
split_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/bin_search_tree_/point_iterators.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_/
|
||||
erase_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_/
|
||||
resize_store_hash_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.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_/gp_ht_map_.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_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/gp_hash_table_map_/erase_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_/
|
||||
debug_store_hash_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/types_traits.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
left_child_next_sibling_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
const_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
|
||||
const_point_iterator.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp: Same.
|
||||
* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/ov_tree_map_/
|
||||
constructors_destructor_fn_imps.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/map_debug_base.hpp: Same.
|
||||
* include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Same.
|
||||
* include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp: Same.
|
||||
* include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.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_/split_join_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.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_/
|
||||
constructor_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/list_update_map_/
|
||||
iterators_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/
|
||||
rc_binomial_heap_.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/
|
||||
constructors_destructor_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp: Same.
|
||||
* include/ext/pb_ds/detail/rc_binomial_heap_/
|
||||
split_join_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_/split_join_fn_imps.hpp: Same.
|
||||
* testsuite/util/regression/res_mng/forced_exception.hpp: Same.
|
||||
* testsuite/util/regression/res_mng/dbg_ex_allocator_base.hpp: Same.
|
||||
* testsuite/util/regression/res_mng/dbg_ex_allocator.hpp: Same.
|
||||
* testsuite/util/rng/twister_rand_gen.cc
|
||||
* testsuite/util/native_type/assoc/native_multimap.hpp: Same.
|
||||
* testsuite/util/native_type/assoc/native_hash_multimap.hpp: Same.
|
||||
|
||||
2006-09-05 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/basic_string.tcc (find(const _CharT*, size_type,
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace __gnu_debug
|
|||
|
||||
# define _GLIBCXX_DEBUG_ASSERT(_Condition)
|
||||
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
|
||||
# define _GLIBCXX_DEBUG_ONLY(_Statement) ;
|
||||
# define __glibcxx_requires_cond(_Cond,_Msg)
|
||||
# define __glibcxx_requires_valid_range(_First,_Last)
|
||||
# define __glibcxx_requires_sorted(_First,_Last)
|
||||
|
@ -109,6 +110,7 @@ namespace std
|
|||
#else
|
||||
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
|
||||
#endif
|
||||
# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
|
||||
|
||||
# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
|
||||
# define __glibcxx_requires_valid_range(_First,_Last) \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Bitmap Allocator. -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -52,23 +52,14 @@
|
|||
// For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock.
|
||||
#include <bits/gthr.h>
|
||||
|
||||
// Define this to enable error checking withing the allocator
|
||||
// itself(to debug the allocator itself).
|
||||
//#define _BALLOC_SANITY_CHECK
|
||||
#include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT
|
||||
|
||||
|
||||
/** @brief The constant in the expression below is the alignment
|
||||
* required in bytes.
|
||||
*/
|
||||
#define _BALLOC_ALIGN_BYTES 8
|
||||
|
||||
#if defined _BALLOC_SANITY_CHECK
|
||||
#include <cassert>
|
||||
#define _BALLOC_ASSERT(_EXPR) assert(_EXPR)
|
||||
#else
|
||||
#define _BALLOC_ASSERT(_EXPR)
|
||||
#endif
|
||||
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
using std::size_t;
|
||||
|
@ -618,7 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
_M_curr_bmap = reinterpret_cast<size_t*>
|
||||
(_M_vbp[_M_curr_index].first) - 1;
|
||||
|
||||
_BALLOC_ASSERT(__index <= (long)_M_vbp.size() - 1);
|
||||
_GLIBCXX_DEBUG_ASSERT(__index <= (long)_M_vbp.size() - 1);
|
||||
|
||||
_M_last_bmap_in_block = _M_curr_bmap
|
||||
- ((_M_vbp[_M_curr_index].second
|
||||
|
@ -904,7 +895,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
typedef typename
|
||||
balloc::__mini_vector<_Block_pair> _BPVector;
|
||||
|
||||
#if defined _BALLOC_SANITY_CHECK
|
||||
#if defined _GLIBCXX_DEBUG
|
||||
// Complexity: O(lg(N)). Where, N is the number of block of size
|
||||
// sizeof(value_type).
|
||||
void
|
||||
|
@ -919,7 +910,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
(_S_mem_blocks.begin(), _S_mem_blocks.end(),
|
||||
__gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff));
|
||||
|
||||
_BALLOC_ASSERT(__bpi == _S_mem_blocks.end());
|
||||
_GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -937,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
void
|
||||
_S_refill_pool() throw(std::bad_alloc)
|
||||
{
|
||||
#if defined _BALLOC_SANITY_CHECK
|
||||
#if defined _GLIBCXX_DEBUG
|
||||
_S_check_for_free_blocks();
|
||||
#endif
|
||||
|
||||
|
@ -1110,14 +1101,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
_Difference_type __diff;
|
||||
long __displacement;
|
||||
|
||||
_BALLOC_ASSERT(_S_last_dealloc_index >= 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0);
|
||||
|
||||
|
||||
if (__gnu_cxx::balloc::_Inclusive_between<_Alloc_block*>
|
||||
(__real_p)
|
||||
(_S_mem_blocks[_S_last_dealloc_index]))
|
||||
{
|
||||
_BALLOC_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1);
|
||||
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1);
|
||||
|
||||
// Initial Assumption was correct!
|
||||
__diff = _S_last_dealloc_index;
|
||||
|
@ -1132,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
__gnu_cxx::balloc::
|
||||
_Inclusive_between<_Alloc_block*>(__real_p));
|
||||
|
||||
_BALLOC_ASSERT(_iter != _S_mem_blocks.end());
|
||||
_GLIBCXX_DEBUG_ASSERT(_iter != _S_mem_blocks.end());
|
||||
|
||||
__diff = _iter - _S_mem_blocks.begin();
|
||||
__displacement = __real_p - _S_mem_blocks[__diff].first;
|
||||
|
@ -1152,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
(_S_mem_blocks[__diff].first)
|
||||
- (__gnu_cxx::balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1);
|
||||
|
||||
_BALLOC_ASSERT(*__puse_count != 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(*__puse_count != 0);
|
||||
|
||||
--(*__puse_count);
|
||||
|
||||
|
@ -1182,7 +1173,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|||
if (_S_last_dealloc_index >= _S_mem_blocks.size())
|
||||
{
|
||||
_S_last_dealloc_index =(__diff != -1 ? __diff : 0);
|
||||
_BALLOC_ASSERT(_S_last_dealloc_index >= 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,40 +58,26 @@
|
|||
#include <ext/pb_ds/detail/tree_trace_base.hpp>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <assert.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Key, \
|
||||
typename Mapped, \
|
||||
class Cmp_Fn, \
|
||||
class Node_And_It_Traits, \
|
||||
class Allocator>
|
||||
template<typename Key, typename Mapped, class Cmp_Fn, \
|
||||
class Node_And_It_Traits, class Allocator>
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
bin_search_tree_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
bin_search_tree_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME< \
|
||||
|
@ -108,26 +94,23 @@ namespace pb_ds
|
|||
Allocator, \
|
||||
false>
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
eq_by_less<Key, Cmp_Fn>, \
|
||||
typename Allocator::template rebind< \
|
||||
Key>::other::const_reference>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
map_debug_base<Key, eq_by_less<Key, Cmp_Fn>, \
|
||||
typename Allocator::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value)
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped_Data()
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value.first)
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#define PB_DS_TREE_TRACE_BASE_C_DEC \
|
||||
|
@ -137,7 +120,7 @@ namespace pb_ds
|
|||
Cmp_Fn, \
|
||||
true, \
|
||||
Allocator>
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* class description = "8i|\|4ree $34rc|-| 7r33 74813.">
|
||||
|
@ -148,12 +131,12 @@ namespace pb_ds
|
|||
class Node_And_It_Traits,
|
||||
class Allocator>
|
||||
class PB_DS_CLASS_NAME :
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
public PB_DS_MAP_DEBUG_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
public PB_DS_TREE_TRACE_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
public Cmp_Fn,
|
||||
public PB_DS_TYPES_TRAITS_C_DEC,
|
||||
public Node_And_It_Traits::node_update
|
||||
|
@ -178,9 +161,9 @@ namespace pb_ds
|
|||
private:
|
||||
typedef cond_dealtor< node, Allocator> cond_dealtor_t;
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
|
@ -203,7 +186,6 @@ namespace pb_ds
|
|||
const_key_reference;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
|
||||
typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type;
|
||||
|
||||
typedef
|
||||
|
@ -221,8 +203,7 @@ namespace pb_ds
|
|||
typedef
|
||||
typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference
|
||||
const_mapped_reference;
|
||||
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type;
|
||||
|
||||
|
@ -426,8 +407,7 @@ namespace pb_ds
|
|||
size_type
|
||||
recursive_count(node_pointer p_nd) const;
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
|
@ -436,12 +416,10 @@ namespace pb_ds
|
|||
|
||||
void
|
||||
assert_node_consistent(const node_pointer p_nd) const;
|
||||
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_iterators() const;
|
||||
|
||||
|
@ -476,8 +454,7 @@ namespace pb_ds
|
|||
|
||||
node_consistent_t
|
||||
assert_node_consistent_(const node_pointer p_nd) const;
|
||||
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
@ -516,15 +493,11 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#undef PB_DS_TREE_TRACE_BASE_C_DEC
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_EP2VP
|
||||
#undef PB_DS_V2S
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
|
|
@ -50,26 +50,20 @@ PB_DS_CLASS_C_DEC::s_node_allocator;
|
|||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME() :
|
||||
m_p_head(s_node_allocator.allocate(1)),
|
||||
m_size(0)
|
||||
PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
|
||||
Cmp_Fn(r_cmp_fn),
|
||||
m_p_head(s_node_allocator.allocate(1)),
|
||||
m_size(0)
|
||||
Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -80,79 +74,64 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
|
|||
m_size(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
map_debug_base(other),
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
PB_DS_TREE_TRACE_BASE_C_DEC(other),
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
Cmp_Fn(other),
|
||||
node_update(other),
|
||||
m_p_head(s_node_allocator.allocate(1)),
|
||||
m_size(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
m_size = other.m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(other.structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
|
||||
|
||||
try
|
||||
{
|
||||
m_p_head->m_p_parent =
|
||||
recursive_copy_node(other.m_p_head->m_p_parent);
|
||||
|
||||
m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
|
||||
if (m_p_head->m_p_parent != NULL)
|
||||
m_p_head->m_p_parent->m_p_parent = m_p_head;
|
||||
|
||||
m_size = other.m_size;
|
||||
|
||||
initialize_min_max();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::clear();)
|
||||
|
||||
s_node_allocator.deallocate(m_p_head, 1);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
|
||||
s_node_allocator.deallocate(m_p_head, 1);
|
||||
throw;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.structure_only_assert_valid();)
|
||||
|
||||
value_swap(other);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
|
||||
value_swap(other);
|
||||
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.structure_only_assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
value_swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::swap(other);)
|
||||
|
||||
std::swap(m_p_head, other.m_p_head);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);)
|
||||
std::swap(m_p_head, other.m_p_head);
|
||||
std::swap(m_size, other.m_size);
|
||||
}
|
||||
|
||||
|
@ -161,7 +140,6 @@ PB_DS_CLASS_C_DEC::
|
|||
~PB_DS_CLASS_NAME()
|
||||
{
|
||||
clear();
|
||||
|
||||
s_node_allocator.deallocate(m_p_head, 1);
|
||||
}
|
||||
|
||||
|
@ -173,7 +151,6 @@ initialize()
|
|||
m_p_head->m_p_parent = NULL;
|
||||
m_p_head->m_p_left = m_p_head;
|
||||
m_p_head->m_p_right = m_p_head;
|
||||
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
|
@ -186,7 +163,6 @@ recursive_copy_node(const node_pointer p_nd)
|
|||
return (NULL);
|
||||
|
||||
node_pointer p_ret = s_node_allocator.allocate(1);
|
||||
|
||||
try
|
||||
{
|
||||
new (p_ret) node(*p_nd);
|
||||
|
@ -194,7 +170,6 @@ recursive_copy_node(const node_pointer p_nd)
|
|||
catch(...)
|
||||
{
|
||||
s_node_allocator.deallocate(p_ret, 1);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -203,13 +178,11 @@ recursive_copy_node(const node_pointer p_nd)
|
|||
try
|
||||
{
|
||||
p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left);
|
||||
|
||||
p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
clear_imp(p_ret);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -219,9 +192,8 @@ recursive_copy_node(const node_pointer p_nd)
|
|||
if (p_ret->m_p_right != NULL)
|
||||
p_ret->m_p_right->m_p_parent = p_ret;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_ret);)
|
||||
|
||||
return (p_ret);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret);)
|
||||
return p_ret;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -232,25 +204,20 @@ initialize_min_max()
|
|||
if (m_p_head->m_p_parent == NULL)
|
||||
{
|
||||
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
node_pointer p_min = m_p_head->m_p_parent;
|
||||
|
||||
while (p_min->m_p_left != NULL)
|
||||
p_min = p_min->m_p_left;
|
||||
|
||||
m_p_head->m_p_left = p_min;
|
||||
}
|
||||
|
||||
{
|
||||
node_pointer p_max = m_p_head->m_p_parent;
|
||||
|
||||
while (p_max->m_p_right != NULL)
|
||||
p_max = p_max->m_p_right;
|
||||
|
||||
m_p_head->m_p_right = p_max;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,20 +52,16 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_valid() const
|
||||
{
|
||||
structure_only_assert_valid();
|
||||
|
||||
assert_consistent_with_debug_base();
|
||||
|
||||
assert_size();
|
||||
|
||||
assert_iterators();
|
||||
|
||||
if (m_p_head->m_p_parent == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,24 +70,21 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
structure_only_assert_valid() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_head != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head != NULL);
|
||||
if (m_p_head->m_p_parent == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_left == m_p_head);
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_right == m_p_head);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head);
|
||||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_left != m_p_head);
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_right != m_p_head);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left != m_p_head);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head);
|
||||
}
|
||||
|
||||
if (m_p_head->m_p_parent != NULL)
|
||||
assert_node_consistent(m_p_head->m_p_parent);
|
||||
|
||||
assert_min();
|
||||
assert_max();
|
||||
}
|
||||
|
@ -116,22 +109,18 @@ assert_node_consistent_(const node_pointer p_nd) const
|
|||
assert_node_consistent_with_right(p_nd);
|
||||
|
||||
const std::pair<const_pointer, const_pointer>
|
||||
l_range =
|
||||
assert_node_consistent_(p_nd->m_p_left);
|
||||
l_range = assert_node_consistent_(p_nd->m_p_left);
|
||||
|
||||
if (l_range.second != NULL)
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(*l_range.second),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
|
||||
const std::pair<const_pointer, const_pointer>
|
||||
r_range =
|
||||
assert_node_consistent_(p_nd->m_p_right);
|
||||
r_range = assert_node_consistent_(p_nd->m_p_right);
|
||||
|
||||
if (r_range.first != NULL)
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(*r_range.first)));
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(*r_range.first)));
|
||||
|
||||
return (std::make_pair((l_range.first != NULL)? l_range.first :& p_nd->m_value,(r_range.second != NULL)? r_range.second :& p_nd->m_value));
|
||||
}
|
||||
|
@ -143,12 +132,9 @@ assert_node_consistent_with_left(const node_pointer p_nd) const
|
|||
{
|
||||
if (p_nd->m_p_left == NULL)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd);
|
||||
|
||||
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(
|
||||
PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(p_nd->m_p_left->m_value)));
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(p_nd->m_p_left->m_value)));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -158,11 +144,8 @@ assert_node_consistent_with_right(const node_pointer p_nd) const
|
|||
{
|
||||
if (p_nd->m_p_right == NULL)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd);
|
||||
|
||||
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(
|
||||
PB_DS_V2F(p_nd->m_p_right->m_value),
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
}
|
||||
|
||||
|
@ -181,18 +164,15 @@ assert_min_imp(const node_pointer p_nd) const
|
|||
{
|
||||
if (p_nd == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_left == m_p_head);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_nd->m_p_left == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd == m_p_head->m_p_left);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_left);
|
||||
return;
|
||||
}
|
||||
|
||||
assert_min_imp(p_nd->m_p_left);
|
||||
}
|
||||
|
||||
|
@ -211,15 +191,13 @@ assert_max_imp(const node_pointer p_nd) const
|
|||
{
|
||||
if (p_nd == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_head->m_p_right == m_p_head);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_nd->m_p_right == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd == m_p_head->m_p_right);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_right);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -232,61 +210,40 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_iterators() const
|
||||
{
|
||||
size_type iterated_num = 0;
|
||||
|
||||
const_iterator prev_it = end();
|
||||
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
++iterated_num;
|
||||
|
||||
PB_DS_DBG_ASSERT(lower_bound(
|
||||
PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
|
||||
|
||||
const_iterator upper_bound_it = upper_bound(
|
||||
PB_DS_V2F(*it));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
|
||||
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
|
||||
--upper_bound_it;
|
||||
|
||||
PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd);
|
||||
|
||||
if (prev_it != end())
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(*prev_it),
|
||||
PB_DS_V2F(*it)));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
|
||||
PB_DS_V2F(*it)));
|
||||
prev_it = it;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(iterated_num == m_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(iterated_num == m_size);
|
||||
size_type reverse_iterated_num = 0;
|
||||
|
||||
const_reverse_iterator reverse_prev_it = rend();
|
||||
|
||||
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
|
||||
++reverse_it)
|
||||
{
|
||||
++reverse_iterated_num;
|
||||
|
||||
PB_DS_DBG_ASSERT(lower_bound(
|
||||
_GLIBCXX_DEBUG_ASSERT(lower_bound(
|
||||
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
|
||||
|
||||
const_iterator upper_bound_it = upper_bound(
|
||||
PB_DS_V2F(*reverse_it));
|
||||
|
||||
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
|
||||
--upper_bound_it;
|
||||
|
||||
PB_DS_DBG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
|
||||
if (reverse_prev_it != rend())
|
||||
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(
|
||||
PB_DS_V2F(*reverse_prev_it),
|
||||
PB_DS_V2F(*reverse_it)));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
|
||||
PB_DS_V2F(*reverse_it)));
|
||||
reverse_prev_it = reverse_it;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(reverse_iterated_num == m_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -295,7 +252,6 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_consistent_with_debug_base() const
|
||||
{
|
||||
map_debug_base::check_size(m_size);
|
||||
|
||||
assert_consistent_with_debug_base(m_p_head->m_p_parent);
|
||||
}
|
||||
|
||||
|
@ -306,10 +262,7 @@ assert_consistent_with_debug_base(const node_pointer p_nd) const
|
|||
{
|
||||
if (p_nd == NULL)
|
||||
return;
|
||||
|
||||
map_debug_base::check_key_exists(
|
||||
PB_DS_V2F(p_nd->m_value));
|
||||
|
||||
map_debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value));
|
||||
assert_consistent_with_debug_base(p_nd->m_p_left);
|
||||
assert_consistent_with_debug_base(p_nd->m_p_right);
|
||||
}
|
||||
|
@ -319,7 +272,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
assert_size() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -49,10 +49,10 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_node(node_pointer p_z)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value)));
|
||||
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value)));
|
||||
|
||||
p_z->~node();
|
||||
|
||||
|
@ -94,7 +94,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
clear_imp(m_p_head->m_p_parent);
|
||||
|
||||
|
@ -102,9 +102,9 @@ clear()
|
|||
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::clear();)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -139,7 +139,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
@ -165,7 +165,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
|
|
@ -49,7 +49,7 @@ inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
|
|||
PB_DS_CLASS_C_DEC::
|
||||
insert_leaf(const_reference r_value)
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
if (m_size == 0)
|
||||
return (std::make_pair(
|
||||
|
@ -80,15 +80,15 @@ insert_leaf(const_reference r_value)
|
|||
PB_DS_V2F(r_value),
|
||||
PB_DS_V2F(p_pot->m_value)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
return (std::make_pair(p_pot, false));
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
p_nd = p_pot->m_p_left;
|
||||
|
@ -115,8 +115,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
|
|||
|
||||
if (left_nd)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_left == NULL);
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(r_value),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
|
||||
|
@ -127,8 +127,8 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
|
|||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_right == NULL);
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
|
@ -142,11 +142,11 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
|
|||
|
||||
p_new_nd->m_p_left = p_new_nd->m_p_right = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_nd));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_nd));
|
||||
|
||||
update_to_top(p_new_nd, (node_update* )this);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
return (iterator(p_new_nd));
|
||||
|
@ -167,7 +167,7 @@ insert_imp_empty(const_reference r_value)
|
|||
|
||||
p_new_node->m_p_left = p_new_node->m_p_right = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
update_to_top(m_p_head->m_p_parent, (node_update* )this);
|
||||
|
|
|
@ -47,10 +47,8 @@
|
|||
#ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
|
||||
#define PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#include <cassert>
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
|
@ -101,16 +99,6 @@ namespace pb_ds
|
|||
!Is_Forward_Iterator, \
|
||||
Allocator>
|
||||
|
||||
#ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BIN_SEARCH_TREE_DEBUG_
|
||||
|
||||
// Const iterator.
|
||||
template<typename Node_Pointer,
|
||||
typename Value_Type,
|
||||
|
@ -142,124 +130,96 @@ namespace pb_ds
|
|||
public:
|
||||
|
||||
inline
|
||||
bin_search_tree_const_it_(const Node_Pointer p_nd = NULL) : m_p_nd(const_cast<Node_Pointer>(p_nd))
|
||||
bin_search_tree_const_it_(const Node_Pointer p_nd = NULL)
|
||||
: m_p_nd(const_cast<Node_Pointer>(p_nd))
|
||||
{ }
|
||||
|
||||
inline
|
||||
bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC&
|
||||
other) : m_p_nd(other.m_p_nd)
|
||||
bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
|
||||
: m_p_nd(other.m_p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_CONST_IT_C_DEC&
|
||||
other)
|
||||
operator=(const PB_DS_TREE_CONST_IT_C_DEC& other)
|
||||
{
|
||||
m_p_nd = other.m_p_nd;
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC&
|
||||
other)
|
||||
operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
|
||||
{
|
||||
m_p_nd = other.m_p_nd;
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const_pointer
|
||||
operator->() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_nd != NULL);
|
||||
|
||||
return (&m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
|
||||
return &m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_nd != NULL);
|
||||
|
||||
return (m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
|
||||
return m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(const PB_DS_TREE_CONST_IT_C_DEC
|
||||
& other) const
|
||||
{
|
||||
return (m_p_nd == other.m_p_nd);
|
||||
}
|
||||
operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC
|
||||
& other) const
|
||||
{
|
||||
return (m_p_nd == other.m_p_nd);
|
||||
}
|
||||
operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator!=(const PB_DS_TREE_CONST_IT_C_DEC&
|
||||
other) const
|
||||
{
|
||||
return (m_p_nd != other.m_p_nd);
|
||||
}
|
||||
operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC&
|
||||
other) const
|
||||
{
|
||||
return (m_p_nd != other.m_p_nd);
|
||||
}
|
||||
operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_nd != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
|
||||
inc(integral_constant<int,Is_Forward_Iterator>());
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC
|
||||
operator++(int)
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC
|
||||
ret_it(m_p_nd);
|
||||
|
||||
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
|
||||
operator++();
|
||||
|
||||
return (ret_it);
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator--()
|
||||
{
|
||||
dec(integral_constant<int,Is_Forward_Iterator>());
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC
|
||||
operator--(int)
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC
|
||||
ret_it(m_p_nd);
|
||||
|
||||
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
|
||||
operator--();
|
||||
|
||||
return (ret_it);
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void
|
||||
inc(false_type)
|
||||
{
|
||||
dec(true_type());
|
||||
}
|
||||
{ dec(true_type()); }
|
||||
|
||||
void
|
||||
inc(true_type)
|
||||
|
@ -268,26 +228,21 @@ namespace pb_ds
|
|||
m_p_nd->m_p_parent->m_p_parent == m_p_nd)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_left;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_right != NULL)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_right;
|
||||
|
||||
while (m_p_nd->m_p_left != NULL)
|
||||
m_p_nd = m_p_nd->m_p_left;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Node_Pointer p_y = m_p_nd->m_p_parent;
|
||||
|
||||
while (m_p_nd == p_y->m_p_right)
|
||||
{
|
||||
m_p_nd = p_y;
|
||||
|
||||
p_y = p_y->m_p_parent;
|
||||
}
|
||||
|
||||
|
@ -297,42 +252,32 @@ namespace pb_ds
|
|||
|
||||
inline void
|
||||
dec(false_type)
|
||||
{
|
||||
inc(true_type());
|
||||
}
|
||||
{ inc(true_type()); }
|
||||
|
||||
void
|
||||
dec(true_type)
|
||||
{
|
||||
if (m_p_nd->special()&&
|
||||
m_p_nd->m_p_parent->m_p_parent == m_p_nd)
|
||||
if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_right;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_left != NULL)
|
||||
{
|
||||
Node_Pointer p_y = m_p_nd->m_p_left;
|
||||
|
||||
while (p_y->m_p_right != NULL)
|
||||
p_y = p_y->m_p_right;
|
||||
|
||||
m_p_nd = p_y;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Node_Pointer p_y = m_p_nd->m_p_parent;
|
||||
|
||||
while (m_p_nd == p_y->m_p_left)
|
||||
{
|
||||
m_p_nd = p_y;
|
||||
|
||||
p_y = p_y->m_p_parent;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_left != p_y)
|
||||
m_p_nd = p_y;
|
||||
}
|
||||
|
@ -358,11 +303,13 @@ namespace pb_ds
|
|||
public:
|
||||
|
||||
inline
|
||||
bin_search_tree_it_(const Node_Pointer p_nd = NULL) : PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd)
|
||||
bin_search_tree_it_(const Node_Pointer p_nd = NULL)
|
||||
: PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other) : PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd)
|
||||
bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other)
|
||||
: PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
|
@ -370,8 +317,7 @@ namespace pb_ds
|
|||
operator=(const PB_DS_TREE_IT_C_DEC& other)
|
||||
{
|
||||
base_it_type::m_p_nd = other.m_p_nd;
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -379,64 +325,51 @@ namespace pb_ds
|
|||
operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other)
|
||||
{
|
||||
base_it_type::m_p_nd = other.m_p_nd;
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer
|
||||
operator->() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL);
|
||||
|
||||
return (&base_it_type::m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL);
|
||||
return &base_it_type::m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline typename PB_DS_TREE_CONST_IT_C_DEC::reference
|
||||
operator*() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_it_type::m_p_nd != NULL);
|
||||
|
||||
return (base_it_type::m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != NULL);
|
||||
return base_it_type::m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC::
|
||||
operator++();
|
||||
|
||||
return (*this);
|
||||
PB_DS_TREE_CONST_IT_C_DEC:: operator++();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC
|
||||
operator++(int)
|
||||
{
|
||||
PB_DS_TREE_IT_C_DEC
|
||||
ret_it(base_it_type::m_p_nd);
|
||||
|
||||
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
|
||||
operator++();
|
||||
|
||||
return (ret_it);
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC&
|
||||
operator--()
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC::
|
||||
operator--();
|
||||
|
||||
return (*this);
|
||||
PB_DS_TREE_CONST_IT_C_DEC:: operator--();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC
|
||||
operator--(int)
|
||||
{
|
||||
PB_DS_TREE_IT_C_DEC
|
||||
ret_it(base_it_type::m_p_nd);
|
||||
|
||||
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
|
||||
operator--();
|
||||
|
||||
return (ret_it);
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -444,18 +377,11 @@ namespace pb_ds
|
|||
};
|
||||
|
||||
#undef PB_DS_TREE_CONST_IT_C_DEC
|
||||
|
||||
#undef PB_DS_TREE_CONST_ODIR_IT_C_DEC
|
||||
|
||||
#undef PB_DS_TREE_IT_C_DEC
|
||||
|
||||
#undef PB_DS_TREE_ODIR_IT_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
|
||||
#endif
|
||||
|
|
|
@ -49,10 +49,10 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_node(node_pointer p_z)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value)));
|
||||
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value)));
|
||||
|
||||
p_z->~node();
|
||||
|
||||
|
@ -94,7 +94,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
|
||||
clear_imp(m_p_head->m_p_parent);
|
||||
|
||||
|
@ -102,9 +102,9 @@ clear()
|
|||
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::clear();)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
|
||||
|
||||
PB_DS_DBG_ONLY(structure_only_assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -68,8 +68,8 @@ rotate_left(node_pointer p_x)
|
|||
p_y->m_p_left = p_x;
|
||||
p_x->m_p_parent = p_y;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_x);)
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_y);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
|
||||
|
||||
apply_update(p_x, (node_update* )this);
|
||||
apply_update(p_x->m_p_parent, (node_update* )this);
|
||||
|
@ -99,8 +99,8 @@ rotate_right(node_pointer p_x)
|
|||
p_y->m_p_right = p_x;
|
||||
p_x->m_p_parent = p_y;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_x);)
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_y);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
|
||||
|
||||
apply_update(p_x, (node_update* )this);
|
||||
apply_update(p_x->m_p_parent, (node_update* )this);
|
||||
|
@ -118,8 +118,8 @@ rotate_parent(node_pointer p_nd)
|
|||
else
|
||||
rotate_left(p_parent);
|
||||
|
||||
PB_DS_DBG_ASSERT(p_parent->m_p_parent = p_nd);
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_left == p_parent ||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
|
||||
p_nd->m_p_right == p_parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
join_prep(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
if (other.m_size == 0)
|
||||
return (false);
|
||||
|
@ -78,7 +78,7 @@ join_prep(PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
m_size += other.m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::join(other);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
@ -98,15 +98,15 @@ bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
other.clear();
|
||||
|
||||
if (m_size == 0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -115,8 +115,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
{
|
||||
value_swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
r_key,
|
||||
PB_DS_V2F(m_p_head->m_p_right->m_value)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -135,13 +135,13 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
{
|
||||
value_swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::split(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::split(
|
||||
r_key,(Cmp_Fn& )(*this),
|
||||
other);)
|
||||
|
||||
|
@ -162,8 +162,8 @@ split_finish(PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
initialize_min_max();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -63,44 +63,25 @@
|
|||
#include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp>
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#endif
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, class Cmp_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_<Value_Type, Cmp_Fn, Allocator>
|
||||
|
||||
#define PB_DS_ENTRY_CMP_DEC \
|
||||
entry_cmp< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
is_simple< \
|
||||
Value_Type>::value, \
|
||||
Allocator>::type
|
||||
#define PB_DS_ENTRY_CMP_DEC \
|
||||
entry_cmp<Value_Type, Cmp_Fn, is_simple<Value_Type>::value, Allocator>::type
|
||||
|
||||
#define PB_DS_RESIZE_POLICY_DEC \
|
||||
resize_policy< \
|
||||
typename Allocator::size_type>
|
||||
#define PB_DS_RESIZE_POLICY_DEC \
|
||||
resize_policy<typename Allocator::size_type>
|
||||
|
||||
/**
|
||||
* class description = "Base class for some types of h3ap$">
|
||||
|
@ -113,8 +94,7 @@ namespace pb_ds
|
|||
private:
|
||||
enum
|
||||
{
|
||||
simple_value = is_simple<
|
||||
Value_Type>::value
|
||||
simple_value = is_simple<Value_Type>::value
|
||||
};
|
||||
|
||||
typedef integral_constant<int, simple_value> no_throw_copies_t;
|
||||
|
@ -276,11 +256,9 @@ namespace pb_ds
|
|||
join(PB_DS_CLASS_C_DEC& other);
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -336,22 +314,18 @@ namespace pb_ds
|
|||
size_type
|
||||
partition(Pred pred);
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
|
||||
void
|
||||
trace_entry(const entry& r_e, false_type) const;
|
||||
|
||||
void
|
||||
trace_entry(const entry& r_e, true_type) const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
static entry_allocator s_entry_allocator;
|
||||
|
@ -379,18 +353,11 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_ENTRY_CMP_DEC
|
||||
|
||||
#undef PB_DS_RESIZE_POLICY_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_HPP
|
||||
#endif
|
||||
|
|
|
@ -49,35 +49,18 @@
|
|||
#define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_const_iterator_<Value_Type, Entry, Simple, Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_const_iterator_< \
|
||||
Value_Type, \
|
||||
Entry, \
|
||||
Simple, \
|
||||
Allocator>
|
||||
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
binary_heap_const_point_iterator_< \
|
||||
Value_Type, \
|
||||
Entry, \
|
||||
Simple, \
|
||||
Allocator>
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
binary_heap_const_point_iterator_<Value_Type, Entry, Simple, Allocator>
|
||||
|
||||
// Const point-type iterator.
|
||||
template<typename Value_Type,
|
||||
|
@ -135,53 +118,41 @@ namespace pb_ds
|
|||
inline bool
|
||||
operator==(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (base_type::m_p_e == other.m_p_e);
|
||||
return base_type::m_p_e == other.m_p_e;
|
||||
}
|
||||
|
||||
// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (base_type::m_p_e != other.m_p_e);
|
||||
return base_type::m_p_e != other.m_p_e;
|
||||
}
|
||||
|
||||
inline PB_DS_CLASS_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_type::m_p_e != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != NULL);
|
||||
inc();
|
||||
|
||||
return (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_CLASS_C_DEC
|
||||
operator++(int)
|
||||
{
|
||||
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_e);
|
||||
|
||||
operator++();
|
||||
|
||||
return (ret_it);
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
inc()
|
||||
{
|
||||
++base_type::m_p_e;
|
||||
}
|
||||
{ ++base_type::m_p_e; }
|
||||
};
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
|
||||
#endif
|
||||
|
|
|
@ -49,35 +49,18 @@
|
|||
#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;m_p_prev_or_parent
|
||||
#endif // #ifdef BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, typename Entry, bool Simple, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Value_Type, \
|
||||
typename Entry, \
|
||||
bool Simple, \
|
||||
class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_const_point_iterator_< \
|
||||
Value_Type, \
|
||||
Entry, \
|
||||
Simple, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap_const_point_iterator_<Value_Type, Entry, Simple, Allocator>
|
||||
|
||||
// Const point-type iterator.
|
||||
template<typename Value_Type,
|
||||
|
@ -136,62 +119,48 @@ namespace pb_ds
|
|||
|
||||
// Default constructor.
|
||||
inline
|
||||
binary_heap_const_point_iterator_()
|
||||
|
||||
: m_p_e(NULL)
|
||||
{ }
|
||||
binary_heap_const_point_iterator_() : m_p_e(NULL) { }
|
||||
|
||||
// Copy constructor.
|
||||
inline
|
||||
binary_heap_const_point_iterator_(const PB_DS_CLASS_C_DEC& other)
|
||||
|
||||
: m_p_e(other.m_p_e)
|
||||
: m_p_e(other.m_p_e)
|
||||
{ }
|
||||
|
||||
// Access.
|
||||
inline const_pointer
|
||||
operator->() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_e != NULL);
|
||||
|
||||
return (to_ptr(integral_constant<int,Simple>()));
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
|
||||
return to_ptr(integral_constant<int,Simple>());
|
||||
}
|
||||
|
||||
// Access.
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_e != NULL);
|
||||
|
||||
return (*to_ptr(integral_constant<int,Simple>()));
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
|
||||
return *to_ptr(integral_constant<int,Simple>());
|
||||
}
|
||||
|
||||
// Compares content to a different iterator object.
|
||||
inline bool
|
||||
operator==(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (m_p_e == other.m_p_e);
|
||||
}
|
||||
{ return m_p_e == other.m_p_e; }
|
||||
|
||||
// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (m_p_e != other.m_p_e);
|
||||
}
|
||||
{ return m_p_e != other.m_p_e; }
|
||||
|
||||
private:
|
||||
inline const_pointer
|
||||
to_ptr(true_type) const
|
||||
{
|
||||
return m_p_e;
|
||||
}
|
||||
{ return m_p_e; }
|
||||
|
||||
inline const_pointer
|
||||
to_ptr(false_type) const
|
||||
{
|
||||
return* m_p_e;
|
||||
}
|
||||
{ return *m_p_e; }
|
||||
|
||||
public:
|
||||
entry_pointer m_p_e;
|
||||
|
@ -200,11 +169,7 @@ namespace pb_ds
|
|||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
#endif
|
||||
|
|
|
@ -71,7 +71,7 @@ copy_from_range(It first_it, It last_it)
|
|||
|
||||
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -81,7 +81,7 @@ binary_heap_() :
|
|||
m_actual_size(resize_policy::min_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -92,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) :
|
|||
m_actual_size(resize_policy::min_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -104,8 +104,8 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
|
|||
m_actual_size(other.m_actual_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
|
||||
const_iterator first_it = other.begin();
|
||||
const_iterator last_it = other.end();
|
||||
|
@ -129,7 +129,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
|
|||
throw;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -137,16 +137,16 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
PB_DS_DBG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
|
||||
value_swap(other);
|
||||
|
||||
std::swap((entry_cmp& )(*this), (entry_cmp& )other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -53,28 +53,26 @@ assert_valid() const
|
|||
{
|
||||
#ifdef PB_DS_REGRESSION
|
||||
s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
|
||||
#endif // #ifdef PB_DS_REGRESSION
|
||||
#endif
|
||||
|
||||
resize_policy::assert_valid();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size <= m_actual_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size);
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
{
|
||||
#ifdef PB_DS_REGRESSION
|
||||
s_value_allocator.check_allocated(m_a_entries[i], 1);
|
||||
#endif // #ifdef PB_DS_REGRESSION
|
||||
#endif
|
||||
|
||||
if (left_child(i) < m_size)
|
||||
PB_DS_DBG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
|
||||
_GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
|
||||
|
||||
PB_DS_DBG_ASSERT(parent(left_child(i)) == i);
|
||||
_GLIBCXX_DEBUG_ASSERT(parent(left_child(i)) == i);
|
||||
|
||||
if (right_child(i) < m_size)
|
||||
PB_DS_DBG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
|
||||
_GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
|
||||
|
||||
PB_DS_DBG_ASSERT(parent(right_child(i)) == i);
|
||||
_GLIBCXX_DEBUG_ASSERT(parent(right_child(i)) == i);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -71,7 +71,7 @@ clear()
|
|||
|
||||
m_size = 0;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -95,8 +95,8 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
pop()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
|
||||
erase_at(m_a_entries, 0, s_no_throw_copies_ind);
|
||||
|
||||
|
@ -104,10 +104,10 @@ pop()
|
|||
|
||||
resize_for_erase_if_needed();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -116,7 +116,7 @@ typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
typedef
|
||||
typename entry_pred<
|
||||
|
@ -128,7 +128,7 @@ erase_if(Pred pred)
|
|||
|
||||
const size_type left = partition(pred_t(pred));
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size >= left);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
|
||||
|
||||
const size_type ersd = m_size - left;
|
||||
|
||||
|
@ -157,7 +157,7 @@ erase_if(Pred pred)
|
|||
|
||||
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return ersd;
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase(point_iterator it)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
|
||||
const size_type fix_pos = it.m_p_e - m_a_entries;
|
||||
|
||||
|
@ -178,15 +178,15 @@ erase(point_iterator it)
|
|||
|
||||
resize_for_erase_if_needed();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
PB_DS_DBG_ASSERT(fix_pos <= m_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size);
|
||||
|
||||
if (fix_pos != m_size)
|
||||
fix(m_a_entries + fix_pos);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -206,7 +206,7 @@ resize_for_erase_if_needed()
|
|||
|
||||
resize_policy::notify_shrink_resize();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
std::copy(m_a_entries, m_a_entries + m_size - 1, a_new_entries);
|
||||
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
|
@ -230,7 +230,7 @@ partition(Pred pred)
|
|||
|
||||
while (right + 1 != left)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(left <= m_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(left <= m_size);
|
||||
|
||||
if (!pred(m_a_entries[left]))
|
||||
++left;
|
||||
|
@ -238,7 +238,7 @@ partition(Pred pred)
|
|||
--right;
|
||||
else
|
||||
{
|
||||
PB_DS_DBG_ASSERT(left < right);
|
||||
_GLIBCXX_DEBUG_ASSERT(left < right);
|
||||
|
||||
std::swap(m_a_entries[left], m_a_entries[right]);
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
|
|||
PB_DS_CLASS_C_DEC::
|
||||
top() const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
|
||||
return top_imp(s_no_throw_copies_ind);
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
push(const_reference r_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
insert_value(r_val, s_no_throw_copies_ind);
|
||||
|
||||
std::push_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return point_iterator(m_a_entries);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ resize_for_insert_if_needed()
|
|||
{
|
||||
if (!resize_policy::resize_needed_for_grow(m_size))
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size < m_actual_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
modify(point_iterator it, const_reference r_new_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
|
||||
|
||||
fix(it.m_p_e);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -160,7 +160,7 @@ fix(entry_pointer p_e)
|
|||
parent_i = parent(i);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ fix(entry_pointer p_e)
|
|||
const size_type left_child_i = left_child(i);
|
||||
const size_type right_child_i = right_child(i);
|
||||
|
||||
PB_DS_DBG_ASSERT(right_child_i > left_child_i);
|
||||
_GLIBCXX_DEBUG_ASSERT(right_child_i > left_child_i);
|
||||
|
||||
const bool smaller_than_left_child =
|
||||
left_child_i < m_size&&
|
||||
|
|
|
@ -47,27 +47,16 @@
|
|||
#ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
|
||||
#define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
|
||||
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Size_Type>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
resize_policy< \
|
||||
Size_Type>
|
||||
#define PB_DS_CLASS_C_DEC resize_policy<Size_Type>
|
||||
|
||||
template<typename Size_Type>
|
||||
class resize_policy
|
||||
|
@ -117,17 +106,15 @@ namespace pb_ds
|
|||
void
|
||||
notify_arbitrary(size_type actual_size);
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum
|
||||
|
@ -138,7 +125,6 @@ namespace pb_ds
|
|||
|
||||
private:
|
||||
size_type m_next_shrink_size;
|
||||
|
||||
size_type m_next_grow_size;
|
||||
};
|
||||
|
||||
|
@ -148,9 +134,7 @@ namespace pb_ds
|
|||
resize_policy() :
|
||||
m_next_shrink_size(0),
|
||||
m_next_grow_size(min_size)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
|
@ -166,8 +150,7 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
resize_needed_for_grow(size_type size) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(size <= m_next_grow_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size);
|
||||
return size == m_next_grow_size;
|
||||
}
|
||||
|
||||
|
@ -176,8 +159,7 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
resize_needed_for_shrink(size_type size) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(size <= m_next_grow_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size);
|
||||
return size == m_next_shrink_size;
|
||||
}
|
||||
|
||||
|
@ -185,9 +167,7 @@ namespace pb_ds
|
|||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_new_size_for_grow() const
|
||||
{
|
||||
return m_next_grow_size* factor;
|
||||
}
|
||||
{ return m_next_grow_size* factor; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
|
@ -195,7 +175,6 @@ namespace pb_ds
|
|||
get_new_size_for_shrink() const
|
||||
{
|
||||
const size_type half_size = m_next_grow_size / factor;
|
||||
|
||||
return std::max(static_cast<size_type>(min_size), half_size);
|
||||
}
|
||||
|
||||
|
@ -205,10 +184,8 @@ namespace pb_ds
|
|||
get_new_size_for_arbitrary(size_type size) const
|
||||
{
|
||||
size_type ret = min_size;
|
||||
|
||||
while (ret < size)
|
||||
ret *= factor;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -217,33 +194,27 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
notify_grow_resize()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
PB_DS_DBG_ASSERT(m_next_grow_size >= min_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
|
||||
m_next_grow_size *= factor;
|
||||
|
||||
m_next_shrink_size = m_next_grow_size / ratio;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
notify_shrink_resize()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
m_next_shrink_size /= factor;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
m_next_shrink_size /= factor;
|
||||
if (m_next_shrink_size == 1)
|
||||
m_next_shrink_size = 0;
|
||||
|
||||
m_next_grow_size =
|
||||
std::max(m_next_grow_size / factor, static_cast<size_type>(min_size));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
|
@ -251,24 +222,22 @@ namespace pb_ds
|
|||
notify_arbitrary(size_type actual_size)
|
||||
{
|
||||
m_next_grow_size = actual_size;
|
||||
|
||||
m_next_shrink_size = m_next_grow_size / ratio;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_next_shrink_size == 0 ||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_next_shrink_size == 0 ||
|
||||
m_next_shrink_size* ratio == m_next_grow_size);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_next_grow_size >= min_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
|
||||
}
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -279,17 +248,12 @@ namespace pb_ds
|
|||
std::cerr << "shrink = " << m_next_shrink_size <<
|
||||
" grow = " << m_next_grow_size << std::endl;
|
||||
}
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
typedef
|
||||
typename entry_pred<
|
||||
|
@ -62,11 +62,11 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
const size_type left = partition(pred_t(pred));
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size >= left);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
|
||||
|
||||
const size_type ersd = m_size - left;
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size >= ersd);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= ersd);
|
||||
|
||||
const size_type actual_size =
|
||||
resize_policy::get_new_size_for_arbitrary(left);
|
||||
|
@ -97,7 +97,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
for (size_type i = 0; i < other.m_size; ++i)
|
||||
erase_at(other.m_a_entries, i, s_no_throw_copies_ind);
|
||||
|
||||
PB_DS_DBG_ASSERT(actual_size >= left);
|
||||
_GLIBCXX_DEBUG_ASSERT(actual_size >= left);
|
||||
std::copy(m_a_entries, m_a_entries + left, a_entries);
|
||||
std::copy(m_a_entries + left, m_a_entries + m_size, a_other_entries);
|
||||
|
||||
|
@ -119,8 +119,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
resize_policy::notify_arbitrary(m_actual_size);
|
||||
other.notify_arbitrary(other.m_actual_size);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -128,8 +128,8 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
const size_type size = m_size + other.m_size;
|
||||
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(size);
|
||||
|
@ -173,7 +173,7 @@ join(PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
other.notify_arbitrary(resize_policy::min_size);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,9 +50,7 @@
|
|||
* Modified from CLRS.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#include <cassert>
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#include <debug/debug.h>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
|
||||
|
@ -62,30 +60,14 @@ namespace pb_ds
|
|||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, class Cmp_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap_<Value_Type, Cmp_Fn, Allocator>
|
||||
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
binomial_heap_base_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Allocator>
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
|
||||
|
||||
/**
|
||||
* class description = "8y|\|0|\/|i41 h34p 74813">
|
||||
|
@ -140,12 +122,10 @@ namespace pb_ds
|
|||
~binomial_heap_();
|
||||
|
||||
protected:
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#endif
|
||||
};
|
||||
|
||||
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
|
||||
|
@ -156,10 +136,5 @@ namespace pb_ds
|
|||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
|
|
@ -47,28 +47,21 @@
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_(const Cmp_Fn& r_cmp_fn) :
|
||||
PB_DS_BASE_C_DEC(r_cmp_fn)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
|
||||
PB_DS_BASE_C_DEC(other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~binomial_heap_()
|
||||
{ }
|
||||
~binomial_heap_() { }
|
||||
|
||||
|
|
|
@ -44,14 +44,12 @@
|
|||
* Contains an implementation for binomial_heap_.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid() const
|
||||
{
|
||||
base_type::assert_valid(true);
|
||||
}
|
||||
{ base_type::assert_valid(true); }
|
||||
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP__DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -53,9 +53,7 @@
|
|||
* Modified from CLRS.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#include <cassert>
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#include <debug/debug.h>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
|
||||
|
@ -66,41 +64,22 @@ namespace pb_ds
|
|||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, class Cmp_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap_base_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
typename Allocator::size_type, \
|
||||
Allocator, \
|
||||
false>
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
typename Allocator::size_type, \
|
||||
Allocator>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
|
||||
typename Allocator::size_type, \
|
||||
Allocator, false>
|
||||
#else
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
|
||||
typename Allocator::size_type, Allocator>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* class description = "8y|\|0|\/|i41 h34p 74813">
|
||||
|
@ -212,15 +191,13 @@ namespace pb_ds
|
|||
inline void
|
||||
find_max();
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(bool strictly_binomial) const;
|
||||
|
||||
void
|
||||
assert_max() const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
@ -236,12 +213,10 @@ namespace pb_ds
|
|||
inline node_pointer
|
||||
join(node_pointer p_lhs, node_pointer p_rhs) const;
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const;
|
||||
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
assert_node_consistent(const_node_pointer, bool, bool) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
node_pointer m_p_max;
|
||||
|
@ -255,16 +230,11 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP
|
||||
#endif
|
||||
|
|
|
@ -53,7 +53,7 @@ copy_from_range(It first_it, It last_it)
|
|||
while (first_it != last_it)
|
||||
push(*(first_it++));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -61,7 +61,7 @@ PB_DS_CLASS_C_DEC::
|
|||
binomial_heap_base_() :
|
||||
m_p_max(NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -70,7 +70,7 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) :
|
|||
PB_DS_BASE_C_DEC(r_cmp_fn),
|
||||
m_p_max(NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -79,7 +79,7 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) :
|
|||
PB_DS_BASE_C_DEC(other),
|
||||
m_p_max(NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -87,13 +87,13 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
|
||||
base_type::swap(other);
|
||||
|
||||
std::swap(m_p_max, other.m_p_max);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,9 +52,7 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_valid(bool strictly_binomial) const
|
||||
{
|
||||
base_type::assert_valid();
|
||||
|
||||
assert_node_consistent(base_type::m_p_root, strictly_binomial, true);
|
||||
|
||||
assert_max();
|
||||
}
|
||||
|
||||
|
@ -65,11 +63,9 @@ assert_max() const
|
|||
{
|
||||
if (m_p_max == NULL)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(base_type::parent(m_p_max) == NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == NULL);
|
||||
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
|
||||
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value));
|
||||
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -77,32 +73,25 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, bool increasing) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(increasing || strictly_binomial);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(increasing || strictly_binomial);
|
||||
base_type::assert_node_consistent(p_nd, false);
|
||||
|
||||
if (p_nd == NULL)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd));
|
||||
|
||||
PB_DS_DBG_ASSERT(base_type::size_under_node(p_nd) ==
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd));
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) ==
|
||||
static_cast<size_type>(1 << p_nd->m_metadata));
|
||||
|
||||
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing);
|
||||
|
||||
assert_node_consistent(p_nd->m_p_l_child, true, false);
|
||||
|
||||
if (p_nd->m_p_next_sibling != NULL)
|
||||
if (increasing)
|
||||
{
|
||||
if (strictly_binomial)
|
||||
PB_DS_DBG_ASSERT(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata);
|
||||
else
|
||||
PB_DS_DBG_ASSERT(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata);
|
||||
}
|
||||
else
|
||||
PB_DS_DBG_ASSERT(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_BINOMIAL_HEAP_BASE_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -49,13 +49,13 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
pop()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
if (m_p_max == NULL)
|
||||
find_max();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_p_max != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_max != NULL);
|
||||
|
||||
node_pointer p_nd = m_p_max;
|
||||
|
||||
|
@ -65,7 +65,7 @@ pop()
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -73,8 +73,8 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
remove_parentless_node(node_pointer p_nd)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ASSERT(base_type::parent(p_nd) == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == NULL);
|
||||
|
||||
node_pointer p_cur_root = p_nd == base_type::m_p_root?
|
||||
p_nd->m_p_next_sibling :
|
||||
|
@ -119,8 +119,8 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase(point_iterator it)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
base_type::bubble_to_top(it.m_p_nd);
|
||||
|
||||
|
@ -130,7 +130,7 @@ erase(point_iterator it)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -139,11 +139,11 @@ typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ erase_if(Pred pred)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
return ersd;
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
|
|||
PB_DS_CLASS_C_DEC::
|
||||
top() const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(false);)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(false);)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
if (m_p_max == NULL)
|
||||
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max();
|
||||
|
||||
PB_DS_DBG_ASSERT(m_p_max != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_max != NULL);
|
||||
return m_p_max->m_value;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
push(const_reference r_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
|
||||
|
||||
|
@ -57,7 +57,7 @@ push(const_reference r_val)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
return point_iterator(p_nd);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ insert_node(node_pointer p_nd)
|
|||
|
||||
p_nd->m_metadata = 0;
|
||||
|
||||
PB_DS_DBG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
|
||||
base_type::m_p_root->m_p_l_child = p_nd;
|
||||
|
||||
base_type::m_p_root->m_metadata = 1;
|
||||
|
@ -177,11 +177,11 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
modify(point_iterator it, const_reference r_new_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
node_pointer p_nd = it.m_p_nd;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false);)
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false);)
|
||||
|
||||
const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
|
||||
|
||||
|
@ -204,7 +204,7 @@ modify(point_iterator it, const_reference r_new_val)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -217,6 +217,6 @@ modify(point_iterator it, const_reference r_new_val)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,15 +50,15 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
|
||||
other.clear();
|
||||
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
while (p_out != NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_type::m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
|
||||
--base_type::m_size;
|
||||
|
||||
++other.m_size;
|
||||
|
@ -92,7 +92,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
p_out = p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
|
||||
|
@ -120,8 +120,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -129,8 +129,8 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
|
||||
node_pointer p_other = other.m_p_root;
|
||||
|
||||
|
@ -153,8 +153,8 @@ join(PB_DS_CLASS_C_DEC& other)
|
|||
other.m_size = 0;
|
||||
other.m_p_max = NULL;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(true);)
|
||||
PB_DS_DBG_ONLY(other.assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(true);)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid(true);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -52,105 +52,62 @@
|
|||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
#include <ext/pb_ds/exception.hpp>
|
||||
#include <ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp>
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#include <ext/pb_ds/detail/map_debug_base.hpp>
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif // PB_DS_HT_MAP_TRACE_
|
||||
#endif
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Key, \
|
||||
typename Mapped, \
|
||||
class Hash_Fn, \
|
||||
class Eq_Fn, \
|
||||
class Allocator, \
|
||||
bool Store_Hash, \
|
||||
class Comb_Hash_Fn, \
|
||||
class Resize_Policy>
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Mapped, class Hash_Fn, \
|
||||
class Eq_Fn, class Allocator, bool Store_Hash, \
|
||||
class Comb_Hash_Fn, class Resize_Policy>
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
cc_ht_map_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME cc_ht_map_data_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
cc_ht_map_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME cc_ht_map_no_data_
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Hash_Fn, \
|
||||
Eq_Fn, \
|
||||
Allocator, \
|
||||
Store_Hash, \
|
||||
Comb_Hash_Fn, \
|
||||
Resize_Policy >
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME<Key, Mapped, Hash_Fn, Eq_Fn, Allocator, \
|
||||
Store_Hash, Comb_Hash_Fn, Resize_Policy>
|
||||
|
||||
#define PB_DS_HASH_EQ_FN_C_DEC \
|
||||
hash_eq_fn< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
Allocator, \
|
||||
Store_Hash>
|
||||
#define PB_DS_HASH_EQ_FN_C_DEC \
|
||||
hash_eq_fn<Key, Eq_Fn, Allocator, Store_Hash>
|
||||
|
||||
#define PB_DS_RANGED_HASH_FN_C_DEC \
|
||||
ranged_hash_fn< \
|
||||
Key, \
|
||||
Hash_Fn, \
|
||||
Allocator, \
|
||||
Comb_Hash_Fn, \
|
||||
Store_Hash>
|
||||
#define PB_DS_RANGED_HASH_FN_C_DEC \
|
||||
ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, Store_Hash>
|
||||
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Allocator, \
|
||||
Store_Hash>
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits<Key, Mapped, Allocator, Store_Hash>
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
typename Allocator::template rebind< \
|
||||
Key>::other::const_reference>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base<Key, Eq_Fn, typename Allocator::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped_Data()
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
|
||||
typedef \
|
||||
static_assert_dumclass< \
|
||||
sizeof(static_assert<(bool)(E)>)> \
|
||||
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
|
||||
typedef static_assert_dumclass<sizeof(static_assert<(bool)(E)>)> \
|
||||
UNIQUE##static_assert_type
|
||||
|
||||
// <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813.
|
||||
|
@ -163,9 +120,9 @@ namespace pb_ds
|
|||
class Comb_Hash_Fn,
|
||||
class Resize_Policy >
|
||||
class PB_DS_CLASS_NAME:
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
protected PB_DS_MAP_DEBUG_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
public PB_DS_HASH_EQ_FN_C_DEC,
|
||||
public Resize_Policy,
|
||||
public PB_DS_RANGED_HASH_FN_C_DEC,
|
||||
|
@ -214,10 +171,7 @@ namespace pb_ds
|
|||
typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
|
||||
const_reference_;
|
||||
|
||||
#define PB_DS_GEN_POS \
|
||||
std::pair< \
|
||||
entry_pointer, \
|
||||
typename Allocator::size_type>
|
||||
#define PB_DS_GEN_POS std::pair<entry_pointer, typename Allocator::size_type>
|
||||
|
||||
#include <ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp>
|
||||
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
|
||||
|
@ -293,21 +247,21 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef point_iterator_ point_iterator;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef const_point_iterator_ point_iterator;
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef const_point_iterator_ const_point_iterator;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef iterator_ iterator;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef const_iterator_ iterator;
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef const_iterator_ const_iterator;
|
||||
|
||||
|
@ -374,7 +328,7 @@ namespace pb_ds
|
|||
inline std::pair<point_iterator, bool>
|
||||
insert(const_reference r_val)
|
||||
{
|
||||
return (insert_imp(r_val, traits_base::m_store_extra_indicator));
|
||||
return insert_imp(r_val, traits_base::m_store_extra_indicator);
|
||||
}
|
||||
|
||||
inline mapped_reference
|
||||
|
@ -382,11 +336,10 @@ namespace pb_ds
|
|||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
return (subscript_imp(r_key, traits_base::m_store_extra_indicator));
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#else
|
||||
insert(r_key);
|
||||
|
||||
return (traits_base::s_null_mapped);
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
return traits_base::s_null_mapped;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline point_iterator
|
||||
|
@ -423,19 +376,15 @@ namespace pb_ds
|
|||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // #ifdef PB_DS_HT_MAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
|
||||
|
@ -446,9 +395,9 @@ namespace pb_ds
|
|||
|
||||
typedef Resize_Policy resize_base;
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
||||
typedef
|
||||
typename PB_DS_TYPES_TRAITS_C_DEC::store_extra_false_type
|
||||
|
@ -486,10 +435,10 @@ namespace pb_ds
|
|||
do_resize(size_type new_size);
|
||||
|
||||
void
|
||||
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, entry_pointer_array, size_type);
|
||||
|
||||
inline entry_pointer
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, store_hash_false_type);
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, store_hash_false_type);
|
||||
|
||||
inline entry_pointer
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, store_hash_true_type);
|
||||
|
@ -510,86 +459,59 @@ namespace pb_ds
|
|||
inline mapped_reference
|
||||
subscript_imp(const_key_reference r_key, store_hash_false_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
const size_type pos = ranged_hash_fn_base::operator()(r_key);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
const size_type pos = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_a_p_entries[pos];
|
||||
|
||||
resize_base::notify_insert_search_start();
|
||||
|
||||
while (p_e != NULL&&
|
||||
!hash_eq_fn_base::operator()(p_e->m_value.first, r_key))
|
||||
while (p_e != NULL
|
||||
&& !hash_eq_fn_base::operator()(p_e->m_value.first, r_key))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
if (p_e != NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return (p_e->m_value.second);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
return (p_e->m_value.second);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
|
||||
|
||||
return (insert_new_imp(
|
||||
value_type(
|
||||
r_key,
|
||||
mapped_type()),
|
||||
pos)->second);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
|
||||
return insert_new_imp(value_type(r_key, mapped_type()), pos)->second;
|
||||
}
|
||||
|
||||
inline mapped_reference
|
||||
subscript_imp(const_key_reference r_key, store_hash_true_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_a_p_entries[pos_hash_pair.first];
|
||||
|
||||
resize_base::notify_insert_search_start();
|
||||
|
||||
while (p_e != NULL&&
|
||||
while (p_e != NULL &&
|
||||
!hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
if (p_e != NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return (p_e->m_value.second);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
return p_e->m_value.second;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
|
||||
|
||||
return (insert_new_imp(
|
||||
value_type(
|
||||
r_key,
|
||||
mapped_type()),
|
||||
pos_hash_pair)->second);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
|
||||
return insert_new_imp(value_type(r_key, mapped_type()), pos_hash_pair)->second;
|
||||
}
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
inline std::pair<
|
||||
point_iterator,
|
||||
bool>
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert_imp(const_reference r_val, store_hash_false_type);
|
||||
|
||||
inline std::pair<
|
||||
point_iterator,
|
||||
bool>
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert_imp(const_reference r_val, store_hash_true_type);
|
||||
|
||||
inline pointer
|
||||
|
@ -599,111 +521,84 @@ namespace pb_ds
|
|||
pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
|
||||
|
||||
// Following lines might throw an exception.
|
||||
entry_pointer p_e = get_entry( r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
entry_pointer p_e = get_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
|
||||
p_e->m_p_next = m_a_p_entries[pos];
|
||||
|
||||
m_a_p_entries[pos] = p_e;
|
||||
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_val));)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return (&p_e->m_value);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair)
|
||||
{
|
||||
// Following lines might throw an exception.
|
||||
|
||||
if (do_resize_if_needed())
|
||||
r_pos_hash_pair = ranged_hash_fn_base::operator()(
|
||||
PB_DS_V2F(r_val));
|
||||
r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
|
||||
|
||||
entry_pointer p_e = get_entry( r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
entry_pointer p_e = get_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
|
||||
p_e->m_hash = r_pos_hash_pair.second;
|
||||
|
||||
p_e->m_p_next = m_a_p_entries[r_pos_hash_pair.first];
|
||||
|
||||
m_a_p_entries[r_pos_hash_pair.first] = p_e;
|
||||
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_val));)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return (&p_e->m_value);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_val));)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
find_key_pointer(const_key_reference r_key, store_hash_false_type)
|
||||
{
|
||||
entry_pointer p_e =
|
||||
m_a_p_entries[ranged_hash_fn_base::operator()(r_key)];
|
||||
|
||||
entry_pointer p_e = m_a_p_entries[ranged_hash_fn_base::operator()(r_key)];
|
||||
resize_base::notify_find_search_start();
|
||||
|
||||
while (p_e != NULL&&
|
||||
while (p_e != NULL &&
|
||||
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
|
||||
{
|
||||
resize_base::notify_find_search_collision();
|
||||
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
if (p_e == NULL)
|
||||
map_debug_base::check_key_does_not_exist(r_key);
|
||||
else
|
||||
map_debug_base::check_key_exists(r_key);
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
|
||||
return (&p_e->m_value);
|
||||
#endif
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
find_key_pointer(const_key_reference r_key, store_hash_true_type)
|
||||
{
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
|
||||
|
||||
entry_pointer p_e = m_a_p_entries[pos_hash_pair.first];
|
||||
|
||||
resize_base::notify_find_search_start();
|
||||
|
||||
while (p_e != NULL&&
|
||||
!hash_eq_fn_base::operator()(
|
||||
PB_DS_V2F(p_e->m_value),
|
||||
while (p_e != NULL &&
|
||||
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
|
||||
p_e->m_hash,
|
||||
r_key, pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_find_search_collision();
|
||||
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
if (p_e == NULL)
|
||||
map_debug_base::check_key_does_not_exist(r_key);
|
||||
else
|
||||
map_debug_base::check_key_exists(r_key);
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
|
||||
return (&p_e->m_value);
|
||||
#endif
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
|
@ -721,19 +616,17 @@ namespace pb_ds
|
|||
{
|
||||
inc_it_state((const_mapped_pointer& )r_p_value, r_pos);
|
||||
}
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
void
|
||||
inc_it_state(const_pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const
|
||||
inc_it_state(const_pointer& r_p_value,
|
||||
std::pair<entry_pointer, size_type>& r_pos) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(r_p_value != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(r_p_value != NULL);
|
||||
r_pos.first = r_pos.first->m_p_next;
|
||||
|
||||
if (r_pos.first != NULL)
|
||||
{
|
||||
r_p_value =& r_pos.first->m_value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -741,50 +634,43 @@ namespace pb_ds
|
|||
if (m_a_p_entries[r_pos.second] != NULL)
|
||||
{
|
||||
r_pos.first = m_a_p_entries[r_pos.second];
|
||||
|
||||
r_p_value =& r_pos.first->m_value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
r_p_value = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
get_start_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const
|
||||
get_start_it_state(pointer& r_p_value,
|
||||
std::pair<entry_pointer, size_type>& r_pos) const
|
||||
{
|
||||
for (r_pos.second = 0; r_pos.second < m_num_e_p; ++r_pos.second)
|
||||
if (m_a_p_entries[r_pos.second] != NULL)
|
||||
{
|
||||
r_pos.first = m_a_p_entries[r_pos.second];
|
||||
|
||||
r_p_value =& r_pos.first->m_value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
r_p_value = NULL;
|
||||
}
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_entry_pointer_array_valid(const entry_pointer_array) const;
|
||||
|
||||
void
|
||||
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const;
|
||||
assert_entry_pointer_valid(const entry_pointer,
|
||||
store_hash_true_type) const;
|
||||
|
||||
void
|
||||
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const;
|
||||
|
||||
void
|
||||
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_type) const;
|
||||
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
assert_entry_pointer_valid(const entry_pointer,
|
||||
store_hash_false_type) const;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
|
||||
void
|
||||
trace_list(const_entry_pointer p_l) const;
|
||||
|
||||
#endif // #ifdef PB_DS_HT_MAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
static entry_allocator s_entry_allocator;
|
||||
|
@ -801,7 +687,7 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
friend class iterator_;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
friend class const_iterator_;
|
||||
|
||||
|
@ -815,11 +701,8 @@ namespace pb_ds
|
|||
|
||||
enum
|
||||
{
|
||||
store_hash_ok =
|
||||
!Store_Hash ||
|
||||
!is_same<
|
||||
Hash_Fn,
|
||||
pb_ds::null_hash_fn>::value
|
||||
store_hash_ok = !Store_Hash
|
||||
|| !is_same<Hash_Fn, pb_ds::null_hash_fn>::value
|
||||
};
|
||||
|
||||
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
|
||||
|
@ -838,26 +721,16 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_HASH_EQ_FN_C_DEC
|
||||
|
||||
#undef PB_DS_RANGED_HASH_FN_C_DEC
|
||||
|
||||
#undef PB_DS_TYPES_TRAITS_C_DEC
|
||||
|
||||
#undef PB_DS_MAP_DEBUG_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_NAME
|
||||
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_V2S
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
#undef PB_DS_STATIC_ASSERT
|
||||
|
||||
} // namespace detail
|
||||
|
|
|
@ -78,7 +78,7 @@ cmp_with_other(const Other_Map_Type& other) const
|
|||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
if (p_mapped_value->second != it->second)
|
||||
return (false);
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
}
|
||||
|
||||
return (true);
|
||||
|
|
|
@ -67,106 +67,87 @@ PB_DS_CLASS_T_DEC
|
|||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME() :
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
|
||||
|
||||
Resize_Policy::notify_cleared();
|
||||
|
||||
ranged_hash_fn_base::notify_resized(m_num_e_p);
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
ranged_hash_fn_base(
|
||||
resize_base::get_nearest_larger_size(1),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn,
|
||||
r_comb_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn, const Resize_Policy& r_resize_policy) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
Resize_Policy(r_resize_policy),
|
||||
ranged_hash_fn_base(
|
||||
resize_base::get_nearest_larger_size(1),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn,
|
||||
r_comb_hash_fn),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_p_entries(s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
PB_DS_MAP_DEBUG_BASE_C_DEC(other),
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
map_debug_base(other),
|
||||
#endif
|
||||
PB_DS_HASH_EQ_FN_C_DEC(other),
|
||||
resize_base(other),
|
||||
ranged_hash_fn_base(other),
|
||||
m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_p_entries(m_a_p_entries = s_entry_pointer_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e_p(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
try
|
||||
{
|
||||
copy_from_range(other.begin(), other.end());
|
||||
|
@ -174,44 +155,34 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
|||
catch(...)
|
||||
{
|
||||
deallocate_all();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_CLASS_NAME()
|
||||
{
|
||||
deallocate_all();
|
||||
}
|
||||
{ deallocate_all(); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid());
|
||||
PB_DS_DBG_ONLY(other.assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
|
||||
|
||||
std::swap(m_a_p_entries, other.m_a_p_entries);
|
||||
|
||||
std::swap(m_num_e_p, other.m_num_e_p);
|
||||
|
||||
std::swap(m_num_used_e, other.m_num_used_e);
|
||||
|
||||
ranged_hash_fn_base::swap(other);
|
||||
|
||||
hash_eq_fn_base::swap(other);
|
||||
|
||||
resize_base::swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::swap(other));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid());
|
||||
PB_DS_DBG_ONLY(other.assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -220,7 +191,6 @@ PB_DS_CLASS_C_DEC::
|
|||
deallocate_all()
|
||||
{
|
||||
clear();
|
||||
|
||||
s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p);
|
||||
}
|
||||
|
||||
|
@ -229,11 +199,8 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
initialize()
|
||||
{
|
||||
std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL);
|
||||
|
||||
std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, entry_pointer(NULL));
|
||||
Resize_Policy::notify_resized(m_num_e_p);
|
||||
|
||||
Resize_Policy::notify_cleared();
|
||||
|
||||
ranged_hash_fn_base::notify_resized(m_num_e_p);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral
|
|||
// At this point no exceptions can be thrown.
|
||||
|
||||
p_e->m_p_next = m_a_p_entries[pos];
|
||||
|
||||
m_a_p_entries[pos] = p_e;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
|
||||
}
|
||||
|
|
|
@ -51,15 +51,13 @@ PB_DS_CLASS_C_DEC::
|
|||
constructor_insert_new_imp(const_reference r_val, size_type pos, true_type)
|
||||
{
|
||||
// Following lines might throw an exception.
|
||||
entry_pointer p_e = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
|
||||
entry_pointer p_e = get_entry(r_val,
|
||||
traits_base::s_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
|
||||
p_e->m_p_next = m_a_p_entries[pos];
|
||||
|
||||
p_e->m_hash = ranged_hash_fn_base::operator()((const_key_reference)(PB_DS_V2F(p_e->m_value))).second;
|
||||
|
||||
m_a_p_entries[pos] = p_e;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(r_key);)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(r_key);)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,7 +52,6 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_valid() const
|
||||
{
|
||||
map_debug_base::check_size(m_num_used_e);
|
||||
|
||||
assert_entry_pointer_array_valid(m_a_p_entries);
|
||||
}
|
||||
|
||||
|
@ -62,25 +61,20 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const
|
||||
{
|
||||
size_type iterated_num_used_e = 0;
|
||||
|
||||
for (size_type pos = 0; pos < m_num_e_p; ++pos)
|
||||
{
|
||||
entry_pointer p_e = a_p_entries[pos];
|
||||
|
||||
while (p_e != NULL)
|
||||
{
|
||||
++iterated_num_used_e;
|
||||
|
||||
assert_entry_pointer_valid(p_e, traits_base::m_store_hash_indicator);
|
||||
|
||||
assert_entry_pointer_valid(p_e, traits_base::m_store_hash_indicator);
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
|
||||
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -44,14 +44,13 @@
|
|||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_type) const
|
||||
{
|
||||
map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value));
|
||||
}
|
||||
assert_entry_pointer_valid(const entry_pointer p_e,
|
||||
store_hash_false_type) const
|
||||
{ map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); }
|
||||
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,11 +52,9 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_type) const
|
||||
{
|
||||
map_debug_base::check_key_exists(PB_DS_V2F(p_e->m_value));
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
|
||||
|
||||
comp_hash pos_hash_pair =
|
||||
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
|
||||
|
||||
PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_CC_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_entry_pointer(entry_pointer& r_p_e)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::erase_existing(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(
|
||||
PB_DS_V2F(r_p_e->m_value)));
|
||||
|
||||
entry_pointer p_e = r_p_e;
|
||||
|
@ -58,7 +58,7 @@ erase_entry_pointer(entry_pointer& r_p_e)
|
|||
|
||||
rels_entry(p_e);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_num_used_e > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
|
||||
resize_base::notify_erased(--m_num_used_e);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ inline bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (erase_in_pos_imp(r_key,
|
||||
ranged_hash_fn_base::operator()(r_key)));
|
||||
|
@ -61,7 +61,7 @@ inline bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_in_pos_imp(const_key_reference r_key, size_type pos)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
entry_pointer p_e = m_a_p_entries[pos];
|
||||
|
||||
|
@ -71,10 +71,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
r_key);)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_exists(r_key);)
|
||||
|
||||
erase_entry_pointer(m_a_p_entries[pos]);
|
||||
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
@ -105,10 +105,10 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -119,14 +119,14 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_exists(r_key);)
|
||||
|
||||
erase_entry_pointer(p_e->m_p_next);
|
||||
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ inline bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
entry_pointer p_e = m_a_p_entries[r_pos_hash_pair.first];
|
||||
|
||||
|
@ -60,11 +60,11 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(
|
||||
r_key);)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -77,14 +77,14 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
|
||||
r_key);)
|
||||
|
||||
erase_entry_pointer(m_a_p_entries[r_pos_hash_pair.first]);
|
||||
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
@ -97,10 +97,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_exists(
|
||||
r_key);)
|
||||
|
||||
|
@ -121,7 +121,7 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
|
|||
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (find_key_pointer(r_key, traits_base::m_store_extra_indicator));
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer( r_key, traits_base::m_store_extra_indicator));
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ inline std::pair<
|
|||
PB_DS_CLASS_C_DEC::
|
||||
insert_imp(const_reference r_val, store_hash_false_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
const_key_reference r_key = PB_DS_V2F(r_val);
|
||||
|
||||
|
@ -74,13 +74,13 @@ insert_imp(const_reference r_val, store_hash_false_type)
|
|||
|
||||
if (p_e != NULL)
|
||||
{
|
||||
PB_DS_DBG_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));
|
||||
}
|
||||
|
||||
PB_DS_DBG_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),
|
||||
|
|
|
@ -52,7 +52,7 @@ inline std::pair<
|
|||
PB_DS_CLASS_C_DEC::
|
||||
insert_imp(const_reference r_val, store_hash_true_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
const_key_reference r_key = PB_DS_V2F(r_val);
|
||||
|
||||
|
@ -77,12 +77,12 @@ insert_imp(const_reference r_val, store_hash_true_type)
|
|||
|
||||
if (p_e != NULL)
|
||||
{
|
||||
PB_DS_DBG_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));
|
||||
}
|
||||
|
||||
PB_DS_DBG_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_hash_pair),
|
||||
|
|
|
@ -81,7 +81,7 @@ do_resize_if_needed_no_throw()
|
|||
catch(...)
|
||||
{ }
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -89,7 +89,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
resize_imp(size_type new_size)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
if (new_size == m_num_e_p)
|
||||
return;
|
||||
|
@ -123,7 +123,7 @@ resize_imp(size_type new_size)
|
|||
|
||||
Resize_Policy::notify_resized(new_size);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -143,13 +143,13 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res
|
|||
|
||||
m_num_e_p = new_size;
|
||||
|
||||
PB_DS_DBG_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_a_p_entries, old_size);
|
||||
|
||||
m_a_p_entries = a_p_entries_resized;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
|
||||
|
|
|
@ -49,34 +49,20 @@
|
|||
#define PB_DS_HASH_EQ_FN_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_HASH_EQ_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_HASH_EQ_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_HASH_EQ_FN_DEBUG
|
||||
|
||||
template<typename Key, class Eq_Fn, class Allocator, bool Store_Hash>
|
||||
struct hash_eq_fn;
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, class Eq_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
hash_eq_fn< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
Allocator, \
|
||||
false>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
hash_eq_fn<Key, Eq_Fn, Allocator, false>
|
||||
|
||||
/**
|
||||
* Specialization 1- The client requests that hash values not be stored.
|
||||
|
@ -110,9 +96,7 @@ namespace pb_ds
|
|||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(const PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
std::swap((Eq_Fn& )(*this), (Eq_Fn& )other);
|
||||
}
|
||||
{ std::swap((Eq_Fn& )(*this), (Eq_Fn& )other); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -124,22 +108,16 @@ namespace pb_ds
|
|||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
|
||||
{
|
||||
return (eq_fn_base::operator()(r_lhs_key, r_rhs_key));
|
||||
}
|
||||
{ return (eq_fn_base::operator()(r_lhs_key, r_rhs_key)); }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, class Eq_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
hash_eq_fn< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
Allocator, \
|
||||
true>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
hash_eq_fn<Key, Eq_Fn, Allocator, true>
|
||||
|
||||
/**
|
||||
* Specialization 2- The client requests that hash values be stored.
|
||||
|
@ -161,7 +139,8 @@ namespace pb_ds
|
|||
hash_eq_fn(const Eq_Fn& r_eq_fn);
|
||||
|
||||
inline bool
|
||||
operator()(const_key_reference r_lhs_key, size_type lhs_hash, const_key_reference r_rhs_key, size_type rhs_hash) const;
|
||||
operator()(const_key_reference r_lhs_key, size_type lhs_hash,
|
||||
const_key_reference r_rhs_key, size_type rhs_hash) const;
|
||||
|
||||
inline void
|
||||
swap(const PB_DS_CLASS_C_DEC& other);
|
||||
|
@ -181,12 +160,13 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator()(const_key_reference r_lhs_key, size_type lhs_hash, const_key_reference r_rhs_key, size_type rhs_hash) const
|
||||
operator()(const_key_reference r_lhs_key, size_type lhs_hash,
|
||||
const_key_reference r_rhs_key, size_type rhs_hash) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key) ||
|
||||
lhs_hash == rhs_hash);
|
||||
_GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
|
||||
|| lhs_hash == rhs_hash);
|
||||
|
||||
return (lhs_hash == rhs_hash&&
|
||||
return (lhs_hash == rhs_hash &&
|
||||
eq_fn_base::operator()(r_lhs_key, r_rhs_key));
|
||||
}
|
||||
|
||||
|
@ -194,18 +174,12 @@ namespace pb_ds
|
|||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(const PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
std::swap((Eq_Fn& )(*this), (Eq_Fn& )(other));
|
||||
}
|
||||
{ std::swap((Eq_Fn& )(*this), (Eq_Fn& )(other)); }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_HASH_EQ_FN_HPP
|
||||
#endif
|
||||
|
|
|
@ -63,44 +63,38 @@ PB_DS_CLASS_T_DEC
|
|||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME() :
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
|
||||
hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -108,15 +102,13 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob
|
|||
hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -124,15 +116,13 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob
|
|||
hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn, r_probe_fn),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -141,22 +131,20 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Prob
|
|||
resize_base(r_resize_policy),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn, r_probe_fn),
|
||||
m_a_entries(s_entry_allocator.allocate(
|
||||
resize_base::get_nearest_larger_size(1))),
|
||||
m_a_entries(s_entry_allocator.allocate(resize_base::get_nearest_larger_size(1))),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_used_e(0)
|
||||
{
|
||||
initialize();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
PB_DS_MAP_DEBUG_BASE_C_DEC(other),
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
map_debug_base(other),
|
||||
#endif
|
||||
hash_eq_fn_base(other),
|
||||
resize_base(other),
|
||||
ranged_probe_fn_base(other),
|
||||
|
@ -172,7 +160,6 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
|||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
{
|
||||
m_a_entries[i].m_stat = other.m_a_entries[i].m_stat;
|
||||
|
||||
if (m_a_entries[i].m_stat == valid_entry_status)
|
||||
new (m_a_entries + i) entry(other.m_a_entries[i]);
|
||||
}
|
||||
|
@ -180,11 +167,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
|||
catch(...)
|
||||
{
|
||||
deallocate_all();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -199,25 +185,17 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid());
|
||||
PB_DS_DBG_ONLY(other.assert_valid());
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
|
||||
std::swap(m_a_entries, other.m_a_entries);
|
||||
|
||||
std::swap(m_num_e, other.m_num_e);
|
||||
|
||||
std::swap(m_num_used_e, other.m_num_used_e);
|
||||
|
||||
ranged_probe_fn_base::swap(other);
|
||||
|
||||
hash_eq_fn_base::swap(other);
|
||||
|
||||
resize_base::swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::swap(other));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid());
|
||||
PB_DS_DBG_ONLY(other.assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid());
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid());
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -226,9 +204,7 @@ PB_DS_CLASS_C_DEC::
|
|||
deallocate_all()
|
||||
{
|
||||
clear();
|
||||
|
||||
erase_all_valid_entries(m_a_entries, m_num_e);
|
||||
|
||||
s_entry_allocator.deallocate(m_a_entries, m_num_e);
|
||||
}
|
||||
|
||||
|
@ -240,7 +216,6 @@ erase_all_valid_entries(entry_array a_entries_resized, size_type size)
|
|||
for (size_type pos = 0; pos < size; ++pos)
|
||||
{
|
||||
entry_pointer p_e =& a_entries_resized[pos];
|
||||
|
||||
if (p_e->m_stat == valid_entry_status)
|
||||
p_e->m_value.~value_type();
|
||||
}
|
||||
|
@ -252,11 +227,8 @@ PB_DS_CLASS_C_DEC::
|
|||
initialize()
|
||||
{
|
||||
Resize_Policy::notify_resized(m_num_e);
|
||||
|
||||
Resize_Policy::notify_cleared();
|
||||
|
||||
ranged_probe_fn_base::notify_resized(m_num_e);
|
||||
|
||||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
m_a_entries[i].m_stat = (entry_status)empty_entry_status;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
|
||||
entry* const p_e = m_a_entries + pos;
|
||||
|
||||
|
@ -58,6 +58,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral
|
|||
|
||||
p_e->m_stat = valid_entry_status;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
insert_new(p_e->m_value.first);)
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_type)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
|
||||
entry* const p_e = m_a_entries + pos;
|
||||
|
||||
|
@ -61,6 +61,6 @@ constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, true_typ
|
|||
|
||||
p_e->m_stat = valid_entry_status;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
insert_new(p_e->m_value.first);)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of gp_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,11 +52,10 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_valid() const
|
||||
{
|
||||
map_debug_base::check_size(m_num_used_e);
|
||||
|
||||
assert_entry_array_valid(m_a_entries, traits_base::m_store_extra_indicator);
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp>
|
||||
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of gp_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -74,11 +74,11 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) con
|
|||
break;
|
||||
}
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of gp_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -56,7 +56,6 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons
|
|||
for (size_type pos = 0; pos < m_num_e; ++pos)
|
||||
{
|
||||
const_entry_pointer p_e =& a_entries[pos];
|
||||
|
||||
switch(p_e->m_stat)
|
||||
{
|
||||
case empty_entry_status:
|
||||
|
@ -64,26 +63,21 @@ assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) cons
|
|||
break;
|
||||
case valid_entry_status:
|
||||
{
|
||||
const_key_reference r_key =
|
||||
PB_DS_V2F(p_e->m_value);
|
||||
|
||||
const_key_reference r_key = PB_DS_V2F(p_e->m_value);
|
||||
map_debug_base::check_key_exists(r_key);
|
||||
|
||||
const comp_hash pos_hash_pair =
|
||||
ranged_probe_fn_base::operator()(r_key);
|
||||
|
||||
PB_DS_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second);
|
||||
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second);
|
||||
++iterated_num_used_e;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
|
|
@ -49,9 +49,9 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_entry(entry_pointer p_e)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_e->m_stat = valid_entry_status);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::erase_existing(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(
|
||||
PB_DS_V2F(p_e->m_value));)
|
||||
|
||||
typedef
|
||||
|
@ -62,7 +62,7 @@ erase_entry(entry_pointer p_e)
|
|||
|
||||
p_e->m_stat = erased_entry_status;
|
||||
|
||||
PB_DS_DBG_ASSERT(m_num_used_e > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
|
||||
resize_base::notify_erased(--m_num_used_e);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
size_type num_ersd = 0;
|
||||
|
||||
|
@ -109,7 +109,7 @@ erase_if(Pred pred)
|
|||
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
return (num_ersd);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ inline bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_imp(const_key_reference r_key, false_type)
|
||||
{
|
||||
PB_DS_DBG_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);
|
||||
|
||||
|
@ -71,7 +71,7 @@ erase_imp(const_key_reference r_key, false_type)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
r_key));
|
||||
|
||||
return (false);
|
||||
|
@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, false_type)
|
|||
case erased_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_erase_search_collision();
|
||||
|
|
|
@ -69,7 +69,7 @@ erase_imp(const_key_reference r_key, true_type)
|
|||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
r_key));
|
||||
|
||||
return (false);
|
||||
|
@ -94,7 +94,7 @@ erase_imp(const_key_reference r_key, true_type)
|
|||
case erased_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_erase_search_collision();
|
||||
|
|
|
@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return ((find_key_pointer(r_key, traits_base::m_store_extra_indicator)));
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).
|
||||
find_key_pointer(r_key, traits_base::m_store_extra_indicator));
|
||||
|
|
|
@ -52,26 +52,17 @@
|
|||
#include <utility>
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif // PB_DS_HT_MAP_TRACE_
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#endif
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#include <ext/pb_ds/detail/map_debug_base.hpp>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#endif
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Key, \
|
||||
|
@ -85,14 +76,12 @@ namespace pb_ds
|
|||
class Resize_Policy>
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
gp_ht_map_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME gp_ht_map_data_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
gp_ht_map_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME gp_ht_map_no_data_
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME< \
|
||||
|
@ -129,24 +118,20 @@ namespace pb_ds
|
|||
Allocator, \
|
||||
Store_Hash>
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
typename Allocator::template rebind< \
|
||||
Key>::other::const_reference>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
map_debug_base<Key, Eq_Fn, typename Allocator::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped()
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
|
||||
typedef \
|
||||
|
@ -164,9 +149,9 @@ namespace pb_ds
|
|||
class Probe_Fn,
|
||||
class Resize_Policy>
|
||||
class PB_DS_CLASS_NAME :
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
protected PB_DS_MAP_DEBUG_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
public PB_DS_HASH_EQ_FN_C_DEC,
|
||||
public Resize_Policy,
|
||||
public PB_DS_RANGED_PROBE_FN_C_DEC,
|
||||
|
@ -362,7 +347,7 @@ namespace pb_ds
|
|||
inline std::pair<point_iterator, bool>
|
||||
insert(const_reference r_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
return (insert_imp(r_val, traits_base::m_store_extra_indicator));
|
||||
}
|
||||
|
@ -413,19 +398,15 @@ namespace pb_ds
|
|||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // #ifdef PB_DS_HT_MAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
|
||||
|
@ -462,9 +443,9 @@ namespace pb_ds
|
|||
|
||||
typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base;
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#endif
|
||||
|
||||
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
|
||||
|
||||
|
@ -525,13 +506,13 @@ namespace pb_ds
|
|||
inline pointer
|
||||
insert_new_imp(const_reference r_val, size_type pos)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
|
||||
if (do_resize_if_needed())
|
||||
pos = find_ins_pos(PB_DS_V2F(r_val),
|
||||
traits_base::m_store_extra_indicator);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[pos].m_stat != valid_entry_status);
|
||||
|
||||
entry* const p_e = m_a_entries + pos;
|
||||
|
||||
|
@ -541,10 +522,10 @@ namespace pb_ds
|
|||
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
insert_new(PB_DS_V2F(p_e->m_value));)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (&p_e->m_value);
|
||||
}
|
||||
|
@ -552,7 +533,7 @@ namespace pb_ds
|
|||
inline pointer
|
||||
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat !=
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat !=
|
||||
valid_entry_status);
|
||||
|
||||
if (do_resize_if_needed())
|
||||
|
@ -560,7 +541,7 @@ namespace pb_ds
|
|||
PB_DS_V2F(r_val),
|
||||
traits_base::m_store_extra_indicator);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat !=
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat !=
|
||||
valid_entry_status);
|
||||
|
||||
entry* const p_e = m_a_entries + r_pos_hash_pair.first;
|
||||
|
@ -573,10 +554,10 @@ namespace pb_ds
|
|||
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(p_e->m_value));)
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (&p_e->m_value);
|
||||
}
|
||||
|
@ -585,7 +566,7 @@ namespace pb_ds
|
|||
inline mapped_reference
|
||||
subscript_imp(const_key_reference r_key, store_hash_false_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
const size_type pos =
|
||||
find_ins_pos(r_key, traits_base::m_store_extra_indicator);
|
||||
|
@ -599,7 +580,7 @@ namespace pb_ds
|
|||
mapped_type()),
|
||||
pos)->second);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return (p_e->m_value.second);
|
||||
}
|
||||
|
@ -607,7 +588,7 @@ namespace pb_ds
|
|||
inline mapped_reference
|
||||
subscript_imp(const_key_reference r_key, store_hash_true_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
comp_hash pos_hash_pair =
|
||||
find_ins_pos(r_key, traits_base::m_store_extra_indicator);
|
||||
|
@ -619,7 +600,7 @@ namespace pb_ds
|
|||
mapped_type()),
|
||||
pos_hash_pair)->second);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
|
||||
return ((m_a_entries + pos_hash_pair.first)->m_value.second);
|
||||
}
|
||||
|
@ -649,7 +630,7 @@ namespace pb_ds
|
|||
{
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
return (NULL);
|
||||
|
@ -662,7 +643,7 @@ namespace pb_ds
|
|||
{
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return ((pointer)&p_e->m_value);
|
||||
}
|
||||
|
@ -670,13 +651,13 @@ namespace pb_ds
|
|||
case erased_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_find_search_collision();
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
@ -708,7 +689,7 @@ namespace pb_ds
|
|||
{
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
return (NULL);
|
||||
|
@ -722,7 +703,7 @@ namespace pb_ds
|
|||
{
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return ((pointer)&p_e->m_value);
|
||||
}
|
||||
|
@ -730,13 +711,13 @@ namespace pb_ds
|
|||
case erased_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_find_search_collision();
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::
|
||||
check_key_does_not_exist(r_key);)
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
@ -764,7 +745,7 @@ namespace pb_ds
|
|||
void
|
||||
inc_it_state(const_pointer& r_p_value, size_type& r_pos) const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(r_p_value != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(r_p_value != NULL);
|
||||
|
||||
for (++r_pos; r_pos < m_num_e; ++r_pos)
|
||||
{
|
||||
|
@ -817,15 +798,15 @@ namespace pb_ds
|
|||
r_p_value = NULL;
|
||||
}
|
||||
|
||||
#ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_entry_array_valid(const entry_array a_entries,
|
||||
store_hash_false_type) const;
|
||||
|
||||
void
|
||||
assert_entry_array_valid(const entry_array a_entries, store_hash_false_type) const;
|
||||
|
||||
void
|
||||
assert_entry_array_valid(const entry_array a_entries, store_hash_true_type) const;
|
||||
|
||||
#endif // #ifdef PB_DS_GP_HT_MAP_DEBUG__
|
||||
assert_entry_array_valid(const entry_array a_entries,
|
||||
store_hash_true_type) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static entry_allocator s_entry_allocator;
|
||||
|
@ -880,10 +861,6 @@ namespace pb_ds
|
|||
#undef PB_DS_V2F
|
||||
#undef PB_DS_V2S
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
#undef PB_DS_STATIC_ASSERT
|
||||
|
||||
} // namespace detail
|
||||
|
|
|
@ -66,7 +66,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
|
|||
const size_type pos =
|
||||
ranged_probe_fn_base::operator()(r_key, hash, i);
|
||||
|
||||
PB_DS_DBG_ASSERT(pos < m_num_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(pos < m_num_e);
|
||||
|
||||
entry* const p_e = m_a_entries + pos;
|
||||
|
||||
|
@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
|
|||
{
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(
|
||||
_GLIBCXX_DEBUG_ONLY(
|
||||
map_debug_base::check_key_does_not_exist(r_key);)
|
||||
|
||||
return ((ins_pos == m_num_e)? pos : ins_pos);
|
||||
|
@ -92,13 +92,13 @@ find_ins_pos(const_key_reference r_key, store_hash_false_type)
|
|||
{
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return (pos);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_insert_search_collision();
|
||||
|
@ -124,14 +124,14 @@ insert_imp(const_reference r_val, store_hash_false_type)
|
|||
|
||||
if (m_a_entries[pos].m_stat == valid_entry_status)
|
||||
{
|
||||
PB_DS_DBG_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_a_entries + pos)->m_value,
|
||||
false));
|
||||
}
|
||||
|
||||
PB_DS_DBG_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),
|
||||
|
|
|
@ -50,7 +50,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find_ins_pos(const_key_reference r_key, store_hash_true_type)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
|
||||
|
||||
|
@ -76,7 +76,7 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type)
|
|||
{
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(
|
||||
_GLIBCXX_DEBUG_ONLY(
|
||||
map_debug_base::check_key_does_not_exist(r_key);)
|
||||
|
||||
return ((ins_pos == m_num_e)?
|
||||
|
@ -97,13 +97,13 @@ find_ins_pos(const_key_reference r_key, store_hash_true_type)
|
|||
{
|
||||
resize_base::notify_insert_search_end();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return (std::make_pair(pos, pos_hash_pair.second));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
resize_base::notify_insert_search_collision();
|
||||
|
@ -127,18 +127,18 @@ insert_imp(const_reference r_val, store_hash_true_type)
|
|||
comp_hash pos_hash_pair =
|
||||
find_ins_pos(r_key, traits_base::m_store_extra_indicator);
|
||||
|
||||
PB_DS_DBG_ASSERT(pos_hash_pair.first < m_num_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(pos_hash_pair.first < m_num_e);
|
||||
|
||||
entry_pointer p_e =& m_a_entries[pos_hash_pair.first];
|
||||
|
||||
if (p_e->m_stat == valid_entry_status)
|
||||
{
|
||||
PB_DS_DBG_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));
|
||||
}
|
||||
|
||||
PB_DS_DBG_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_hash_pair),
|
||||
|
|
|
@ -81,7 +81,7 @@ do_resize_if_needed_no_throw()
|
|||
catch(...)
|
||||
{ }
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -96,7 +96,7 @@ resize_imp(size_type new_size)
|
|||
if (new_size == m_num_e)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
const size_type old_size = m_num_e;
|
||||
|
||||
|
@ -132,7 +132,7 @@ resize_imp(size_type new_size)
|
|||
|
||||
// At this point no exceptions can be thrown.
|
||||
|
||||
PB_DS_DBG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator);)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator);)
|
||||
|
||||
Resize_Policy::notify_resized(new_size);
|
||||
|
||||
|
@ -142,7 +142,7 @@ resize_imp(size_type new_size)
|
|||
|
||||
m_a_entries = a_entries_resized;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -73,12 +73,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
|
|||
|
||||
return;
|
||||
case erased_entry_status:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
break;
|
||||
case valid_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -76,12 +76,12 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, store_hash
|
|||
|
||||
return;
|
||||
case erased_entry_status:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
break;
|
||||
case valid_entry_status:
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ trace() const
|
|||
std::cerr << PB_DS_V2F(m_a_entries[i].m_value);
|
||||
break;
|
||||
default:
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
};
|
||||
|
||||
std::cerr << std::endl;
|
||||
|
|
|
@ -51,48 +51,15 @@
|
|||
|
||||
namespace pb_ds
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PROBE_FN_BASE_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PROBE_FN_BASE_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PROBE_FN_BASE_DEBUG
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
probe_fn_base< \
|
||||
Allocator>
|
||||
|
||||
template<typename Allocator>
|
||||
class probe_fn_base
|
||||
{
|
||||
protected:
|
||||
~probe_fn_base();
|
||||
~probe_fn_base() { }
|
||||
};
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~probe_fn_base()
|
||||
{ }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_PROBE_FN_BASE_HPP
|
||||
#endif
|
||||
|
|
|
@ -50,22 +50,13 @@
|
|||
|
||||
#include <ext/pb_ds/detail/basic_types.hpp>
|
||||
#include <utility>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
|
||||
template<typename Key,
|
||||
class Hash_Fn,
|
||||
class Allocator,
|
||||
|
@ -254,26 +245,20 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_hash_fn(size_type size)
|
||||
{
|
||||
Comb_Hash_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Hash_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) :
|
||||
Hash_Fn(r_hash_fn)
|
||||
{
|
||||
Comb_Hash_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Hash_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) :
|
||||
Hash_Fn(r_hash_fn),
|
||||
Comb_Hash_Fn(r_comb_hash_fn)
|
||||
{
|
||||
comb_hash_fn_base::notify_resized(size);
|
||||
}
|
||||
{ comb_hash_fn_base::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -281,7 +266,6 @@ namespace pb_ds
|
|||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
comb_hash_fn_base::swap(other);
|
||||
|
||||
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
|
||||
}
|
||||
|
||||
|
@ -289,9 +273,7 @@ namespace pb_ds
|
|||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
notify_resized(size_type size)
|
||||
{
|
||||
comb_hash_fn_base::notify_resized(size);
|
||||
}
|
||||
{ comb_hash_fn_base::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::comp_hash
|
||||
|
@ -299,23 +281,21 @@ namespace pb_ds
|
|||
operator()(const_key_reference r_key) const
|
||||
{
|
||||
const size_type hash = hash_fn_base::operator()(r_key);
|
||||
|
||||
return (std::make_pair(comb_hash_fn_base::operator()(hash), hash));
|
||||
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::comp_hash
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator()
|
||||
#ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
(const_key_reference r_key, size_type hash) const
|
||||
#else // #ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
#else
|
||||
(const_key_reference /*r_key*/, size_type hash) const
|
||||
#endif // #ifdef PB_DS_RANGED_HASH_FN_DEBUG
|
||||
#endif
|
||||
{
|
||||
PB_DS_DBG_ASSERT(hash == hash_fn_base::operator()(r_key));
|
||||
|
||||
return (std::make_pair(comb_hash_fn_base::operator()(hash), hash));
|
||||
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
|
||||
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
|
||||
}
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
@ -359,7 +339,7 @@ namespace pb_ds
|
|||
|
||||
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
|
||||
ranged_hash_fn(size_type size, const null_hash_fn & r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC& other);
|
||||
|
@ -368,9 +348,7 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_hash_fn(size_type size)
|
||||
{
|
||||
Comb_Hash_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Hash_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -388,9 +366,7 @@ namespace pb_ds
|
|||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
comb_hash_fn_base::swap(other);
|
||||
}
|
||||
{ comb_hash_fn_base::swap(other); }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
@ -432,7 +408,7 @@ namespace pb_ds
|
|||
|
||||
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
|
||||
ranged_hash_fn(size_type size, const null_hash_fn & r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn);
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC& other);
|
||||
|
@ -441,9 +417,7 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_hash_fn(size_type size)
|
||||
{
|
||||
Comb_Hash_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Hash_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -461,18 +435,12 @@ namespace pb_ds
|
|||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
comb_hash_fn_base::swap(other);
|
||||
}
|
||||
{ comb_hash_fn_base::swap(other); }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_RANGED_HASH_FN_HPP
|
||||
#endif
|
||||
|
|
|
@ -50,22 +50,12 @@
|
|||
|
||||
#include <ext/pb_ds/detail/basic_types.hpp>
|
||||
#include <utility>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
|
||||
template<typename Key,
|
||||
class Hash_Fn,
|
||||
class Allocator,
|
||||
|
@ -298,26 +288,20 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_probe_fn(size_type size)
|
||||
{
|
||||
Comb_Probe_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Probe_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) :
|
||||
Hash_Fn(r_hash_fn)
|
||||
{
|
||||
Comb_Probe_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Probe_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn) :
|
||||
Hash_Fn(r_hash_fn),
|
||||
Comb_Probe_Fn(r_comb_probe_fn)
|
||||
{
|
||||
comb_probe_fn_base::notify_resized(size);
|
||||
}
|
||||
{ comb_probe_fn_base::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -325,9 +309,7 @@ namespace pb_ds
|
|||
Hash_Fn(r_hash_fn),
|
||||
Comb_Probe_Fn(r_comb_probe_fn),
|
||||
Probe_Fn(r_probe_fn)
|
||||
{
|
||||
comb_probe_fn_base::notify_resized(size);
|
||||
}
|
||||
{ comb_probe_fn_base::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -335,7 +317,6 @@ namespace pb_ds
|
|||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
comb_probe_fn_base::swap(other);
|
||||
|
||||
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other);
|
||||
}
|
||||
|
||||
|
@ -343,9 +324,7 @@ namespace pb_ds
|
|||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
notify_resized(size_type size)
|
||||
{
|
||||
comb_probe_fn_base::notify_resized(size);
|
||||
}
|
||||
{ comb_probe_fn_base::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::comp_hash
|
||||
|
@ -353,8 +332,7 @@ namespace pb_ds
|
|||
operator()(const_key_reference r_key) const
|
||||
{
|
||||
const size_type hash = hash_fn_base::operator()(r_key);
|
||||
|
||||
return (std::make_pair(comb_probe_fn_base::operator()(hash), hash));
|
||||
return std::make_pair(comb_probe_fn_base::operator()(hash), hash);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -362,23 +340,21 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
operator()(const_key_reference /*r_key*/, size_type hash, size_type i) const
|
||||
{
|
||||
return (comb_probe_fn_base::operator()(
|
||||
hash + probe_fn_base::operator()(i)));
|
||||
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator()
|
||||
#ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
(const_key_reference r_key, size_type hash) const
|
||||
#else // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
#else
|
||||
(const_key_reference /*r_key*/, size_type hash) const
|
||||
#endif // #ifdef PB_DS_RANGED_PROBE_FN_DEBUG
|
||||
#endif
|
||||
{
|
||||
PB_DS_DBG_ASSERT(hash == hash_fn_base::operator()(r_key));
|
||||
|
||||
return (hash);
|
||||
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
|
||||
return hash;
|
||||
}
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
@ -435,9 +411,7 @@ namespace pb_ds
|
|||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
ranged_probe_fn(size_type size)
|
||||
{
|
||||
Comb_Probe_Fn::notify_resized(size);
|
||||
}
|
||||
{ Comb_Probe_Fn::notify_resized(size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -455,19 +429,12 @@ namespace pb_ds
|
|||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
comb_probe_fn_base::swap(other);
|
||||
}
|
||||
{ comb_probe_fn_base::swap(other); }
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_RANGED_PROBE_FN_HPP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,31 +49,18 @@
|
|||
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
left_child_next_sibling_heap_const_iterator_< \
|
||||
Node, \
|
||||
Allocator>
|
||||
left_child_next_sibling_heap_const_iterator_<Node, Allocator>
|
||||
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_node_const_point_iterator_< \
|
||||
Node, \
|
||||
Allocator>
|
||||
left_child_next_sibling_heap_node_const_point_iterator_<Node, Allocator>
|
||||
|
||||
// Const point-type iterator.
|
||||
template<typename Node, class Allocator>
|
||||
|
@ -127,24 +114,18 @@ namespace pb_ds
|
|||
// Compares content to a different iterator object.
|
||||
inline bool
|
||||
operator==(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (base_type::m_p_nd == other.m_p_nd);
|
||||
}
|
||||
{ return (base_type::m_p_nd == other.m_p_nd); }
|
||||
|
||||
// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (base_type::m_p_nd != other.m_p_nd);
|
||||
}
|
||||
{ return (base_type::m_p_nd != other.m_p_nd); }
|
||||
|
||||
inline PB_DS_CLASS_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_type::m_p_nd != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != NULL);
|
||||
inc();
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
@ -152,9 +133,7 @@ namespace pb_ds
|
|||
operator++(int)
|
||||
{
|
||||
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_nd);
|
||||
|
||||
operator++();
|
||||
|
||||
return (ret_it);
|
||||
}
|
||||
|
||||
|
@ -165,10 +144,8 @@ namespace pb_ds
|
|||
if (base_type::m_p_nd->m_p_next_sibling != NULL)
|
||||
{
|
||||
base_type::m_p_nd = base_type::m_p_nd->m_p_next_sibling;
|
||||
|
||||
while (base_type::m_p_nd->m_p_l_child != NULL)
|
||||
base_type::m_p_nd = base_type::m_p_nd->m_p_l_child;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,7 +153,6 @@ namespace pb_ds
|
|||
{
|
||||
node_pointer p_next = base_type::m_p_nd;
|
||||
base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent;
|
||||
|
||||
if (base_type::m_p_nd == NULL || base_type::m_p_nd->m_p_l_child == p_next)
|
||||
return;
|
||||
}
|
||||
|
@ -184,14 +160,9 @@ namespace pb_ds
|
|||
};
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
|
||||
#endif
|
||||
|
|
|
@ -49,29 +49,18 @@
|
|||
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;m_p_prev_or_parent
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Node, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
left_child_next_sibling_heap_node_const_point_iterator_< \
|
||||
Node, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
left_child_next_sibling_heap_node_const_point_iterator_<Node, Allocator>
|
||||
|
||||
// Const point-type iterator.
|
||||
template<typename Node, class Allocator>
|
||||
|
@ -79,10 +68,7 @@ namespace pb_ds
|
|||
{
|
||||
|
||||
protected:
|
||||
typedef
|
||||
typename Allocator::template rebind<
|
||||
Node>::other::pointer
|
||||
node_pointer;
|
||||
typedef typename Allocator::template rebind<Node>::other::pointer node_pointer;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -127,49 +113,39 @@ namespace pb_ds
|
|||
|
||||
// Default constructor.
|
||||
inline
|
||||
left_child_next_sibling_heap_node_const_point_iterator_()
|
||||
|
||||
: m_p_nd(NULL)
|
||||
left_child_next_sibling_heap_node_const_point_iterator_() : m_p_nd(NULL)
|
||||
{ }
|
||||
|
||||
// Copy constructor.
|
||||
inline
|
||||
left_child_next_sibling_heap_node_const_point_iterator_(const PB_DS_CLASS_C_DEC& other)
|
||||
|
||||
: m_p_nd(other.m_p_nd)
|
||||
left_child_next_sibling_heap_node_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd)
|
||||
{ }
|
||||
|
||||
// Access.
|
||||
inline const_pointer
|
||||
operator->() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_nd != NULL);
|
||||
|
||||
return (&m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
|
||||
return &m_p_nd->m_value;
|
||||
}
|
||||
|
||||
// Access.
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_nd != NULL);
|
||||
|
||||
return (m_p_nd->m_value);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != NULL);
|
||||
return m_p_nd->m_value;
|
||||
}
|
||||
|
||||
// Compares content to a different iterator object.
|
||||
inline bool
|
||||
operator==(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (m_p_nd == other.m_p_nd);
|
||||
}
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const PB_DS_CLASS_C_DEC& other) const
|
||||
{
|
||||
return (m_p_nd != other.m_p_nd);
|
||||
}
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
public:
|
||||
node_pointer m_p_nd;
|
||||
|
@ -178,11 +154,7 @@ namespace pb_ds
|
|||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
#endif
|
||||
|
|
|
@ -58,7 +58,7 @@ left_child_next_sibling_heap_() :
|
|||
m_p_root(NULL),
|
||||
m_size(0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -68,7 +68,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
|
|||
m_p_root(NULL),
|
||||
m_size(0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -80,13 +80,13 @@ left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) :
|
|||
{
|
||||
m_size = other.m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
m_p_root = recursive_copy_node(other.m_p_root);
|
||||
|
||||
m_size = other.m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -94,15 +94,15 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
value_swap(other);
|
||||
|
||||
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -44,20 +44,18 @@
|
|||
* Contains an implementation class for left_child_next_sibling_heap_.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_p_root == NULL || m_p_root->m_p_prev_or_parent == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_root == NULL || m_p_root->m_p_prev_or_parent == NULL);
|
||||
|
||||
if (m_p_root != NULL)
|
||||
assert_node_consistent(m_p_root, Single_Link_Roots);
|
||||
|
||||
assert_size();
|
||||
|
||||
assert_iterators();
|
||||
}
|
||||
|
||||
|
@ -73,25 +71,21 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const
|
|||
assert_node_consistent(p_nd->m_p_next_sibling, single_link);
|
||||
|
||||
if (single_link)
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_prev_or_parent == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent == NULL);
|
||||
else if (p_nd->m_p_next_sibling != NULL)
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd);
|
||||
|
||||
if (p_nd->m_p_l_child == NULL)
|
||||
return;
|
||||
|
||||
const_node_pointer p_child = p_nd->m_p_l_child;
|
||||
|
||||
while (p_child != NULL)
|
||||
{
|
||||
const_node_pointer p_next_child = p_child->m_p_next_sibling;
|
||||
|
||||
PB_DS_DBG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value));
|
||||
p_child = p_next_child;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -100,11 +94,9 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_iterators() const
|
||||
{
|
||||
const size_type calc_size = std::distance(begin(), end());
|
||||
|
||||
if (calc_size == size())
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -114,17 +106,14 @@ assert_size() const
|
|||
{
|
||||
if (size_from_node(m_p_root) == m_size)
|
||||
return;
|
||||
|
||||
PB_DS_DBG_ASSERT(0);
|
||||
_GLIBCXX_DEBUG_ASSERT(0);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
size_under_node(const_node_pointer p_nd)
|
||||
{
|
||||
return 1 + size_from_node(p_nd->m_p_l_child);
|
||||
}
|
||||
{ return 1 + size_from_node(p_nd->m_p_l_child); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
|
@ -132,14 +121,11 @@ PB_DS_CLASS_C_DEC::
|
|||
size_from_node(const_node_pointer p_nd)
|
||||
{
|
||||
size_type ret = 0;
|
||||
|
||||
while (p_nd != NULL)
|
||||
{
|
||||
ret += 1 + size_from_node(p_nd->m_p_l_child);
|
||||
|
||||
p_nd = p_nd->m_p_next_sibling;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -149,17 +135,13 @@ PB_DS_CLASS_C_DEC::
|
|||
degree(const_node_pointer p_nd)
|
||||
{
|
||||
size_type ret = 0;
|
||||
|
||||
const_node_pointer p_child = p_nd->m_p_l_child;
|
||||
|
||||
while (p_child != NULL)
|
||||
{
|
||||
++ret;
|
||||
|
||||
p_child = p_child->m_p_next_sibling;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -50,8 +50,7 @@ PB_DS_CLASS_C_DEC::
|
|||
clear()
|
||||
{
|
||||
clear_imp(m_p_root);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size == 0);
|
||||
m_p_root = NULL;
|
||||
}
|
||||
|
||||
|
@ -60,11 +59,9 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_node(node_pointer p_nd)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
p_nd->~node();
|
||||
|
||||
s_node_allocator.deallocate(p_nd, 1);
|
||||
}
|
||||
|
||||
|
@ -76,11 +73,8 @@ clear_imp(node_pointer p_nd)
|
|||
while (p_nd != NULL)
|
||||
{
|
||||
clear_imp(p_nd->m_p_l_child);
|
||||
|
||||
node_pointer p_next = p_nd->m_p_next_sibling;
|
||||
|
||||
actual_erase_node(p_nd);
|
||||
|
||||
p_nd = p_next;
|
||||
}
|
||||
}
|
||||
|
@ -90,40 +84,30 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
to_linked_list()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
node_pointer p_cur = m_p_root;
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
node_pointer p_cur = m_p_root;
|
||||
while (p_cur != NULL)
|
||||
if (p_cur->m_p_l_child != NULL)
|
||||
{
|
||||
node_pointer p_child_next = p_cur->m_p_l_child->m_p_next_sibling;
|
||||
|
||||
p_cur->m_p_l_child->m_p_next_sibling = p_cur->m_p_next_sibling;
|
||||
|
||||
p_cur->m_p_next_sibling = p_cur->m_p_l_child;
|
||||
|
||||
p_cur->m_p_l_child = p_child_next;
|
||||
}
|
||||
else
|
||||
p_cur = p_cur->m_p_next_sibling;
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
const_node_pointer p_counter = m_p_root;
|
||||
|
||||
size_type count = 0;
|
||||
|
||||
while (p_counter != NULL)
|
||||
{
|
||||
++count;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_counter->m_p_l_child == NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_counter->m_p_l_child == NULL);
|
||||
p_counter = p_counter->m_p_next_sibling;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(count == m_size);
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
_GLIBCXX_DEBUG_ASSERT(count == m_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -133,37 +117,27 @@ PB_DS_CLASS_C_DEC::
|
|||
prune(Pred pred)
|
||||
{
|
||||
node_pointer p_cur = m_p_root;
|
||||
|
||||
m_p_root = NULL;
|
||||
|
||||
node_pointer p_out = NULL;
|
||||
|
||||
while (p_cur != NULL)
|
||||
{
|
||||
node_pointer p_next = p_cur->m_p_next_sibling;
|
||||
|
||||
if (pred(p_cur->m_value))
|
||||
{
|
||||
p_cur->m_p_next_sibling = p_out;
|
||||
|
||||
if (p_out != NULL)
|
||||
p_out->m_p_prev_or_parent = p_cur;
|
||||
|
||||
p_out = p_cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_cur->m_p_next_sibling = m_p_root;
|
||||
|
||||
if (m_p_root != NULL)
|
||||
m_p_root->m_p_prev_or_parent = p_cur;
|
||||
|
||||
m_p_root = p_cur;
|
||||
}
|
||||
|
||||
p_cur = p_next;
|
||||
}
|
||||
|
||||
return p_out;
|
||||
}
|
||||
|
||||
|
@ -173,11 +147,9 @@ PB_DS_CLASS_C_DEC::
|
|||
bubble_to_top(node_pointer p_nd)
|
||||
{
|
||||
node_pointer p_parent = parent(p_nd);
|
||||
|
||||
while (p_parent != NULL)
|
||||
{
|
||||
swap_with_parent(p_nd, p_parent);
|
||||
|
||||
p_parent = parent(p_nd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
make_child_of(node_pointer p_nd, node_pointer p_new_parent)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ASSERT(p_new_parent != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_new_parent != NULL);
|
||||
|
||||
p_nd->m_p_next_sibling = p_new_parent->m_p_l_child;
|
||||
|
||||
|
@ -130,9 +130,9 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent)
|
|||
if (p_parent == m_p_root)
|
||||
m_p_root = p_nd;
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ASSERT(p_parent != NULL);
|
||||
PB_DS_DBG_ASSERT(parent(p_nd) == p_parent);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_parent != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent);
|
||||
|
||||
const bool nd_direct_child = p_parent->m_p_l_child == p_nd;
|
||||
const bool parent_root = p_parent->m_p_prev_or_parent == NULL;
|
||||
|
@ -144,8 +144,8 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent)
|
|||
std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child);
|
||||
std::swap(p_parent->m_metadata, p_nd->m_metadata);
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_l_child != NULL);
|
||||
PB_DS_DBG_ASSERT(p_parent->m_p_prev_or_parent != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != NULL);
|
||||
|
||||
if (p_nd->m_p_next_sibling != NULL)
|
||||
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
|
||||
|
@ -169,13 +169,13 @@ swap_with_parent(node_pointer p_nd, node_pointer p_parent)
|
|||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_l_child == p_nd);
|
||||
PB_DS_DBG_ASSERT(p_parent->m_p_prev_or_parent == p_parent);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent);
|
||||
|
||||
p_nd->m_p_l_child = p_parent;
|
||||
p_parent->m_p_prev_or_parent = p_nd;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(parent(p_parent) == p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,24 +59,15 @@
|
|||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp>
|
||||
#ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
#endif
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Value_Type, \
|
||||
|
@ -84,16 +75,16 @@ namespace pb_ds
|
|||
typename Node_Metadata, \
|
||||
class Allocator, \
|
||||
bool Single_Link_Roots>
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#else
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Value_Type, \
|
||||
class Cmp_Fn, \
|
||||
typename Node_Metadata, \
|
||||
class Allocator>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
|
@ -101,30 +92,30 @@ namespace pb_ds
|
|||
Node_Metadata, \
|
||||
Allocator, \
|
||||
Single_Link_Roots>
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#else
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Node_Metadata, \
|
||||
Allocator>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* class description = "Base class for some types of h3ap$">
|
||||
**/
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
template<typename Value_Type,
|
||||
class Cmp_Fn,
|
||||
typename Node_Metadata,
|
||||
class Allocator,
|
||||
bool Single_Link_Roots>
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#else
|
||||
template<typename Value_Type,
|
||||
class Cmp_Fn,
|
||||
typename Node_Metadata,
|
||||
class Allocator>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
class left_child_next_sibling_heap_ : public Cmp_Fn
|
||||
{
|
||||
|
||||
|
@ -152,8 +143,7 @@ namespace pb_ds
|
|||
|
||||
enum
|
||||
{
|
||||
simple_value = is_simple<
|
||||
Value_Type>::value
|
||||
simple_value = is_simple<Value_Type>::value
|
||||
};
|
||||
|
||||
typedef integral_constant<int, simple_value> no_throw_copies_t;
|
||||
|
@ -250,11 +240,9 @@ namespace pb_ds
|
|||
clear();
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -289,8 +277,7 @@ namespace pb_ds
|
|||
node_pointer
|
||||
prune(Pred pred);
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
|
@ -302,15 +289,12 @@ namespace pb_ds
|
|||
|
||||
static size_type
|
||||
degree(const_node_pointer p_nd);
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
|
||||
static void
|
||||
trace_node(const_node_pointer, size_type level);
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
protected:
|
||||
node_pointer m_p_root;
|
||||
|
@ -318,8 +302,7 @@ namespace pb_ds
|
|||
size_type m_size;
|
||||
|
||||
private:
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_iterators() const;
|
||||
|
||||
|
@ -328,8 +311,7 @@ namespace pb_ds
|
|||
|
||||
static size_type
|
||||
size_from_node(const_node_pointer p_nd);
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
node_pointer
|
||||
recursive_copy_node(const_node_pointer p_nd);
|
||||
|
@ -341,15 +323,13 @@ namespace pb_ds
|
|||
get_new_node_for_insert(const_reference r_val, true_type);
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
|
||||
template<typename Metadata_>
|
||||
static void
|
||||
trace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>);
|
||||
|
||||
static void
|
||||
trace_node_metadata(const_node_pointer, type_to_type<null_left_child_next_sibling_heap_node_metadata>);
|
||||
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
static node_allocator s_node_allocator;
|
||||
|
@ -367,14 +347,9 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP
|
||||
#endif
|
||||
|
|
|
@ -73,69 +73,57 @@ copy_from_range(It first_it, It last_it)
|
|||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME() :
|
||||
m_p_l(NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
PB_DS_CLASS_NAME() : m_p_l(NULL)
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(It first_it, It last_it) :
|
||||
m_p_l(NULL)
|
||||
PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(NULL)
|
||||
{
|
||||
copy_from_range(first_it, last_it);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid(););
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(););
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
PB_DS_MAP_DEBUG_BASE_C_DEC(),
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
m_p_l(NULL)
|
||||
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
map_debug_base(),
|
||||
#endif
|
||||
m_p_l(NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (const_iterator it = other.begin(); it != other.end(); ++it)
|
||||
{
|
||||
entry_pointer p_l =
|
||||
allocate_new_entry( * it, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
entry_pointer p_l = allocate_new_entry(*it,
|
||||
PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
|
||||
p_l->m_p_next = m_p_l;
|
||||
|
||||
m_p_l = p_l;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
deallocate_all();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::swap(other);)
|
||||
|
||||
std::swap(m_p_l, other.m_p_l);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);)
|
||||
std::swap(m_p_l, other.m_p_l);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -143,23 +131,17 @@ PB_DS_CLASS_C_DEC::
|
|||
deallocate_all()
|
||||
{
|
||||
entry_pointer p_l = m_p_l;
|
||||
|
||||
while (p_l != NULL)
|
||||
{
|
||||
entry_pointer p_next_l = p_l->m_p_next;
|
||||
|
||||
actual_erase_entry(p_l);
|
||||
|
||||
p_l = p_next_l;
|
||||
}
|
||||
|
||||
m_p_l = NULL;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_CLASS_NAME()
|
||||
{
|
||||
deallocate_all();
|
||||
}
|
||||
{ deallocate_all(); }
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -52,15 +52,12 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_valid() const
|
||||
{
|
||||
size_type calc_size = 0;
|
||||
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
map_debug_base::check_key_exists(PB_DS_V2F(*it));
|
||||
|
||||
++calc_size;
|
||||
}
|
||||
|
||||
map_debug_base::check_size(calc_size);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ inline bool
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
if (m_p_l == NULL)
|
||||
return false;
|
||||
|
@ -94,7 +94,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
size_type num_ersd = 0;
|
||||
|
||||
|
@ -126,7 +126,7 @@ erase_if(Pred pred)
|
|||
p_l = p_l->m_p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
return (num_ersd);
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_next(entry_pointer p_l)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_l != NULL);
|
||||
PB_DS_DBG_ASSERT(p_l != m_p_l);
|
||||
PB_DS_DBG_ASSERT(p_l->m_p_next != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_l != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_l != m_p_l);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != NULL);
|
||||
|
||||
entry_pointer p_next_l = p_l->m_p_next->m_p_next;
|
||||
|
||||
|
@ -152,7 +152,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_entry(entry_pointer p_l)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::erase_existing(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::erase_existing(
|
||||
PB_DS_V2F(p_l->m_value));)
|
||||
|
||||
p_l->~entry();
|
||||
|
|
|
@ -56,7 +56,7 @@ find_imp(const_key_reference r_key) const
|
|||
{
|
||||
apply_update(m_p_l, s_metadata_type_indicator);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
|
||||
|
||||
return m_p_l;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ find_imp(const_key_reference r_key) const
|
|||
p_l = p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_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;
|
||||
}
|
||||
|
|
|
@ -51,19 +51,19 @@ inline std::pair<
|
|||
PB_DS_CLASS_C_DEC::
|
||||
insert(const_reference r_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
entry_pointer p_l = find_imp(PB_DS_V2F(r_val));
|
||||
|
||||
if (p_l != NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(
|
||||
PB_DS_V2F(r_val));)
|
||||
|
||||
return std::make_pair(point_iterator(&p_l->m_value), false);
|
||||
}
|
||||
|
||||
PB_DS_DBG_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));)
|
||||
|
||||
p_l = allocate_new_entry(r_val, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
|
||||
|
@ -72,7 +72,7 @@ insert(const_reference r_val)
|
|||
|
||||
m_p_l = p_l;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return std::make_pair(point_iterator(&p_l->m_value), true);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ allocate_new_entry(const_reference r_val, false_type)
|
|||
|
||||
cond.set_no_action();
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_val));)
|
||||
|
||||
init_entry_metadata(p_l, s_metadata_type_indicator);
|
||||
|
@ -109,7 +109,7 @@ allocate_new_entry(const_reference r_val, true_type)
|
|||
|
||||
new (&p_l->m_value) value_type(r_val);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_val));)
|
||||
|
||||
init_entry_metadata(p_l, s_metadata_type_indicator);
|
||||
|
|
|
@ -51,7 +51,7 @@ begin()
|
|||
{
|
||||
if (m_p_l == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(empty());
|
||||
_GLIBCXX_DEBUG_ASSERT(empty());
|
||||
|
||||
return (end());
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ begin() const
|
|||
{
|
||||
if (m_p_l == NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(empty());
|
||||
_GLIBCXX_DEBUG_ASSERT(empty());
|
||||
|
||||
return (end());
|
||||
}
|
||||
|
|
|
@ -51,94 +51,56 @@
|
|||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
#include <ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp>
|
||||
#include <ext/pb_ds/exception.hpp>
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#include <ext/pb_ds/detail/map_debug_base.hpp>
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
#ifdef PB_DS_LU_MAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif // PB_DS_LU_MAP_TRACE_
|
||||
#endif
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Key, \
|
||||
typename Mapped, \
|
||||
class Eq_Fn, \
|
||||
class Allocator, \
|
||||
class Update_Policy>
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Mapped, class Eq_Fn, \
|
||||
class Allocator, class Update_Policy>
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
lu_map_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME lu_map_data_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME \
|
||||
lu_map_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CLASS_NAME lu_map_no_data_
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Eq_Fn, \
|
||||
Allocator, \
|
||||
Update_Policy>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CLASS_NAME<Key, Mapped, Eq_Fn, Allocator, Update_Policy>
|
||||
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Allocator, \
|
||||
false>
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits<Key, Mapped, Allocator, false>
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
typename Allocator::template rebind< \
|
||||
Key>::other::const_reference>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base<Key, Eq_Fn, \
|
||||
typename Allocator::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value)
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped_Data()
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value.first)
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
|
||||
/* Skip to the lu, my darling. */
|
||||
|
||||
// list-based (with updates) associative container.
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
|
@ -146,16 +108,15 @@ namespace pb_ds
|
|||
class Allocator,
|
||||
class Update_Policy>
|
||||
class PB_DS_CLASS_NAME :
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
protected PB_DS_MAP_DEBUG_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
public PB_DS_TYPES_TRAITS_C_DEC
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
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;
|
||||
|
||||
|
@ -172,9 +133,7 @@ namespace pb_ds
|
|||
|
||||
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
|
||||
typename Allocator::template rebind<entry_pointer>::other
|
||||
|
@ -265,21 +224,21 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef point_iterator_ point_iterator;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef const_point_iterator_ point_iterator;
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef const_point_iterator_ const_point_iterator;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef iterator_ iterator;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef const_iterator_ iterator;
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef const_iterator_ const_iterator;
|
||||
|
||||
|
@ -311,39 +270,31 @@ namespace pb_ds
|
|||
operator[](const_key_reference r_key)
|
||||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return insert(std::make_pair(r_key, mapped_type())).first->second;
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return insert(std::make_pair(r_key, mapped_type())).first->second;
|
||||
#else
|
||||
insert(r_key);
|
||||
|
||||
return (traits_base::s_null_mapped);
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
return traits_base::s_null_mapped;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::pair<
|
||||
point_iterator,
|
||||
bool>
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert(const_reference r_val);
|
||||
|
||||
inline point_iterator
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
entry_pointer p_e = find_imp(r_key);
|
||||
|
||||
return point_iterator(p_e == NULL? NULL :& p_e->m_value);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
entry_pointer p_e = find_imp(r_key);
|
||||
return point_iterator(p_e == NULL ? NULL: &p_e->m_value);
|
||||
}
|
||||
|
||||
inline const_point_iterator
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
entry_pointer p_e = find_imp(r_key);
|
||||
|
||||
return const_point_iterator(p_e == NULL? NULL :& p_e->m_value);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
entry_pointer p_e = find_imp(r_key);
|
||||
return const_point_iterator(p_e == NULL ? NULL: &p_e->m_value);
|
||||
}
|
||||
|
||||
inline bool
|
||||
|
@ -368,26 +319,22 @@ namespace pb_ds
|
|||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_LU_MAP_TRACE_
|
||||
|
||||
void
|
||||
trace() const;
|
||||
|
||||
#endif // PB_DS_LU_MAP_TRACE_
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
|
||||
|
||||
#ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
|
||||
#endif // #ifdef PB_DS_LU_MAP_DEBUG_
|
||||
#endif
|
||||
|
||||
typedef
|
||||
typename PB_DS_TYPES_TRAITS_C_DEC::
|
||||
|
@ -433,7 +380,6 @@ namespace pb_ds
|
|||
inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const
|
||||
{
|
||||
r_pos = r_pos->m_p_next;
|
||||
|
||||
r_p_value = (r_pos == NULL)? NULL :& r_pos->m_value;
|
||||
}
|
||||
|
||||
|
@ -454,7 +400,7 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
friend class iterator_;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
friend class const_iterator_;
|
||||
|
||||
|
@ -479,22 +425,14 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_TYPES_TRAITS_C_DEC
|
||||
|
||||
#undef PB_DS_MAP_DEBUG_BASE_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_NAME
|
||||
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_EP2VP
|
||||
#undef PB_DS_V2S
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
|
||||
/**
|
||||
* @file map_debug_base.hpp
|
||||
* Contains a debug-mode base for all maps.
|
||||
|
@ -47,37 +47,23 @@
|
|||
#ifndef PB_DS_MAP_DEBUG_BASE_HPP
|
||||
#define PB_DS_MAP_DEBUG_BASE_HPP
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
#include <assert.h>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <pb_ds/testsuite/regression/res_mng/dbg_ex_allocator.hpp>
|
||||
#include <regression/res_mng/dbg_ex_allocator.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, class Eq_Fn, typename Const_Key_Reference>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
Eq_Fn, \
|
||||
Const_Key_Reference>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
map_debug_base<Key, Eq_Fn, Const_Key_Reference>
|
||||
|
||||
template<typename Key, class Eq_Fn, typename Const_Key_Reference>
|
||||
class map_debug_base
|
||||
|
@ -119,23 +105,20 @@ namespace pb_ds
|
|||
|
||||
template<typename Cmp_Fn>
|
||||
void
|
||||
split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other);
|
||||
split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
join(PB_DS_CLASS_C_DEC& other);
|
||||
|
||||
private:
|
||||
typedef std::list< Key> key_set;
|
||||
typedef std::list< Key> key_set;
|
||||
typedef typename key_set::iterator key_set_iterator;
|
||||
typedef typename key_set::const_iterator const_key_set_iterator;
|
||||
|
||||
typedef typename key_set::iterator key_set_iterator;
|
||||
|
||||
typedef typename key_set::const_iterator const_key_set_iterator;
|
||||
|
||||
private:
|
||||
#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#endif
|
||||
|
||||
const_key_set_iterator
|
||||
find(const_key_reference r_key) const;
|
||||
|
@ -143,51 +126,37 @@ namespace pb_ds
|
|||
key_set_iterator
|
||||
find(const_key_reference r_key);
|
||||
|
||||
private:
|
||||
key_set m_key_set;
|
||||
|
||||
Eq_Fn m_eq;
|
||||
key_set m_key_set;
|
||||
Eq_Fn m_eq;
|
||||
};
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
map_debug_base()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
map_debug_base(const PB_DS_CLASS_C_DEC& other) :
|
||||
m_key_set(other.m_key_set)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
map_debug_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set)
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~map_debug_base()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_new(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
pb_ds::test::dbg_ex_allocator<char> alloc;
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
pb_ds::test::dbg_ex_allocator<char> alloc;
|
||||
const double orig_throw_prob = alloc.get_throw_prob();
|
||||
|
||||
alloc.set_throw_prob(0);
|
||||
|
||||
if (find(r_key) != m_key_set.end())
|
||||
{
|
||||
std::cerr << "insert_new " << r_key << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -198,78 +167,63 @@ namespace pb_ds
|
|||
catch(...)
|
||||
{
|
||||
std::cerr << "insert_new 1" << r_key << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
alloc.set_throw_prob(orig_throw_prob);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_existing(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
key_set_iterator it = find(r_key);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
key_set_iterator it = find(r_key);
|
||||
if (it == m_key_set.end())
|
||||
{
|
||||
std::cerr << "erase_existing " << r_key << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
m_key_set.erase(it);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
m_key_set.clear();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
m_key_set.clear();
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
check_key_exists(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
if (find(r_key) == m_key_set.end())
|
||||
{
|
||||
std::cerr << "check_key_exists " << r_key << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
if (find(r_key) == m_key_set.end())
|
||||
{
|
||||
std::cerr << "check_key_exists " << r_key << std::endl;
|
||||
abort();
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
check_key_does_not_exist(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
if (find(r_key) != m_key_set.end())
|
||||
{
|
||||
std::cerr << "check_key_does_not_exist " << r_key << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
if (find(r_key) != m_key_set.end())
|
||||
{
|
||||
std::cerr << "check_key_does_not_exist " << r_key << std::endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -277,45 +231,38 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
check_size(size_type size) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
const size_type key_set_size = m_key_set.size();
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
const size_type key_set_size = m_key_set.size();
|
||||
if (size != key_set_size)
|
||||
{
|
||||
std::cerr << "check_size " << size << " " << key_set_size << std::endl;
|
||||
|
||||
std::cerr << "check_size " << size
|
||||
<< " " << key_set_size << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
m_key_set.swap(other.m_key_set);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
m_key_set.swap(other.m_key_set);
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::const_key_set_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
for (const_key_set_iterator it = m_key_set.begin(); it != m_key_set.end();
|
||||
++it)
|
||||
if (m_eq(*it, r_key))
|
||||
return (it);
|
||||
|
||||
return (m_key_set.end());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
typedef const_key_set_iterator iterator_type;
|
||||
for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it)
|
||||
if (m_eq(*it, r_key))
|
||||
return it;
|
||||
return m_key_set.end();
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -323,49 +270,39 @@ namespace pb_ds
|
|||
PB_DS_CLASS_C_DEC::
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
key_set_iterator it = m_key_set.begin();
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
key_set_iterator it = m_key_set.begin();
|
||||
while (it != m_key_set.end())
|
||||
{
|
||||
if (m_eq(*it, r_key))
|
||||
return (it);
|
||||
|
||||
return it;
|
||||
++it;
|
||||
}
|
||||
return it;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
return (it);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
#ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid() const
|
||||
{
|
||||
const_key_set_iterator prime_it = m_key_set.begin();
|
||||
|
||||
while (prime_it != m_key_set.end())
|
||||
{
|
||||
const_key_set_iterator sec_it = prime_it;
|
||||
|
||||
++sec_it;
|
||||
|
||||
while (sec_it != m_key_set.end())
|
||||
{
|
||||
assert(!m_eq(*sec_it, * prime_it));
|
||||
assert(!m_eq(*prime_it, * sec_it));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it));
|
||||
_GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it));
|
||||
++sec_it;
|
||||
}
|
||||
|
||||
++prime_it;
|
||||
}
|
||||
}
|
||||
#endif // #ifdef PB_DS_MAP_DEBUG_BASE_DEBUG
|
||||
#endif
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Cmp_Fn>
|
||||
|
@ -374,25 +311,18 @@ namespace pb_ds
|
|||
split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
pb_ds::test::dbg_ex_allocator<char> alloc;
|
||||
|
||||
const double orig_throw_prob = alloc.get_throw_prob();
|
||||
|
||||
alloc.set_throw_prob(0);
|
||||
|
||||
other.clear();
|
||||
|
||||
key_set_iterator it = m_key_set.begin();
|
||||
|
||||
while (it != m_key_set.end())
|
||||
if (cmp_fn(r_key, * it))
|
||||
{
|
||||
other.insert_new(*it);
|
||||
|
||||
it = m_key_set.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
||||
alloc.set_throw_prob(orig_throw_prob);
|
||||
}
|
||||
|
||||
|
@ -402,37 +332,25 @@ namespace pb_ds
|
|||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
pb_ds::test::dbg_ex_allocator<char> alloc;
|
||||
|
||||
const double orig_throw_prob = alloc.get_throw_prob();
|
||||
|
||||
alloc.set_throw_prob(0);
|
||||
|
||||
key_set_iterator it = other.m_key_set.begin();
|
||||
|
||||
while (it != other.m_key_set.end())
|
||||
{
|
||||
insert_new(*it);
|
||||
|
||||
it = other.m_key_set.erase(it);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(other.m_key_set.empty());
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty());
|
||||
alloc.set_throw_prob(orig_throw_prob);
|
||||
}
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#endif
|
||||
|
||||
#endif // #ifndef PB_DS_MAP_DEBUG_BASE_HPP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,23 +48,19 @@ template<typename Size_Type>
|
|||
class cond_dtor
|
||||
{
|
||||
public:
|
||||
cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size) : m_a_vec(a_vec),
|
||||
m_r_last_it(r_last_it),
|
||||
m_max_size(total_size),
|
||||
m_no_action(false)
|
||||
cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size)
|
||||
: m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size),
|
||||
m_no_action(false)
|
||||
{ }
|
||||
|
||||
~cond_dtor()
|
||||
{
|
||||
if (m_no_action)
|
||||
return;
|
||||
|
||||
iterator it = m_a_vec;
|
||||
|
||||
while (it != m_r_last_it)
|
||||
{
|
||||
it->~value_type();
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
|
@ -74,16 +70,11 @@ public:
|
|||
|
||||
inline void
|
||||
set_no_action()
|
||||
{
|
||||
m_no_action = true;
|
||||
}
|
||||
{ m_no_action = true; }
|
||||
|
||||
protected:
|
||||
value_vector m_a_vec;
|
||||
|
||||
iterator& m_r_last_it;
|
||||
|
||||
const Size_Type m_max_size;
|
||||
|
||||
bool m_no_action;
|
||||
};
|
||||
|
|
|
@ -59,9 +59,7 @@ PB_DS_OV_TREE_CLASS_NAME() :
|
|||
m_a_metadata(NULL),
|
||||
m_end_it(NULL),
|
||||
m_size(0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -71,9 +69,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
|
|||
m_a_metadata(NULL),
|
||||
m_end_it(NULL),
|
||||
m_size(0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
|
@ -84,19 +80,17 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_updat
|
|||
m_a_metadata(NULL),
|
||||
m_end_it(NULL),
|
||||
m_size(0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
PB_DS_MAP_DEBUG_BASE_C_DEC(other),
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
map_debug_base(other),
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
PB_DS_TREE_TRACE_BASE_C_DEC(other),
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
cmp_fn_base(other),
|
||||
node_update(other),
|
||||
m_a_values(NULL),
|
||||
|
@ -105,9 +99,8 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
|
|||
m_size(0)
|
||||
{
|
||||
copy_from_ordered_range(other.begin(), other.end());
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
|
@ -124,7 +117,7 @@ copy_from_range(It first_it, It last_it)
|
|||
typename Allocator::template rebind<
|
||||
value_type>::other>
|
||||
map_type;
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#else
|
||||
typedef
|
||||
std::set<
|
||||
key_type,
|
||||
|
@ -132,10 +125,9 @@ copy_from_range(It first_it, It last_it)
|
|||
typename Allocator::template rebind<
|
||||
Key>::other>
|
||||
map_type;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
map_type m(first_it, last_it);
|
||||
|
||||
copy_from_ordered_range(m.begin(), m.end());
|
||||
}
|
||||
|
||||
|
@ -146,64 +138,51 @@ PB_DS_CLASS_C_DEC::
|
|||
copy_from_ordered_range(It first_it, It last_it)
|
||||
{
|
||||
const size_type size = std::distance(first_it, last_it);
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
value_vector a_values = s_value_alloc.allocate(size);
|
||||
|
||||
iterator target_it = a_values;
|
||||
It source_it = first_it;
|
||||
It source_end_it = last_it;
|
||||
|
||||
cond_dtor<size_type> cd(a_values, target_it, size);
|
||||
|
||||
while (source_it != source_end_it)
|
||||
{
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(target_it)))
|
||||
value_type(*source_it++);
|
||||
|
||||
++target_it;
|
||||
}
|
||||
|
||||
reallocate_metadata((node_update* )this, size);
|
||||
|
||||
cd.set_no_action();
|
||||
|
||||
m_a_values = a_values;
|
||||
|
||||
m_size = size;
|
||||
|
||||
m_end_it = m_a_values + m_size;
|
||||
|
||||
update(PB_DS_node_begin_imp(), (node_update* )this);
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
const_iterator dbg_it = m_a_values;
|
||||
|
||||
while (dbg_it != m_end_it)
|
||||
{
|
||||
map_debug_base::insert_new(PB_DS_V2F(*dbg_it));
|
||||
|
||||
dbg_it++;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_C_DEC::assert_valid();
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#endif
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it)
|
||||
copy_from_ordered_range(It first_it, It last_it, It other_first_it,
|
||||
It other_last_it)
|
||||
{
|
||||
clear();
|
||||
|
||||
const size_type size =
|
||||
std::distance(first_it, last_it) +
|
||||
std::distance(other_first_it, other_last_it);
|
||||
const size_type size = std::distance(first_it, last_it)
|
||||
+ std::distance(other_first_it, other_last_it);
|
||||
|
||||
value_vector a_values = s_value_alloc.allocate(size);
|
||||
|
||||
|
@ -212,13 +191,10 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_las
|
|||
It source_end_it = last_it;
|
||||
|
||||
cond_dtor<size_type> cd(a_values, target_it, size);
|
||||
|
||||
while (source_it != source_end_it)
|
||||
{
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(target_it)))
|
||||
value_type(*source_it++);
|
||||
|
||||
++target_it;
|
||||
}
|
||||
|
||||
|
@ -227,37 +203,27 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_las
|
|||
|
||||
while (source_it != source_end_it)
|
||||
{
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(target_it)))
|
||||
value_type(*source_it++);
|
||||
|
||||
++target_it;
|
||||
}
|
||||
|
||||
reallocate_metadata((node_update* )this, size);
|
||||
|
||||
cd.set_no_action();
|
||||
|
||||
m_a_values = a_values;
|
||||
|
||||
m_size = size;
|
||||
|
||||
m_end_it = m_a_values + m_size;
|
||||
|
||||
update(PB_DS_node_begin_imp(), (node_update* )this);
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
const_iterator dbg_it = m_a_values;
|
||||
|
||||
while (dbg_it != m_end_it)
|
||||
{
|
||||
map_debug_base::insert_new(PB_DS_V2F(*dbg_it));
|
||||
|
||||
dbg_it++;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_C_DEC::assert_valid();
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#endif
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -265,14 +231,11 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
value_swap(other);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
value_swap(other);
|
||||
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -280,24 +243,18 @@ PB_DS_CLASS_C_DEC::
|
|||
value_swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
std::swap(m_a_values, other.m_a_values);
|
||||
|
||||
std::swap(m_a_metadata, other.m_a_metadata);
|
||||
|
||||
std::swap(m_size, other.m_size);
|
||||
|
||||
std::swap(m_end_it, other.m_end_it);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::swap(other);)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::swap(other);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_OV_TREE_CLASS_NAME()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
|
||||
reallocate_metadata((node_update* )this, 0);
|
||||
}
|
||||
|
||||
|
@ -314,12 +271,9 @@ PB_DS_CLASS_C_DEC::
|
|||
update(node_iterator nd_it, Node_Update* p_update)
|
||||
{
|
||||
const_node_iterator end_it = PB_DS_node_end_imp();
|
||||
|
||||
if (nd_it == end_it)
|
||||
return;
|
||||
|
||||
update(nd_it.get_l_child(), p_update);
|
||||
update(nd_it.get_r_child(), p_update);
|
||||
|
||||
node_update::operator()(nd_it, end_it);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
* Contains an implementation class for ov_tree_.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
|
@ -54,13 +54,10 @@ assert_valid() const
|
|||
std::cout << "av1" << std::endl;
|
||||
|
||||
if (m_a_values == NULL || m_end_it == NULL || m_size == 0)
|
||||
PB_DS_DBG_ASSERT(m_a_values == NULL&& m_end_it == NULL&&
|
||||
m_size == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_values == NULL&& m_end_it == NULL && m_size == 0);
|
||||
|
||||
std::cout << "av2" << std::endl;
|
||||
|
||||
assert_iterators();
|
||||
|
||||
std::cout << "av3" << std::endl;
|
||||
}
|
||||
|
||||
|
@ -70,40 +67,24 @@ PB_DS_CLASS_C_DEC::
|
|||
assert_iterators() const
|
||||
{
|
||||
map_debug_base::check_size(m_size);
|
||||
|
||||
size_type iterated_num = 0;
|
||||
|
||||
const_iterator prev_it = end();
|
||||
|
||||
PB_DS_DBG_ASSERT( m_end_it == m_a_values + m_size);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT( m_end_it == m_a_values + m_size);
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
++iterated_num;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(
|
||||
PB_DS_V2F(*it));)
|
||||
|
||||
PB_DS_DBG_ASSERT(lower_bound(
|
||||
PB_DS_V2F(*it)) == it);
|
||||
|
||||
const_iterator upper_bound_it = upper_bound(
|
||||
PB_DS_V2F(*it));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(PB_DS_V2F(*it));)
|
||||
_GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it);
|
||||
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
|
||||
--upper_bound_it;
|
||||
|
||||
PB_DS_DBG_ASSERT(upper_bound_it == it);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(upper_bound_it == it);
|
||||
if (prev_it != end())
|
||||
PB_DS_DBG_ASSERT(Cmp_Fn::operator()(
|
||||
PB_DS_V2F(*prev_it),
|
||||
PB_DS_V2F(*it)));
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
|
||||
PB_DS_V2F(*it)));
|
||||
prev_it = it;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(iterated_num == m_size);
|
||||
_GLIBCXX_DEBUG_ASSERT(iterated_num == m_size);
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,11 +49,11 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
if (m_size == 0)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ clear()
|
|||
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::clear();)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
|
||||
|
||||
m_a_values = NULL;
|
||||
|
||||
|
@ -72,7 +72,7 @@ clear()
|
|||
|
||||
m_end_it = m_a_values;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
#ifdef PB_DS_REGRESSION
|
||||
typename Allocator::group_throw_prob_adjustor adjust(m_size);
|
||||
|
@ -112,7 +112,7 @@ erase_if(Pred pred)
|
|||
|
||||
cond_dtor<size_type> cd(a_new_values, target_it, new_size);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::clear());
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear());
|
||||
|
||||
for (source_it = begin(); source_it != m_end_it; ++source_it)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ erase_if(Pred pred)
|
|||
static_cast<const void* >(target_it)))
|
||||
value_type(*source_it);
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(*source_it)));
|
||||
|
||||
++target_it;
|
||||
|
@ -145,7 +145,7 @@ erase_if(Pred pred)
|
|||
|
||||
update(node_begin(), (node_update* )this);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (num_val_ersd);
|
||||
}
|
||||
|
@ -156,19 +156,19 @@ It
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_imp(It it)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
if (it == end())
|
||||
return end();
|
||||
|
||||
PB_DS_DBG_ONLY(
|
||||
_GLIBCXX_DEBUG_ONLY(
|
||||
PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));)
|
||||
|
||||
#ifdef PB_DS_REGRESSION
|
||||
typename Allocator::group_throw_prob_adjustor adjust(m_size);
|
||||
#endif // #ifdef PB_DS_REGRESSION
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
|
||||
value_vector a_values = s_value_alloc.allocate(m_size - 1);
|
||||
|
||||
|
@ -179,14 +179,14 @@ erase_imp(It it)
|
|||
|
||||
cond_dtor<size_type> cd(a_values, target_it, m_size - 1);
|
||||
|
||||
PB_DS_DBG_ONLY(size_type cnt = 0;)
|
||||
_GLIBCXX_DEBUG_ONLY(size_type cnt = 0;)
|
||||
|
||||
while (source_it != source_end_it)
|
||||
{
|
||||
if (source_it != it)
|
||||
{
|
||||
PB_DS_DBG_ONLY(++cnt;)
|
||||
PB_DS_DBG_ASSERT(cnt != m_size);
|
||||
_GLIBCXX_DEBUG_ONLY(++cnt;)
|
||||
_GLIBCXX_DEBUG_ASSERT(cnt != m_size);
|
||||
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
|
@ -200,13 +200,13 @@ erase_imp(It it)
|
|||
++source_it;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
|
||||
reallocate_metadata((node_update* )this, m_size - 1);
|
||||
|
||||
cd.set_no_action();
|
||||
|
||||
PB_DS_DBG_ONLY(
|
||||
_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);
|
||||
|
@ -220,7 +220,7 @@ erase_imp(It it)
|
|||
|
||||
update(node_begin(), (node_update* )this);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (It(ret_it));
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
size() const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return (m_size);
|
||||
}
|
||||
|
|
|
@ -47,11 +47,9 @@
|
|||
#ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP
|
||||
#define PB_DS_OV_TREE_NODE_ITERATORS_HPP
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#include <cassert>
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
|
@ -60,25 +58,11 @@ namespace pb_ds
|
|||
|
||||
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \
|
||||
typedef \
|
||||
static_assert_dumclass< \
|
||||
sizeof(static_assert<(bool)(E)>)> \
|
||||
static_assert_dumclass<sizeof(static_assert<(bool)(E)>)> \
|
||||
UNIQUE##static_assert_type
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X);
|
||||
#define PB_DS_DBG_VERIFY(X) PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) ((void)0)
|
||||
#define PB_DS_DBG_VERIFY(X) X
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
|
||||
#define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \
|
||||
ov_tree_node_const_it_< \
|
||||
Value_Type, \
|
||||
Metadata_Type, \
|
||||
Allocator>
|
||||
ov_tree_node_const_it_<Value_Type, Metadata_Type, Allocator>
|
||||
|
||||
// Const node reference.
|
||||
template<typename Value_Type, typename Metadata_Type, class Allocator>
|
||||
|
@ -109,8 +93,7 @@ namespace pb_ds
|
|||
inline static Ptr
|
||||
mid_pointer(Ptr p_begin, Ptr p_end)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_end >= p_begin);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin);
|
||||
return (p_begin + (p_end - p_begin) / 2);
|
||||
}
|
||||
|
||||
|
@ -146,47 +129,36 @@ namespace pb_ds
|
|||
|
||||
public:
|
||||
inline
|
||||
ov_tree_node_const_it_(const_pointer p_nd = NULL, const_pointer p_begin_nd = NULL, const_pointer p_end_nd = NULL, const_metadata_pointer p_metadata = NULL) : m_p_value(const_cast<pointer>(p_nd)),
|
||||
m_p_begin_value(const_cast<pointer>(p_begin_nd)),
|
||||
m_p_end_value(const_cast<pointer>(p_end_nd)),
|
||||
m_p_metadata(p_metadata)
|
||||
ov_tree_node_const_it_(const_pointer p_nd = NULL, const_pointer p_begin_nd = NULL, const_pointer p_end_nd = NULL, const_metadata_pointer p_metadata = NULL) : m_p_value(const_cast<pointer>(p_nd)), m_p_begin_value(const_cast<pointer>(p_begin_nd)), m_p_end_value(const_cast<pointer>(p_end_nd)), m_p_metadata(p_metadata)
|
||||
{ }
|
||||
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
return (m_p_value);
|
||||
}
|
||||
{ return m_p_value; }
|
||||
|
||||
inline const_metadata_reference
|
||||
get_metadata() const
|
||||
{
|
||||
enum
|
||||
{
|
||||
has_metadata =
|
||||
!is_same<
|
||||
Metadata_Type,
|
||||
null_node_metadata>::value
|
||||
has_metadata = !is_same<Metadata_Type, null_node_metadata>::value
|
||||
};
|
||||
|
||||
PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata);
|
||||
|
||||
PB_DS_DBG_ASSERT(m_p_metadata != NULL);
|
||||
|
||||
return (*m_p_metadata);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_metadata != NULL);
|
||||
return *m_p_metadata;
|
||||
}
|
||||
|
||||
inline this_type
|
||||
get_l_child() const
|
||||
{
|
||||
if (m_p_begin_value == m_p_value)
|
||||
return (this_type( m_p_begin_value, m_p_begin_value, m_p_begin_value));
|
||||
return (this_type(m_p_begin_value, m_p_begin_value, m_p_begin_value));
|
||||
|
||||
const_metadata_pointer p_begin_metadata =
|
||||
m_p_metadata - (m_p_value - m_p_begin_value);
|
||||
|
||||
return (this_type(
|
||||
mid_pointer(m_p_begin_value, m_p_value),
|
||||
return (this_type(mid_pointer(m_p_begin_value, m_p_value),
|
||||
m_p_begin_value,
|
||||
m_p_value,
|
||||
mid_pointer(p_begin_metadata, m_p_metadata)));
|
||||
|
@ -196,15 +168,14 @@ namespace pb_ds
|
|||
get_r_child() const
|
||||
{
|
||||
if (m_p_value == m_p_end_value)
|
||||
return (this_type( m_p_end_value, m_p_end_value, m_p_end_value));
|
||||
return (this_type(m_p_end_value, m_p_end_value, m_p_end_value));
|
||||
|
||||
const_metadata_pointer p_end_metadata =
|
||||
m_p_metadata + (m_p_end_value - m_p_value);
|
||||
|
||||
return (this_type(
|
||||
mid_pointer(m_p_value + 1, m_p_end_value),
|
||||
return (this_type(mid_pointer(m_p_value + 1, m_p_end_value),
|
||||
m_p_value + 1,
|
||||
m_p_end_value,(m_p_metadata == NULL)?
|
||||
m_p_end_value,(m_p_metadata == NULL) ?
|
||||
NULL : mid_pointer(m_p_metadata + 1, p_end_metadata)));
|
||||
}
|
||||
|
||||
|
@ -220,14 +191,12 @@ namespace pb_ds
|
|||
if (is_other_end)
|
||||
return (is_end);
|
||||
|
||||
return (m_p_value == other.m_p_value);
|
||||
return m_p_value == other.m_p_value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator!=(const this_type& other) const
|
||||
{
|
||||
return (!operator==(other));
|
||||
}
|
||||
{ return !operator==(other); }
|
||||
|
||||
public:
|
||||
pointer m_p_value;
|
||||
|
@ -238,10 +207,7 @@ namespace pb_ds
|
|||
};
|
||||
|
||||
#define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \
|
||||
ov_tree_node_it_< \
|
||||
Value_Type, \
|
||||
Metadata_Type, \
|
||||
Allocator>
|
||||
ov_tree_node_it_<Value_Type, Metadata_Type, Allocator>
|
||||
|
||||
// Node reference.
|
||||
template<typename Value_Type, typename Metadata_Type, class Allocator>
|
||||
|
@ -292,22 +258,19 @@ namespace pb_ds
|
|||
// Access.
|
||||
inline reference
|
||||
operator*() const
|
||||
{
|
||||
return (reference(base_type::m_p_value));
|
||||
}
|
||||
{ return reference(base_type::m_p_value); }
|
||||
|
||||
// Returns the node reference associated with the left node.
|
||||
inline ov_tree_node_it_
|
||||
get_l_child() const
|
||||
{
|
||||
if (base_type::m_p_begin_value == base_type::m_p_value)
|
||||
return (this_type( base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value));
|
||||
return (this_type(base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value));
|
||||
|
||||
const_metadata_pointer p_begin_metadata =
|
||||
base_type::m_p_metadata - (base_type::m_p_value - base_type::m_p_begin_value);
|
||||
|
||||
return (this_type(
|
||||
base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value),
|
||||
return (this_type(base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value),
|
||||
base_type::m_p_begin_value,
|
||||
base_type::m_p_value,
|
||||
base_type::mid_pointer(p_begin_metadata, base_type::m_p_metadata)));
|
||||
|
@ -318,13 +281,12 @@ namespace pb_ds
|
|||
get_r_child() const
|
||||
{
|
||||
if (base_type::m_p_value == base_type::m_p_end_value)
|
||||
return (this_type( base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value));
|
||||
return (this_type(base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value));
|
||||
|
||||
const_metadata_pointer p_end_metadata =
|
||||
base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value);
|
||||
|
||||
return (this_type(
|
||||
base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value),
|
||||
return (this_type(base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value),
|
||||
base_type::m_p_value + 1,
|
||||
base_type::m_p_end_value,(base_type::m_p_metadata == NULL)?
|
||||
NULL : base_type::mid_pointer(base_type::m_p_metadata + 1, p_end_metadata)));
|
||||
|
@ -333,16 +295,10 @@ namespace pb_ds
|
|||
};
|
||||
|
||||
#undef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC
|
||||
|
||||
#undef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC
|
||||
|
||||
#undef PB_DS_STATIC_ASSERT
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
||||
#endif // #ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP
|
||||
#endif
|
||||
|
|
|
@ -58,105 +58,72 @@
|
|||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X);
|
||||
#define PB_DS_DBG_VERIFY(X) PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) ((void)0)
|
||||
#define PB_DS_DBG_VERIFY(X) X
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template< \
|
||||
typename Key, \
|
||||
typename Mapped, \
|
||||
class Cmp_Fn, \
|
||||
class Node_And_It_Traits, \
|
||||
class Allocator>
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Mapped, class Cmp_Fn, \
|
||||
class Node_And_It_Traits, class Allocator>
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_OV_TREE_CLASS_NAME \
|
||||
ov_tree_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_OV_TREE_CLASS_NAME ov_tree_data_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_OV_TREE_CLASS_NAME \
|
||||
ov_tree_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_OV_TREE_CLASS_NAME ov_tree_no_data_
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_data_
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#else
|
||||
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_no_data_
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_OV_TREE_CLASS_NAME< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Cmp_Fn, \
|
||||
Node_And_It_Traits, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_OV_TREE_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
|
||||
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits< \
|
||||
Key, \
|
||||
Mapped, \
|
||||
Allocator, \
|
||||
false>
|
||||
#define PB_DS_TYPES_TRAITS_C_DEC \
|
||||
types_traits<Key, Mapped, Allocator, false>
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base< \
|
||||
Key, \
|
||||
eq_by_less<Key, Cmp_Fn>, \
|
||||
typename Allocator::template rebind< \
|
||||
Key>::other::const_reference>
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_MAP_DEBUG_BASE_C_DEC \
|
||||
map_debug_base<Key, eq_by_less<Key, Cmp_Fn>, \
|
||||
typename Allocator::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value)
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped_Data()
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value.first)
|
||||
#endif // #ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#define PB_DS_TREE_TRACE_BASE_C_DEC \
|
||||
tree_trace_base< \
|
||||
typename Node_And_It_Traits::const_node_iterator, \
|
||||
typename Node_And_It_Traits::node_iterator, \
|
||||
Cmp_Fn, \
|
||||
false, \
|
||||
Allocator>
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#define PB_DS_TREE_TRACE_BASE_C_DEC \
|
||||
tree_trace_base<typename Node_And_It_Traits::const_node_iterator, \
|
||||
typename Node_And_It_Traits::node_iterator, \
|
||||
Cmp_Fn, false, Allocator>
|
||||
#endif
|
||||
|
||||
// Ordered-vector tree associative-container.
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
class Cmp_Fn,
|
||||
class Node_And_It_Traits,
|
||||
class Allocator>
|
||||
template<typename Key, typename Mapped, class Cmp_Fn,
|
||||
class Node_And_It_Traits, class Allocator>
|
||||
class PB_DS_OV_TREE_CLASS_NAME :
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
protected PB_DS_MAP_DEBUG_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
public PB_DS_TREE_TRACE_BASE_C_DEC,
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
public Cmp_Fn,
|
||||
public Node_And_It_Traits::node_update,
|
||||
public PB_DS_TYPES_TRAITS_C_DEC
|
||||
|
@ -179,9 +146,9 @@ namespace pb_ds
|
|||
|
||||
typedef Cmp_Fn cmp_fn_base;
|
||||
|
||||
#ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_MAP_DEBUG_BASE_C_DEC map_debug_base;
|
||||
#endif // #ifdef PB_DS_USE_MAP_DEBUG_BASE
|
||||
#endif
|
||||
|
||||
typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer mapped_pointer_;
|
||||
|
||||
|
@ -268,9 +235,9 @@ namespace pb_ds
|
|||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef pointer point_iterator;
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#else
|
||||
typedef const_point_iterator point_iterator;
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#endif
|
||||
|
||||
typedef const_point_iterator const_iterator;
|
||||
|
||||
|
@ -322,79 +289,55 @@ namespace pb_ds
|
|||
operator[](const_key_reference r_key)
|
||||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
point_iterator it = lower_bound(r_key);
|
||||
|
||||
if (it != end()&& !Cmp_Fn::operator()(
|
||||
r_key,
|
||||
PB_DS_V2F(*it)))
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
point_iterator it = lower_bound(r_key);
|
||||
if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return (it->second);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return (insert_new_val(it,
|
||||
std::make_pair(
|
||||
r_key,
|
||||
mapped_type()))->second);
|
||||
#else // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second);
|
||||
#else
|
||||
insert(r_key);
|
||||
|
||||
return (traits_base::s_null_mapped);
|
||||
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
return traits_base::s_null_mapped;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert(const_reference r_value)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
const_key_reference r_key = PB_DS_V2F(r_value);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
const_key_reference r_key = PB_DS_V2F(r_value);
|
||||
point_iterator it = lower_bound(r_key);
|
||||
|
||||
if (it != end()&& !Cmp_Fn::operator()(
|
||||
r_key,
|
||||
PB_DS_V2F(*it)))
|
||||
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
|
||||
return (std::make_pair(it, false));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
return std::make_pair(it, false);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return (std::make_pair(insert_new_val(it, r_value), true));
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return std::make_pair(insert_new_val(it, r_value), true);
|
||||
}
|
||||
|
||||
inline point_iterator
|
||||
lower_bound(const_key_reference r_key)
|
||||
{
|
||||
pointer it = m_a_values;
|
||||
|
||||
pointer e_it = m_a_values + m_size;
|
||||
|
||||
while (it != e_it)
|
||||
{
|
||||
pointer mid_it = it + ((e_it - it) >> 1);
|
||||
|
||||
if (cmp_fn_base::operator()(
|
||||
PB_DS_V2F(*mid_it),
|
||||
r_key))
|
||||
if (cmp_fn_base::operator()(PB_DS_V2F(*mid_it), r_key))
|
||||
it = ++mid_it;
|
||||
else
|
||||
e_it = mid_it;
|
||||
}
|
||||
|
||||
return (it);
|
||||
return it;
|
||||
}
|
||||
|
||||
inline const_point_iterator
|
||||
|
@ -407,53 +350,38 @@ namespace pb_ds
|
|||
upper_bound(const_key_reference r_key)
|
||||
{
|
||||
iterator pot_it = lower_bound(r_key);
|
||||
|
||||
if (pot_it != end()&& !Cmp_Fn::operator()(
|
||||
r_key,
|
||||
PB_DS_V2F(*pot_it)))
|
||||
if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
return (++pot_it);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
|
||||
|
||||
return (pot_it);
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
|
||||
return pot_it;
|
||||
}
|
||||
|
||||
inline const_point_iterator
|
||||
upper_bound(const_key_reference r_key) const
|
||||
{
|
||||
return (const_cast<PB_DS_CLASS_C_DEC& >(*this).upper_bound(r_key));
|
||||
}
|
||||
{ return const_cast<PB_DS_CLASS_C_DEC& >(*this).upper_bound(r_key); }
|
||||
|
||||
inline point_iterator
|
||||
find(const_key_reference r_key)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
iterator pot_it = lower_bound(r_key);
|
||||
|
||||
if (pot_it != end()&& !Cmp_Fn::operator()(
|
||||
r_key,
|
||||
PB_DS_V2F(*pot_it)))
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
iterator pot_it = lower_bound(r_key);
|
||||
if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
|
||||
{
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key));
|
||||
return (pot_it);
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
|
||||
|
||||
return (end());
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key));
|
||||
return end();
|
||||
}
|
||||
|
||||
inline const_point_iterator
|
||||
find(const_key_reference r_key) const
|
||||
{
|
||||
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
|
||||
erase(const_key_reference r_key);
|
||||
|
@ -464,9 +392,7 @@ namespace pb_ds
|
|||
|
||||
inline iterator
|
||||
erase(iterator it)
|
||||
{
|
||||
return (erase_imp<iterator>(it));
|
||||
}
|
||||
{ return erase_imp<iterator>(it); }
|
||||
|
||||
void
|
||||
clear();
|
||||
|
@ -479,27 +405,19 @@ namespace pb_ds
|
|||
|
||||
inline iterator
|
||||
begin()
|
||||
{
|
||||
return (m_a_values);
|
||||
}
|
||||
{ return m_a_values; }
|
||||
|
||||
inline const_iterator
|
||||
begin() const
|
||||
{
|
||||
return (m_a_values);
|
||||
}
|
||||
{ return m_a_values; }
|
||||
|
||||
inline iterator
|
||||
end()
|
||||
{
|
||||
return (m_end_it);
|
||||
}
|
||||
{ return m_end_it; }
|
||||
|
||||
inline const_iterator
|
||||
end() const
|
||||
{
|
||||
return (m_end_it);
|
||||
}
|
||||
{ return m_end_it; }
|
||||
|
||||
inline const_node_iterator
|
||||
node_begin() const;
|
||||
|
@ -544,22 +462,19 @@ namespace pb_ds
|
|||
inline static Ptr
|
||||
mid_pointer(Ptr p_begin, Ptr p_end)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_end >= p_begin);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin);
|
||||
return (p_begin + (p_end - p_begin) / 2);
|
||||
}
|
||||
|
||||
inline iterator
|
||||
insert_new_val(iterator it, const_reference r_value)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
#ifdef PB_DS_REGRESSION
|
||||
typename Allocator::group_throw_prob_adjustor adjust(m_size);
|
||||
#endif // #ifdef PB_DS_REGRESSION
|
||||
#endif
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::check_key_does_not_exist(
|
||||
PB_DS_V2F(r_value)));
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(PB_DS_V2F(r_value)));
|
||||
|
||||
value_vector a_values = s_value_alloc.allocate(m_size + 1);
|
||||
|
||||
|
@ -569,65 +484,47 @@ namespace pb_ds
|
|||
iterator ret_it;
|
||||
|
||||
cond_dtor<size_type> cd(a_values, target_it, m_size + 1);
|
||||
|
||||
while (source_it != it)
|
||||
{
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(target_it)))
|
||||
value_type(*source_it++);
|
||||
|
||||
++target_it;
|
||||
}
|
||||
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(ret_it = target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(ret_it = target_it)))
|
||||
value_type(r_value);
|
||||
|
||||
++target_it;
|
||||
|
||||
while (source_it != source_end_it)
|
||||
{
|
||||
new (const_cast<void* >(
|
||||
static_cast<const void* >(target_it)))
|
||||
new (const_cast<void* >(static_cast<const void* >(target_it)))
|
||||
value_type(*source_it++);
|
||||
|
||||
++target_it;
|
||||
}
|
||||
|
||||
reallocate_metadata((node_update* )this, m_size + 1);
|
||||
|
||||
cd.set_no_action();
|
||||
|
||||
if (m_size != 0)
|
||||
{
|
||||
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
|
||||
}
|
||||
|
||||
++m_size;
|
||||
|
||||
m_a_values = a_values;
|
||||
|
||||
m_end_it = m_a_values + m_size;
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::insert_new(
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::insert_new(PB_DS_V2F(r_value)));
|
||||
update(node_begin(), (node_update* )this);
|
||||
|
||||
PB_DS_DBG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
|
||||
return (ret_it);
|
||||
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
#ifdef PB_DS_OV_TREE_DEBUG_
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
|
||||
void
|
||||
assert_iterators() const;
|
||||
|
||||
#endif // #ifdef PB_DS_OV_TREE_DEBUG_
|
||||
#endif
|
||||
|
||||
template<typename It>
|
||||
It
|
||||
|
@ -669,27 +566,18 @@ namespace pb_ds
|
|||
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
|
||||
#undef PB_DS_OV_TREE_CLASS_NAME
|
||||
|
||||
#undef PB_DS_TYPES_TRAITS_C_DEC
|
||||
|
||||
#undef PB_DS_MAP_DEBUG_BASE_C_DEC
|
||||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#undef PB_DS_TREE_TRACE_BASE_C_DEC
|
||||
#endif // #ifdef PB_DS_TREE_TRACE
|
||||
#endif
|
||||
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_EP2VP
|
||||
#undef PB_DS_V2S
|
||||
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
#undef PB_DS_CONST_NODE_ITERATOR_NAME
|
||||
|
||||
} // namespace detail
|
||||
|
|
|
@ -49,15 +49,15 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
if (m_size == 0)
|
||||
{
|
||||
other.clear();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
{
|
||||
value_swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
r_key,
|
||||
PB_DS_V2F(*(end() - 1))))
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -86,13 +86,13 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
{
|
||||
value_swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::join(other);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
|
||||
|
||||
iterator it = upper_bound(r_key);
|
||||
|
||||
|
@ -106,7 +106,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
// No exceptions from this point.
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::split(
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::split(
|
||||
r_key,(Cmp_Fn& )(*this),
|
||||
other);)
|
||||
|
||||
|
@ -118,8 +118,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
value_swap(new_this);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -127,8 +127,8 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
if (other.m_size == 0)
|
||||
return;
|
||||
|
@ -168,12 +168,12 @@ join(PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
// No exceptions from this point.
|
||||
|
||||
PB_DS_DBG_ONLY(map_debug_base::join(other);)
|
||||
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
|
||||
|
||||
value_swap(new_this);
|
||||
|
||||
other.clear();
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
|
|
@ -53,14 +53,14 @@ copy_from_range(It first_it, It last_it)
|
|||
while (first_it != last_it)
|
||||
push(*(first_it++));
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
pairing_heap_()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -68,7 +68,7 @@ PB_DS_CLASS_C_DEC::
|
|||
pairing_heap_(const Cmp_Fn& r_cmp_fn) :
|
||||
PB_DS_BASE_C_DEC(r_cmp_fn)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -76,7 +76,7 @@ PB_DS_CLASS_C_DEC::
|
|||
pairing_heap_(const PB_DS_CLASS_C_DEC& other) :
|
||||
PB_DS_BASE_C_DEC(other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -84,11 +84,11 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
PB_DS_BASE_C_DEC::swap(other);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
|
|
@ -44,17 +44,16 @@
|
|||
* Contains an implementation class for a pairing heap.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid() const
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_type::m_p_root == NULL ||
|
||||
base_type::m_p_root->m_p_next_sibling == NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_root == NULL
|
||||
|| base_type::m_p_root->m_p_next_sibling == NULL);
|
||||
base_type::assert_valid();
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#endif
|
||||
|
|
|
@ -49,139 +49,107 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
pop()
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
node_pointer p_new_root = join_node_children(base_type::m_p_root);
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_new_root, false);)
|
||||
|
||||
if (p_new_root != NULL)
|
||||
p_new_root->m_p_prev_or_parent = NULL;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_new_root, false);)
|
||||
if (p_new_root != NULL)
|
||||
p_new_root->m_p_prev_or_parent = NULL;
|
||||
|
||||
base_type::actual_erase_node(base_type::m_p_root);
|
||||
|
||||
base_type::m_p_root = p_new_root;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase(point_iterator it)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
remove_node(it.m_p_nd);
|
||||
|
||||
base_type::actual_erase_node(it.m_p_nd);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
remove_node(node_pointer p_nd)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
node_pointer p_new_child = join_node_children(p_nd);
|
||||
|
||||
#ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
if (p_new_child != NULL)
|
||||
base_type::assert_node_consistent(p_new_child, false);
|
||||
#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
if (p_nd == base_type::m_p_root)
|
||||
{
|
||||
if (p_new_child != NULL)
|
||||
p_new_child->m_p_prev_or_parent = NULL;
|
||||
|
||||
base_type::m_p_root = p_new_child;
|
||||
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);)
|
||||
|
||||
return;
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);)
|
||||
return;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_prev_or_parent != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != NULL);
|
||||
if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd)
|
||||
{
|
||||
if (p_new_child != NULL)
|
||||
{
|
||||
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
|
||||
|
||||
if (p_new_child->m_p_next_sibling != NULL)
|
||||
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
|
||||
|
||||
p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child;
|
||||
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
|
||||
return;
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
return;
|
||||
}
|
||||
|
||||
p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling;
|
||||
|
||||
if (p_nd->m_p_next_sibling != NULL)
|
||||
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
|
||||
return;
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_new_child != NULL)
|
||||
{
|
||||
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
|
||||
|
||||
if (p_new_child->m_p_next_sibling != NULL)
|
||||
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
|
||||
|
||||
p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child;
|
||||
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
|
||||
return;
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
return;
|
||||
}
|
||||
|
||||
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
|
||||
|
||||
if (p_nd->m_p_next_sibling != NULL)
|
||||
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
}
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join_node_children(node_pointer p_nd)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
node_pointer p_ret = p_nd->m_p_l_child;
|
||||
|
||||
if (p_ret == NULL)
|
||||
return NULL;
|
||||
|
||||
while (p_ret->m_p_next_sibling != NULL)
|
||||
p_ret = forward_join(p_ret, p_ret->m_p_next_sibling);
|
||||
|
||||
while (p_ret->m_p_prev_or_parent != p_nd)
|
||||
p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_node_consistent(p_ret, false);)
|
||||
|
||||
return p_ret;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret, false);)
|
||||
return p_ret;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -189,36 +157,27 @@ typename PB_DS_CLASS_C_DEC::node_pointer
|
|||
PB_DS_CLASS_C_DEC::
|
||||
forward_join(node_pointer p_nd, node_pointer p_next)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ASSERT(p_nd->m_p_next_sibling == p_next);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next);
|
||||
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
|
||||
{
|
||||
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
base_type::make_child_of(p_nd, p_next);
|
||||
|
||||
return p_next->m_p_next_sibling == NULL?
|
||||
p_next :
|
||||
p_next->m_p_next_sibling;
|
||||
return p_next->m_p_next_sibling == NULL
|
||||
? p_next : p_next->m_p_next_sibling;
|
||||
}
|
||||
|
||||
if (p_next->m_p_next_sibling != NULL)
|
||||
{
|
||||
p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd;
|
||||
|
||||
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
|
||||
|
||||
base_type::make_child_of(p_next, p_nd);
|
||||
|
||||
return p_nd->m_p_next_sibling;
|
||||
}
|
||||
|
||||
p_nd->m_p_next_sibling = NULL;
|
||||
|
||||
base_type::make_child_of(p_next, p_nd);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
return p_nd;
|
||||
}
|
||||
|
||||
|
@ -227,24 +186,20 @@ typename PB_DS_CLASS_C_DEC::node_pointer
|
|||
PB_DS_CLASS_C_DEC::
|
||||
back_join(node_pointer p_nd, node_pointer p_next)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(p_nd != NULL);
|
||||
PB_DS_DBG_ASSERT(p_next->m_p_next_sibling == NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != NULL);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == NULL);
|
||||
|
||||
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
|
||||
{
|
||||
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
base_type::make_child_of(p_nd, p_next);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_next, false));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_next, false));
|
||||
return p_next;
|
||||
}
|
||||
|
||||
p_nd->m_p_next_sibling = NULL;
|
||||
|
||||
base_type::make_child_of(p_next, p_nd);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
return p_nd;
|
||||
}
|
||||
|
||||
|
@ -254,49 +209,34 @@ typename PB_DS_CLASS_C_DEC::size_type
|
|||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return 0;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
base_type::to_linked_list();
|
||||
|
||||
node_pointer p_out = base_type::prune(pred);
|
||||
|
||||
size_type ersd = 0;
|
||||
|
||||
while (p_out != NULL)
|
||||
{
|
||||
++ersd;
|
||||
|
||||
node_pointer p_next = p_out->m_p_next_sibling;
|
||||
|
||||
base_type::actual_erase_node(p_out);
|
||||
|
||||
p_out = p_next;
|
||||
}
|
||||
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
|
||||
base_type::m_p_root = NULL;
|
||||
|
||||
while (p_cur != NULL)
|
||||
{
|
||||
node_pointer p_next = p_cur->m_p_next_sibling;
|
||||
|
||||
p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = NULL;
|
||||
|
||||
push_imp(p_cur);
|
||||
|
||||
p_cur = p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
|
||||
return ersd;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
return ersd;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference
|
|||
PB_DS_CLASS_C_DEC::
|
||||
top() const
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ASSERT(!base_type::empty());
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
return base_type::m_p_root->m_value;
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator
|
|||
PB_DS_CLASS_C_DEC::
|
||||
push(const_reference r_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
|
||||
|
||||
push_imp(p_new_nd);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
return point_iterator(p_new_nd);
|
||||
}
|
||||
|
@ -78,14 +78,14 @@ push_imp(node_pointer p_nd)
|
|||
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = NULL;
|
||||
|
||||
base_type::make_child_of(base_type::m_p_root, p_nd);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false));
|
||||
|
||||
base_type::m_p_root = p_nd;
|
||||
}
|
||||
else
|
||||
{
|
||||
base_type::make_child_of(p_nd, base_type::m_p_root);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
modify(point_iterator it, const_reference r_new_val)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
|
||||
remove_node(it.m_p_nd);
|
||||
|
||||
|
@ -102,6 +102,6 @@ modify(point_iterator it, const_reference r_new_val)
|
|||
|
||||
push_imp(it.m_p_nd);
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,47 +55,35 @@
|
|||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
|
||||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace pb_ds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X) assert(X)
|
||||
#define PB_DS_DBG_VERIFY(X) assert(X)
|
||||
#define PB_DS_DBG_ONLY(X) X
|
||||
#else // #ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#define PB_DS_DBG_ASSERT(X)
|
||||
#define PB_DS_DBG_VERIFY(X) {if((X)==0);}
|
||||
#define PB_DS_DBG_ONLY(X) ;
|
||||
#endif // #ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, class Cmp_Fn, class Allocator>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
pairing_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
Allocator>
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
pairing_heap_<Value_Type, Cmp_Fn, Allocator>
|
||||
|
||||
#ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
null_left_child_next_sibling_heap_node_metadata, \
|
||||
Allocator, \
|
||||
false>
|
||||
#else // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#else
|
||||
#define PB_DS_BASE_C_DEC \
|
||||
left_child_next_sibling_heap_< \
|
||||
Value_Type, \
|
||||
Cmp_Fn, \
|
||||
null_left_child_next_sibling_heap_node_metadata, \
|
||||
Allocator>
|
||||
#endif // #ifdef PB_DS_LC_NS_HEAP_DEBUG_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* class description = "P4ri|\|g h3ap$">
|
||||
|
@ -195,7 +183,7 @@ namespace pb_ds
|
|||
void
|
||||
copy_from_range(It first_it, It last_it);
|
||||
|
||||
#ifdef PB_DS_PAIRING_HEAP_DEBUG_
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid() const;
|
||||
#endif
|
||||
|
@ -229,9 +217,6 @@ namespace pb_ds
|
|||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_BASE_C_DEC
|
||||
#undef PB_DS_DBG_ASSERT
|
||||
#undef PB_DS_DBG_VERIFY
|
||||
#undef PB_DS_DBG_ONLY
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pb_ds
|
||||
|
|
|
@ -50,15 +50,15 @@ void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
other.clear();
|
||||
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
|
||||
while (p_out != NULL)
|
||||
{
|
||||
PB_DS_DBG_ASSERT(base_type::m_size > 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
|
||||
--base_type::m_size;
|
||||
|
||||
++other.m_size;
|
||||
|
@ -83,7 +83,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
p_out = p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
|
||||
|
@ -100,8 +100,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
|||
p_cur = p_next;
|
||||
}
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
|
@ -109,13 +109,13 @@ inline void
|
|||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
if (other.m_p_root == NULL)
|
||||
{
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -125,14 +125,14 @@ join(PB_DS_CLASS_C_DEC& other)
|
|||
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
|
||||
{
|
||||
base_type::make_child_of(base_type::m_p_root, other.m_p_root);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(other.m_p_root, false));
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(other.m_p_root, false));
|
||||
|
||||
base_type::m_p_root = other.m_p_root;
|
||||
}
|
||||
else
|
||||
{
|
||||
base_type::make_child_of(other.m_p_root, base_type::m_p_root);
|
||||
PB_DS_DBG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false));
|
||||
}
|
||||
|
||||
base_type::m_size += other.m_size;
|
||||
|
@ -140,7 +140,7 @@ join(PB_DS_CLASS_C_DEC& other)
|
|||
other.m_p_root = NULL;
|
||||
other.m_size = 0;
|
||||
|
||||
PB_DS_DBG_ONLY(assert_valid();)
|
||||
PB_DS_DBG_ONLY(other.assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid();)
|
||||
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
node_pointer_pointer
|
||||
operator->()
|
||||
{
|
||||
PB_DS_DBG_ONLY(const_iterator::assert_referencible();)
|
||||
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
|
||||
|
||||
return (const_iterator::m_p_p_cur);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
node_pointer
|
||||
operator*()
|
||||
{
|
||||
PB_DS_DBG_ONLY(const_iterator::assert_referencible();)
|
||||
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
|
||||
|
||||
return (*const_iterator::m_p_p_cur);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue