Commit a345e45d by Benjamin Kosnik Committed by Benjamin Kosnik

re PR libstdc++/37144 (A bug in…

re PR libstdc++/37144 (A bug in include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp)

2011-05-23  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/37144
	PR libstdc++/28457
	Interface changes for ext/pb_ds.
	PB_DS_BASE_C_DEC to unique PB_DS_*_BASE macros.
	* include/ext/pb_ds/assoc_container.hpp (container_base): Remove.
	(basic_hash_table, basic_branch, list_update): Derive from
	container_base_dispatch.
	* include/ext/pb_ds/list_update_policy.hpp (null_lu_metadata): Remove.
	(move_to_front_lu_policy): To lu_move_to_front_policy.
	(counter_lu_policy): To lu_counter_policy.
	* include/ext/pb_ds/tree_policy.hpp (null_tree_node_update): Remove.
	* include/ext/pb_ds/tag_and_trait.hpp (container_base_dispatch): Adjust
	template parameters, declare here.
	(null_mapped_type) Remove.
	(null_type): Just use this for template tricks everywhere.
	* include/ext/pb_ds/hash_policy.hpp (null_hash_fn, null_probe_fn):
	Remove.
	* include/ext/pb_ds/trie_policy.hpp (null_trie_node_update): Remove.
	(string_trie_e_access_traits): To trie_string_access_traits.
	* include/ext/pb_ds/priority_queue.hpp: Use container_base_dispatch.

	File changes.
	* include/Makefile.am (pb_headers): Removed and changed file names.
	* include/Makefile.in: Regenerated.
	* include/ext/pb_ds/detail/basic_types.hpp: Remove.
	* include/ext/pb_ds/detail/bin_search_tree_/
	  cond_dtor_entry_dealtor.hpp: Remove.
	* include/ext/pb_ds/detail/bin_search_tree_/
	  cond_key_dtor_entry_dealtor.hpp: Remove.
	* include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Move..
	* include/ext/pb_ds/detail/binary_heap_/
	  point_const_iterator.hpp: ..here.
	* include/ext/pb_ds/detail/basic_tree_policy: Move to...
	* include/ext/pb_ds/detail/branch_policy: This.
	* include/ext/pb_ds/detail/branch_policy/
	  basic_tree_policy_base.hpp: Move...
	* include/ext/pb_ds/detail/branch_policy/branch_policy.hpp: ...here.
	* include/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp: Add.
	* include/ext/pb_ds/detail/branch_policy/traits.hpp: Add.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	null_metadata.hpp: Remove.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	const_point_iterator.hpp: Move...
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	point_const_iterator.hpp: ...here.
	* include/ext/pb_ds/detail/list_update_policy/
	counter_lu_metadata.hpp: Move..
	* include/ext/pb_ds/detail/list_update_policy/
	lu_counter_metadata.hpp: ...here.
	* include/ext/pb_ds/detail/list_update_policy/
	counter_lu_policy_imp.hpp: Remove.
	* include/ext/pb_ds/detail/list_update_policy/
	mtf_lu_policy_imp.hpp: Remove.
	* include/ext/pb_ds/detail/trie_policy/
	string_trie_e_access_traits_imp.hpp: Move...
	* include/ext/pb_ds/detail/trie_policy/
	sample_trie_access_traits.hpp: ...here.
	* include/ext/pb_ds/detail/trie_policy/
	sample_trie_e_access_traits.hpp: Move...
	* include/ext/pb_ds/detail/trie_policy/
	trie_string_access_traits_imp.hpp: ...here.
	* include/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp: Remove.
	* include/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp: Remove.
	* include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp: Remove.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp: New, fold all
	types found in the following files into pat_trie_base.
	* include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/
	  cond_dtor_entry_dealtor.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/head.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/leaf.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/node_base.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/internal_node.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp: Folded.
	* include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp: Move...
	* include/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp: ...here.
	* include/ext/pb_ds/detail/unordered_iterator/
	const_point_iterator.hpp: Move...
	* include/ext/pb_ds/detail/unordered_iterator/
	point_const_iterator.hpp: ...here.


	Adjust for above changes.
	* include/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp: Same.
	* include/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp: Same.
	* include/ext/pb_ds/detail/resize_policy/
	  sample_resize_trigger.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/container_base_dispatch.hpp: Same. Adjust
	  for template parameter ordering change.
	* 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_/
	  constructor_destructor_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  insert_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  resize_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  constructor_destructor_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  insert_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  entry_list_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  find_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  debug_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/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_/
	  cond_key_dtor_entry_dealtor.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/insert_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/cc_hash_table_map_/size_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  resize_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	  standard_policies.hpp: Same.
	* include/ext/pb_ds/detail/tree_trace_base.hpp: Same.
	* include/ext/pb_ds/detail/unordered_iterator/iterator.hpp: Same.
	* include/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp: Same.
	* include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/
	  constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/traits.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/
	  policy_access_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_/traits.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/info_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_/node_iterators.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/
	  split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_policy/
	  sample_update_policy.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	  trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	  erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  erase_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  constructor_destructor_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  insert_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  resize_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  constructor_destructor_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  insert_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  iterator_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  find_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/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_/
	  find_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  debug_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	  constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/insert_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/gp_hash_table_map_/
	  standard_policies.hpp: Same.
	* include/ext/pb_ds/detail/standard_policies.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_/policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/entry_cmp.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_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/entry_pred.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/binary_heap_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp: Same.
	* include/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp: Same.
	* include/ext/pb_ds/detail/tree_policy/
	  sample_tree_node_update.hpp: Same.
	* include/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp: Same.
	* include/ext/pb_ds/detail/trie_policy/
	  sample_trie_node_update.hpp: Same.
	* include/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp: Same.
	* include/ext/pb_ds/detail/trie_policy/
	  prefix_search_node_update_imp.hpp: Same.
	* include/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp: Same.
	* include/ext/pb_ds/detail/cond_dealtor.hpp: Same.
	* include/ext/pb_ds/detail/priority_queue_base_dispatch.hpp: Same.
	  Adjust for template parameter change, fold into
	  container_base_dispatch.
	* 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/constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/type_utils.hpp: Same.
	* include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp: Same.
	* include/ext/pb_ds/detail/eq_fn/eq_by_less.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	  policy_access_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_/
	  node.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	  info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	  iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/thin_heap_/trace_fn_imps.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_/policy_access_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/
	  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/ov_tree_map_/traits.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/debug_map_base.hpp: Same.
	* include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Same.
	* include/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp: Same.
	* include/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp: Same.
	* include/ext/pb_ds/detail/hash_fn/sample_range_hashing.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/hash_fn/sample_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_/node.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp: Same.
	* include/ext/pb_ds/detail/splay_tree_/traits.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/
	  entry_metadata_base.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/
	  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_/info_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_/trace_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_/find_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/
	  constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/node.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/rb_tree_map_/traits.hpp: Same.


	Documentation changes.
	* include/ext/pb_ds/*: Add doxygen markup.
	* doc/doxygen/user.cfg.in: Add details for extracting comments
	from pb_ds.
	* scripts/run_doxygen: Fixup __gnu_pb_ds::detail.
	* scripts/make_graph.py: Move to svg output. Re-format generated tables.

	* doc/Makefile.am (stamp-html-copy): New rule.
	(stamp-html): Use it to copy non-generated files into html docs.
	* doc/Makefile.in: Regenerated.

	* doc/html/ext/pb_ds/sample_trie_e_access_traits.html: Move...
	* doc/html/ext/pb_ds/trie_string_access_traits.html: ...here.
	* doc/html/ext/pb_ds/string_trie_e_access_traits.html: Move..
	* doc/html/ext/pb_ds/sample_trie_access_traits.html: ...here.

	* doc/html/ext/pb_ds/tree_text_lor_find_timing_test_local.png,
	hash_random_int_erase_mem_usage_test_local.png,
	multimap_text_insert_mem_usage_test_small_s2p_hash_local.png,
	tree_text_insert_timing_test_pat_trie_local.png ,
	multimap_text_insert_mem_usage_test_small_s2p_tree_local.png ,
	priority_queue_text_modify_down_timing_test_local.png,
	gp_hash_random_int_subscript_timing_test_find_local.png,
	text_find_timing_test_hash_local.png,
	multimap_text_insert_timing_test_small_s2p_hash_local.png,
	multimap_text_insert_timing_test_small_s2p_tree_local.png,
	multimap_text_insert_mem_usage_test_large_s2p_hash_local.png,
	multimap_text_insert_mem_usage_test_large_s2p_tree_local.png,
	multimap_text_insert_timing_test_large_s2p_hash_local.png,
	hash_zlob_random_int_find_timing_test_local.png,
	multimap_text_insert_timing_test_large_s2p_tree_local.png,
	binary_priority_queue_random_int_push_timing_test_local.png,
	priority_queue_text_pop_mem_usage_test_local.png,
	priority_queue_text_modify_down_timing_test_pairing_thin_local.png,
	tree_split_join_timing_test_local.png,
	multimap_text_find_timing_test_small_s2p_hash_local.png,
	ccgp_hash_random_int_subscript_timing_test_insert_local.png,
	priority_queue_random_int_push_pop_timing_test_local.png,
	multimap_text_find_timing_test_small_s2p_tree_local.png,
	gp_hash_random_int_subscript_timing_test_insert_local.png,
	priority_queue_text_push_timing_test_local.png,
	cc_hash_random_int_subscript_timing_test_find_local.png,
	tree_text_insert_timing_test_vector_tree_local.png,
	multimap_text_find_timing_test_large_s2p_hash_local.png,
	pairing_priority_queue_text_push_timing_test_local.png,
	tree_order_statistics_timing_test_local.png,
	priority_queue_text_push_pop_timing_test_local.png,
	text_find_timing_test_tree_like_local.png,
	multimap_text_find_timing_test_large_s2p_tree_local.png,
	priority_queue_text_modify_up_timing_test_pairing_thin_local.png,
	cc_hash_random_int_subscript_timing_test_insert_local.png,
	priority_queue_text_modify_up_timing_test_local.png,
	random_int_find_find_timing_test_tree_local.png,
	priority_queue_random_int_push_timing_test_local.png,
	tree_text_insert_timing_test_node_tree_local.png,
	pairing_priority_queue_text_push_pop_timing_test_local.png,
	gp_hash_random_int_find_timing_test_local.png,
	cc_hash_random_int_find_timing_test_local.png,
	priority_queue_text_join_timing_test_local.png: Update local pngs.


	Testsuite changes.
	* testsuite/ext/pb_ds/regression/tree_no_data_map_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/tree_data_map_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/priority_queue_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/trie_no_data_map_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/trie_data_map_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/list_update_no_data_map_rand_debug.cc:
	New.
	* testsuite/ext/pb_ds/regression/list_update_data_map_rand_debug.cc:
	New.
	* testsuite/ext/pb_ds/regression/hash_no_data_map_rand_debug.cc: New.
	* testsuite/ext/pb_ds/regression/hash_data_map_rand_debug.cc: New.

	* testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc: Fix typo.

	* testsuite/ext/pb_ds/example/basic_set.cc: Update.
	* testsuite/ext/pb_ds/example/ranged_hash.cc: Same.
	* testsuite/ext/pb_ds/example/tree_order_statistics.cc: Same.
	* testsuite/ext/pb_ds/example/trie_prefix_search.cc: Same.
	* testsuite/ext/pb_ds/example/trie_dna.cc: Same.
	* testsuite/ext/pb_ds/example/tree_intervals.cc: Same.
	* testsuite/ext/pb_ds/example/basic_multimap.cc: Same.
	* testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc:
	  Same.
	* testsuite/performance/ext/pb_ds/tree_split_join_timing.cc: Same.
	* testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc: Same.
	* testsuite/data/make_graph_test_infos.xml: Same.
	* testsuite/util/regression/common_type.hpp: Same.
	* testsuite/util/regression/trait/assoc/native_type_trait.hpp: Same.
	* testsuite/util/regression/trait/assoc/trait.hpp: Same.
	* testsuite/util/regression/trait/assoc/type_trait.hpp: Same.
	* testsuite/util/regression/rand/priority_queue/
	  rand_regression_test.hpp: Same.
	* testsuite/util/regression/rand/priority_queue/
	  container_rand_regression_test.tcc: Same.
	* testsuite/util/regression/rand/assoc/rand_regression_test.hpp: Same.
	* testsuite/util/regression/rand/assoc/container_rand_regression_test.h
	* testsuite/util/regression/rand/assoc/
	  container_rand_regression_test.tcc: Same.
	* testsuite/util/native_type/native_priority_queue.hpp: Same.
	* testsuite/util/native_type/native_multimap.hpp: Same.
	* testsuite/util/native_type/native_hash_multimap.hpp: Same.
	* testsuite/util/native_type/native_set.hpp: Same.
	* testsuite/util/native_type/native_map.hpp: Same.
	* testsuite/util/native_type/native_hash_set.hpp: Same.
	* testsuite/util/native_type/native_hash_map.hpp: Same.
	* testsuite/util/testsuite_containers.h
	* testsuite/util/common_type/priority_queue/common_type.hpp: Same.
	* testsuite/util/common_type/assoc/common_type.hpp: Same.
	* testsuite/util/common_type/assoc/string_form.hpp: Same.
	* testsuite/util/common_type/assoc/template_policy.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  trigger_policy_string_form.hpp: Same.
	* testsuite/util/common_type/assoc/detail/ds_string_form.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  size_policy_string_form.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  probe_fn_string_form.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  tree_supports_order_statistics.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  trie_supports_prefix_search.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  list_update_policy_string_form.hpp: Same.
	* testsuite/util/common_type/assoc/detail/
	  trie_supports_order_statistics.hpp: Same.
	* testsuite/util/common_type/assoc/native_set.hpp: Same.
	* testsuite/util/performance/assoc/timing/common_type.hpp: Same.
	* testsuite/util/performance/assoc/timing/multimap_find_test.hpp: Same.
	* testsuite/util/performance/assoc/multimap_common_type.hpp: Same.

From-SVN: r174100
parent ab015ce4
......@@ -136,9 +136,17 @@ doc-install-xml: doc-xml
# HTML
htmldir="$(DESTDIR)@docdir@"
stamp-html: stamp-html-docbook stamp-html-doxygen
stamp-html: stamp-html-copy stamp-html-doxygen
$(STAMP) stamp-html
copydir=${docbook_outdir}/html/manual/ext/
stamp-html-copy: stamp-html-docbook
cp -r ${top_srcdir}/doc/html/ext ${docbook_outdir}/html/manual/ext
cd ${docbook_outdir}/html/manual/ext
rm -rf ${docbook_outdir}/html/manual/ext/.svn
rm -rf ${docbook_outdir}/html/manual/ext/pb_ds/.svn
$(STAMP) stamp-html-copy
doc-html: stamp-html
doc-install-html: doc-html
......
......@@ -324,6 +324,7 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
# XML
xmldir = "$(DESTDIR)@docdir@"
copydir = ${docbook_outdir}/html/manual/ext/
# EPUB
# Assumes ruby installed
......@@ -649,8 +650,14 @@ doc-install-xml: doc-xml
test -z ${xmldir} || $(mkinstalldirs) ${xmldir}
$(INSTALL_DATA) ${manual_xml} ${xmldir}
$(INSTALL_DATA) ${api_xml} ${xmldir}
stamp-html: stamp-html-docbook stamp-html-doxygen
stamp-html: stamp-html-copy stamp-html-doxygen
$(STAMP) stamp-html
stamp-html-copy: stamp-html-docbook
cp -r ${top_srcdir}/doc/html/ext ${docbook_outdir}/html/manual/ext
cd ${docbook_outdir}/html/manual/ext
rm -rf ${docbook_outdir}/html/manual/ext/.svn
rm -rf ${docbook_outdir}/html/manual/ext/pb_ds/.svn
$(STAMP) stamp-html-copy
doc-html: stamp-html
......
......@@ -201,7 +201,7 @@ pb_subdirs = \
${pb_builddir}/detail/pairing_heap_ \
${pb_builddir}/detail/splay_tree_ \
${pb_builddir}/detail/list_update_map_ \
${pb_builddir}/detail/basic_tree_policy \
${pb_builddir}/detail/branch_policy \
${pb_builddir}/detail/trie_policy \
${pb_builddir}/detail/gp_hash_table_map_ \
${pb_builddir}/detail/tree_policy \
......@@ -236,13 +236,12 @@ pb_headers1 = \
${pb_srcdir}/tag_and_trait.hpp \
${pb_srcdir}/tree_policy.hpp \
${pb_srcdir}/trie_policy.hpp \
${pb_srcdir}/detail/basic_tree_policy/basic_tree_policy_base.hpp \
${pb_srcdir}/detail/basic_tree_policy/null_node_metadata.hpp \
${pb_srcdir}/detail/basic_tree_policy/traits.hpp \
${pb_srcdir}/detail/basic_types.hpp \
${pb_srcdir}/detail/branch_policy/branch_policy.hpp \
${pb_srcdir}/detail/branch_policy/null_node_metadata.hpp \
${pb_srcdir}/detail/branch_policy/traits.hpp \
${pb_srcdir}/detail/binary_heap_/binary_heap_.hpp \
${pb_srcdir}/detail/binary_heap_/const_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/const_point_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/point_const_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/binary_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/binary_heap_/entry_cmp.hpp \
......@@ -266,9 +265,7 @@ pb_headers1 = \
${pb_srcdir}/detail/binomial_heap_/binomial_heap_.hpp \
${pb_srcdir}/detail/binomial_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/binomial_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \
${pb_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \
${pb_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp
${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp
pb_headers2 = \
${pb_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \
......@@ -359,7 +356,7 @@ pb_headers4 = \
${pb_srcdir}/detail/hash_fn/sample_ranged_probe_fn.hpp \
${pb_srcdir}/detail/hash_fn/sample_range_hashing.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/const_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/const_point_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/point_const_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp \
......@@ -368,7 +365,6 @@ pb_headers4 = \
${pb_srcdir}/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/node.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/null_metadata.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp \
${pb_srcdir}/detail/list_update_map_/constructor_destructor_fn_imps.hpp \
......@@ -381,12 +377,9 @@ pb_headers4 = \
${pb_srcdir}/detail/list_update_map_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/list_update_map_/lu_map_.hpp \
${pb_srcdir}/detail/list_update_map_/trace_fn_imps.hpp \
${pb_srcdir}/detail/list_update_policy/counter_lu_metadata.hpp \
${pb_srcdir}/detail/list_update_policy/counter_lu_policy_imp.hpp \
${pb_srcdir}/detail/list_update_policy/mtf_lu_policy_imp.hpp \
${pb_srcdir}/detail/list_update_policy/lu_counter_metadata.hpp \
${pb_srcdir}/detail/list_update_policy/sample_update_policy.hpp \
${pb_srcdir}/detail/debug_map_base.hpp \
${pb_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \
${pb_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \
${pb_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \
......@@ -407,30 +400,20 @@ pb_headers5 = \
${pb_srcdir}/detail/pairing_heap_/insert_fn_imps.hpp \
${pb_srcdir}/detail/pairing_heap_/pairing_heap_.hpp \
${pb_srcdir}/detail/pairing_heap_/split_join_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/child_iterator.hpp \
${pb_srcdir}/detail/pat_trie_/cond_dtor_entry_dealtor.hpp \
${pb_srcdir}/detail/pat_trie_/const_child_iterator.hpp \
${pb_srcdir}/detail/pat_trie_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/debug_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/erase_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/find_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/head.hpp \
${pb_srcdir}/detail/pat_trie_/info_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/insert_join_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/internal_node.hpp \
${pb_srcdir}/detail/pat_trie_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/leaf.hpp \
${pb_srcdir}/detail/pat_trie_/node_base.hpp \
${pb_srcdir}/detail/pat_trie_/node_iterators.hpp \
${pb_srcdir}/detail/pat_trie_/node_metadata_base.hpp \
${pb_srcdir}/detail/pat_trie_/pat_trie_.hpp \
${pb_srcdir}/detail/pat_trie_/point_iterators.hpp \
${pb_srcdir}/detail/pat_trie_/pat_trie_base.hpp \
${pb_srcdir}/detail/pat_trie_/policy_access_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/r_erase_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/rotate_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/split_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/split_join_branch_bag.hpp \
${pb_srcdir}/detail/pat_trie_/synth_e_access_traits.hpp \
${pb_srcdir}/detail/pat_trie_/synth_access_traits.hpp \
${pb_srcdir}/detail/pat_trie_/trace_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/traits.hpp \
${pb_srcdir}/detail/pat_trie_/update_fn_imps.hpp \
......@@ -487,22 +470,20 @@ pb_headers7 = \
${pb_srcdir}/detail/thin_heap_/thin_heap_.hpp \
${pb_srcdir}/detail/thin_heap_/trace_fn_imps.hpp \
${pb_srcdir}/detail/tree_policy/node_metadata_selector.hpp \
${pb_srcdir}/detail/tree_policy/null_node_update_imp.hpp \
${pb_srcdir}/detail/tree_policy/order_statistics_imp.hpp \
${pb_srcdir}/detail/tree_policy/sample_tree_node_update.hpp \
${pb_srcdir}/detail/tree_trace_base.hpp \
${pb_srcdir}/detail/trie_policy/node_metadata_selector.hpp \
${pb_srcdir}/detail/trie_policy/null_node_update_imp.hpp \
${pb_srcdir}/detail/trie_policy/order_statistics_imp.hpp \
${pb_srcdir}/detail/trie_policy/prefix_search_node_update_imp.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_e_access_traits.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_access_traits.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_node_update.hpp \
${pb_srcdir}/detail/trie_policy/string_trie_e_access_traits_imp.hpp \
${pb_srcdir}/detail/trie_policy/trie_string_access_traits_imp.hpp \
${pb_srcdir}/detail/trie_policy/trie_policy_base.hpp \
${pb_srcdir}/detail/types_traits.hpp \
${pb_srcdir}/detail/type_utils.hpp \
${pb_srcdir}/detail/unordered_iterator/const_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/const_point_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/point_const_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/point_iterator.hpp
......
......@@ -451,7 +451,7 @@ pb_subdirs = \
${pb_builddir}/detail/pairing_heap_ \
${pb_builddir}/detail/splay_tree_ \
${pb_builddir}/detail/list_update_map_ \
${pb_builddir}/detail/basic_tree_policy \
${pb_builddir}/detail/branch_policy \
${pb_builddir}/detail/trie_policy \
${pb_builddir}/detail/gp_hash_table_map_ \
${pb_builddir}/detail/tree_policy \
......@@ -486,13 +486,12 @@ pb_headers1 = \
${pb_srcdir}/tag_and_trait.hpp \
${pb_srcdir}/tree_policy.hpp \
${pb_srcdir}/trie_policy.hpp \
${pb_srcdir}/detail/basic_tree_policy/basic_tree_policy_base.hpp \
${pb_srcdir}/detail/basic_tree_policy/null_node_metadata.hpp \
${pb_srcdir}/detail/basic_tree_policy/traits.hpp \
${pb_srcdir}/detail/basic_types.hpp \
${pb_srcdir}/detail/branch_policy/branch_policy.hpp \
${pb_srcdir}/detail/branch_policy/null_node_metadata.hpp \
${pb_srcdir}/detail/branch_policy/traits.hpp \
${pb_srcdir}/detail/binary_heap_/binary_heap_.hpp \
${pb_srcdir}/detail/binary_heap_/const_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/const_point_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/point_const_iterator.hpp \
${pb_srcdir}/detail/binary_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/binary_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/binary_heap_/entry_cmp.hpp \
......@@ -516,9 +515,7 @@ pb_headers1 = \
${pb_srcdir}/detail/binomial_heap_/binomial_heap_.hpp \
${pb_srcdir}/detail/binomial_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/binomial_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \
${pb_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \
${pb_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp
${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp
pb_headers2 = \
${pb_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \
......@@ -609,7 +606,7 @@ pb_headers4 = \
${pb_srcdir}/detail/hash_fn/sample_ranged_probe_fn.hpp \
${pb_srcdir}/detail/hash_fn/sample_range_hashing.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/const_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/const_point_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/point_const_iterator.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp \
......@@ -618,7 +615,6 @@ pb_headers4 = \
${pb_srcdir}/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/node.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/null_metadata.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp \
${pb_srcdir}/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp \
${pb_srcdir}/detail/list_update_map_/constructor_destructor_fn_imps.hpp \
......@@ -631,12 +627,9 @@ pb_headers4 = \
${pb_srcdir}/detail/list_update_map_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/list_update_map_/lu_map_.hpp \
${pb_srcdir}/detail/list_update_map_/trace_fn_imps.hpp \
${pb_srcdir}/detail/list_update_policy/counter_lu_metadata.hpp \
${pb_srcdir}/detail/list_update_policy/counter_lu_policy_imp.hpp \
${pb_srcdir}/detail/list_update_policy/mtf_lu_policy_imp.hpp \
${pb_srcdir}/detail/list_update_policy/lu_counter_metadata.hpp \
${pb_srcdir}/detail/list_update_policy/sample_update_policy.hpp \
${pb_srcdir}/detail/debug_map_base.hpp \
${pb_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \
${pb_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \
${pb_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \
......@@ -657,30 +650,20 @@ pb_headers5 = \
${pb_srcdir}/detail/pairing_heap_/insert_fn_imps.hpp \
${pb_srcdir}/detail/pairing_heap_/pairing_heap_.hpp \
${pb_srcdir}/detail/pairing_heap_/split_join_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/child_iterator.hpp \
${pb_srcdir}/detail/pat_trie_/cond_dtor_entry_dealtor.hpp \
${pb_srcdir}/detail/pat_trie_/const_child_iterator.hpp \
${pb_srcdir}/detail/pat_trie_/constructors_destructor_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/debug_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/erase_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/find_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/head.hpp \
${pb_srcdir}/detail/pat_trie_/info_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/insert_join_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/internal_node.hpp \
${pb_srcdir}/detail/pat_trie_/iterators_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/leaf.hpp \
${pb_srcdir}/detail/pat_trie_/node_base.hpp \
${pb_srcdir}/detail/pat_trie_/node_iterators.hpp \
${pb_srcdir}/detail/pat_trie_/node_metadata_base.hpp \
${pb_srcdir}/detail/pat_trie_/pat_trie_.hpp \
${pb_srcdir}/detail/pat_trie_/point_iterators.hpp \
${pb_srcdir}/detail/pat_trie_/pat_trie_base.hpp \
${pb_srcdir}/detail/pat_trie_/policy_access_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/r_erase_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/rotate_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/split_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/split_join_branch_bag.hpp \
${pb_srcdir}/detail/pat_trie_/synth_e_access_traits.hpp \
${pb_srcdir}/detail/pat_trie_/synth_access_traits.hpp \
${pb_srcdir}/detail/pat_trie_/trace_fn_imps.hpp \
${pb_srcdir}/detail/pat_trie_/traits.hpp \
${pb_srcdir}/detail/pat_trie_/update_fn_imps.hpp \
......@@ -737,22 +720,20 @@ pb_headers7 = \
${pb_srcdir}/detail/thin_heap_/thin_heap_.hpp \
${pb_srcdir}/detail/thin_heap_/trace_fn_imps.hpp \
${pb_srcdir}/detail/tree_policy/node_metadata_selector.hpp \
${pb_srcdir}/detail/tree_policy/null_node_update_imp.hpp \
${pb_srcdir}/detail/tree_policy/order_statistics_imp.hpp \
${pb_srcdir}/detail/tree_policy/sample_tree_node_update.hpp \
${pb_srcdir}/detail/tree_trace_base.hpp \
${pb_srcdir}/detail/trie_policy/node_metadata_selector.hpp \
${pb_srcdir}/detail/trie_policy/null_node_update_imp.hpp \
${pb_srcdir}/detail/trie_policy/order_statistics_imp.hpp \
${pb_srcdir}/detail/trie_policy/prefix_search_node_update_imp.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_e_access_traits.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_access_traits.hpp \
${pb_srcdir}/detail/trie_policy/sample_trie_node_update.hpp \
${pb_srcdir}/detail/trie_policy/string_trie_e_access_traits_imp.hpp \
${pb_srcdir}/detail/trie_policy/trie_string_access_traits_imp.hpp \
${pb_srcdir}/detail/trie_policy/trie_policy_base.hpp \
${pb_srcdir}/detail/types_traits.hpp \
${pb_srcdir}/detail/type_utils.hpp \
${pb_srcdir}/detail/unordered_iterator/const_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/const_point_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/point_const_iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/iterator.hpp \
${pb_srcdir}/detail/unordered_iterator/point_iterator.hpp
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file basic_types.hpp
* Contains basic types used by containers.
*/
#ifndef PB_DS_BASIC_TYPES_HPP
#define PB_DS_BASIC_TYPES_HPP
#include <algorithm>
#include <utility>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
namespace __gnu_pbds
{
namespace detail
{
template<typename Key, typename Mapped, typename Allocator, bool Store_Hash>
struct value_type_base;
/**
* Specialization of value_type_base for the case where the hash value
* is not stored alongside each value.
**/
template<typename Key, typename Mapped, typename Allocator>
struct value_type_base<Key, Mapped, Allocator, false>
{
typedef typename Allocator::template rebind<Mapped>::other mapped_type_allocator;
typedef typename mapped_type_allocator::value_type mapped_type;
typedef typename mapped_type_allocator::pointer mapped_pointer;
typedef typename mapped_type_allocator::const_pointer const_mapped_pointer;
typedef typename mapped_type_allocator::reference mapped_reference;
typedef typename mapped_type_allocator::const_reference const_mapped_reference;
typedef typename Allocator::template rebind<std::pair<const Key, Mapped> >::other value_type_allocator;
typedef typename value_type_allocator::value_type value_type;
typedef typename value_type_allocator::pointer pointer;
typedef typename value_type_allocator::const_pointer const_pointer;
typedef typename value_type_allocator::reference reference;
typedef typename value_type_allocator::const_reference const_reference;
struct stored_value_type
{
value_type m_value;
};
};
/**
* Specialization of value_type_base for the case where the hash value
* is stored alongside each value.
**/
template<typename Key, typename Mapped, typename Allocator>
struct value_type_base<Key, Mapped, Allocator, true>
{
typedef typename Allocator::template rebind<Mapped>::other mapped_type_allocator;
typedef typename mapped_type_allocator::value_type mapped_type;
typedef typename mapped_type_allocator::pointer mapped_pointer;
typedef typename mapped_type_allocator::const_pointer const_mapped_pointer;
typedef typename mapped_type_allocator::reference mapped_reference;
typedef typename mapped_type_allocator::const_reference const_mapped_reference;
typedef typename Allocator::template rebind<std::pair<const Key, Mapped> >::other value_type_allocator;
typedef typename value_type_allocator::value_type value_type;
typedef typename value_type_allocator::pointer pointer;
typedef typename value_type_allocator::const_pointer const_pointer;
typedef typename value_type_allocator::reference reference;
typedef typename value_type_allocator::const_reference const_reference;
struct stored_value_type
{
value_type m_value;
typename Allocator::size_type m_hash;
};
};
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, null_mapped_type, Allocator, false>
/**
* Specialization of value_type_base for the case where the hash value
* is not stored alongside each value.
**/
template<typename Key, typename Allocator>
struct value_type_base<Key, null_mapped_type, Allocator, false>
{
typedef typename Allocator::template rebind<null_mapped_type>::other mapped_type_allocator;
typedef typename mapped_type_allocator::value_type mapped_type;
typedef typename mapped_type_allocator::pointer mapped_pointer;
typedef typename mapped_type_allocator::const_pointer const_mapped_pointer;
typedef typename mapped_type_allocator::reference mapped_reference;
typedef typename mapped_type_allocator::const_reference const_mapped_reference;
typedef Key value_type;
typedef typename Allocator::template rebind<value_type>::other value_type_allocator;
typedef typename value_type_allocator::pointer pointer;
typedef typename value_type_allocator::const_pointer const_pointer;
typedef typename value_type_allocator::reference reference;
typedef typename value_type_allocator::const_reference const_reference;
struct stored_value_type
{
value_type m_value;
};
static null_mapped_type s_null_mapped;
};
PB_DS_CLASS_T_DEC
null_mapped_type PB_DS_CLASS_C_DEC::s_null_mapped;
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, null_mapped_type, Allocator, true>
/**
* Specialization of value_type_base for the case where the hash value
* is stored alongside each value.
**/
template<typename Key, typename Allocator>
struct value_type_base<Key, null_mapped_type, Allocator, true>
{
typedef typename Allocator::template rebind<null_mapped_type>::other mapped_type_allocator;
typedef typename mapped_type_allocator::value_type mapped_type;
typedef typename mapped_type_allocator::pointer mapped_pointer;
typedef typename mapped_type_allocator::const_pointer const_mapped_pointer;
typedef typename mapped_type_allocator::reference mapped_reference;
typedef typename mapped_type_allocator::const_reference const_mapped_reference;
typedef Key value_type;
typedef typename Allocator::template rebind<value_type>::other value_type_allocator;
typedef typename value_type_allocator::pointer pointer;
typedef typename value_type_allocator::const_pointer const_pointer;
typedef typename value_type_allocator::reference reference;
typedef typename value_type_allocator::const_reference const_reference;
struct stored_value_type
{
value_type m_value;
typename Allocator::size_type m_hash;
};
static null_mapped_type s_null_mapped;
};
PB_DS_CLASS_T_DEC
null_mapped_type PB_DS_CLASS_C_DEC::s_null_mapped;
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
template<typename Key, typename Mapped>
struct no_throw_copies
{
typedef integral_constant<int, is_simple<Key>::value && is_simple<Mapped>::value> indicator;
};
template<typename Key>
struct no_throw_copies<Key, null_mapped_type>
{
typedef integral_constant<int, is_simple<Key>::value> indicator;
};
} // namespace detail
} // namespace __gnu_pbds
#endif
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cond_dtor_entry_dealtor.hpp
* Contains a binary tree container conditional deallocator
*/
class bin_search_tree_cond_dtor_entry_dealtor_
{
public:
inline
bin_search_tree_cond_dtor_entry_dealtor_(node_pointer p_nd) : m_p_nd(p_nd),
m_no_action_dtor(false)
{ }
inline void
set_no_action_dtor()
{
m_no_action_dtor = true;
}
inline
~bin_search_tree_cond_dtor_entry_dealtor_()
{
if (m_no_action_dtor)
return;
typename Allocator::template rebind<Node>::other().
deallocate(m_p_nd, 1);
}
protected:
node_pointer m_p_nd;
bool m_no_action_dtor;
};
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file cond_key_dtor_entry_dealtor.hpp
* Contains a binary tree container conditional deallocator
*/
class bin_seach_tree_cond_key_dtor_entry_dealtor_
{
public:
inline
bin_seach_tree_cond_key_dtor_entry_dealtor_(node_pointer p_nd) : m_p_nd(p_nd),
m_no_action_dtor(false),
m_key_destruct(false)
{ }
inline void
set_no_action_dtor()
{
m_no_action_dtor = true;
}
inline void
set_key_destruct()
{
m_key_destruct = true;
}
inline
~bin_seach_tree_cond_key_dtor_entry_dealtor_()
{
if (m_no_action_dtor)
return;
if (m_key_destruct)
m_p_nd->m_value.first.~Key();
bin_tree_base::s_alloc.deallocate(m_p_nd, 1);
}
protected:
node_pointer m_p_nd;
bool m_no_action_dtor;
bool m_key_destruct;
};
......@@ -35,7 +35,7 @@
// warranty.
/**
* @file constructors_destructor_fn_imps.hpp
* @file bin_search_tree_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -45,7 +45,7 @@ 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_BIN_TREE_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
{
initialize();
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
......@@ -53,7 +53,7 @@ PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
{
initialize();
......@@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
Cmp_Fn(r_cmp_fn),
node_update(r_node_update),
m_p_head(s_node_allocator.allocate(1)),
......@@ -74,7 +74,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
......@@ -132,7 +132,7 @@ value_swap(PB_DS_CLASS_C_DEC& other)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~PB_DS_CLASS_NAME()
~PB_DS_BIN_TREE_NAME()
{
clear();
s_node_allocator.deallocate(m_p_head, 1);
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file debug_fn_imps.hpp
* @file bin_search_tree_/debug_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -272,8 +272,6 @@ PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_size(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size);
}
{ PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); }
#endif
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file erase_fn_imps.hpp
* @file bin_search_tree_/erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -45,11 +45,8 @@ actual_erase_node(node_pointer p_z)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node();
s_node_allocator.deallocate(p_z, 1);
}
......@@ -61,24 +58,19 @@ update_min_max_for_erased_node(node_pointer p_z)
if (m_size == 1)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
if (m_p_head->m_p_left == p_z)
{
iterator it(p_z);
++it;
m_p_head->m_p_left = it.m_p_nd;
}
else if (m_p_head->m_p_right == p_z)
{
iterator it(p_z);
--it;
m_p_head->m_p_right = it.m_p_nd;
}
}
......@@ -89,15 +81,10 @@ PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
......@@ -110,11 +97,7 @@ clear_imp(node_pointer p_nd)
return;
clear_imp(p_nd->m_p_left);
clear_imp(p_nd->m_p_right);
p_nd->~node();
s_node_allocator.deallocate(p_nd, 1);
}
......@@ -34,107 +34,92 @@
// warranty.
/**
* @file find_fn_imps.hpp
* @file bin_search_tree_/find_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_point_iterator
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
lower_bound(const_key_reference r_key) const
lower_bound(key_const_reference r_key) const
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_value),
r_key))
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
p_nd = p_nd->m_p_right;
else
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
return (iterator(p_pot));
return iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
lower_bound(const_key_reference r_key)
lower_bound(key_const_reference r_key)
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_value),
r_key))
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
p_nd = p_nd->m_p_right;
else
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
return (iterator(p_pot));
return iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_point_iterator
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
upper_bound(const_key_reference r_key) const
upper_bound(key_const_reference r_key) const
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_nd->m_value)))
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
{
p_pot = p_nd,
p_nd = p_nd->m_p_left;
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return (const_iterator(p_pot));
return const_iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
upper_bound(const_key_reference r_key)
upper_bound(key_const_reference r_key)
{
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
while (p_nd != 0)
if (Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_nd->m_value)))
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
{
p_pot = p_nd,
p_nd = p_nd->m_p_left;
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return (point_iterator(p_pot));
return point_iterator(p_pot);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::point_iterator
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key)
find(key_const_reference r_key)
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
......@@ -142,25 +127,27 @@ find(const_key_reference r_key)
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return point_iterator((p_pot != m_p_head
&& Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))
? m_p_head : p_pot);
node_pointer ret = p_pot;
if (p_pot != m_p_head)
{
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
if (__cmp)
ret = m_p_head;
}
return point_iterator(ret);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_point_iterator
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
PB_DS_CLASS_C_DEC::
find(const_key_reference r_key) const
find(key_const_reference r_key) const
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
node_pointer p_pot = m_p_head;
node_pointer p_nd = m_p_head->m_p_parent;
......@@ -168,15 +155,17 @@ find(const_key_reference r_key) const
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
{
p_pot = p_nd;
p_nd = p_nd->m_p_left;
}
else
p_nd = p_nd->m_p_right;
return const_point_iterator((p_pot != m_p_head
&& Cmp_Fn::operator()(r_key,
PB_DS_V2F(p_pot->m_value)))
? m_p_head : p_pot);
node_pointer ret = p_pot;
if (p_pot != m_p_head)
{
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
if (__cmp)
ret = m_p_head;
}
return point_const_iterator(ret);
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file info_fn_imps.hpp
* @file bin_search_tree_/info_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file insert_fn_imps.hpp
* @file bin_search_tree_/insert_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -101,38 +101,30 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
if (left_nd)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0);
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
PB_DS_V2F(r_value),
PB_DS_V2F(p_nd->m_value)));
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value),
PB_DS_V2F(p_nd->m_value)));
p_nd->m_p_left = p_new_nd;
if (m_p_head->m_p_left == p_nd)
m_p_head->m_p_left = p_new_nd;
}
else
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0);
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(
PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value)));
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
PB_DS_V2F(r_value)));
p_nd->m_p_right = p_new_nd;
if (m_p_head->m_p_right == p_nd)
m_p_head->m_p_right = p_new_nd;
}
p_new_nd->m_p_parent = p_nd;
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
update_to_top(p_new_nd, (node_update* )this);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
return iterator(p_new_nd);
}
......@@ -148,13 +140,10 @@ insert_imp_empty(const_reference r_value)
m_p_head->m_p_parent = p_new_node;
p_new_node->m_p_parent = m_p_head;
p_new_node->m_p_left = p_new_node->m_p_right = 0;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
update_to_top(m_p_head->m_p_parent, (node_update*)this);
return iterator(p_new_node);
}
......@@ -164,18 +153,14 @@ PB_DS_CLASS_C_DEC::
get_new_node_for_leaf_insert(const_reference r_val, false_type)
{
node_pointer p_new_nd = s_node_allocator.allocate(1);
cond_dealtor_t cond(p_new_nd);
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
typename node::value_type(r_val);
cond.set_no_action();
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size;
return p_new_nd;
}
......@@ -190,9 +175,6 @@ get_new_node_for_leaf_insert(const_reference r_val, true_type)
typename node::value_type(r_val);
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
++m_size;
return p_new_nd;
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file iterators_fn_imps.hpp
* @file bin_search_tree_/iterators_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -103,11 +103,11 @@ rend() const
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_begin() const
{
return (const_node_iterator(m_p_head->m_p_parent));
return (node_const_iterator(m_p_head->m_p_parent));
}
PB_DS_CLASS_T_DEC
......@@ -119,11 +119,11 @@ node_begin()
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_node_iterator
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_end() const
{
return (const_node_iterator(0));
return (node_const_iterator(0));
}
PB_DS_CLASS_T_DEC
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file node_iterators.hpp
* @file bin_search_tree_/node_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -47,31 +47,27 @@ namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC \
bin_search_tree_const_node_it_< \
Node, \
Const_Iterator, \
Iterator, \
Allocator>
_Alloc>
// Const node iterator.
/// Const node iterator.
template<typename Node,
class Const_Iterator,
class Iterator,
class Allocator>
typename _Alloc>
class bin_search_tree_const_node_it_
{
private:
private:
typedef
typename Allocator::template rebind<
typename _Alloc::template rebind<
Node>::other::pointer
node_pointer;
public:
// Category.
typedef trivial_iterator_tag iterator_category;
......@@ -92,11 +88,9 @@ namespace __gnu_pbds
// Const metadata reference type.
typedef
typename Allocator::template rebind<
typename _Alloc::template rebind<
metadata_type>::other::const_reference
const_metadata_reference;
public:
metadata_const_reference;
// Default constructor.
/*
......@@ -105,7 +99,8 @@ namespace __gnu_pbds
*/
inline
bin_search_tree_const_node_it_(const node_pointer p_nd = 0) : m_p_nd(const_cast<node_pointer>(p_nd))
bin_search_tree_const_node_it_(const node_pointer p_nd = 0)
: m_p_nd(const_cast<node_pointer>(p_nd))
{ }
// Access.
......@@ -116,7 +111,7 @@ namespace __gnu_pbds
}
// Metadata access.
inline const_metadata_reference
inline metadata_const_reference
get_metadata() const
{
return (m_p_nd->get_metadata());
......@@ -150,7 +145,6 @@ namespace __gnu_pbds
return (m_p_nd != other.m_p_nd);
}
public:
node_pointer m_p_nd;
};
......@@ -159,26 +153,23 @@ namespace __gnu_pbds
Node, \
Const_Iterator, \
Iterator, \
Allocator>
_Alloc>
// Node iterator.
/// Node iterator.
template<typename Node,
class Const_Iterator,
class Iterator,
class Allocator>
class bin_search_tree_node_it_ :
public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
typename _Alloc>
class bin_search_tree_node_it_
: public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
{
private:
typedef
typename Allocator::template rebind<
typename _Alloc::template rebind<
Node>::other::pointer
node_pointer;
public:
// __Iterator's value type.
typedef Iterator value_type;
......@@ -188,8 +179,6 @@ namespace __gnu_pbds
// __Iterator's __const reference type.
typedef Iterator const_reference;
public:
// Default constructor.
/*
inline
......@@ -197,8 +186,8 @@ namespace __gnu_pbds
*/
inline
bin_search_tree_node_it_(const node_pointer p_nd = 0) : PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(
const_cast<node_pointer>(p_nd))
bin_search_tree_node_it_(const node_pointer p_nd = 0)
: PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(const_cast<node_pointer>(p_nd))
{ }
// Access.
......@@ -227,7 +216,6 @@ namespace __gnu_pbds
};
#undef PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
#undef PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
} // namespace detail
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file point_iterators.hpp
* @file bin_search_tree_/point_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -58,7 +58,7 @@ namespace __gnu_pbds
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
Allocator>
_Alloc>
#define PB_DS_TREE_CONST_ODIR_IT_C_DEC \
bin_search_tree_const_it_< \
......@@ -69,7 +69,7 @@ namespace __gnu_pbds
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
Allocator>
_Alloc>
#define PB_DS_TREE_IT_C_DEC \
bin_search_tree_it_< \
......@@ -80,7 +80,7 @@ namespace __gnu_pbds
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
Allocator>
_Alloc>
#define PB_DS_TREE_ODIR_IT_C_DEC \
bin_search_tree_it_< \
......@@ -91,9 +91,9 @@ namespace __gnu_pbds
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
Allocator>
_Alloc>
// Const iterator.
/// Const iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
......@@ -101,27 +101,17 @@ namespace __gnu_pbds
typename Reference,
typename Const_Reference,
bool Is_Forward_Iterator,
class Allocator>
typename _Alloc>
class bin_search_tree_const_it_
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename Allocator::difference_type difference_type;
typedef Value_Type value_type;
typedef Pointer pointer;
typedef Const_Pointer const_pointer;
typedef Reference reference;
typedef Const_Reference const_reference;
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename _Alloc::difference_type difference_type;
typedef Value_Type value_type;
typedef Pointer pointer;
typedef Const_Pointer const_pointer;
typedef Reference reference;
typedef Const_Reference const_reference;
inline
bin_search_tree_const_it_(const Node_Pointer p_nd = 0)
......@@ -280,7 +270,7 @@ namespace __gnu_pbds
Node_Pointer m_p_nd;
};
// Iterator.
/// Iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
......@@ -288,14 +278,10 @@ namespace __gnu_pbds
typename Reference,
typename Const_Reference,
bool Is_Forward_Iterator,
class Allocator>
class bin_search_tree_it_ :
public PB_DS_TREE_CONST_IT_C_DEC
typename _Alloc>
class bin_search_tree_it_ : public PB_DS_TREE_CONST_IT_C_DEC
{
public:
inline
bin_search_tree_it_(const Node_Pointer p_nd = 0)
: PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd)
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file policy_access_fn_imps.hpp
* @file bin_search_tree_/policy_access_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -42,15 +42,11 @@ PB_DS_CLASS_T_DEC
Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn()
{
return (*this);
}
{ return (*this); }
PB_DS_CLASS_T_DEC
const Cmp_Fn&
PB_DS_CLASS_C_DEC::
get_cmp_fn() const
{
return (*this);
}
{ return (*this); }
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file r_erase_fn_imps.hpp
* @file bin_search_tree_/r_erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -45,11 +45,8 @@ actual_erase_node(node_pointer p_z)
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
p_z->~node();
s_node_allocator.deallocate(p_z, 1);
}
......@@ -61,24 +58,19 @@ update_min_max_for_erased_node(node_pointer p_z)
if (m_size == 1)
{
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
return;
}
if (m_p_head->m_p_left == p_z)
{
iterator it(p_z);
++it;
m_p_head->m_p_left = it.m_p_nd;
}
else if (m_p_head->m_p_right == p_z)
{
iterator it(p_z);
--it;
m_p_head->m_p_right = it.m_p_nd;
}
}
......@@ -89,15 +81,10 @@ PB_DS_CLASS_C_DEC::
clear()
{
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
clear_imp(m_p_head->m_p_parent);
clear_imp(m_p_head->m_p_parent);
m_size = 0;
initialize();
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
}
......@@ -110,11 +97,7 @@ clear_imp(node_pointer p_nd)
return;
clear_imp(p_nd->m_p_left);
clear_imp(p_nd->m_p_right);
p_nd->~Node();
s_node_allocator.deallocate(p_nd, 1);
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file rotate_fn_imps.hpp
* @file bin_search_tree_/rotate_fn_imps.hpp
* Contains imps for rotating nodes.
*/
......@@ -130,7 +130,7 @@ PB_DS_CLASS_C_DEC::
apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
{
node_update::operator()(node_iterator(p_nd),
const_node_iterator(static_cast<node_pointer>(0)));
node_const_iterator(static_cast<node_pointer>(0)));
}
PB_DS_CLASS_T_DEC
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file split_join_fn_imps.hpp
* @file bin_search_tree_/split_join_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
......@@ -85,7 +85,7 @@ join_finish(PB_DS_CLASS_C_DEC& other)
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file traits.hpp
* @file bin_search_tree_/traits.hpp
* Contains an implementation for bin_search_tree_.
*/
......@@ -48,34 +48,28 @@ namespace __gnu_pbds
{
namespace detail
{
/// Binary search tree traits, primary template.
template<typename Key,
typename Mapped,
class Cmp_Fn,
template<typename Const_Node_Iterator,
class Node_Iterator,
template<typename Node_CItr,
class Node_Itr,
class Cmp_Fn,
class Allocator>
typename _Alloc>
class Node_Update,
class Node,
class Allocator>
typename _Alloc>
struct bin_search_tree_traits
{
private:
typedef
types_traits<
Key,
Mapped,
Allocator,
false>
type_traits;
typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -83,12 +77,12 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
true,
Allocator>
const_point_iterator;
_Alloc>
point_const_iterator;
typedef
bin_search_tree_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -96,12 +90,12 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
true,
Allocator>
_Alloc>
point_iterator;
typedef
bin_search_tree_const_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -109,12 +103,12 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
false,
Allocator>
_Alloc>
const_reverse_iterator;
typedef
bin_search_tree_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -122,74 +116,69 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
false,
Allocator>
_Alloc>
reverse_iterator;
typedef
bin_search_tree_const_node_it_<
Node,
const_point_iterator,
point_const_iterator,
point_iterator,
Allocator>
const_node_iterator;
_Alloc>
node_const_iterator;
typedef
bin_search_tree_node_it_<
Node,
const_point_iterator,
point_const_iterator,
point_iterator,
Allocator>
_Alloc>
node_iterator;
typedef
Node_Update<
const_node_iterator,
node_const_iterator,
node_iterator,
Cmp_Fn,
Allocator>
_Alloc>
node_update;
typedef
__gnu_pbds::null_tree_node_update<
const_node_iterator,
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
Allocator>*
_Alloc>*
null_node_update_pointer;
};
/// Specialization.
template<typename Key,
class Cmp_Fn,
template<typename Const_Node_Iterator,
class Node_Iterator,
template<typename Node_CItr,
class Node_Itr,
class Cmp_Fn,
class Allocator>
typename _Alloc>
class Node_Update,
class Node,
class Allocator>
typename _Alloc>
struct bin_search_tree_traits<
Key,
null_mapped_type,
null_type,
Cmp_Fn,
Node_Update,
Node,
Allocator>
_Alloc>
{
private:
typedef
types_traits<
Key,
null_mapped_type,
Allocator,
false>
type_traits;
typedef types_traits<Key, null_type, _Alloc, false> type_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -197,14 +186,14 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
true,
Allocator>
const_point_iterator;
_Alloc>
point_const_iterator;
typedef const_point_iterator point_iterator;
typedef point_const_iterator point_iterator;
typedef
bin_search_tree_const_it_<
typename Allocator::template rebind<
typename _Alloc::template rebind<
node>::other::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
......@@ -212,7 +201,7 @@ namespace __gnu_pbds
typename type_traits::reference,
typename type_traits::const_reference,
false,
Allocator>
_Alloc>
const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
......@@ -220,27 +209,23 @@ namespace __gnu_pbds
typedef
bin_search_tree_const_node_it_<
Node,
const_point_iterator,
point_const_iterator,
point_iterator,
Allocator>
const_node_iterator;
_Alloc>
node_const_iterator;
typedef const_node_iterator node_iterator;
typedef node_const_iterator node_iterator;
typedef
Node_Update<
const_node_iterator,
node_iterator,
Cmp_Fn,
Allocator>
Node_Update<node_const_iterator, node_iterator, Cmp_Fn, _Alloc>
node_update;
typedef
__gnu_pbds::null_tree_node_update<
const_node_iterator,
__gnu_pbds::null_node_update<
node_const_iterator,
node_iterator,
Cmp_Fn,
Allocator>*
_Alloc>*
null_node_update_pointer;
};
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file const_iterator.hpp
* @file binary_heap_/const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
*/
......@@ -42,57 +42,48 @@
#ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
#define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
#include <ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp>
#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_BIN_HEAP_CIT_BASE \
binary_heap_point_const_iterator_<Value_Type, Entry, Simple, _Alloc>
#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>
// Const point-type iterator.
/// Const point-type iterator.
template<typename Value_Type,
typename Entry,
bool Simple,
class Allocator>
class binary_heap_const_iterator_ : public PB_DS_BASE_C_DEC
typename _Alloc>
class binary_heap_const_iterator_ : public PB_DS_BIN_HEAP_CIT_BASE
{
private:
typedef typename PB_DS_BASE_C_DEC::entry_pointer entry_pointer;
typedef PB_DS_BASE_C_DEC base_type;
typedef PB_DS_BIN_HEAP_CIT_BASE base_type;
typedef typename base_type::entry_pointer entry_pointer;
public:
// Category.
typedef std::forward_iterator_tag iterator_category;
typedef std::forward_iterator_tag iterator_category;
// Difference type.
typedef typename Allocator::difference_type difference_type;
typedef typename _Alloc::difference_type difference_type;
// Iterator's value type.
typedef typename base_type::value_type value_type;
typedef typename base_type::value_type value_type;
// Iterator's pointer type.
typedef typename base_type::pointer pointer;
typedef typename base_type::pointer pointer;
// Iterator's const pointer type.
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::const_pointer const_pointer;
// Iterator's reference type.
typedef typename base_type::reference reference;
typedef typename base_type::reference reference;
// Iterator's const reference type.
typedef typename base_type::const_reference const_reference;
public:
typedef typename base_type::const_reference const_reference;
inline
binary_heap_const_iterator_(entry_pointer p_e) : base_type(p_e)
......@@ -105,24 +96,21 @@ namespace __gnu_pbds
// Copy constructor.
inline
binary_heap_const_iterator_(const PB_DS_CLASS_C_DEC& other) : base_type(other)
binary_heap_const_iterator_(const binary_heap_const_iterator_& other)
: base_type(other)
{ }
// Compares content 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;
}
operator==(const binary_heap_const_iterator_& other) const
{ 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;
}
operator!=(const binary_heap_const_iterator_& other) const
{ return base_type::m_p_e != other.m_p_e; }
inline PB_DS_CLASS_C_DEC&
inline binary_heap_const_iterator_&
operator++()
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != 0);
......@@ -130,10 +118,10 @@ namespace __gnu_pbds
return *this;
}
inline PB_DS_CLASS_C_DEC
inline binary_heap_const_iterator_
operator++(int)
{
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_e);
binary_heap_const_iterator_ ret_it(base_type::m_p_e);
operator++();
return ret_it;
}
......@@ -144,8 +132,7 @@ namespace __gnu_pbds
{ ++base_type::m_p_e; }
};
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_BASE_C_DEC
#undef PB_DS_BIN_HEAP_CIT_BASE
} // namespace detail
} // namespace __gnu_pbds
......
......@@ -35,7 +35,7 @@
// warranty.
/**
* @file constructors_destructor_fn_imps.hpp
* @file binary_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for binary_heap_.
*/
......@@ -62,55 +62,37 @@ copy_from_range(It first_it, It last_it)
insert_value(*first_it, s_no_throw_copies_ind);
++first_it;
}
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
PB_DS_ASSERT_VALID((*this))
make_heap();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap_() :
m_size(0),
m_actual_size(resize_policy::min_size),
binary_heap()
: m_size(0), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
PB_DS_ASSERT_VALID((*this))
}
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap_(const Cmp_Fn& r_cmp_fn) :
entry_cmp(r_cmp_fn),
m_size(0),
m_actual_size(resize_policy::min_size),
binary_heap(const Cmp_Fn& r_cmp_fn)
: entry_cmp(r_cmp_fn), m_size(0), m_actual_size(resize_policy::min_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
PB_DS_ASSERT_VALID((*this))
}
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binary_heap_(const PB_DS_CLASS_C_DEC& other) :
entry_cmp(other),
resize_policy(other),
m_size(0),
binary_heap(const PB_DS_CLASS_C_DEC& other)
: entry_cmp(other), resize_policy(other), m_size(0),
m_actual_size(other.m_actual_size),
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
const_iterator first_it = other.begin();
const_iterator last_it = other.end();
__try
{
while (first_it != last_it)
{
insert_value(*first_it, s_no_throw_copies_ind);
++first_it;
}
copy_from_range(other.begin(), other.end());
}
__catch(...)
{
......@@ -131,9 +113,8 @@ swap(PB_DS_CLASS_C_DEC& other)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other);
std::swap((entry_cmp& )(*this), (entry_cmp& )other);
std::swap((entry_cmp&)(*this), (entry_cmp&)other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
......@@ -151,10 +132,9 @@ value_swap(PB_DS_CLASS_C_DEC& other)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binary_heap_()
~binary_heap()
{
for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file debug_fn_imps.hpp
* @file binary_heap_/debug_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -47,7 +47,7 @@ assert_valid(const char* __file, int __line) const
{
#ifdef PB_DS_REGRESSION
s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
#endif
#endif
resize_policy::assert_valid(__file, __line);
PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
......@@ -55,7 +55,7 @@ assert_valid(const char* __file, int __line) const
{
#ifdef PB_DS_REGRESSION
s_value_allocator.check_allocated(m_a_entries[i], 1);
#endif
#endif
if (left_child(i) < m_size)
PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
......@@ -69,4 +69,4 @@ assert_valid(const char* __file, int __line) const
}
}
#endif
#endif
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file entry_cmp.hpp
* @file binary_heap_/entry_cmp.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -45,48 +45,40 @@ namespace __gnu_pbds
{
namespace detail
{
/// Entry compare, primary template.
template<typename _VTp, typename Cmp_Fn, typename _Alloc, bool No_Throw>
struct entry_cmp;
template<typename Value_Type,
class Cmp_Fn,
bool No_Throw,
class Allocator>
struct entry_cmp
{
typedef Cmp_Fn type;
};
template<typename Value_Type, class Cmp_Fn, class Allocator>
struct entry_cmp<
Value_Type,
Cmp_Fn,
false,
Allocator>
{
public:
typedef
typename Allocator::template rebind<
Value_Type>::other::const_pointer
entry;
struct type : public Cmp_Fn
/// Specialization, true.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, true>
{
public:
inline
type()
{ }
/// Compare.
typedef Cmp_Fn type;
};
/// Specialization, false.
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false>
{
private:
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
inline
type(const Cmp_Fn& other) : Cmp_Fn(other)
{ }
public:
typedef typename __rebind_v::other::const_pointer entry;
inline bool
operator()(entry p_lhs, entry p_rhs) const
/// Compare plus entry.
struct type : public Cmp_Fn
{
return Cmp_Fn::operator()(*p_lhs, * p_rhs);
}
};
};
type() { }
type(const Cmp_Fn& other) : Cmp_Fn(other) { }
bool
operator()(entry lhs, entry rhs) const
{ return Cmp_Fn::operator()(*lhs, *rhs); }
};
};
} // namespace detail
} // namespace __gnu_pbds
......
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file entry_pred.hpp
* @file binary_heap_/entry_pred.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -45,48 +45,40 @@ namespace __gnu_pbds
{
namespace detail
{
/// Entry predicate primary class template.
template<typename _VTp, typename Pred, typename _Alloc, bool No_Throw>
struct entry_pred;
template<typename Value_Type,
class Pred,
bool No_Throw,
class Allocator>
struct entry_pred
{
typedef Pred type;
};
template<typename Value_Type, class Pred, class Allocator>
struct entry_pred<
Value_Type,
Pred,
false,
Allocator>
{
public:
typedef
typename Allocator::template rebind<
Value_Type>::other::const_pointer
entry;
struct type : public Pred
/// Specialization, true.
template<typename _VTp, typename Pred, typename _Alloc>
struct entry_pred<_VTp, Pred, _Alloc, true>
{
public:
inline
type()
{ }
typedef Pred type;
};
/// Specialization, false.
template<typename _VTp, typename Pred, typename _Alloc>
struct entry_pred<_VTp, Pred, _Alloc, false>
{
private:
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
inline
type(const Pred& other) : Pred(other)
{ }
public:
typedef typename __rebind_v::other::const_pointer entry;
inline bool
operator()(entry p_v) const
struct type : public Pred
{
return Pred::operator()(*p_v);
}
};
};
inline
type() { }
inline
type(const Pred& other) : Pred(other) { }
inline bool
operator()(entry p_v) const
{ return Pred::operator()(*p_v); }
};
};
} // namespace detail
} // namespace __gnu_pbds
......
......@@ -35,7 +35,7 @@
// warranty.
/**
* @file erase_fn_imps.hpp
* @file binary_heap_/erase_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -49,23 +49,17 @@ clear()
__try
{
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(0);
entry_pointer a_entries = s_entry_allocator.allocate(actual_size);
resize_policy::notify_arbitrary(actual_size);
const size_type new_size = resize_policy::get_new_size_for_arbitrary(0);
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_arbitrary(new_size);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = actual_size;
m_a_entries = a_entries;
m_actual_size = new_size;
m_a_entries = new_entries;
}
__catch(...)
{ }
m_size = 0;
PB_DS_ASSERT_VALID((*this))
}
......@@ -92,13 +86,9 @@ pop()
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
erase_at(m_a_entries, 0, s_no_throw_copies_ind);
std::pop_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp& >(*this));
pop_heap();
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
resize_for_erase_if_needed();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
......@@ -113,43 +103,32 @@ erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
typedef typename entry_pred<value_type, Pred, simple_value, Allocator>::type
typedef typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
pred_t;
const size_type left = partition(pred_t(pred));
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
const size_type ersd = m_size - left;
for (size_type i = left; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
__try
{
const size_type actual_size =
const size_type new_size =
resize_policy::get_new_size_for_arbitrary(left);
entry_pointer a_entries = s_entry_allocator.allocate(actual_size);
std::copy(m_a_entries, m_a_entries + left, a_entries);
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
std::copy(m_a_entries, m_a_entries + left, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = actual_size;
m_actual_size = new_size;
resize_policy::notify_arbitrary(m_actual_size);
}
__catch(...)
{ };
m_size = left;
std::make_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp& >(*this));
make_heap();
PB_DS_ASSERT_VALID((*this))
return ersd;
}
......@@ -162,16 +141,12 @@ erase(point_iterator it)
_GLIBCXX_DEBUG_ASSERT(!empty());
const size_type fix_pos = it.m_p_e - m_a_entries;
std::swap(*it.m_p_e, m_a_entries[m_size - 1]);
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
resize_for_erase_if_needed();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
_GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size);
if (fix_pos != m_size)
......@@ -190,21 +165,15 @@ resize_for_erase_if_needed()
__try
{
const size_type new_actual_size =
resize_policy::get_new_size_for_shrink();
entry_pointer a_new_entries = s_entry_allocator.allocate(new_actual_size);
const size_type new_size = resize_policy::get_new_size_for_shrink();
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_shrink_resize();
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
std::copy(m_a_entries, m_a_entries + m_size - 1, a_new_entries);
std::copy(m_a_entries, m_a_entries + m_size - 1, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_actual_size;
m_a_entries = a_new_entries;
m_actual_size = new_size;
m_a_entries = new_entries;
}
__catch(...)
{ }
......@@ -230,9 +199,7 @@ partition(Pred pred)
else
{
_GLIBCXX_DEBUG_ASSERT(left < right);
std::swap(m_a_entries[left], m_a_entries[right]);
++left;
--right;
}
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file find_fn_imps.hpp
* @file binary_heap_/find_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -45,7 +45,6 @@ top() const
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
return top_imp(s_no_throw_copies_ind);
}
......@@ -53,39 +52,28 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top_imp(true_type) const
{
return* m_a_entries;
}
{ return *m_a_entries; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_reference
PB_DS_CLASS_C_DEC::
top_imp(false_type) const
{
return** m_a_entries;
}
{ return **m_a_entries; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
left_child(size_type i)
{
return i* 2 + 1;
}
{ return i * 2 + 1; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
right_child(size_type i)
{
return i* 2 + 2;
}
{ return i * 2 + 2; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
parent(size_type i)
{
return (i - 1) / 2;
}
{ return (i - 1) / 2; }
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file info_fn_imps.hpp
* @file binary_heap_/info_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -42,23 +42,17 @@ PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
empty() const
{
return (m_size == 0);
}
{ return m_size == 0; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
size() const
{
return (m_size);
}
{ return m_size; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
{
return (s_entry_allocator.max_size());
}
{ return s_entry_allocator.max_size(); }
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file insert_fn_imps.hpp
* @file binary_heap_/insert_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -45,8 +45,7 @@ push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
insert_value(r_val, s_no_throw_copies_ind);
std::push_heap(m_a_entries, m_a_entries + m_size,
static_cast<entry_cmp&>(*this));
push_heap();
PB_DS_ASSERT_VALID((*this))
return point_iterator(m_a_entries);
}
......@@ -57,7 +56,6 @@ PB_DS_CLASS_C_DEC::
insert_value(value_type val, true_type)
{
resize_for_insert_if_needed();
m_a_entries[m_size++] = val;
}
......@@ -77,15 +75,6 @@ insert_value(const_reference r_val, false_type)
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
insert_entry(entry e)
{
resize_for_insert_if_needed();
m_a_entries[m_size++] = e;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
resize_for_insert_if_needed()
{
if (!resize_policy::resize_needed_for_grow(m_size))
......@@ -94,13 +83,15 @@ resize_for_insert_if_needed()
return;
}
const size_type new_actual_size = resize_policy::get_new_size_for_grow();
entry_pointer a_new_entries = s_entry_allocator.allocate(new_actual_size);
const size_type new_size = resize_policy::get_new_size_for_grow();
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
resize_policy::notify_grow_resize();
std::copy(m_a_entries, m_a_entries + m_size, a_new_entries);
std::copy(m_a_entries, m_a_entries + m_size, new_entries);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_actual_size = new_actual_size;
m_a_entries = a_new_entries;
m_actual_size = new_size;
m_a_entries = new_entries;
make_heap();
}
PB_DS_CLASS_T_DEC
......@@ -112,6 +103,7 @@ modify(point_iterator it, const_reference r_new_val)
swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
fix(it.m_p_e);
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(is_heap());
}
PB_DS_CLASS_T_DEC
......@@ -123,13 +115,13 @@ fix(entry_pointer p_e)
if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i]))
{
size_type parent_i = parent(i);
while (i > 0
while (i > 0
&& entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i]))
{
{
std::swap(m_a_entries[i], m_a_entries[parent_i]);
i = parent_i;
parent_i = parent(i);
}
}
PB_DS_ASSERT_VALID((*this))
return;
......@@ -137,29 +129,30 @@ fix(entry_pointer p_e)
while (i < m_size)
{
const size_type left_child_i = left_child(i);
const size_type right_child_i = right_child(i);
_GLIBCXX_DEBUG_ASSERT(right_child_i > left_child_i);
const bool smaller_than_left_child = left_child_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child_i]);
const bool smaller_than_right_child = right_child_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child_i]);
const bool swap_with_r_child = smaller_than_right_child && (!smaller_than_left_child || entry_cmp::operator()(m_a_entries[left_child_i], m_a_entries[right_child_i]));
const bool swap_with_l_child = !swap_with_r_child && smaller_than_left_child;
if (swap_with_l_child)
{
std::swap(m_a_entries[i], m_a_entries[left_child_i]);
i = left_child_i;
}
else if (swap_with_r_child)
{
std::swap(m_a_entries[i], m_a_entries[right_child_i]);
i = right_child_i;
}
const size_type lchild_i = left_child(i);
const size_type rchild_i = right_child(i);
_GLIBCXX_DEBUG_ASSERT(rchild_i > lchild_i);
const bool smaller_than_lchild = lchild_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]);
const bool smaller_than_rchild = rchild_i < m_size &&
entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]);
const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i]));
const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild;
if (swap_with_lchild)
{
std::swap(m_a_entries[i], m_a_entries[lchild_i]);
i = lchild_i;
}
else if (swap_with_rchild)
{
std::swap(m_a_entries[i], m_a_entries[rchild_i]);
i = rchild_i;
}
else
i = m_size;
}
......@@ -169,9 +162,7 @@ PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
swap_value_imp(entry_pointer p_e, value_type new_val, true_type)
{
* p_e = new_val;
}
{ *p_e = new_val; }
PB_DS_CLASS_T_DEC
inline void
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file iterators_fn_imps.hpp
* @file binary_heap_/iterators_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -42,31 +42,23 @@ PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
begin()
{
return (iterator(m_a_entries));
}
{ return iterator(m_a_entries); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
begin() const
{
return (const_iterator(m_a_entries));
}
{ return const_iterator(m_a_entries); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
end()
{
return (iterator(m_a_entries + m_size));
}
{ return iterator(m_a_entries + m_size); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
end() const
{
return (const_iterator(m_a_entries + m_size));
}
{ return const_iterator(m_a_entries + m_size); }
......@@ -34,9 +34,9 @@
// warranty.
/**
* @file const_point_iterator.hpp
* @file binary_heap_/point_const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
* methods.
* methods.
*/
#ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
......@@ -51,11 +51,11 @@ namespace __gnu_pbds
{
// Const point-type iterator.
template<typename Value_Type, typename Entry, bool Simple,
typename Allocator>
class binary_heap_const_point_iterator_
typename _Alloc>
class binary_heap_point_const_iterator_
{
protected:
typedef typename Allocator::template rebind<Entry>::other::pointer entry_pointer;
typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
public:
// Category.
......@@ -68,35 +68,35 @@ namespace __gnu_pbds
typedef Value_Type value_type;
// Iterator's pointer type.
typedef typename Allocator::template rebind<value_type>::other::pointer
typedef typename _Alloc::template rebind<value_type>::other::pointer
pointer;
// Iterator's const pointer type.
typedef
typename Allocator::template rebind<value_type>::other::const_pointer
typename _Alloc::template rebind<value_type>::other::const_pointer
const_pointer;
// Iterator's reference type.
typedef
typename Allocator::template rebind<value_type>::other::reference
typename _Alloc::template rebind<value_type>::other::reference
reference;
// Iterator's const reference type.
typedef
typename Allocator::template rebind<value_type>::other::const_reference
typename _Alloc::template rebind<value_type>::other::const_reference
const_reference;
inline
binary_heap_const_point_iterator_(entry_pointer p_e) : m_p_e(p_e)
binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
{ }
// Default constructor.
inline
binary_heap_const_point_iterator_() : m_p_e(0) { }
binary_heap_point_const_iterator_() : m_p_e(0) { }
// Copy constructor.
inline
binary_heap_const_point_iterator_(const binary_heap_const_point_iterator_& other)
binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other)
: m_p_e(other.m_p_e)
{ }
......@@ -118,12 +118,12 @@ namespace __gnu_pbds
// Compares content to a different iterator object.
inline bool
operator==(const binary_heap_const_point_iterator_& other) const
operator==(const binary_heap_point_const_iterator_& other) const
{ return m_p_e == other.m_p_e; }
// Compares content (negatively) to a different iterator object.
inline bool
operator!=(const binary_heap_const_point_iterator_& other) const
operator!=(const binary_heap_point_const_iterator_& other) const
{ return m_p_e != other.m_p_e; }
private:
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file policy_access_fn_imps.hpp
* @file binary_heap_/policy_access_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file resize_policy.hpp
* @file binary_heap_/resize_policy.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -47,40 +47,49 @@ namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC resize_policy<Size_Type>
template<typename Size_Type>
/// Resize policy for binary heap.
template<typename _Tp>
class resize_policy
{
public:
typedef Size_Type size_type;
private:
enum
{
min_size = 16
ratio = 8,
factor = 2
};
// Next shrink size.
_Tp m_shrink_size;
// Next grow size.
_Tp m_grow_size;
public:
inline
resize_policy();
typedef _Tp size_type;
static const _Tp min_size = 16;
resize_policy() : m_shrink_size(0), m_grow_size(min_size)
{ PB_DS_ASSERT_VALID((*this)) }
resize_policy(const resize_policy& other)
: m_shrink_size(other.m_shrink_size), m_grow_size(other.m_grow_size)
{ PB_DS_ASSERT_VALID((*this)) }
inline void
swap(PB_DS_CLASS_C_DEC& other);
swap(resize_policy<_Tp>&);
inline bool
resize_needed_for_grow(size_type size) const;
resize_needed_for_grow(size_type) const;
inline bool
resize_needed_for_shrink(size_type size) const;
resize_needed_for_shrink(size_type) const;
inline bool
grow_needed(size_type size) const;
grow_needed(size_type) const;
inline bool
shrink_needed(size_type size) const;
shrink_needed(size_type) const;
inline size_type
get_new_size_for_grow() const;
......@@ -88,8 +97,8 @@ namespace __gnu_pbds
inline size_type
get_new_size_for_shrink() const;
size_type
get_new_size_for_arbitrary(size_type size) const;
inline size_type
get_new_size_for_arbitrary(size_type) const;
inline void
notify_grow_resize();
......@@ -98,83 +107,67 @@ namespace __gnu_pbds
notify_shrink_resize();
void
notify_arbitrary(size_type actual_size);
notify_arbitrary(size_type);
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
#endif
assert_valid(const char*, int) const;
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
void
trace() const;
#endif
private:
enum
{
ratio = 8,
factor = 2
};
private:
size_type m_next_shrink_size;
size_type m_next_grow_size;
#endif
};
PB_DS_CLASS_T_DEC
inline
PB_DS_CLASS_C_DEC::
resize_policy() :
m_next_shrink_size(0),
m_next_grow_size(min_size)
{ PB_DS_ASSERT_VALID((*this)) }
template<typename _Tp>
const _Tp resize_policy<_Tp>::min_size;
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline void
PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
resize_policy<_Tp>::
swap(resize_policy<_Tp>& other)
{
std::swap(m_next_shrink_size, other.m_next_shrink_size);
std::swap(m_next_grow_size, other.m_next_grow_size);
std::swap(m_shrink_size, other.m_shrink_size);
std::swap(m_grow_size, other.m_grow_size);
}
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline bool
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
resize_needed_for_grow(size_type size) const
{
_GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size);
return size == m_next_grow_size;
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
return size == m_grow_size;
}
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline bool
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
resize_needed_for_shrink(size_type size) const
{
_GLIBCXX_DEBUG_ASSERT(size <= m_next_grow_size);
return size == m_next_shrink_size;
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
return size == m_shrink_size;
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
get_new_size_for_grow() const
{ return m_next_grow_size* factor; }
{ return m_grow_size * factor; }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
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);
const size_type half_size = m_grow_size / factor;
return std::max(min_size, half_size);
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
template<typename _Tp>
inline typename resize_policy<_Tp>::size_type
resize_policy<_Tp>::
get_new_size_for_arbitrary(size_type size) const
{
size_type ret = min_size;
......@@ -183,71 +176,65 @@ namespace __gnu_pbds
return ret;
}
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline void
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
notify_grow_resize()
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size);
m_next_grow_size *= factor;
m_next_shrink_size = m_next_grow_size / ratio;
_GLIBCXX_DEBUG_ASSERT(m_grow_size >= min_size);
m_grow_size *= factor;
m_shrink_size = m_grow_size / ratio;
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline void
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
notify_shrink_resize()
{
PB_DS_ASSERT_VALID((*this))
m_next_shrink_size /= factor;
if (m_next_shrink_size == 1)
m_next_shrink_size = 0;
m_next_grow_size =
std::max(m_next_grow_size / factor, static_cast<size_type>(min_size));
m_shrink_size /= factor;
if (m_shrink_size == 1)
m_shrink_size = 0;
m_grow_size = std::max(m_grow_size / factor, min_size);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
template<typename _Tp>
inline void
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
notify_arbitrary(size_type actual_size)
{
m_next_grow_size = actual_size;
m_next_shrink_size = m_next_grow_size / ratio;
m_grow_size = actual_size;
m_shrink_size = m_grow_size / ratio;
PB_DS_ASSERT_VALID((*this))
}
#ifdef _GLIBCXX_DEBUG
PB_DS_CLASS_T_DEC
template<typename _Tp>
void
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
assert_valid(const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(m_next_shrink_size == 0 ||
m_next_shrink_size* ratio == m_next_grow_size);
PB_DS_DEBUG_VERIFY(m_next_grow_size >= min_size);
PB_DS_DEBUG_VERIFY(m_shrink_size == 0
|| m_shrink_size * ratio == m_grow_size);
PB_DS_DEBUG_VERIFY(m_grow_size >= min_size);
}
#endif
#endif
#ifdef PB_DS_BINARY_HEAP_TRACE_
PB_DS_CLASS_T_DEC
template<typename _Tp>
void
PB_DS_CLASS_C_DEC::
resize_policy<_Tp>::
trace() const
{
std::cerr << "shrink = " << m_next_shrink_size <<
" grow = " << m_next_grow_size << std::endl;
std::cerr << "shrink = " << m_shrink_size
<< " grow = " << m_grow_size << std::endl;
}
#endif
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#endif
} // namespace detail
} // namespace __gnu_pbds
#endif
#endif
......@@ -35,7 +35,7 @@
// warranty.
/**
* @file split_join_fn_imps.hpp
* @file binary_heap_/split_join_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......@@ -48,40 +48,30 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
PB_DS_ASSERT_VALID((*this))
typedef
typename entry_pred<
value_type,
Pred,
simple_value,
Allocator>::type
typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
pred_t;
const size_type left = partition(pred_t(pred));
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
const size_type ersd = m_size - left;
_GLIBCXX_DEBUG_ASSERT(m_size >= ersd);
const size_type actual_size =
resize_policy::get_new_size_for_arbitrary(left);
const size_type other_actual_size =
other.get_new_size_for_arbitrary(ersd);
const size_type new_size = resize_policy::get_new_size_for_arbitrary(left);
const size_type other_actual_size = other.get_new_size_for_arbitrary(ersd);
entry_pointer a_entries = 0;
entry_pointer a_other_entries = 0;
__try
{
a_entries = s_entry_allocator.allocate(actual_size);
a_entries = s_entry_allocator.allocate(new_size);
a_other_entries = s_entry_allocator.allocate(other_actual_size);
}
__catch(...)
{
if (a_entries != 0)
s_entry_allocator.deallocate(a_entries, actual_size);
s_entry_allocator.deallocate(a_entries, new_size);
if (a_other_entries != 0)
s_entry_allocator.deallocate(a_other_entries, other_actual_size);
......@@ -92,14 +82,14 @@ 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);
_GLIBCXX_DEBUG_ASSERT(actual_size >= left);
_GLIBCXX_DEBUG_ASSERT(new_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);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
m_actual_size = actual_size;
m_actual_size = new_size;
other.m_actual_size = other_actual_size;
m_size = left;
......@@ -108,8 +98,8 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
m_a_entries = a_entries;
other.m_a_entries = a_other_entries;
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
std::make_heap(other.m_a_entries, other.m_a_entries + other.m_size, static_cast<entry_cmp& >(other));
make_heap();
other.make_heap();
resize_policy::notify_arbitrary(m_actual_size);
other.notify_arbitrary(other.m_actual_size);
......@@ -127,20 +117,20 @@ join(PB_DS_CLASS_C_DEC& other)
PB_DS_ASSERT_VALID(other)
const size_type len = m_size + other.m_size;
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(len);
const size_type new_size = resize_policy::get_new_size_for_arbitrary(len);
entry_pointer a_entries = 0;
entry_pointer a_other_entries = 0;
__try
{
a_entries = s_entry_allocator.allocate(actual_size);
a_entries = s_entry_allocator.allocate(new_size);
a_other_entries = s_entry_allocator.allocate(resize_policy::min_size);
}
__catch(...)
{
if (a_entries != 0)
s_entry_allocator.deallocate(a_entries, actual_size);
s_entry_allocator.deallocate(a_entries, new_size);
if (a_other_entries != 0)
s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size);
......@@ -149,25 +139,23 @@ join(PB_DS_CLASS_C_DEC& other)
}
std::copy(m_a_entries, m_a_entries + m_size, a_entries);
std::copy(other.m_a_entries, other.m_a_entries + other.m_size, a_entries + m_size);
std::copy(other.m_a_entries, other.m_a_entries + other.m_size,
a_entries + m_size);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
m_a_entries = a_entries;
m_size = len;
m_actual_size = actual_size;
resize_policy::notify_arbitrary(actual_size);
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
m_actual_size = new_size;
resize_policy::notify_arbitrary(new_size);
make_heap();
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
other.m_a_entries = a_other_entries;
other.m_size = 0;
other.m_actual_size = resize_policy::min_size;
other.notify_arbitrary(resize_policy::min_size);
other.make_heap();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file trace_fn_imps.hpp
* @file binary_heap_/trace_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
......
......@@ -53,64 +53,56 @@ namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, class Cmp_Fn, class Allocator>
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#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>
binomial_heap<Value_Type, Cmp_Fn, _Alloc>
/**
* class description = "8y|\|0|\/|i41 h34p 74813">
**/
template<typename Value_Type, class Cmp_Fn, class Allocator>
class binomial_heap_ : public PB_DS_BASE_C_DEC
/// Binomial heap.
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class binomial_heap
: public binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
{
private:
typedef PB_DS_BASE_C_DEC base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::const_node_pointer const_node_pointer;
typedef binomial_heap_base<Value_Type, Cmp_Fn, _Alloc> base_type;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
public:
typedef Value_Type value_type;
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::const_point_iterator const_point_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::cmp_fn cmp_fn;
typedef typename base_type::allocator_type allocator_type;
typedef Value_Type value_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename base_type::pointer pointer;
typedef typename base_type::const_pointer const_pointer;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
typedef typename base_type::cmp_fn cmp_fn;
typedef typename base_type::allocator_type allocator_type;
binomial_heap_();
binomial_heap();
binomial_heap_(const Cmp_Fn& r_cmp_fn);
binomial_heap(const Cmp_Fn&);
binomial_heap_(const PB_DS_CLASS_C_DEC& other);
binomial_heap(const binomial_heap&);
~binomial_heap_();
~binomial_heap();
protected:
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
#endif
assert_valid(const char*, int) const;
#endif
};
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC
} // namespace detail
} // namespace __gnu_pbds
......@@ -34,28 +34,27 @@
// warranty.
/**
* @file constructors_destructor_fn_imps.hpp
* @file detail/binomial_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for binomial_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_()
binomial_heap()
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn)
binomial_heap(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other)
binomial_heap(const PB_DS_CLASS_C_DEC& other)
: base_type(other)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binomial_heap_() { }
~binomial_heap() { }
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file debug_fn_imps.hpp
* @file detail/binomial_heap_/debug_fn_imps.hpp
* Contains an implementation for binomial_heap_.
*/
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file binomial_heap_base_.hpp
* @file binomial_heap_base_/binomial_heap_base_.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -51,96 +51,65 @@
#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>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp>
namespace __gnu_pbds
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, class Cmp_Fn, class Allocator>
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
#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">
**/
template<typename Value_Type, class Cmp_Fn, class Allocator>
class binomial_heap_base_ : public PB_DS_BASE_C_DEC
{
#define PB_DS_B_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
typename _Alloc::size_type, _Alloc, false>
#else
#define PB_DS_B_HEAP_BASE \
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
typename _Alloc::size_type, _Alloc>
#endif
/// Base class for binomial heap.
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
class binomial_heap_base
: public PB_DS_B_HEAP_BASE
{
private:
typedef PB_DS_BASE_C_DEC base_type;
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_v;
typedef PB_DS_B_HEAP_BASE base_type;
protected:
typedef typename base_type::node node;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::const_node_pointer const_node_pointer;
typedef typename base_type::node node;
typedef typename base_type::node_pointer node_pointer;
typedef typename base_type::node_const_pointer node_const_pointer;
public:
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef Value_Type value_type;
typedef
typename Allocator::template rebind<
value_type>::other::pointer
pointer;
typedef
typename Allocator::template rebind<
value_type>::other::const_pointer
const_pointer;
typedef
typename Allocator::template rebind<
value_type>::other::reference
reference;
typedef
typename Allocator::template rebind<
value_type>::other::const_reference
const_reference;
typedef
typename PB_DS_BASE_C_DEC::const_point_iterator
const_point_iterator;
typedef typename PB_DS_BASE_C_DEC::point_iterator point_iterator;
typedef typename PB_DS_BASE_C_DEC::const_iterator const_iterator;
typedef typename PB_DS_BASE_C_DEC::iterator iterator;
typedef Cmp_Fn cmp_fn;
typedef Allocator allocator_type;
typedef Value_Type value_type;
typedef Cmp_Fn cmp_fn;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef typename __rebind_v::pointer pointer;
typedef typename __rebind_v::const_pointer const_pointer;
typedef typename __rebind_v::reference reference;
typedef typename __rebind_v::const_reference const_reference;
typedef typename base_type::point_const_iterator point_const_iterator;
typedef typename base_type::point_iterator point_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::iterator iterator;
public:
inline point_iterator
push(const_reference r_val);
push(const_reference);
void
modify(point_iterator it, const_reference r_new_val);
modify(point_iterator, const_reference);
inline const_reference
top() const;
......@@ -149,72 +118,72 @@ namespace __gnu_pbds
pop();
void
erase(point_iterator it);
erase(point_iterator);
inline void
clear();
template<typename Pred>
size_type
erase_if(Pred pred);
erase_if(Pred);
template<typename Pred>
void
split(Pred pred, PB_DS_CLASS_C_DEC& other);
split(Pred, PB_DS_CLASS_C_DEC&);
void
join(PB_DS_CLASS_C_DEC& other);
join(PB_DS_CLASS_C_DEC&);
protected:
binomial_heap_base_();
binomial_heap_base();
binomial_heap_base_(const Cmp_Fn& r_cmp_fn);
binomial_heap_base(const Cmp_Fn&);
binomial_heap_base_(const PB_DS_CLASS_C_DEC& other);
binomial_heap_base(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC& other);
swap(PB_DS_CLASS_C_DEC&);
~binomial_heap_base_();
~binomial_heap_base();
template<typename It>
void
copy_from_range(It first_it, It last_it);
copy_from_range(It, It);
inline void
find_max();
#ifdef _GLIBCXX_DEBUG
void
assert_valid(bool strictly_binomial, const char* file, int line) const;
assert_valid(bool, const char*, int) const;
void
assert_max(const char* file, int line) const;
#endif
assert_max(const char*, int) const;
#endif
private:
inline node_pointer
fix(node_pointer p_nd) const;
fix(node_pointer) const;
inline void
insert_node(node_pointer p_nd);
insert_node(node_pointer);
inline void
remove_parentless_node(node_pointer p_nd);
remove_parentless_node(node_pointer);
inline node_pointer
join(node_pointer p_lhs, node_pointer p_rhs) const;
join(node_pointer, node_pointer) const;
#ifdef _GLIBCXX_DEBUG
void
assert_node_consistent(const_node_pointer, bool, bool,
assert_node_consistent(node_const_pointer, bool, bool,
const char*, int) const;
#endif
protected:
node_pointer m_p_max;
node_pointer m_p_max;
};
#define PB_DS_ASSERT_VALID_COND(X, _StrictlyBinomial) \
......@@ -235,10 +204,8 @@ namespace __gnu_pbds
#undef PB_DS_ASSERT_VALID_COND
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_BASE_C_DEC
#undef PB_DS_B_HEAP_BASE
} // namespace detail
} // namespace __gnu_pbds
#endif
#endif
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file constructors_destructor_fn_imps.hpp
* @file binomial_heap_base_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -46,35 +46,27 @@ copy_from_range(It first_it, It last_it)
{
while (first_it != last_it)
push(*(first_it++));
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base_() :
m_p_max(0)
binomial_heap_base() : m_p_max(0)
{
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base_(const Cmp_Fn& r_cmp_fn) :
PB_DS_BASE_C_DEC(r_cmp_fn),
m_p_max(0)
{
PB_DS_ASSERT_VALID_COND((*this),false)
}
binomial_heap_base(const Cmp_Fn& r_cmp_fn)
: base_type(r_cmp_fn), m_p_max(0)
{ PB_DS_ASSERT_VALID_COND((*this),false) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) :
PB_DS_BASE_C_DEC(other),
m_p_max(0)
{
PB_DS_ASSERT_VALID_COND((*this),false)
}
binomial_heap_base(const PB_DS_CLASS_C_DEC& other)
: base_type(other), m_p_max(0)
{ PB_DS_ASSERT_VALID_COND((*this),false) }
PB_DS_CLASS_T_DEC
void
......@@ -82,16 +74,12 @@ PB_DS_CLASS_C_DEC::
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID_COND((*this),false)
base_type::swap(other);
std::swap(m_p_max, other.m_p_max);
PB_DS_ASSERT_VALID_COND((*this),false)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~binomial_heap_base_()
~binomial_heap_base()
{ }
......@@ -35,7 +35,7 @@
// warranty.
/**
* @file debug_fn_imps.hpp
* @file binomial_heap_base_/debug_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -68,7 +68,7 @@ assert_max(const char* __file, int __line) const
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial,
assert_node_consistent(node_const_pointer p_nd, bool strictly_binomial,
bool increasing, const char* __file, int __line) const
{
PB_DS_DEBUG_VERIFY(increasing || strictly_binomial);
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file erase_fn_imps.hpp
* @file binomial_heap_base_/erase_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -50,15 +50,10 @@ pop()
find_max();
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
node_pointer p_nd = m_p_max;
remove_parentless_node(m_p_max);
base_type::actual_erase_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
......@@ -71,8 +66,7 @@ remove_parentless_node(node_pointer p_nd)
_GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == 0);
node_pointer p_cur_root = p_nd == base_type::m_p_root?
p_nd->m_p_next_sibling :
base_type::m_p_root;
p_nd->m_p_next_sibling : base_type::m_p_root;
if (p_cur_root != 0)
p_cur_root->m_p_prev_or_parent = 0;
......@@ -84,17 +78,14 @@ remove_parentless_node(node_pointer p_nd)
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
node_pointer p_child = p_nd->m_p_l_child;
if (p_child != 0)
{
p_child->m_p_prev_or_parent = 0;
while (p_child->m_p_next_sibling != 0)
p_child = p_child->m_p_next_sibling;
}
m_p_max = 0;
base_type::m_p_root = join(p_cur_root, p_child);
}
......@@ -104,7 +95,6 @@ PB_DS_CLASS_C_DEC::
clear()
{
base_type::clear();
m_p_max = 0;
}
......@@ -117,13 +107,9 @@ erase(point_iterator it)
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
base_type::bubble_to_top(it.m_p_nd);
remove_parentless_node(it.m_p_nd);
base_type::actual_erase_node(it.m_p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
......@@ -138,55 +124,38 @@ erase_if(Pred pred)
if (base_type::empty())
{
PB_DS_ASSERT_VALID_COND((*this),true)
return 0;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
size_type ersd = 0;
while (p_out != 0)
{
++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 = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
p_cur->m_metadata = 0;
p_cur->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = p_cur;
base_type::m_p_root = p_cur;
base_type::m_p_root = fix(base_type::m_p_root);
p_cur = p_next;
}
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return ersd;
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file find_fn_imps.hpp
* @file binomial_heap_base_/find_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -59,14 +59,11 @@ PB_DS_CLASS_C_DEC::
find_max()
{
node_pointer p_cur = base_type::m_p_root;
m_p_max = p_cur;
while (p_cur != 0)
{
if (Cmp_Fn::operator()(m_p_max->m_value, p_cur->m_value))
m_p_max = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
}
......
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file insert_fn_imps.hpp
* @file binomial_heap_base_/insert_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -44,15 +44,10 @@ PB_DS_CLASS_C_DEC::
push(const_reference r_val)
{
PB_DS_ASSERT_VALID_COND((*this),true)
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
insert_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return point_iterator(p_nd);
}
......@@ -63,60 +58,42 @@ insert_node(node_pointer p_nd)
{
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent =
p_nd->m_p_l_child = 0;
p_nd->m_p_next_sibling = 0;
p_nd->m_p_prev_or_parent = 0;
p_nd->m_p_l_child = 0;
p_nd->m_metadata = 0;
base_type::m_p_root = p_nd;
return;
}
if (base_type::m_p_root->m_metadata > 0)
{
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
p_nd->m_p_next_sibling = base_type::m_p_root;
base_type::m_p_root->m_p_prev_or_parent = p_nd;
base_type::m_p_root = p_nd;
p_nd->m_metadata = 0;
return;
}
if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
{
p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling;
p_nd->m_p_prev_or_parent = 0;
p_nd->m_metadata = 1;
p_nd->m_p_l_child = base_type::m_p_root;
base_type::m_p_root->m_p_prev_or_parent = p_nd;
base_type::m_p_root->m_p_next_sibling = 0;
base_type::m_p_root = p_nd;
}
else
{
p_nd->m_p_next_sibling = 0;
p_nd->m_p_l_child = 0;
p_nd->m_p_prev_or_parent = base_type::m_p_root;
p_nd->m_metadata = 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;
}
......@@ -128,36 +105,31 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
fix(node_pointer p_nd) const
{
while (p_nd->m_p_next_sibling != 0&&
while (p_nd->m_p_next_sibling != 0 &&
p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata)
{
node_pointer p_next = p_nd->m_p_next_sibling;
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;
{
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
if (p_nd->m_p_prev_or_parent != 0)
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next;
base_type::make_child_of(p_nd, p_next);
++p_next->m_metadata;
p_nd = p_next;
}
}
else
{
{
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
if (p_nd->m_p_next_sibling != 0)
p_next->m_p_next_sibling = 0;
base_type::make_child_of(p_next, p_nd);
++p_nd->m_metadata;
}
}
}
if (p_nd->m_p_next_sibling != 0)
......@@ -178,39 +150,29 @@ modify(point_iterator it, const_reference r_new_val)
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
p_nd->m_value = r_new_val;
if (bubble_up)
{
node_pointer p_parent = base_type::parent(p_nd);
while (p_parent != 0&&
while (p_parent != 0 &&
Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value))
{
{
base_type::swap_with_parent(p_nd, p_parent);
p_parent = base_type::parent(p_nd);
}
}
if (p_nd->m_p_prev_or_parent == 0)
base_type::m_p_root = p_nd;
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
return;
return;
}
base_type::bubble_to_top(p_nd);
remove_parentless_node(p_nd);
insert_node(p_nd);
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
}
......@@ -34,7 +34,7 @@
// warranty.
/**
* @file split_join_fn_imps.hpp
* @file binomial_heap_base_/split_join_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
......@@ -48,72 +48,54 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
PB_DS_ASSERT_VALID_COND(other,true)
other.clear();
if (base_type::empty())
{
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
return;
}
base_type::to_linked_list();
node_pointer p_out = base_type::prune(pred);
while (p_out != 0)
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
--base_type::m_size;
++other.m_size;
node_pointer p_next = p_out->m_p_next_sibling;
p_out->m_p_l_child = p_out->m_p_prev_or_parent = 0;
p_out->m_metadata = 0;
p_out->m_p_next_sibling = other.m_p_root;
if (other.m_p_root != 0)
other.m_p_root->m_p_prev_or_parent = p_out;
other.m_p_root = p_out;
other.m_p_root = other.fix(other.m_p_root);
p_out = p_next;
}
PB_DS_ASSERT_VALID_COND(other,true)
node_pointer p_cur = base_type::m_p_root;
base_type::m_p_root = 0;
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
p_cur->m_metadata = 0;
p_cur->m_p_next_sibling = base_type::m_p_root;
if (base_type::m_p_root != 0)
base_type::m_p_root->m_p_prev_or_parent = p_cur;
base_type::m_p_root = p_cur;
base_type::m_p_root = fix(base_type::m_p_root);
p_cur = p_next;
}
m_p_max = 0;
PB_DS_ASSERT_VALID_COND((*this),true)
PB_DS_ASSERT_VALID_COND(other,true)
}
......@@ -127,14 +109,11 @@ join(PB_DS_CLASS_C_DEC& other)
PB_DS_ASSERT_VALID_COND(other,true)
node_pointer p_other = other.m_p_root;
if (p_other != 0)
do
{
node_pointer p_next = p_other->m_p_next_sibling;
std::swap(p_other->m_p_next_sibling, p_other->m_p_prev_or_parent);
p_other = p_next;
}
while (p_other != 0);
......@@ -157,68 +136,55 @@ PB_DS_CLASS_C_DEC::
join(node_pointer p_lhs, node_pointer p_rhs) const
{
node_pointer p_ret = 0;
node_pointer p_cur = 0;
while (p_lhs != 0 || p_rhs != 0)
{
if (p_rhs == 0)
{
{
if (p_cur == 0)
p_ret = p_cur = p_lhs;
else
{
{
p_cur->m_p_next_sibling = p_lhs;
p_lhs->m_p_prev_or_parent = p_cur;
}
}
p_cur = p_lhs = 0;
}
}
else if (p_lhs == 0 || p_rhs->m_metadata < p_lhs->m_metadata)
{
{
if (p_cur == 0)
{
{
p_ret = p_cur = p_rhs;
p_rhs = p_rhs->m_p_prev_or_parent;
}
}
else
{
{
p_cur->m_p_next_sibling = p_rhs;
p_rhs = p_rhs->m_p_prev_or_parent;
p_cur->m_p_next_sibling->m_p_prev_or_parent = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
}
}
}
else if (p_lhs->m_metadata < p_rhs->m_metadata)
{
{
if (p_cur == 0)
p_ret = p_cur = p_lhs;
else
{
{
p_cur->m_p_next_sibling = p_lhs;
p_lhs->m_p_prev_or_parent = p_cur;
p_cur = p_cur->m_p_next_sibling;
}
}
p_lhs = p_cur->m_p_next_sibling;
}
}
else
{
{
node_pointer p_next_rhs = p_rhs->m_p_prev_or_parent;
p_rhs->m_p_next_sibling = p_lhs;
p_lhs = fix(p_rhs);
p_rhs = p_next_rhs;
}
}
}
if (p_cur != 0)
......@@ -229,4 +195,3 @@ join(node_pointer p_lhs, node_pointer p_rhs) const
return p_ret;
}
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file branch_policy/branch_policy.hpp
* Contains a base class for branch policies.
*/
#ifndef PB_DS_BRANCH_POLICY_BASE_HPP
#define PB_DS_BRANCH_POLICY_BASE_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
namespace __gnu_pbds
{
/// A null node updator, indicating that no node updates are required.
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
struct null_node_update : public null_type
{ };
namespace detail
{
/// Primary template, base class for branch structure policies.
template<typename Node_CItr, typename Node_Itr, typename _Alloc>
struct branch_policy
{
protected:
typedef typename Node_Itr::value_type it_type;
typedef typename std::iterator_traits<it_type>::value_type value_type;
typedef typename value_type::first_type key_type;
typedef typename remove_const<value_type>::type rcvalue_type;
typedef typename remove_const<key_type>::type rckey_type;
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
typedef typename _Alloc::template rebind<rckey_type>::other rebind_k;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename rebind_v::const_pointer const_pointer;
typedef typename rebind_k::const_reference key_const_reference;
static inline key_const_reference
extract_key(const_reference r_val)
{ return r_val.first; }
virtual it_type
end() = 0;
it_type
end_iterator() const
{ return const_cast<branch_policy*>(this)->end(); }
virtual
~branch_policy() { }
};
/// Specialization for const iterators.
template<typename Node_CItr, typename _Alloc>
struct branch_policy<Node_CItr, Node_CItr, _Alloc>
{
protected:
typedef typename Node_CItr::value_type it_type;
typedef typename std::iterator_traits<it_type>::value_type value_type;
typedef typename remove_const<value_type>::type rcvalue_type;
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename rebind_v::const_pointer const_pointer;
typedef value_type key_type;
typedef typename rebind_v::const_reference key_const_reference;
static inline key_const_reference
extract_key(const_reference r_val)
{ return r_val; }
virtual it_type
end() const = 0;
it_type
end_iterator() const
{ return end(); }
virtual
~branch_policy() { }
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_BRANCH_POLICY_BASE_HPP
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -34,22 +34,33 @@
// warranty.
/**
* @file null_metadata.hpp
* Contains an implementation struct for this type of heap's node.
* @file branch_policy/null_node_metadata.hpp
* Contains an implementation class for tree-like classes.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
#ifndef PB_DS_0_NODE_METADATA_HPP
#define PB_DS_0_NODE_METADATA_HPP
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
struct null_left_child_next_sibling_heap_node_metadata
{ };
/// Constant node iterator.
template<typename Key, typename Data, typename _Alloc>
struct dumnode_const_iterator
{
private:
typedef types_traits<Key, Data, _Alloc, false> __traits_type;
typedef typename __traits_type::pointer const_iterator;
public:
typedef const_iterator value_type;
typedef const_iterator const_reference;
typedef const_reference reference;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
#endif
// -*- C++ -*-
// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.
/**
* @file branch_policy/traits.hpp
* Contains an implementation class for tree-like classes.
*/
#ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
#define PB_DS_NODE_AND_IT_TRAITS_HPP
#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/bin_search_tree_/traits.hpp>
#include <ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp>
#include <ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp>
#define PB_DS_DEBUG_VERIFY(_Cond) \
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
_M_message(#_Cond" assertion from %1;:%2;") \
._M_string(__FILE__)._M_integer(__LINE__) \
,__file,__line)
namespace __gnu_pbds
{
namespace detail
{
/// Tree traits class, primary template.
template<typename Key,
typename Data,
typename Cmp_Fn,
template<typename Node_CItr,
typename Node_Itr,
typename Cmp_Fn_,
typename _Alloc>
class Node_Update,
typename Tag,
typename _Alloc>
struct tree_traits;
/// Trie traits class, primary template.
template<typename Key,
typename Data,
typename _ATraits,
template<typename Node_CItr,
typename Node_Itr,
typename _ATraits_,
typename _Alloc>
class Node_Update,
typename Tag,
typename _Alloc>
struct trie_traits;
} // namespace detail
} // namespace __gnu_pbds
#include <ext/pb_ds/detail/rb_tree_map_/traits.hpp>
#include <ext/pb_ds/detail/splay_tree_/traits.hpp>
#include <ext/pb_ds/detail/ov_tree_map_/traits.hpp>
#include <ext/pb_ds/detail/pat_trie_/traits.hpp>
#undef PB_DS_DEBUG_VERIFY
#endif // #ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment