+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.
+
2011-05-23 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/streambuf_iterator.h: Use noexcept per the FDIS.
# 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
# XML
xmldir = "$(DESTDIR)@docdir@"
+copydir = ${docbook_outdir}/html/manual/ext/
# EPUB
# Assumes ruby installed
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
-# Doxyfile 1.7.2
+# Doxyfile 1.7.4
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
PROJECT_NUMBER =
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO =
+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
OUTPUT_LANGUAGE = English
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
-ALIASES = doctodo="@todo\nNeeds documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_style.html"
-
-ALIASES += headername{1}="Instead, include <\1>."
-ALIASES += headername{2}="Instead, include <\1> or <\2>."
+ALIASES = "doctodo=@todo\nNeeds documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_style.html" \
+ "headername{1}=Instead, include <\1>." \
+ "headername{2}=Instead, include <\1> or <\2>."
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C.
SUBGROUPING = YES
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
# is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
+# causing a significant performance penalty.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will roughly double the
SORT_BY_SCOPE_NAME = YES
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
# with spaces.
INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
- @srcdir@/libsupc++/cxxabi.h \
- @srcdir@/libsupc++/exception \
- @srcdir@/libsupc++/initializer_list \
- @srcdir@/libsupc++/new \
- @srcdir@/libsupc++/typeinfo \
- include/algorithm \
- include/array \
- include/atomic \
- include/bitset \
- include/chrono \
- include/complex \
- include/condition_variable \
- include/deque \
- include/forward_list \
- include/fstream \
- include/functional \
- include/future \
- include/iomanip \
- include/ios \
- include/iosfwd \
- include/iostream \
- include/istream \
- include/iterator \
- include/limits \
- include/list \
- include/locale \
- include/map \
- include/memory \
- include/mutex \
- include/numeric \
- include/ostream \
- include/queue \
- include/random \
- include/ratio \
- include/regex \
- include/set \
- include/sstream \
- include/stack \
- include/stdexcept \
- include/streambuf \
- include/string \
- include/system_error \
- include/thread \
- include/tuple \
- include/typeindex \
- include/type_traits \
- include/unordered_map \
- include/unordered_set \
- include/utility \
- include/valarray \
- include/vector \
- include/cassert \
- include/ccomplex \
- include/cctype \
- include/cerrno \
- include/cfenv \
- include/cfloat \
- include/cinttypes \
- include/ciso646 \
- include/climits \
- include/clocale \
- include/cmath \
- include/csetjmp \
- include/csignal \
- include/cstdarg \
- include/cstdbool \
- include/cstddef \
- include/cstdint \
- include/cstdio \
- include/cstdlib \
- include/cstring \
- include/ctgmath \
- include/ctime \
- include/cwchar \
- include/cwctype \
- include/backward/hash_map \
- include/backward/hash_set \
- include/backward/strstream \
- include/debug/bitset \
- include/debug/deque \
- include/debug/forward_list \
- include/debug/list \
- include/debug/map \
- include/debug/set \
- include/debug/string \
- include/debug/unordered_map \
- include/debug/unordered_set \
- include/debug/vector \
- include/profile/bitset \
- include/profile/deque \
- include/profile/forward_list \
- include/profile/list \
- include/profile/map \
- include/profile/set \
- include/profile/unordered_map \
- include/profile/unordered_set \
- include/profile/vector \
- include/ext/algorithm \
- include/ext/functional \
- include/ext/iterator \
- include/ext/memory \
- include/ext/numeric \
- include/ext/rb_tree \
- include/ext/rope \
- include/ext/slist \
- include/parallel/algorithm \
- include/parallel/numeric \
- include/tr1/ccomplex \
- include/tr1/cctype \
- include/tr1/cfenv \
- include/tr1/cfloat \
- include/tr1/cinttypes \
- include/tr1/climits \
- include/tr1/cmath \
- include/tr1/complex \
- include/tr1/cstdarg \
- include/tr1/cstdbool \
- include/tr1/cstdint \
- include/tr1/cstdio \
- include/tr1/cstdlib \
- include/tr1/ctgmath \
- include/tr1/ctime \
- include/tr1/cwchar \
- include/tr1/cwctype \
- include/decimal/decimal \
- include/ \
- include/@host_alias@/bits \
- include/backward \
- include/bits \
- include/debug \
- include/parallel \
- include/profile \
- include/profile/impl \
- include/ext \
- include/ext/pb_ds \
- include/ext/pb_ds/detail
+ @srcdir@/libsupc++/cxxabi.h \
+ @srcdir@/libsupc++/exception \
+ @srcdir@/libsupc++/initializer_list \
+ @srcdir@/libsupc++/new \
+ @srcdir@/libsupc++/typeinfo \
+ include/algorithm \
+ include/array \
+ include/atomic \
+ include/bitset \
+ include/chrono \
+ include/complex \
+ include/condition_variable \
+ include/deque \
+ include/forward_list \
+ include/fstream \
+ include/functional \
+ include/future \
+ include/iomanip \
+ include/ios \
+ include/iosfwd \
+ include/iostream \
+ include/istream \
+ include/iterator \
+ include/limits \
+ include/list \
+ include/locale \
+ include/map \
+ include/memory \
+ include/mutex \
+ include/numeric \
+ include/ostream \
+ include/queue \
+ include/random \
+ include/ratio \
+ include/regex \
+ include/set \
+ include/sstream \
+ include/stack \
+ include/stdexcept \
+ include/streambuf \
+ include/string \
+ include/system_error \
+ include/thread \
+ include/tuple \
+ include/typeindex \
+ include/type_traits \
+ include/unordered_map \
+ include/unordered_set \
+ include/utility \
+ include/valarray \
+ include/vector \
+ include/cassert \
+ include/ccomplex \
+ include/cctype \
+ include/cerrno \
+ include/cfenv \
+ include/cfloat \
+ include/cinttypes \
+ include/ciso646 \
+ include/climits \
+ include/clocale \
+ include/cmath \
+ include/csetjmp \
+ include/csignal \
+ include/cstdarg \
+ include/cstdbool \
+ include/cstddef \
+ include/cstdint \
+ include/cstdio \
+ include/cstdlib \
+ include/cstring \
+ include/ctgmath \
+ include/ctime \
+ include/cwchar \
+ include/cwctype \
+ include/ \
+ include/bits \
+ include/@host_alias@/bits \
+ include/backward \
+ include/backward/hash_map \
+ include/backward/hash_set \
+ include/backward/strstream \
+ include/debug \
+ include/debug/bitset \
+ include/debug/deque \
+ include/debug/forward_list \
+ include/debug/list \
+ include/debug/map \
+ include/debug/set \
+ include/debug/string \
+ include/debug/unordered_map \
+ include/debug/unordered_set \
+ include/debug/vector \
+ include/profile \
+ include/profile/impl \
+ include/profile/bitset \
+ include/profile/deque \
+ include/profile/forward_list \
+ include/profile/list \
+ include/profile/map \
+ include/profile/set \
+ include/profile/unordered_map \
+ include/profile/unordered_set \
+ include/profile/vector \
+ include/ext/algorithm \
+ include/ext/functional \
+ include/ext/iterator \
+ include/ext/memory \
+ include/ext/numeric \
+ include/ext/rb_tree \
+ include/ext/rope \
+ include/ext/slist \
+ include/parallel \
+ include/parallel/algorithm \
+ include/parallel/numeric \
+ include/tr1/ccomplex \
+ include/tr1/cctype \
+ include/tr1/cfenv \
+ include/tr1/cfloat \
+ include/tr1/cinttypes \
+ include/tr1/climits \
+ include/tr1/cmath \
+ include/tr1/complex \
+ include/tr1/cstdarg \
+ include/tr1/cstdbool \
+ include/tr1/cstdint \
+ include/tr1/cstdio \
+ include/tr1/cstdlib \
+ include/tr1/ctgmath \
+ include/tr1/ctime \
+ include/tr1/cwchar \
+ include/tr1/cwctype \
+ include/decimal/decimal \
+ include/ext \
+ include/ext/pb_ds \
+ include/ext/pb_ds/detail \
+ include/ext/pb_ds/detail/binary_heap_ \
+ include/ext/pb_ds/detail/binomial_heap_ \
+ include/ext/pb_ds/detail/binomial_heap_base_ \
+ include/ext/pb_ds/detail/bin_search_tree_ \
+ include/ext/pb_ds/detail/branch_policy \
+ include/ext/pb_ds/detail/cc_hash_table_map_ \
+ include/ext/pb_ds/detail/eq_fn \
+ include/ext/pb_ds/detail/gp_hash_table_map_ \
+ include/ext/pb_ds/detail/hash_fn \
+ include/ext/pb_ds/detail/left_child_next_sibling_heap_ \
+ include/ext/pb_ds/detail/list_update_map_ \
+ include/ext/pb_ds/detail/list_update_policy \
+ include/ext/pb_ds/detail/ov_tree_map_ \
+ include/ext/pb_ds/detail/pairing_heap_ \
+ include/ext/pb_ds/detail/pat_trie_ \
+ include/ext/pb_ds/detail/rb_tree_map_ \
+ include/ext/pb_ds/detail/rc_binomial_heap_ \
+ include/ext/pb_ds/detail/resize_policy \
+ include/ext/pb_ds/detail/splay_tree_ \
+ include/ext/pb_ds/detail/thin_heap_ \
+ include/ext/pb_ds/detail/tree_policy \
+ include/ext/pb_ds/detail/trie_policy \
+ include/ext/pb_ds/detail/unordered_iterator
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
-# *.f90 *.f *.vhd *.vhdl
+# *.f90 *.f *.for *.vhd *.vhdl
FILE_PATTERNS = *.h \
- *.hpp \
- *.tcc
+ *.hpp \
+ *.tcc
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
EXCLUDE = Makefile
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
+# directories that are symbolic links (a Unix file system feature) are excluded
# from the input.
EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
-EXCLUDE_PATTERNS = stamp-* doxygroups.cc \
- *.gch \
- */.svn/*
+EXCLUDE_PATTERNS = stamp-* \
+ doxygroups.cc \
+ *.gch \
+ */.svn/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# filter if there is a match.
# The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is adviced to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW!
HTML_HEADER =
HTML_STYLESHEET =
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
# Doxygen will adjust the colors in the stylesheet and background images
# according to this color. Hue is specified as an angle on a colorwheel,
DISABLE_INDEX = YES
-# This tag can be used to set the number of enum values (range [0,1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-# Note that a value of 0 will completely suppress the enum values from appearing in the overview section.
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
ENUM_VALUES_PER_LINE = 4
# HTML output directory using the MATHJAX_RELPATH option. The destination
# directory should contain the MathJax.js script. For instance, if the mathjax
# directory is located at the same level as the HTML output directory, then
-# MATHJAX_RELPATH should be ../mathjax. The default value points to the mathjax.org site, so you can quickly see the result without installing
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the
+# mathjax.org site, so you can quickly see the result without installing
# MathJax, but it is strongly recommended to install a local copy of MathJax
# before deployment.
LATEX_HEADER =
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
SEARCH_INCLUDES = YES
# contain include files that are not input files but should be processed by
# the preprocessor.
-INCLUDE_PATH =
+INCLUDE_PATH = include
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# instead of the = operator.
PREDEFINED = __cplusplus \
- __GTHREADS \
- _GLIBCXX_HAS_GTHREADS \
- __GXX_EXPERIMENTAL_CXX0X__ \
- _GLIBCXX_INCLUDE_AS_CXX0X \
- "_GLIBCXX_PURE= " \
- "_GLIBCXX_CONST= " \
- "_GLIBCXX_NORETURN= " \
- "_GLIBCXX_NOTHROW= " \
- "_GLIBCXX_STD_C= " \
- "_GLIBCXX_STD_A= " \
+ __GTHREADS \
+ _GLIBCXX_HAS_GTHREADS \
+ __GXX_EXPERIMENTAL_CXX0X__ \
+ _GLIBCXX_INCLUDE_AS_CXX0X \
+ "_GLIBCXX_PURE= " \
+ "_GLIBCXX_CONST= " \
+ "_GLIBCXX_NORETURN= " \
+ "_GLIBCXX_NOTHROW= " \
+ "_GLIBCXX_STD_C= " \
+ "_GLIBCXX_STD_A= " \
"_GLIBCXX_VISIBILITY(V)= " \
- "_GLIBCXX_BEGIN_NAMESPACE_VERSION= " \
- "_GLIBCXX_BEGIN_NAMESPACE_ALGO= " \
- "_GLIBCXX_BEGIN_NAMESPACE_CONTAINER= " \
- "_GLIBCXX_BEGIN_NAMESPACE_LDBL= " \
- "_GLIBCXX_END_NAMESPACE_VERSION= " \
- "_GLIBCXX_END_NAMESPACE_ALGO= " \
- "_GLIBCXX_END_NAMESPACE_CONTAINER= " \
- "_GLIBCXX_END_NAMESPACE_LDBL= " \
- "_GLIBCXX_TEMPLATE_ARGS=... " \
- _GLIBCXX_DEPRECATED \
- _GLIBCXX_CONSTEXPR=constexpr \
- _GLIBCXX_USE_CONSTEXPR=constexpr \
- _GLIBCXX_USE_WCHAR_T \
- _GLIBCXX_USE_LONG_LONG \
- _GLIBCXX_USE_C99_STDINT_TR1 \
- _GLIBCXX_ATOMIC_BUILTINS_1 \
- _GLIBCXX_ATOMIC_BUILTINS_2 \
- _GLIBCXX_ATOMIC_BUILTINS_4 \
- _GLIBCXX_ATOMIC_BUILTINS_8 \
- _GLIBCXX_USE_SCHED_YIELD \
- _GLIBCXX_USE_NANOSLEEP \
- __GXX_RTTI \
- __glibcxx_function_requires=// \
- __glibcxx_class_requires=// \
- __glibcxx_class_requires2=// \
- __glibcxx_class_requires3=// \
- __glibcxx_class_requires4=//
+ "_GLIBCXX_BEGIN_NAMESPACE_VERSION= " \
+ "_GLIBCXX_BEGIN_NAMESPACE_ALGO= " \
+ "_GLIBCXX_BEGIN_NAMESPACE_CONTAINER= " \
+ "_GLIBCXX_BEGIN_NAMESPACE_LDBL= " \
+ "_GLIBCXX_END_NAMESPACE_VERSION= " \
+ "_GLIBCXX_END_NAMESPACE_ALGO= " \
+ "_GLIBCXX_END_NAMESPACE_CONTAINER= " \
+ "_GLIBCXX_END_NAMESPACE_LDBL= " \
+ "_GLIBCXX_TEMPLATE_ARGS=... " \
+ _GLIBCXX_DEPRECATED \
+ _GLIBCXX_CONSTEXPR=constexpr \
+ _GLIBCXX_USE_CONSTEXPR=constexpr \
+ _GLIBCXX_USE_WCHAR_T \
+ _GLIBCXX_USE_LONG_LONG \
+ _GLIBCXX_USE_C99_STDINT_TR1 \
+ _GLIBCXX_ATOMIC_BUILTINS_1 \
+ _GLIBCXX_ATOMIC_BUILTINS_2 \
+ _GLIBCXX_ATOMIC_BUILTINS_4 \
+ _GLIBCXX_ATOMIC_BUILTINS_8 \
+ _GLIBCXX_USE_SCHED_YIELD \
+ _GLIBCXX_USE_NANOSLEEP \
+ PB_DS_DATA_TRUE_INDICATOR \
+ __EXCEPTIONS \
+ __GXX_RTTI \
+ __glibcxx_function_requires=// \
+ __glibcxx_class_requires=// \
+ __glibcxx_class_requires2=// \
+ __glibcxx_class_requires3=// \
+ __glibcxx_class_requires4=//
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
SKIP_FUNCTION_MACROS = YES
DOT_NUM_THREADS = 0
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# By default doxygen will write a font called Helvetica to the output
+# directory and reference it in all dot files that doxygen generates.
+# When you want a differently looking font you can specify the font name
+# using DOT_FONTNAME. You need to make sure dot is able to find the font,
# which can be done by putting it in a standard location or by setting the
# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
# containing the font.
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif.
+# generated by dot. Possible values are svg, png, jpg, or gif.
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta name="generator" content=
+ "HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
+
+ <title>sample_trie_e_access_traits Interface</title>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii" />
+ </head>
+
+<body>
+ <div id="page">
+ <h1><tt>sample_trie_e_access_traits</tt> Interface</h1>
+
+ <p>A sample trie element-access traits.</p>
+
+ <p>This class serves to show the interface an element- access
+ traits class needs to support.</p>
+
+ <p>Defined in: <a href=
+ "http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/include/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp">
+ <tt>sample_trie_e_access_traits.hpp</tt></a></p>
+
+ <h2><a name="link1" id="link1">Public Types and
+ Constants</a></h2>
+
+ <h3><a name="link2" id="link2">General definitions.</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Types">
+ <tr>
+ <td width="30%" align="left"><b>Type</b></td>
+
+ <td width="55%" align="left"><b>Definition</b></td>
+
+ <td width="15%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="size_type55424436" id="size_type55424436">size_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+size_t, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Size type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="key_type10393186" id="key_type10393186">key_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+std::string, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Key type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="const_key_reference3185471705" id=
+"const_key_reference3185471705">const_key_reference</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+const string &, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Const key reference type.</p>
+ </td>
+ </tr>
+ </table>
+
+ <h3><a name="link3" id="link3">Element definitions.</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Types">
+ <tr>
+ <td width="30%" align="left"><b>Type</b></td>
+
+ <td width="55%" align="left"><b>Definition</b></td>
+
+ <td width="15%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="const_iterator98626788" id=
+"const_iterator98626788">const_iterator</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+string::const_iterator, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Element <tt><b>const</b></tt> iterator type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="e_type393186" id="e_type393186">e_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+char, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Element type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="max_size10483336" id="max_size10483336">max_size</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+4, e.g.
+</pre>
+ </td>
+
+ <td>
+ <p>Number of distinct elements.</p>
+ </td>
+ </tr>
+ </table>
+
+ <h2><a name="link4" id="link4">Public Methods</a></h2>
+
+ <h3><a name="link5" id="link5">Access methods.</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Methods">
+ <tr>
+ <td width="45%" align="left"><b>Method</b></td>
+
+ <td width="55%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#const_iterator98626788"><tt>const_iterator</tt></a>
+ begin
+ (<a href=
+"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
+</pre>
+ </td>
+
+ <td>
+ <p>Returns a <a href=
+ "#const_iterator98626788"><tt>const_iterator</tt></a> to
+ the first element of <span class=
+ "c1"><tt>r_key</tt></span>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#const_iterator98626788"><tt>const_iterator</tt></a>
+ end
+ (<a href=
+"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
+</pre>
+ </td>
+
+ <td>
+ <p>Returns a <a href=
+ "#const_iterator98626788"><tt>const_iterator</tt></a> to
+ the after-last element of <span class=
+ "c1"><tt>r_key</tt></span>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#size_type55424436"><tt>size_type</tt></a>
+ e_pos
+ (<a href="#e_type393186"><tt>e_type</tt></a> e)
+</pre>
+ </td>
+
+ <td>
+ <p>Maps an <span class="c1"><tt>element</tt></span> to a
+ position.</p>
+ </td>
+ </tr>
+ </table>
+ </div>
+</body>
+</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <meta name="generator" content=
- "HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
-
- <title>sample_trie_e_access_traits Interface</title>
- <meta http-equiv="Content-Type" content=
- "text/html; charset=us-ascii" />
- </head>
-
-<body>
- <div id="page">
- <h1><tt>sample_trie_e_access_traits</tt> Interface</h1>
-
- <p>A sample trie element-access traits.</p>
-
- <p>This class serves to show the interface an element- access
- traits class needs to support.</p>
-
- <p>Defined in: <a href=
- "http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/include/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp">
- <tt>sample_trie_e_access_traits.hpp</tt></a></p>
-
- <h2><a name="link1" id="link1">Public Types and
- Constants</a></h2>
-
- <h3><a name="link2" id="link2">General definitions.</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Types">
- <tr>
- <td width="30%" align="left"><b>Type</b></td>
-
- <td width="55%" align="left"><b>Definition</b></td>
-
- <td width="15%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="size_type55424436" id="size_type55424436">size_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-size_t, e.g.
-</pre>
- </td>
-
- <td>
- <p>Size type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="key_type10393186" id="key_type10393186">key_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-std::string, e.g.
-</pre>
- </td>
-
- <td>
- <p>Key type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="const_key_reference3185471705" id=
-"const_key_reference3185471705">const_key_reference</a>
-</pre>
- </td>
-
- <td>
- <pre>
-const string &, e.g.
-</pre>
- </td>
-
- <td>
- <p>Const key reference type.</p>
- </td>
- </tr>
- </table>
-
- <h3><a name="link3" id="link3">Element definitions.</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Types">
- <tr>
- <td width="30%" align="left"><b>Type</b></td>
-
- <td width="55%" align="left"><b>Definition</b></td>
-
- <td width="15%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="const_iterator98626788" id=
-"const_iterator98626788">const_iterator</a>
-</pre>
- </td>
-
- <td>
- <pre>
-string::const_iterator, e.g.
-</pre>
- </td>
-
- <td>
- <p>Element <tt><b>const</b></tt> iterator type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="e_type393186" id="e_type393186">e_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-char, e.g.
-</pre>
- </td>
-
- <td>
- <p>Element type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="max_size10483336" id="max_size10483336">max_size</a>
-</pre>
- </td>
-
- <td>
- <pre>
-4, e.g.
-</pre>
- </td>
-
- <td>
- <p>Number of distinct elements.</p>
- </td>
- </tr>
- </table>
-
- <h2><a name="link4" id="link4">Public Methods</a></h2>
-
- <h3><a name="link5" id="link5">Access methods.</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Methods">
- <tr>
- <td width="45%" align="left"><b>Method</b></td>
-
- <td width="55%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#const_iterator98626788"><tt>const_iterator</tt></a>
- begin
- (<a href=
-"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
-</pre>
- </td>
-
- <td>
- <p>Returns a <a href=
- "#const_iterator98626788"><tt>const_iterator</tt></a> to
- the first element of <span class=
- "c1"><tt>r_key</tt></span>.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#const_iterator98626788"><tt>const_iterator</tt></a>
- end
- (<a href=
-"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
-</pre>
- </td>
-
- <td>
- <p>Returns a <a href=
- "#const_iterator98626788"><tt>const_iterator</tt></a> to
- the after-last element of <span class=
- "c1"><tt>r_key</tt></span>.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#size_type55424436"><tt>size_type</tt></a>
- e_pos
- (<a href="#e_type393186"><tt>e_type</tt></a> e)
-</pre>
- </td>
-
- <td>
- <p>Maps an <span class="c1"><tt>element</tt></span> to a
- position.</p>
- </td>
- </tr>
- </table>
- </div>
-</body>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <meta name="generator" content=
- "HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
-
- <title>string_trie_e_access_traits Interface</title>
- <meta http-equiv="Content-Type" content=
- "text/html; charset=us-ascii" />
- </head>
-
-<body>
- <div id="page">
- <h1><tt>string_trie_e_access_traits</tt> Interface</h1>
-
- <p>Element access traits for string types.</p>
-
- <p>Defined in: <a href=
- "http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/include/ext/pb_ds/trie_policy.hpp"><tt>trie_policy.hpp</tt></a></p>
-
- <h2><a name="link1" id="link1">Template Parameters</a></h2>
-
- <table class="c1" width="100%" border="1" summary=
- "Template Parameters">
- <tr>
- <td width="20%" align="left"><b>Parameter</b></td>
-
- <td width="50%" align="left"><b>Description</b></td>
-
- <td width="30%" align="left"><b>Default Value</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="String349403" id="String349403"><b>class</b> String </a>
-</pre>
- </td>
-
- <td>
- <p>String type.</p>
- </td>
-
- <td><tt>std::string</tt></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="Min_E_Val40354618" id=
-"Min_E_Val40354618"><b>typename</b> </a><a href=
-"#String349403"><tt>String</tt></a>::value_type Min_E_Val
-</pre>
- </td>
-
- <td>
- <p>Minimal element.</p>
- </td>
-
- <td><tt>SCHAR_MIN</tt></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="Max_E_Val39885868" id=
-"Max_E_Val39885868"><b>typename</b> </a><a href=
-"#String349403"><tt>String</tt></a>::value_type Max_E_Val
-</pre>
- </td>
-
- <td>
- <p>Maximal element.</p>
- </td>
-
- <td><tt>SCHAR_MAX</tt></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="Reverse1686776" id=
-"Reverse1686776"><b>bool</b> Reverse </a>
-</pre>
- </td>
-
- <td>
- <p>Indicates whether reverse iteration should be
- used.</p>
- </td>
-
- <td><tt><b>false</b></tt></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="Allocator35940069" id=
-"Allocator35940069"><b>class</b> Allocator </a>
-</pre>
- </td>
-
- <td>
- <p>Allocator type.</p>
- </td>
-
- <td>
- <pre>
-std::allocator<<b>char</b>>
-</pre>
- </td>
- </tr>
- </table>
-
- <h2><a name="link2" id="link2">Public Types and
- Constants</a></h2>
-
- <h3><a name="link3" id="link3">General Definitions</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Types">
- <tr>
- <td width="30%" align="left"><b>Type</b></td>
-
- <td width="55%" align="left"><b>Definition</b></td>
-
- <td width="15%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="size_type55424436" id="size_type55424436">size_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<b>typename</b> <a href=
-"#Allocator35940069"><tt>Allocator</tt></a>::size_type
-</pre>
- </td>
-
- <td>
- <p>Size type.</p>
- </td>
- </tr>
- </table>
-
- <h3><a name="link4" id="link4">Key-Type Definitions</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Types">
- <tr>
- <td width="30%" align="left"><b>Type</b></td>
-
- <td width="55%" align="left"><b>Definition</b></td>
-
- <td width="15%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="key_type10393186" id="key_type10393186">key_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<a href="#String349403"><tt>String</tt></a>
-</pre>
- </td>
-
- <td>
- <p>Key type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="const_key_reference3185471705" id=
-"const_key_reference3185471705">const_key_reference</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<b>typename</b> <a href=
-"#Allocator35940069"><tt>Allocator</tt></a>::<b>template</b> rebind<
- <a href=
-"#key_type10393186"><tt>key_type</tt></a>>::other::const_reference
-</pre>
- </td>
-
- <td>
- <p>Const key reference type.</p>
- </td>
- </tr>
- </table>
-
- <h3><a name="link5" id="link5">Element-Type
- Definitions</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Types">
- <tr>
- <td width="30%" align="left"><b>Type</b></td>
-
- <td width="55%" align="left"><b>Definition</b></td>
-
- <td width="15%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="reverse2186776" id="reverse2186776">reverse</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<a href="#Reverse1686776"><tt>Reverse</tt></a>
-</pre>
- </td>
-
- <td>
- <p><a href="#Reverse1686776"><tt>Reverse</tt></a>
- iteration indicator.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="const_iterator98626788" id=
-"const_iterator98626788">const_iterator</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<b>typename</b> __gnu_pbds::detail::__conditional_type<
- <a href="#Reverse1686776"><tt>Reverse</tt></a>,
- <b>typename</b> <a href=
-"#String349403"><tt>String</tt></a>::const_reverse_iterator,
- <b>typename</b> <a href=
-"#String349403"><tt>String</tt></a>::const_iterator>::__type
-</pre>
- </td>
-
- <td>
- <p>Element <tt><b>const</b></tt> iterator type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="e_type393186" id="e_type393186">e_type</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<b>typename</b> std::iterator_traits<<a href=
-"#const_iterator98626788"><tt>const_iterator</tt></a>>::value_type
-</pre>
- </td>
-
- <td>
- <p>Element type.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="min_e_val52875418" id="min_e_val52875418">min_e_val</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<a href="#Min_E_Val40354618"><tt>Min_E_Val</tt></a>
-</pre>
- </td>
-
- <td>
- <p>Minimal element.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="max_e_val52406668" id="max_e_val52406668">max_e_val</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<a href="#Max_E_Val39885868"><tt>Max_E_Val</tt></a>
-</pre>
- </td>
-
- <td>
- <p>Maximal element.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<a name="max_size10483336" id="max_size10483336">max_size</a>
-</pre>
- </td>
-
- <td>
- <pre>
-<a href="#max_e_val52406668"><tt>max_e_val</tt></a> - <a href=
-"#min_e_val52875418"><tt>min_e_val</tt></a> + 1
-</pre>
- </td>
-
- <td>
- <p>Number of distinct elements.</p>
- </td>
- </tr>
- </table>
-
- <h2><a name="link6" id="link6">Public Methods</a></h2>
-
- <h3><a name="link7" id="link7">Access Methods</a></h3>
-
- <table class="c1" width="100%" border="1" summary="Methods">
- <tr>
- <td width="45%" align="left"><b>Method</b></td>
-
- <td width="55%" align="left"><b>Description</b></td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#const_iterator98626788"><tt>const_iterator</tt></a>
- begin
- (<a href=
-"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
-</pre>
- </td>
-
- <td>
- <p>Returns a <a href=
- "#const_iterator98626788"><tt>const_iterator</tt></a> to
- the first element of <span class=
- "c1"><tt>r_key</tt></span>.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#const_iterator98626788"><tt>const_iterator</tt></a>
- end
- (<a href=
-"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
-</pre>
- </td>
-
- <td>
- <p>Returns a <a href=
- "#const_iterator98626788"><tt>const_iterator</tt></a> to
- the after-last element of <span class=
- "c1"><tt>r_key</tt></span>.</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <pre>
-<b>inline</b> <b>static</b> <a href=
-"#size_type55424436"><tt>size_type</tt></a>
- e_pos
- (<a href="#e_type393186"><tt>e_type</tt></a> e)
-</pre>
- </td>
-
- <td>
- <p>Maps an <span class="c1"><tt>e</tt></span>element to a
- position.</p>
- </td>
- </tr>
- </table>
- </div>
-</body>
-</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta name="generator" content=
+ "HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
+
+ <title>string_trie_e_access_traits Interface</title>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii" />
+ </head>
+
+<body>
+ <div id="page">
+ <h1><tt>string_trie_e_access_traits</tt> Interface</h1>
+
+ <p>Element access traits for string types.</p>
+
+ <p>Defined in: <a href=
+ "http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/include/ext/pb_ds/trie_policy.hpp"><tt>trie_policy.hpp</tt></a></p>
+
+ <h2><a name="link1" id="link1">Template Parameters</a></h2>
+
+ <table class="c1" width="100%" border="1" summary=
+ "Template Parameters">
+ <tr>
+ <td width="20%" align="left"><b>Parameter</b></td>
+
+ <td width="50%" align="left"><b>Description</b></td>
+
+ <td width="30%" align="left"><b>Default Value</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="String349403" id="String349403"><b>class</b> String </a>
+</pre>
+ </td>
+
+ <td>
+ <p>String type.</p>
+ </td>
+
+ <td><tt>std::string</tt></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="Min_E_Val40354618" id=
+"Min_E_Val40354618"><b>typename</b> </a><a href=
+"#String349403"><tt>String</tt></a>::value_type Min_E_Val
+</pre>
+ </td>
+
+ <td>
+ <p>Minimal element.</p>
+ </td>
+
+ <td><tt>SCHAR_MIN</tt></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="Max_E_Val39885868" id=
+"Max_E_Val39885868"><b>typename</b> </a><a href=
+"#String349403"><tt>String</tt></a>::value_type Max_E_Val
+</pre>
+ </td>
+
+ <td>
+ <p>Maximal element.</p>
+ </td>
+
+ <td><tt>SCHAR_MAX</tt></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="Reverse1686776" id=
+"Reverse1686776"><b>bool</b> Reverse </a>
+</pre>
+ </td>
+
+ <td>
+ <p>Indicates whether reverse iteration should be
+ used.</p>
+ </td>
+
+ <td><tt><b>false</b></tt></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="Allocator35940069" id=
+"Allocator35940069"><b>class</b> Allocator </a>
+</pre>
+ </td>
+
+ <td>
+ <p>Allocator type.</p>
+ </td>
+
+ <td>
+ <pre>
+std::allocator<<b>char</b>>
+</pre>
+ </td>
+ </tr>
+ </table>
+
+ <h2><a name="link2" id="link2">Public Types and
+ Constants</a></h2>
+
+ <h3><a name="link3" id="link3">General Definitions</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Types">
+ <tr>
+ <td width="30%" align="left"><b>Type</b></td>
+
+ <td width="55%" align="left"><b>Definition</b></td>
+
+ <td width="15%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="size_type55424436" id="size_type55424436">size_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<b>typename</b> <a href=
+"#Allocator35940069"><tt>Allocator</tt></a>::size_type
+</pre>
+ </td>
+
+ <td>
+ <p>Size type.</p>
+ </td>
+ </tr>
+ </table>
+
+ <h3><a name="link4" id="link4">Key-Type Definitions</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Types">
+ <tr>
+ <td width="30%" align="left"><b>Type</b></td>
+
+ <td width="55%" align="left"><b>Definition</b></td>
+
+ <td width="15%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="key_type10393186" id="key_type10393186">key_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<a href="#String349403"><tt>String</tt></a>
+</pre>
+ </td>
+
+ <td>
+ <p>Key type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="const_key_reference3185471705" id=
+"const_key_reference3185471705">const_key_reference</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<b>typename</b> <a href=
+"#Allocator35940069"><tt>Allocator</tt></a>::<b>template</b> rebind<
+ <a href=
+"#key_type10393186"><tt>key_type</tt></a>>::other::const_reference
+</pre>
+ </td>
+
+ <td>
+ <p>Const key reference type.</p>
+ </td>
+ </tr>
+ </table>
+
+ <h3><a name="link5" id="link5">Element-Type
+ Definitions</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Types">
+ <tr>
+ <td width="30%" align="left"><b>Type</b></td>
+
+ <td width="55%" align="left"><b>Definition</b></td>
+
+ <td width="15%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="reverse2186776" id="reverse2186776">reverse</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<a href="#Reverse1686776"><tt>Reverse</tt></a>
+</pre>
+ </td>
+
+ <td>
+ <p><a href="#Reverse1686776"><tt>Reverse</tt></a>
+ iteration indicator.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="const_iterator98626788" id=
+"const_iterator98626788">const_iterator</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<b>typename</b> __gnu_pbds::detail::__conditional_type<
+ <a href="#Reverse1686776"><tt>Reverse</tt></a>,
+ <b>typename</b> <a href=
+"#String349403"><tt>String</tt></a>::const_reverse_iterator,
+ <b>typename</b> <a href=
+"#String349403"><tt>String</tt></a>::const_iterator>::__type
+</pre>
+ </td>
+
+ <td>
+ <p>Element <tt><b>const</b></tt> iterator type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="e_type393186" id="e_type393186">e_type</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<b>typename</b> std::iterator_traits<<a href=
+"#const_iterator98626788"><tt>const_iterator</tt></a>>::value_type
+</pre>
+ </td>
+
+ <td>
+ <p>Element type.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="min_e_val52875418" id="min_e_val52875418">min_e_val</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<a href="#Min_E_Val40354618"><tt>Min_E_Val</tt></a>
+</pre>
+ </td>
+
+ <td>
+ <p>Minimal element.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="max_e_val52406668" id="max_e_val52406668">max_e_val</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<a href="#Max_E_Val39885868"><tt>Max_E_Val</tt></a>
+</pre>
+ </td>
+
+ <td>
+ <p>Maximal element.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<a name="max_size10483336" id="max_size10483336">max_size</a>
+</pre>
+ </td>
+
+ <td>
+ <pre>
+<a href="#max_e_val52406668"><tt>max_e_val</tt></a> - <a href=
+"#min_e_val52875418"><tt>min_e_val</tt></a> + 1
+</pre>
+ </td>
+
+ <td>
+ <p>Number of distinct elements.</p>
+ </td>
+ </tr>
+ </table>
+
+ <h2><a name="link6" id="link6">Public Methods</a></h2>
+
+ <h3><a name="link7" id="link7">Access Methods</a></h3>
+
+ <table class="c1" width="100%" border="1" summary="Methods">
+ <tr>
+ <td width="45%" align="left"><b>Method</b></td>
+
+ <td width="55%" align="left"><b>Description</b></td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#const_iterator98626788"><tt>const_iterator</tt></a>
+ begin
+ (<a href=
+"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
+</pre>
+ </td>
+
+ <td>
+ <p>Returns a <a href=
+ "#const_iterator98626788"><tt>const_iterator</tt></a> to
+ the first element of <span class=
+ "c1"><tt>r_key</tt></span>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#const_iterator98626788"><tt>const_iterator</tt></a>
+ end
+ (<a href=
+"#const_key_reference3185471705"><tt>const_key_reference</tt></a> r_key)
+</pre>
+ </td>
+
+ <td>
+ <p>Returns a <a href=
+ "#const_iterator98626788"><tt>const_iterator</tt></a> to
+ the after-last element of <span class=
+ "c1"><tt>r_key</tt></span>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<b>inline</b> <b>static</b> <a href=
+"#size_type55424436"><tt>size_type</tt></a>
+ e_pos
+ (<a href="#e_type393186"><tt>e_type</tt></a> e)
+</pre>
+ </td>
+
+ <td>
+ <p>Maps an <span class="c1"><tt>e</tt></span>element to a
+ position.</p>
+ </td>
+ </tr>
+ </table>
+ </div>
+</body>
+</html>
${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 \
${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 \
${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 \
${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 \
${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 \
${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 \
${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 \
${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
${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 \
${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 \
${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 \
${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 \
${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 \
${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 \
${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 \
${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, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/detail/container_base_dispatch.hpp>
-#include <ext/pb_ds/detail/basic_tree_policy/traits.hpp>
+#include <ext/pb_ds/detail/branch_policy/traits.hpp>
namespace __gnu_pbds
{
- /** @defgroup pbds Policy-Based Data Structures
- * @ingroup extensions
- *
- * This is a library of policy-based elementary data structures:
- * associative containers and priority queues. It is designed for
- * high-performance, flexibility, semantic safety, and conformance
- * to the corresponding containers in std (except for some points
- * where it differs by design).
- *
- * For details, see:
- * http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html
- *
+ /**
+ * @addtogroup pbds
* @{
*/
-
-#define PB_DS_BASE_C_DEC \
- detail::container_base_dispatch<Key, Mapped, Tag, Policy_Tl, Allocator>::type
-
- /// An abstract basic associative container.
- template<typename Key,
- typename Mapped,
- typename Tag,
- typename Policy_Tl,
- typename Allocator>
- class container_base : public PB_DS_BASE_C_DEC
- {
- private:
- typedef typename PB_DS_BASE_C_DEC base_type;
-
- public:
- typedef Tag container_category;
- typedef Allocator allocator_type;
- typedef typename allocator_type::size_type size_type;
- typedef typename allocator_type::difference_type difference_type;
-
- // key_type
- typedef typename allocator_type::template rebind<Key>::other::value_type key_type;
- typedef typename allocator_type::template rebind<key_type>::other key_rebind;
- typedef typename key_rebind::reference key_reference;
- typedef typename key_rebind::const_reference const_key_reference;
- typedef typename key_rebind::pointer key_pointer;
- typedef typename key_rebind::const_pointer const_key_pointer;
-
- // mapped_type
- typedef Mapped mapped_type;
- typedef typename allocator_type::template rebind<mapped_type>::other mapped_rebind;
- typedef typename mapped_rebind::reference mapped_reference;
- typedef typename mapped_rebind::const_reference const_mapped_reference;
- typedef typename mapped_rebind::pointer mapped_pointer;
- typedef typename mapped_rebind::const_pointer const_mapped_pointer;
-
- // value_type
- typedef typename base_type::value_type value_type;
- typedef typename allocator_type::template rebind<value_type>::other value_rebind;
- typedef typename value_rebind::reference reference;
- typedef typename value_rebind::const_reference const_reference;
- typedef typename value_rebind::pointer pointer;
- typedef typename value_rebind::const_pointer const_pointer;
-
- // iterators
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::point_iterator point_iterator;
- typedef typename base_type::const_point_iterator const_point_iterator;
-
- virtual
- ~container_base() { }
-
- protected:
-#define PB_DS_CLASS_NAME container_base
-#include <ext/pb_ds/detail/constructors_destructor_fn_imps.hpp>
-#undef PB_DS_CLASS_NAME
- };
-
-#undef PB_DS_BASE_C_DEC
-
-#define PB_DS_BASE_C_DEC \
- container_base<Key, Mapped, Tag, typename __gnu_cxx::typelist::append< \
- typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, detail::integral_constant<int, Store_Hash> >::type, Policy_TL>::type, Allocator>
+#define PB_DS_HASH_BASE \
+ detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, \
+ typename __gnu_cxx::typelist::append< \
+ typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, \
+ detail::integral_constant<int, Store_Hash> >::type, Policy_Tl>::type>::type
/// An abstract basic hash-based associative container.
template<typename Key,
typename Resize_Policy,
bool Store_Hash,
typename Tag,
- typename Policy_TL,
- typename Allocator>
- class basic_hash_table : public PB_DS_BASE_C_DEC
+ typename Policy_Tl,
+ typename _Alloc>
+ class basic_hash_table : public PB_DS_HASH_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename PB_DS_HASH_BASE base_type;
public:
virtual
#undef PB_DS_CLASS_NAME
private:
- basic_hash_table&
+ basic_hash_table&
operator=(const base_type&);
};
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_HASH_BASE
-#define PB_DS_BASE_C_DEC \
+#define PB_DS_CC_HASH_BASE \
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
cc_hash_tag, \
- typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, Allocator>
+ typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, _Alloc>
/// A concrete collision-chaining hash-based associative container.
template<typename Key,
typename Comb_Hash_Fn = detail::default_comb_hash_fn::type,
typename Resize_Policy = typename detail::default_resize_policy<Comb_Hash_Fn>::type,
bool Store_Hash = detail::default_store_hash,
- typename Allocator = std::allocator<char> >
- class cc_hash_table : public PB_DS_BASE_C_DEC
+ typename _Alloc = std::allocator<char> >
+ class cc_hash_table : public PB_DS_CC_HASH_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_CC_HASH_BASE base_type;
public:
- typedef Hash_Fn hash_fn;
- typedef Eq_Fn eq_fn;
- typedef Resize_Policy resize_policy;
- typedef Comb_Hash_Fn comb_hash_fn;
+ typedef cc_hash_tag container_category;
+ typedef Hash_Fn hash_fn;
+ typedef Eq_Fn eq_fn;
+ typedef Resize_Policy resize_policy;
+ typedef Comb_Hash_Fn comb_hash_fn;
// Default constructor.
cc_hash_table() { }
// Constructor taking some policy objects. r_hash_fn will be
// copied by the Hash_Fn object of the container object.
- cc_hash_table(const hash_fn& h)
+ cc_hash_table(const hash_fn& h)
: base_type(h) { }
// Constructor taking some policy objects. r_hash_fn will be
// r_comb_hash_fn will be copied by the comb_hash_fn object of the
// container object, and r_resize_policy will be copied by the
// resize_policy object of the container object.
- cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch,
- const resize_policy& rp)
+ cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch,
+ const resize_policy& rp)
: base_type(h, e, ch, rp) { }
// Constructor taking __iterators to a range of value_types. The
// object of the container object, and r_resize_policy will be
// copied by the resize_policy object of the container object.
template<typename It>
- cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
+ cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_hash_fn& ch, const resize_policy& rp)
: base_type(h, e, ch, rp)
{ this->copy_from_range(first, last); }
virtual
~cc_hash_table() { }
- cc_hash_table&
+ cc_hash_table&
operator=(const cc_hash_table& other)
{
if (this != &other)
{ base_type::swap(other); }
};
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_CC_HASH_BASE
-#define PB_DS_BASE_C_DEC \
+#define PB_DS_GP_HASH_BASE \
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
gp_hash_tag, \
- typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, Allocator>
+ typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, _Alloc>
/// A concrete general-probing hash-based associative container.
template<typename Key,
typename Probe_Fn = typename detail::default_probe_fn<Comb_Probe_Fn>::type,
typename Resize_Policy = typename detail::default_resize_policy<Comb_Probe_Fn>::type,
bool Store_Hash = detail::default_store_hash,
- typename Allocator = std::allocator<char> >
- class gp_hash_table : public PB_DS_BASE_C_DEC
+ typename _Alloc = std::allocator<char> >
+ class gp_hash_table : public PB_DS_GP_HASH_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_GP_HASH_BASE base_type;
public:
- typedef Hash_Fn hash_fn;
- typedef Eq_Fn eq_fn;
- typedef Comb_Probe_Fn comb_probe_fn;
- typedef Probe_Fn probe_fn;
- typedef Resize_Policy resize_policy;
+ typedef gp_hash_tag container_category;
+ typedef Hash_Fn hash_fn;
+ typedef Eq_Fn eq_fn;
+ typedef Comb_Probe_Fn comb_probe_fn;
+ typedef Probe_Fn probe_fn;
+ typedef Resize_Policy resize_policy;
// Default constructor.
gp_hash_table() { }
// r_comb_probe_fn will be copied by the comb_probe_fn object of
// the container object, and r_probe_fn will be copied by the
// probe_fn object of the container object.
- gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
+ gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
const probe_fn& p)
: base_type(h, e, cp, p) { }
// the container object, r_probe_fn will be copied by the probe_fn
// object of the container object, and r_resize_policy will be
// copied by the Resize_Policy object of the container object.
- gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
+ gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
const probe_fn& p, const resize_policy& rp)
: base_type(h, e, cp, p, rp) { }
// object, and r_comb_probe_fn will be copied by the comb_probe_fn
// object of the container object.
template<typename It>
- gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
+ gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_probe_fn& cp)
: base_type(h, e, cp)
{ base_type::copy_from_range(first, last); }
// object of the container object, and r_probe_fn will be copied
// by the probe_fn object of the container object.
template<typename It>
- gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
+ gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
const comb_probe_fn& cp, const probe_fn& p)
: base_type(h, e, cp, p)
{ base_type::copy_from_range(first, last); }
// r_resize_policy will be copied by the resize_policy object of
// the container object.
template<typename It>
- gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
- const comb_probe_fn& cp, const probe_fn& p,
+ gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
+ const comb_probe_fn& cp, const probe_fn& p,
const resize_policy& rp)
: base_type(h, e, cp, p, rp)
{ base_type::copy_from_range(first, last); }
virtual
~gp_hash_table() { }
- gp_hash_table&
+ gp_hash_table&
operator=(const gp_hash_table& other)
{
if (this != &other)
{ base_type::swap(other); }
};
-#undef PB_DS_BASE_C_DEC
-
+#undef PB_DS_GP_HASH_BASE
-#define PB_DS_BASE_C_DEC \
- container_base<Key, Mapped, Tag, Policy_Tl, Allocator>
+#define PB_DS_BRANCH_BASE \
+ detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, Policy_Tl>::type
/// An abstract basic tree-like (tree, trie) associative container.
- template<typename Key, typename Mapped, typename Tag,
- typename Node_Update, typename Policy_Tl, typename Allocator>
- class basic_tree : public PB_DS_BASE_C_DEC
+ template<typename Key, typename Mapped, typename Tag,
+ typename Node_Update, typename Policy_Tl, typename _Alloc>
+ class basic_branch : public PB_DS_BRANCH_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename PB_DS_BRANCH_BASE base_type;
public:
- typedef Node_Update node_update;
+ typedef Node_Update node_update;
virtual
- ~basic_tree() { }
+ ~basic_branch() { }
protected:
-#define PB_DS_CLASS_NAME basic_tree
+#define PB_DS_CLASS_NAME basic_branch
#include <ext/pb_ds/detail/constructors_destructor_fn_imps.hpp>
#undef PB_DS_CLASS_NAME
};
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_BRANCH_BASE
-#define PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC \
- detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag, Allocator>
+#define PB_DS_TREE_NODE_AND_IT_TRAITS \
+ detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag,_Alloc>
-#define PB_DS_BASE_C_DEC \
- basic_tree<Key,Mapped,Tag,typename PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC::node_update, \
- typename __gnu_cxx::typelist::create2<Cmp_Fn, PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC >::type, Allocator>
+#define PB_DS_TREE_BASE \
+ basic_branch<Key,Mapped, Tag, \
+ typename PB_DS_TREE_NODE_AND_IT_TRAITS::node_update, \
+ typename __gnu_cxx::typelist::create2<Cmp_Fn, \
+ PB_DS_TREE_NODE_AND_IT_TRAITS>::type, _Alloc>
- /// A concrete basic tree-based associative container.
+ /// A basic tree-based associative container.
template<typename Key, typename Mapped, typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag,
- template<typename Const_Node_Iterator, typename Node_Iterator, typename Cmp_Fn_, typename Allocator_>
- class Node_Update = __gnu_pbds::null_tree_node_update,
- typename Allocator = std::allocator<char> >
- class tree : public PB_DS_BASE_C_DEC
+ template<typename Node_CItr, typename Node_Itr,
+ typename Cmp_Fn_, typename _Alloc_>
+ class Node_Update = null_node_update,
+ typename _Alloc = std::allocator<char> >
+ class tree : public PB_DS_TREE_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_TREE_BASE base_type;
public:
// Comparison functor type.
- typedef Cmp_Fn cmp_fn;
+ typedef Cmp_Fn cmp_fn;
tree() { }
virtual
~tree() { }
- tree&
+ tree&
operator=(const tree& other)
{
if (this != &other)
{ base_type::swap(other); }
};
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC
+#undef PB_DS_TREE_BASE
+#undef PB_DS_TREE_NODE_AND_IT_TRAITS
-#define PB_DS_TRIE_NODE_AND_ITS_TRAITS \
- detail::trie_traits<Key,Mapped,E_Access_Traits,Node_Update,Tag,Allocator>
+#define PB_DS_TRIE_NODE_AND_IT_TRAITS \
+ detail::trie_traits<Key,Mapped,_ATraits,Node_Update,Tag,_Alloc>
-#define PB_DS_BASE_C_DEC \
- basic_tree<Key,Mapped,Tag, typename PB_DS_TRIE_NODE_AND_ITS_TRAITS::node_update, \
- typename __gnu_cxx::typelist::create2<E_Access_Traits, PB_DS_TRIE_NODE_AND_ITS_TRAITS >::type, Allocator>
+#define PB_DS_TRIE_BASE \
+ basic_branch<Key,Mapped,Tag, \
+ typename PB_DS_TRIE_NODE_AND_IT_TRAITS::node_update, \
+ typename __gnu_cxx::typelist::create2<_ATraits, \
+ PB_DS_TRIE_NODE_AND_IT_TRAITS >::type, _Alloc>
- /// A concrete basic trie-based associative container.
+ /// A basic trie-based associative container.
template<typename Key,
typename Mapped,
- typename E_Access_Traits = typename detail::default_trie_e_access_traits<Key>::type,
+ typename _ATraits = \
+ typename detail::default_trie_access_traits<Key>::type,
typename Tag = pat_trie_tag,
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- typename E_Access_Traits_,
- typename Allocator_>
- class Node_Update = null_trie_node_update,
- typename Allocator = std::allocator<char> >
- class trie : public PB_DS_BASE_C_DEC
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename _ATraits_,
+ typename _Alloc_>
+ class Node_Update = null_node_update,
+ typename _Alloc = std::allocator<char> >
+ class trie : public PB_DS_TRIE_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_TRIE_BASE base_type;
public:
// Element access traits type.
- typedef E_Access_Traits e_access_traits;
+ typedef _ATraits access_traits;
trie() { }
- // Constructor taking some policy objects. r_e_access_traits will
- // be copied by the E_Access_Traits object of the container
+ // Constructor taking some policy objects. r_access_traits will
+ // be copied by the _ATraits object of the container
// object.
- trie(const e_access_traits& t)
+ trie(const access_traits& t)
: base_type(t) { }
// Constructor taking __iterators to a range of value_types. The
// some policy objects. The value_types between first_it and
// last_it will be inserted into the container object.
template<typename It>
- trie(It first, It last, const e_access_traits& t)
+ trie(It first, It last, const access_traits& t)
: base_type(t)
{ base_type::copy_from_range(first, last); }
virtual
~trie() { }
- trie&
+ trie&
operator=(const trie& other)
{
if (this != &other)
{ base_type::swap(other); }
};
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_TRIE_NODE_AND_ITS_TRAITS
+#undef PB_DS_TRIE_BASE
+#undef PB_DS_TRIE_NODE_AND_IT_TRAITS
-#define PB_DS_BASE_C_DEC \
- container_base<Key, Mapped, list_update_tag, \
- typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type, Allocator>
+#define PB_DS_LU_BASE \
+ detail::container_base_dispatch<Key, Mapped, _Alloc, list_update_tag, \
+ typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type>::type
/// A list-update based associative container.
template<typename Key,
typename Mapped,
class Eq_Fn = typename detail::default_eq_fn<Key>::type,
class Update_Policy = detail::default_update_policy::type,
- class Allocator = std::allocator<char> >
- class list_update : public PB_DS_BASE_C_DEC
+ class _Alloc = std::allocator<char> >
+ class list_update : public PB_DS_LU_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename PB_DS_LU_BASE base_type;
public:
- typedef Eq_Fn eq_fn;
- typedef Update_Policy update_policy;
- typedef Allocator allocator;
+ typedef list_update_tag container_category;
+ typedef Eq_Fn eq_fn;
+ typedef Update_Policy update_policy;
list_update() { }
virtual
~list_update() { }
- list_update&
+ list_update&
operator=(const list_update& other)
{
if (this !=& other)
{ base_type::swap(other); }
};
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_LU_BASE
// @} group pbds
} // namespace __gnu_pbds
-#endif
+#endif
+++ /dev/null
-// -*- 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
-
// warranty.
/**
- * @file bin_search_tree_.hpp
- * Contains an implementation class for bin_search_tree_.
- */
-/*
- * This implementation uses an idea from the SGI STL (using a @a header node
- * which is needed for efficient iteration).
+ * @file bin_search_tree_/bin_search_tree_.hpp
+ * Contains an implementation class for binary search tree.
*/
#include <ext/pb_ds/exception.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
-#include <ext/pb_ds/detail/debug_map_base.hpp>
-#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <ext/pb_ds/detail/tree_trace_base.hpp>
+#ifdef _GLIBCXX_DEBUG
+#include <ext/pb_ds/detail/debug_map_base.hpp>
+#endif
#include <utility>
#include <functional>
#include <debug/debug.h>
{
namespace detail
{
-
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, class Cmp_Fn, \
- class Node_And_It_Traits, class Allocator>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME \
- bin_search_tree_data_
-#endif
+#define PB_DS_BIN_TREE_NAME bin_search_tree_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME \
- bin_search_tree_no_data_
-#endif
-
-#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME< \
- Key, \
- Mapped, \
- Cmp_Fn, \
- Node_And_It_Traits, \
- Allocator>
-
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits< \
- Key, \
- Mapped, \
- Allocator, \
- false>
+#define PB_DS_BIN_TREE_NAME bin_search_tree_set
+#endif
-#ifdef _GLIBCXX_DEBUG
-#define PB_DS_DEBUG_MAP_BASE_C_DEC \
- debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
- typename Allocator::template rebind<Key>::other::const_reference>
-#endif
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Cmp_Fn, \
+ typename Node_And_It_Traits, typename _Alloc>
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
+#define PB_DS_CLASS_C_DEC \
+ PB_DS_BIN_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
+#define PB_DS_BIN_TREE_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, false>
+
+#ifdef _GLIBCXX_DEBUG
+#define PB_DS_DEBUG_MAP_BASE_C_DEC \
+ debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
+ typename _Alloc::template rebind<Key>::other::const_reference>
+#endif
#ifdef PB_DS_TREE_TRACE
-#define PB_DS_TREE_TRACE_BASE_C_DEC \
- tree_trace_base< \
- typename Node_And_It_Traits::const_node_iterator, \
- typename Node_And_It_Traits::node_iterator, \
- Cmp_Fn, \
- true, \
- Allocator>
-#endif
-
- /**
- * class description = "8i|\|4ree $34rc|-| 7r33 74813.">
- **/
- template<typename Key,
- typename Mapped,
- class Cmp_Fn,
- class Node_And_It_Traits,
- class Allocator>
- class PB_DS_CLASS_NAME :
+#define PB_DS_TREE_TRACE_BASE_C_DEC \
+ tree_trace_base<typename Node_And_It_Traits::node_const_iterator, \
+ typename Node_And_It_Traits::node_iterator, \
+ Cmp_Fn, true, _Alloc>
+#endif
+
+
+ /*
+ * @brief Binary search tree (BST).
+ *
+ * This implementation uses an idea from the SGI STL (using a @a
+ * header node which is needed for efficient iteration).
+ */
+ template<typename Key, typename Mapped, typename Cmp_Fn,
+ typename Node_And_It_Traits, typename _Alloc>
+ class PB_DS_BIN_TREE_NAME :
#ifdef _GLIBCXX_DEBUG
public PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
+#endif
#ifdef PB_DS_TREE_TRACE
public PB_DS_TREE_TRACE_BASE_C_DEC,
-#endif
+#endif
public Cmp_Fn,
- public PB_DS_TYPES_TRAITS_C_DEC,
+ public PB_DS_BIN_TREE_TRAITS_BASE,
public Node_And_It_Traits::node_update
{
+ typedef Node_And_It_Traits traits_type;
protected:
+ typedef PB_DS_BIN_TREE_TRAITS_BASE traits_base;
+
typedef
- typename Allocator::template rebind<
- typename Node_And_It_Traits::node>::other
+ typename _Alloc::template rebind<typename traits_type::node>::other
node_allocator;
- typedef typename node_allocator::value_type node;
-
- typedef typename node_allocator::pointer node_pointer;
+ typedef typename node_allocator::value_type node;
+ typedef typename node_allocator::pointer node_pointer;
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
-
- typedef
- typename Node_And_It_Traits::null_node_update_pointer
+ typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
private:
- typedef cond_dealtor< node, Allocator> cond_dealtor_t;
+ typedef cond_dealtor<node, _Alloc> cond_dealtor_t;
#ifdef _GLIBCXX_DEBUG
- typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+ typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
+#endif
public:
-
- typedef typename Allocator::size_type size_type;
-
- typedef typename Allocator::difference_type difference_type;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_type key_type;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_pointer key_pointer;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::const_key_pointer
- const_key_pointer;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::key_reference key_reference;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::const_key_reference
- const_key_reference;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef typename traits_base::key_type key_type;
+ typedef typename traits_base::key_pointer key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
+ typedef typename traits_base::key_reference key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::mapped_type mapped_type;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::mapped_pointer
- mapped_pointer;
+ typedef typename traits_base::mapped_type mapped_type;
+ typedef typename traits_base::mapped_pointer mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
+ typedef typename traits_base::mapped_reference mapped_reference;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
+#endif
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_pointer
- const_mapped_pointer;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::mapped_reference
- mapped_reference;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::const_mapped_reference
- const_mapped_reference;
-#endif
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::value_type value_type;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::pointer pointer;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::const_pointer const_pointer;
-
- typedef typename PB_DS_TYPES_TRAITS_C_DEC::reference reference;
-
- typedef
- typename PB_DS_TYPES_TRAITS_C_DEC::const_reference
- const_reference;
-
- typedef
- typename Node_And_It_Traits::const_point_iterator
- const_point_iterator;
-
- typedef const_point_iterator const_iterator;
-
- typedef typename Node_And_It_Traits::point_iterator point_iterator;
+ typedef typename traits_base::value_type value_type;
+ typedef typename traits_base::pointer pointer;
+ typedef typename traits_base::const_pointer const_pointer;
+ typedef typename traits_base::reference reference;
+ typedef typename traits_base::const_reference const_reference;
+ typedef typename traits_type::point_const_iterator point_const_iterator;
- typedef point_iterator iterator;
+ typedef point_const_iterator const_iterator;
+ typedef typename traits_type::point_iterator point_iterator;
+ typedef point_iterator iterator;
- typedef
- typename Node_And_It_Traits::const_reverse_iterator
- const_reverse_iterator;
-
- typedef typename Node_And_It_Traits::reverse_iterator reverse_iterator;
-
- typedef
- typename Node_And_It_Traits::const_node_iterator
- const_node_iterator;
+ typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
- typedef typename Node_And_It_Traits::node_iterator node_iterator;
+ typedef typename traits_type::reverse_iterator reverse_iterator;
+ typedef typename traits_type::node_const_iterator node_const_iterator;
+ typedef typename traits_type::node_iterator node_iterator;
+ typedef typename traits_type::node_update node_update;
- typedef Cmp_Fn cmp_fn;
-
- typedef Allocator allocator_type;
-
- typedef typename Node_And_It_Traits::node_update node_update;
-
- public:
+ typedef Cmp_Fn cmp_fn;
+ typedef _Alloc allocator_type;
- PB_DS_CLASS_NAME();
+ PB_DS_BIN_TREE_NAME();
- PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn);
+ PB_DS_BIN_TREE_NAME(const Cmp_Fn&);
- PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_update);
+ PB_DS_BIN_TREE_NAME(const Cmp_Fn&, const node_update&);
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other);
+ PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
- ~PB_DS_CLASS_NAME();
+ ~PB_DS_BIN_TREE_NAME();
inline bool
empty() const;
inline size_type
max_size() const;
- Cmp_Fn&
+ Cmp_Fn&
get_cmp_fn();
- const Cmp_Fn&
+ const Cmp_Fn&
get_cmp_fn() const;
inline point_iterator
- lower_bound(const_key_reference r_key);
+ lower_bound(key_const_reference);
- inline const_point_iterator
- lower_bound(const_key_reference r_key) const;
+ inline point_const_iterator
+ lower_bound(key_const_reference) const;
inline point_iterator
- upper_bound(const_key_reference r_key);
+ upper_bound(key_const_reference);
- inline const_point_iterator
- upper_bound(const_key_reference r_key) const;
+ inline point_const_iterator
+ upper_bound(key_const_reference) const;
inline point_iterator
- find(const_key_reference r_key);
+ find(key_const_reference);
- inline const_point_iterator
- find(const_key_reference r_key) const;
+ inline point_const_iterator
+ find(key_const_reference) const;
inline iterator
begin();
inline const_reverse_iterator
rend() const;
- inline const_node_iterator
+ inline node_const_iterator
node_begin() const;
inline node_iterator
node_begin();
- inline const_node_iterator
+ inline node_const_iterator
node_end() const;
inline node_iterator
clear();
protected:
-
void
- value_swap(PB_DS_CLASS_C_DEC& other);
+ value_swap(PB_DS_CLASS_C_DEC&);
void
initialize_min_max();
inline iterator
- insert_imp_empty(const_reference r_value);
+ insert_imp_empty(const_reference);
inline iterator
- insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd);
+ insert_leaf_new(const_reference, node_pointer, bool);
inline node_pointer
- get_new_node_for_leaf_insert(const_reference r_val, false_type);
+ get_new_node_for_leaf_insert(const_reference, false_type);
inline node_pointer
- get_new_node_for_leaf_insert(const_reference r_val, true_type);
+ get_new_node_for_leaf_insert(const_reference, true_type);
inline void
- actual_erase_node(node_pointer p_nd);
+ actual_erase_node(node_pointer);
inline std::pair<node_pointer, bool>
- erase(node_pointer p_nd);
+ erase(node_pointer);
inline void
- update_min_max_for_erased_node(node_pointer p_nd);
+ update_min_max_for_erased_node(node_pointer);
static void
- clear_imp(node_pointer p_nd);
+ clear_imp(node_pointer);
- inline std::pair<
- point_iterator,
- bool>
- insert_leaf(const_reference r_value);
+ inline std::pair<point_iterator, bool>
+ insert_leaf(const_reference);
inline void
- rotate_left(node_pointer p_x);
+ rotate_left(node_pointer);
inline void
- rotate_right(node_pointer p_y);
+ rotate_right(node_pointer);
inline void
- rotate_parent(node_pointer p_nd);
+ rotate_parent(node_pointer);
inline void
- apply_update(node_pointer p_nd, null_node_update_pointer);
+ apply_update(node_pointer, null_node_update_pointer);
template<typename Node_Update_>
- inline void
- apply_update(node_pointer p_nd, Node_Update_* p_update);
+ inline void
+ apply_update(node_pointer, Node_Update_*);
inline void
- update_to_top(node_pointer p_nd, null_node_update_pointer);
+ update_to_top(node_pointer, null_node_update_pointer);
template<typename Node_Update_>
- inline void
- update_to_top(node_pointer p_nd, Node_Update_* p_update);
+ inline void
+ update_to_top(node_pointer, Node_Update_*);
bool
- join_prep(PB_DS_CLASS_C_DEC& other);
+ join_prep(PB_DS_CLASS_C_DEC&);
void
- join_finish(PB_DS_CLASS_C_DEC& other);
+ join_finish(PB_DS_CLASS_C_DEC&);
bool
- split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other);
+ split_prep(key_const_reference, PB_DS_CLASS_C_DEC&);
void
- split_finish(PB_DS_CLASS_C_DEC& other);
+ split_finish(PB_DS_CLASS_C_DEC&);
size_type
- recursive_count(node_pointer p_nd) const;
+ recursive_count(node_pointer) const;
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
void
- structure_only_assert_valid(const char* file, int line) const;
+ structure_only_assert_valid(const char*, int) const;
void
- assert_node_consistent(const node_pointer p_nd,
- const char* file, int line) const;
-#endif
+ assert_node_consistent(const node_pointer, const char*, int) const;
+#endif
private:
#ifdef _GLIBCXX_DEBUG
void
- assert_iterators(const char* file, int line) const;
+ assert_iterators(const char*, int) const;
void
- assert_consistent_with_debug_base(const char* file, int line) const;
+ assert_consistent_with_debug_base(const char*, int) const;
void
- assert_node_consistent_with_left(const node_pointer p_nd,
- const char* file, int line) const;
+ assert_node_consistent_with_left(const node_pointer,
+ const char*, int) const;
void
- assert_node_consistent_with_right(const node_pointer p_nd,
- const char* file, int line) const;
+ assert_node_consistent_with_right(const node_pointer,
+ const char*, int) const;
void
- assert_consistent_with_debug_base(const node_pointer p_nd,
- const char* file, int line) const;
+ assert_consistent_with_debug_base(const node_pointer,
+ const char*, int) const;
void
- assert_min(const char* file, int line) const;
+ assert_min(const char*, int) const;
void
- assert_min_imp(const node_pointer p_nd,
- const char* file, int line) const;
+ assert_min_imp(const node_pointer, const char*, int) const;
void
- assert_max(const char* file, int line) const;
+ assert_max(const char*, int) const;
void
- assert_max_imp(const node_pointer p_nd,
- const char* file, int line) const;
+ assert_max_imp(const node_pointer, const char*, int) const;
void
- assert_size(const char* file, int line) const;
+ assert_size(const char*, int) const;
- typedef std::pair< const_pointer, const_pointer> node_consistent_t;
+ typedef std::pair<const_pointer, const_pointer> node_consistent_t;
node_consistent_t
- assert_node_consistent_(const node_pointer p_nd,
- const char* file, int line) const;
-#endif
+ assert_node_consistent_(const node_pointer, const char*, int) const;
+#endif
void
initialize();
node_pointer
- recursive_copy_node(const node_pointer p_nd);
+ recursive_copy_node(const node_pointer);
protected:
- node_pointer m_p_head;
-
- size_type m_size;
-
- static node_allocator s_node_allocator;
+ node_pointer m_p_head;
+ size_type m_size;
+ static node_allocator s_node_allocator;
};
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_BIN_TREE_NAME
+#undef PB_DS_BIN_TREE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE
#undef PB_DS_TREE_TRACE_BASE_C_DEC
-#endif
-
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
-
+#endif
} // namespace detail
} // namespace __gnu_pbds
+++ /dev/null
-// -*- 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;
-};
-
+++ /dev/null
-// -*- 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;
-};
-
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file bin_search_tree_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
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))
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();
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)),
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
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);
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file bin_search_tree_/debug_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
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
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file bin_search_tree_/erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
{
_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);
}
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;
}
}
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))
}
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);
}
-
// 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;
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;
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);
}
-
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file bin_search_tree_/info_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file bin_search_tree_/insert_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
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);
}
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);
}
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;
}
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;
}
-
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file bin_search_tree_/iterators_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
}
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
}
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
// warranty.
/**
- * @file node_iterators.hpp
+ * @file bin_search_tree_/node_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
{
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;
// 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.
/*
*/
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.
}
// Metadata access.
- inline const_metadata_reference
+ inline metadata_const_reference
get_metadata() const
{
return (m_p_nd->get_metadata());
return (m_p_nd != other.m_p_nd);
}
- public:
node_pointer m_p_nd;
};
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;
// __Iterator's __const reference type.
typedef Iterator const_reference;
- public:
-
// Default constructor.
/*
inline
*/
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.
};
#undef PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
-
#undef PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
} // namespace detail
// warranty.
/**
- * @file point_iterators.hpp
+ * @file bin_search_tree_/point_iterators.hpp
* Contains an implementation class for bin_search_tree_.
*/
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
- Allocator>
+ _Alloc>
#define PB_DS_TREE_CONST_ODIR_IT_C_DEC \
bin_search_tree_const_it_< \
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
- Allocator>
+ _Alloc>
#define PB_DS_TREE_IT_C_DEC \
bin_search_tree_it_< \
Reference, \
Const_Reference, \
Is_Forward_Iterator, \
- Allocator>
+ _Alloc>
#define PB_DS_TREE_ODIR_IT_C_DEC \
bin_search_tree_it_< \
Reference, \
Const_Reference, \
!Is_Forward_Iterator, \
- Allocator>
+ _Alloc>
- // Const iterator.
+ /// Const iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
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)
Node_Pointer m_p_nd;
};
- // Iterator.
+ /// Iterator.
template<typename Node_Pointer,
typename Value_Type,
typename Pointer,
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)
// warranty.
/**
- * @file policy_access_fn_imps.hpp
+ * @file bin_search_tree_/policy_access_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
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); }
// warranty.
/**
- * @file r_erase_fn_imps.hpp
+ * @file bin_search_tree_/r_erase_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
{
_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);
}
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;
}
}
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))
}
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);
}
-
// warranty.
/**
- * @file rotate_fn_imps.hpp
+ * @file bin_search_tree_/rotate_fn_imps.hpp
* Contains imps for rotating nodes.
*/
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
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file bin_search_tree_/split_join_fn_imps.hpp
* Contains an implementation class for bin_search_tree_.
*/
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)
// warranty.
/**
- * @file traits.hpp
+ * @file bin_search_tree_/traits.hpp
* Contains an implementation for bin_search_tree_.
*/
{
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,
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,
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,
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,
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,
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,
typename type_traits::reference,
typename type_traits::const_reference,
false,
- Allocator>
+ _Alloc>
const_reverse_iterator;
typedef const_reverse_iterator 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 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;
};
// warranty.
/**
- * @file binary_heap_.hpp
+ * @file binary_heap_/binary_heap_.hpp
* Contains an implementation class for a binary heap.
*/
#ifndef PB_DS_BINARY_HEAP_HPP
#define PB_DS_BINARY_HEAP_HPP
-/*
- * Based on CLRS.
- */
-
#include <queue>
#include <algorithm>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/detail/binary_heap_/entry_cmp.hpp>
#include <ext/pb_ds/detail/binary_heap_/entry_pred.hpp>
#include <ext/pb_ds/detail/binary_heap_/resize_policy.hpp>
-#include <ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
#include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp>
#ifdef PB_DS_BINARY_HEAP_TRACE_
#include <iostream>
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 \
- binary_heap_<Value_Type, Cmp_Fn, Allocator>
+ binary_heap<Value_Type, Cmp_Fn, _Alloc>
#define PB_DS_ENTRY_CMP_DEC \
- entry_cmp<Value_Type, Cmp_Fn, is_simple<Value_Type>::value, Allocator>::type
+ entry_cmp<Value_Type, Cmp_Fn, _Alloc, is_simple<Value_Type>::value>::type
#define PB_DS_RESIZE_POLICY_DEC \
- __gnu_pbds::detail::resize_policy<typename Allocator::size_type>
+ __gnu_pbds::detail::resize_policy<typename _Alloc::size_type>
/**
- * class description = "Base class for some types of h3ap$">
- **/
- template<typename Value_Type, class Cmp_Fn, class Allocator>
- class binary_heap_ : public PB_DS_ENTRY_CMP_DEC,
- public PB_DS_RESIZE_POLICY_DEC
+ * @brief Binary heaps composed of resize and compare policies.
+ *
+ * Based on CLRS.
+ */
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+ class binary_heap
+ : public PB_DS_ENTRY_CMP_DEC, public PB_DS_RESIZE_POLICY_DEC
{
+ public:
+ 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 PB_DS_ENTRY_CMP_DEC entry_cmp;
+ typedef PB_DS_RESIZE_POLICY_DEC resize_policy;
+ typedef cond_dealtor<value_type, _Alloc> cond_dealtor_t;
private:
enum
{
- simple_value = is_simple<Value_Type>::value
+ simple_value = is_simple<value_type>::value
};
- typedef integral_constant<int, simple_value> no_throw_copies_t;
-
- typedef
- typename Allocator::template rebind<
- Value_Type>::other
- value_allocator;
-
- typedef
- typename __conditional_type<
- simple_value,
- Value_Type,
- typename value_allocator::pointer>::__type
- entry;
+ typedef integral_constant<int, simple_value> no_throw_copies_t;
- typedef
- typename Allocator::template rebind<
- entry>::other
- entry_allocator;
-
- typedef typename entry_allocator::pointer entry_pointer;
-
- typedef typename PB_DS_ENTRY_CMP_DEC entry_cmp;
-
- typedef PB_DS_RESIZE_POLICY_DEC resize_policy;
-
- typedef
- cond_dealtor<
- Value_Type,
- Allocator>
- cond_dealtor_t;
+ typedef typename _Alloc::template rebind<value_type> __rebind_v;
+ typedef typename __rebind_v::other value_allocator;
public:
+ typedef typename value_allocator::pointer pointer;
+ typedef typename value_allocator::const_pointer const_pointer;
+ typedef typename value_allocator::reference reference;
+ typedef typename value_allocator::const_reference const_reference;
- typedef typename Allocator::size_type size_type;
-
- typedef typename Allocator::difference_type difference_type;
+ typedef typename __conditional_type<simple_value,
+ value_type, pointer>::__type
+ entry;
- typedef Value_Type value_type;
+ typedef typename _Alloc::template rebind<entry>::other
+ entry_allocator;
- typedef
- typename Allocator::template rebind<
- value_type>::other::pointer
- pointer;
+ typedef typename entry_allocator::pointer entry_pointer;
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_pointer
- const_pointer;
+ typedef binary_heap_point_const_iterator_<value_type, entry,
+ simple_value, _Alloc>
+ point_const_iterator;
- typedef
- typename Allocator::template rebind<
- value_type>::other::reference
- reference;
+ typedef point_const_iterator point_iterator;
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_reference
- const_reference;
+ typedef binary_heap_const_iterator_<value_type, entry,
+ simple_value, _Alloc>
+ const_iterator;
- typedef
- binary_heap_const_point_iterator_<
- value_type,
- entry,
- simple_value,
- Allocator>
- const_point_iterator;
+ typedef const_iterator iterator;
- typedef const_point_iterator point_iterator;
- typedef
- binary_heap_const_iterator_<
- value_type,
- entry,
- simple_value,
- Allocator>
- const_iterator;
+ binary_heap();
- typedef const_iterator iterator;
+ binary_heap(const cmp_fn&);
- typedef Cmp_Fn cmp_fn;
-
- typedef Allocator allocator_type;
-
- public:
-
- binary_heap_();
-
- binary_heap_(const Cmp_Fn& r_cmp_fn);
-
- binary_heap_(const PB_DS_CLASS_C_DEC& other);
+ binary_heap(const binary_heap&);
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(binary_heap&);
- ~binary_heap_();
+ ~binary_heap();
inline bool
empty() const;
inline size_type
max_size() const;
- Cmp_Fn&
+ Cmp_Fn&
get_cmp_fn();
- const Cmp_Fn&
+ const Cmp_Fn&
get_cmp_fn() const;
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;
pop();
inline void
- erase(point_iterator it);
+ erase(point_iterator);
template<typename Pred>
- typename PB_DS_CLASS_C_DEC::size_type
- erase_if(Pred pred);
+ size_type
+ erase_if(Pred);
- inline static void
- erase_at(entry_pointer a_entries, size_type size, false_type);
+ inline void
+ erase_at(entry_pointer, size_type, false_type);
- inline static void
- erase_at(entry_pointer a_entries, size_type size, true_type);
+ inline void
+ erase_at(entry_pointer, size_type, true_type);
inline iterator
begin();
clear();
template<typename Pred>
- void
- split(Pred pred, PB_DS_CLASS_C_DEC& other);
+ void
+ split(Pred, binary_heap&);
void
- join(PB_DS_CLASS_C_DEC& other);
+ join(binary_heap&);
#ifdef PB_DS_BINARY_HEAP_TRACE_
void
trace() const;
-#endif
+#endif
protected:
-
template<typename It>
- void
- copy_from_range(It first_it, It last_it);
+ void
+ copy_from_range(It, It);
private:
-
void
- value_swap(PB_DS_CLASS_C_DEC& other);
-
- inline void
- insert_value(const_reference r_val, false_type);
+ value_swap(binary_heap&);
inline void
- insert_value(value_type val, true_type);
+ insert_value(const_reference, false_type);
inline void
- insert_entry(entry e);
+ insert_value(value_type, true_type);
inline void
resize_for_insert_if_needed();
inline void
- swap_value_imp(entry_pointer p_e, value_type new_val, true_type);
+ swap_value_imp(entry_pointer, value_type, true_type);
inline void
- swap_value_imp(entry_pointer p_e, const_reference r_new_val, false_type);
+ swap_value_imp(entry_pointer, const_reference, false_type);
void
- fix(entry_pointer p_e);
+ fix(entry_pointer);
inline const_reference
top_imp(true_type) const;
top_imp(false_type) const;
inline static size_type
- left_child(size_type i);
+ left_child(size_type);
inline static size_type
- right_child(size_type i);
+ right_child(size_type);
inline static size_type
- parent(size_type i);
+ parent(size_type);
inline void
resize_for_erase_if_needed();
template<typename Pred>
size_type
- partition(Pred pred);
+ partition(Pred);
-#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
-#endif
+ make_heap()
+ {
+ const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
+ entry_pointer end = m_a_entries + m_size;
+ std::make_heap(m_a_entries, end, m_cmp);
+ _GLIBCXX_DEBUG_ASSERT(is_heap());
+ }
-#ifdef PB_DS_BINARY_HEAP_TRACE_
void
- trace_entry(const entry& r_e, false_type) const;
+ push_heap()
+ {
+ if (!is_heap())
+ make_heap();
+ else
+ {
+ const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
+ entry_pointer end = m_a_entries + m_size;
+ std::push_heap(m_a_entries, end, m_cmp);
+ }
+ }
void
- trace_entry(const entry& r_e, true_type) const;
-#endif
+ pop_heap()
+ {
+ const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
+ entry_pointer end = m_a_entries + m_size;
+ std::pop_heap(m_a_entries, end, m_cmp);
+ }
+
+ bool
+ is_heap()
+ {
+ const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
+ entry_pointer end = m_a_entries + m_size;
+ bool p = std::__is_heap(m_a_entries, end, m_cmp);
+ return p;
+ }
- private:
- static entry_allocator s_entry_allocator;
-
- static value_allocator s_value_allocator;
+#ifdef _GLIBCXX_DEBUG
+ void
+ assert_valid(const char*, int) const;
+#endif
- static no_throw_copies_t s_no_throw_copies_ind;
+#ifdef PB_DS_BINARY_HEAP_TRACE_
+ void
+ trace_entry(const entry&, false_type) const;
- size_type m_size;
+ void
+ trace_entry(const entry&, true_type) const;
+#endif
- size_type m_actual_size;
+ static entry_allocator s_entry_allocator;
+ static value_allocator s_value_allocator;
+ static no_throw_copies_t s_no_throw_copies_ind;
- entry_pointer m_a_entries;
+ size_type m_size;
+ size_type m_actual_size;
+ entry_pointer m_a_entries;
};
+#define PB_DS_ASSERT_VALID(X) \
+ _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
+
+#define PB_DS_DEBUG_VERIFY(_Cond) \
+ _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
+ _M_message(#_Cond" assertion from %1;:%2;") \
+ ._M_string(__FILE__)._M_integer(__LINE__) \
+ ,__file,__line)
+
#include <ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp>
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// 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.
*/
#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)
// 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);
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;
}
{ ++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
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 const_point_iterator.hpp
- * Contains an iterator class returned by the table's const find and insert
- * methods.
- */
-
-#ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
-#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
-
-#include <ext/pb_ds/tag_and_trait.hpp>
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
- // Const point-type iterator.
- template<typename Value_Type, typename Entry, bool Simple,
- typename Allocator>
- class binary_heap_const_point_iterator_
- {
- protected:
- typedef typename Allocator::template rebind<Entry>::other::pointer entry_pointer;
-
- public:
- // Category.
- typedef trivial_iterator_tag iterator_category;
-
- // Difference type.
- typedef trivial_iterator_difference_type difference_type;
-
- // Iterator's value type.
- typedef Value_Type value_type;
-
- // Iterator's pointer type.
- typedef typename Allocator::template rebind<value_type>::other::pointer
- pointer;
-
- // Iterator's const pointer type.
- typedef
- typename Allocator::template rebind<value_type>::other::const_pointer
- const_pointer;
-
- // Iterator's reference type.
- typedef
- typename Allocator::template rebind<value_type>::other::reference
- reference;
-
- // Iterator's const reference type.
- typedef
- typename Allocator::template rebind<value_type>::other::const_reference
- const_reference;
-
- inline
- binary_heap_const_point_iterator_(entry_pointer p_e) : m_p_e(p_e)
- { }
-
- // Default constructor.
- inline
- binary_heap_const_point_iterator_() : m_p_e(0) { }
-
- // Copy constructor.
- inline
- binary_heap_const_point_iterator_(const binary_heap_const_point_iterator_& other)
- : m_p_e(other.m_p_e)
- { }
-
- // Access.
- inline const_pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
- return to_ptr(integral_constant<int, Simple>());
- }
-
- // Access.
- inline const_reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
- return *to_ptr(integral_constant<int, Simple>());
- }
-
- // Compares content to a different iterator object.
- inline bool
- operator==(const binary_heap_const_point_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
- { return m_p_e != other.m_p_e; }
-
- private:
- inline const_pointer
- to_ptr(true_type) const
- { return m_p_e; }
-
- inline const_pointer
- to_ptr(false_type) const
- { return *m_p_e; }
-
- public:
- entry_pointer m_p_e;
- };
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file binary_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for binary_heap_.
*/
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(...)
{
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)
}
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);
}
-
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file binary_heap_/debug_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
{
#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);
{
#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)]));
}
}
-#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
// warranty.
/**
- * @file entry_cmp.hpp
+ * @file binary_heap_/entry_cmp.hpp
* Contains an implementation class for a binary_heap.
*/
{
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
// warranty.
/**
- * @file entry_pred.hpp
+ * @file binary_heap_/entry_pred.hpp
* Contains an implementation class for a binary_heap.
*/
{
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
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file binary_heap_/erase_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
__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))
}
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;
{
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;
}
_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)
__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(...)
{ }
else
{
_GLIBCXX_DEBUG_ASSERT(left < right);
-
std::swap(m_a_entries[left], m_a_entries[right]);
-
++left;
--right;
}
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file binary_heap_/find_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!empty());
-
return top_imp(s_no_throw_copies_ind);
}
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; }
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file binary_heap_/info_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
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(); }
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file binary_heap_/insert_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
{
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);
}
insert_value(value_type val, true_type)
{
resize_for_insert_if_needed();
-
m_a_entries[m_size++] = val;
}
m_a_entries[m_size++] = p_new;
}
-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::
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
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
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;
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;
}
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
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file binary_heap_/iterators_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
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); }
--- /dev/null
+// -*- C++ -*-
+
+// 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
+// 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 binary_heap_/point_const_iterator.hpp
+ * Contains an iterator class returned by the table's const find and insert
+ * methods.
+ */
+
+#ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
+#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
+
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <debug/debug.h>
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+ // Const point-type iterator.
+ template<typename Value_Type, typename Entry, bool Simple,
+ typename _Alloc>
+ class binary_heap_point_const_iterator_
+ {
+ protected:
+ typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
+
+ public:
+ // Category.
+ typedef trivial_iterator_tag iterator_category;
+
+ // Difference type.
+ typedef trivial_iterator_difference_type difference_type;
+
+ // Iterator's value type.
+ typedef Value_Type value_type;
+
+ // Iterator's pointer type.
+ typedef typename _Alloc::template rebind<value_type>::other::pointer
+ pointer;
+
+ // Iterator's const pointer type.
+ typedef
+ typename _Alloc::template rebind<value_type>::other::const_pointer
+ const_pointer;
+
+ // Iterator's reference type.
+ typedef
+ typename _Alloc::template rebind<value_type>::other::reference
+ reference;
+
+ // Iterator's const reference type.
+ typedef
+ typename _Alloc::template rebind<value_type>::other::const_reference
+ const_reference;
+
+ inline
+ binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
+ { }
+
+ // Default constructor.
+ inline
+ binary_heap_point_const_iterator_() : m_p_e(0) { }
+
+ // Copy constructor.
+ inline
+ binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other)
+ : m_p_e(other.m_p_e)
+ { }
+
+ // Access.
+ inline const_pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
+ return to_ptr(integral_constant<int, Simple>());
+ }
+
+ // Access.
+ inline const_reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
+ return *to_ptr(integral_constant<int, Simple>());
+ }
+
+ // Compares content to a different iterator object.
+ inline bool
+ 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_point_const_iterator_& other) const
+ { return m_p_e != other.m_p_e; }
+
+ private:
+ inline const_pointer
+ to_ptr(true_type) const
+ { return m_p_e; }
+
+ inline const_pointer
+ to_ptr(false_type) const
+ { return *m_p_e; }
+
+ public:
+ entry_pointer m_p_e;
+ };
+ } // namespace detail
+} // namespace __gnu_pbds
+
+#endif
// warranty.
/**
- * @file policy_access_fn_imps.hpp
+ * @file binary_heap_/policy_access_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
// warranty.
/**
- * @file resize_policy.hpp
+ * @file binary_heap_/resize_policy.hpp
* Contains an implementation class for a binary_heap.
*/
{
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;
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();
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;
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
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file binary_heap_/split_join_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
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);
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;
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);
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);
}
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)
}
-
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file binary_heap_/trace_fn_imps.hpp
* Contains an implementation class for a binary_heap.
*/
{
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
// 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() { }
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file detail/binomial_heap_/debug_fn_imps.hpp
* Contains an implementation for binomial_heap_.
*/
// warranty.
/**
- * @file binomial_heap_base_.hpp
+ * @file binomial_heap_base_/binomial_heap_base_.hpp
* Contains an implementation class for a base of binomial heaps.
*/
#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;
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) \
#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
// 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.
*/
{
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
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()
{ }
-
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file binomial_heap_base_/debug_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
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);
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file binomial_heap_base_/erase_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
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)
}
_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;
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);
}
clear()
{
base_type::clear();
-
m_p_max = 0;
}
_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)
}
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;
}
-
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file binomial_heap_base_/find_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
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;
}
}
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file binomial_heap_base_/insert_fn_imps.hpp
* Contains an implementation class for a base of binomial heaps.
*/
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);
}
{
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;
}
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)
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)
}
-
// 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.
*/
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)
}
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);
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)
return p_ret;
}
-
--- /dev/null
+// -*- 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
--- /dev/null
+// -*- C++ -*-
+
+// 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
+// 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/null_node_metadata.hpp
+ * Contains an implementation class for tree-like classes.
+ */
+
+#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
+ {
+ /// 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
--- /dev/null
+// -*- 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
// warranty.
/**
- * @file cc_ht_map_.hpp
+ * @file cc_hash_table_map_/cc_ht_map_.hpp
* Contains an implementation class for cc_ht_map_.
*/
#include <ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
-#endif
+#endif
#ifdef PB_DS_HT_MAP_TRACE_
#include <iostream>
-#endif
+#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
+#ifdef PB_DS_DATA_TRUE_INDICATOR
+#define PB_DS_CC_HASH_NAME cc_ht_map
+#endif
+
+#ifdef PB_DS_DATA_FALSE_INDICATOR
+#define PB_DS_CC_HASH_NAME cc_ht_set
+#endif
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Hash_Fn, \
- typename Eq_Fn, typename Allocator, bool Store_Hash, \
+ typename Eq_Fn, typename _Alloc, bool Store_Hash, \
typename Comb_Hash_Fn, typename Resize_Policy>
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME cc_ht_map_data_
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME cc_ht_map_no_data_
-#endif
-
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Hash_Fn, Eq_Fn, Allocator, \
+ PB_DS_CC_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
Store_Hash, Comb_Hash_Fn, Resize_Policy>
#define PB_DS_HASH_EQ_FN_C_DEC \
- hash_eq_fn<Key, Eq_Fn, Allocator, Store_Hash>
+ hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
#define PB_DS_RANGED_HASH_FN_C_DEC \
- ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, Store_Hash>
+ ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, Store_Hash>
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits<Key, Mapped, Allocator, Store_Hash>
+#define PB_DS_CC_HASH_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, Store_Hash>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
- debug_map_base<Key, Eq_Fn, typename Allocator::template rebind<Key>::other::const_reference>
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
+ debug_map_base<Key, Eq_Fn, \
+ typename _Alloc::template rebind<Key>::other::const_reference>
#endif
- // <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813.
+ /// Collision chaining hash.
template<typename Key,
typename Mapped,
typename Hash_Fn,
typename Eq_Fn,
- typename Allocator,
+ typename _Alloc,
bool Store_Hash,
typename Comb_Hash_Fn,
typename Resize_Policy >
- class PB_DS_CLASS_NAME:
+ class PB_DS_CC_HASH_NAME:
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
+#endif
public PB_DS_HASH_EQ_FN_C_DEC,
public Resize_Policy,
public PB_DS_RANGED_HASH_FN_C_DEC,
- public PB_DS_TYPES_TRAITS_C_DEC
+ public PB_DS_CC_HASH_TRAITS_BASE
{
private:
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
- typedef typename traits_base::comp_hash comp_hash;
- typedef typename traits_base::value_type value_type_;
- typedef typename traits_base::pointer pointer_;
+ typedef PB_DS_CC_HASH_TRAITS_BASE traits_base;
+ typedef typename traits_base::comp_hash comp_hash;
+ typedef typename traits_base::value_type value_type_;
+ typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
- typedef typename traits_base::reference reference_;
+ typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
- struct entry : public traits_base::stored_value_type
+ struct entry : public traits_base::stored_data_type
{
- typename Allocator::template rebind<entry>::other::pointer m_p_next;
+ typename _Alloc::template rebind<entry>::other::pointer m_p_next;
};
- typedef cond_dealtor<entry, Allocator> cond_dealtor_t;
+ typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
- typedef typename Allocator::template rebind<entry>::other entry_allocator;
+ typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
- typedef typename Allocator::template rebind<entry_pointer>::other entry_pointer_allocator;
+ typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
typedef PB_DS_RANGED_HASH_FN_C_DEC ranged_hash_fn_base;
typedef Resize_Policy resize_base;
#ifdef _GLIBCXX_DEBUG
- typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+ typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
+#endif
-#define PB_DS_GEN_POS std::pair<entry_pointer, typename Allocator::size_type>
+#define PB_DS_GEN_POS std::pair<entry_pointer, typename _Alloc::size_type>
-#include <ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#undef PB_DS_GEN_POS
public:
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
- typedef Hash_Fn hash_fn;
- typedef Eq_Fn eq_fn;
- typedef Comb_Hash_Fn comb_hash_fn;
- typedef Resize_Policy resize_policy;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef Hash_Fn hash_fn;
+ typedef Eq_Fn eq_fn;
+ typedef Comb_Hash_Fn comb_hash_fn;
+ typedef Resize_Policy resize_policy;
enum
{
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
- typedef typename traits_base::const_key_pointer const_key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
- typedef typename traits_base::const_key_reference const_key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
- typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
- typedef typename traits_base::const_mapped_reference const_mapped_reference;
- typedef typename traits_base::value_type value_type;
- typedef typename traits_base::pointer pointer;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
+ typedef typename traits_base::value_type value_type;
+ typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
- typedef typename traits_base::reference reference;
+ typedef typename traits_base::reference reference;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef point_iterator_ point_iterator;
-#endif
+ typedef point_iterator_ point_iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_point_iterator_ point_iterator;
-#endif
+ typedef point_const_iterator_ point_iterator;
+#endif
- typedef const_point_iterator_ const_point_iterator;
+ typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef iterator_ iterator;
-#endif
+ typedef iterator_ iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_iterator_ iterator;
-#endif
+ typedef const_iterator_ iterator;
+#endif
- typedef const_iterator_ const_iterator;
+ typedef const_iterator_ const_iterator;
- PB_DS_CLASS_NAME();
+ PB_DS_CC_HASH_NAME();
- PB_DS_CLASS_NAME(const Hash_Fn&);
+ PB_DS_CC_HASH_NAME(const Hash_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&);
+ PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&);
+ PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&,
+ PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&,
const Resize_Policy&);
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC&);
virtual
- ~PB_DS_CLASS_NAME();
+ ~PB_DS_CC_HASH_NAME();
void
swap(PB_DS_CLASS_C_DEC&);
inline bool
empty() const;
- Hash_Fn&
+ Hash_Fn&
get_hash_fn();
- const Hash_Fn&
+ const Hash_Fn&
get_hash_fn() const;
- Eq_Fn&
+ Eq_Fn&
get_eq_fn();
- const Eq_Fn&
+ const Eq_Fn&
get_eq_fn() const;
- Comb_Hash_Fn&
+ Comb_Hash_Fn&
get_comb_hash_fn();
- const Comb_Hash_Fn&
+ const Comb_Hash_Fn&
get_comb_hash_fn() const;
- Resize_Policy&
+ Resize_Policy&
get_resize_policy();
- const Resize_Policy&
+ const Resize_Policy&
get_resize_policy() const;
inline std::pair<point_iterator, bool>
{ return insert_imp(r_val, traits_base::m_store_extra_indicator); }
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return (subscript_imp(r_key, traits_base::m_store_extra_indicator));
-#else
+#else
insert(r_key);
- return traits_base::s_null_mapped;
-#endif
+ return traits_base::s_null_type;
+#endif
}
inline point_iterator
- find(const_key_reference);
+ find(key_const_reference);
- inline const_point_iterator
- find(const_key_reference) const;
+ inline point_const_iterator
+ find(key_const_reference) const;
inline point_iterator
find_end();
- inline const_point_iterator
+ inline point_const_iterator
find_end() const;
inline bool
- erase(const_key_reference);
+ erase(key_const_reference);
template<typename Pred>
inline 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_HT_MAP_TRACE_
void
trace() const;
-#endif
+#endif
private:
void
do_resize_if_needed_no_throw();
void
- resize_imp(size_type new_size);
+ resize_imp(size_type);
void
- do_resize(size_type new_size);
+ do_resize(size_type);
void
resize_imp_no_exceptions(size_type, entry_pointer_array, size_type);
inline entry_pointer
- resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, false_type);
+ resize_imp_no_exceptions_reassign_pointer(entry_pointer,
+ entry_pointer_array,
+ false_type);
inline entry_pointer
- resize_imp_no_exceptions_reassign_pointer(entry_pointer, entry_pointer_array, true_type);
+ resize_imp_no_exceptions_reassign_pointer(entry_pointer,
+ entry_pointer_array,
+ true_type);
void
deallocate_links_in_list(entry_pointer);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline mapped_reference
- subscript_imp(const_key_reference r_key, false_type)
+ subscript_imp(key_const_reference r_key, false_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
- const size_type pos = ranged_hash_fn_base::operator()(r_key);
+ const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
- while (p_e != 0
+ while (p_e != 0
&& !hash_eq_fn_base::operator()(p_e->m_value.first, r_key))
{
resize_base::notify_insert_search_collision();
}
inline mapped_reference
- subscript_imp(const_key_reference r_key, true_type)
+ subscript_imp(key_const_reference r_key, true_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start();
- while (p_e != 0 &&
- !hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second))
+ while (p_e != 0 &&
+ !hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash,
+ r_key, pos_hash_pair.second))
{
resize_base::notify_insert_search_collision();
p_e = p_e->m_p_next;
}
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
- return insert_new_imp(value_type(r_key, mapped_type()),
+ return insert_new_imp(value_type(r_key, mapped_type()),
pos_hash_pair)->second;
}
-#endif
+#endif
inline std::pair<point_iterator, bool>
insert_imp(const_reference, false_type);
pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
// Following lines might throw an exception.
- entry_pointer p_e = get_entry(r_val, traits_base::m_no_throw_copies_indicator);
+ entry_pointer p_e = get_entry(r_val,
+ traits_base::m_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_p_next = m_entries[pos];
if (do_resize_if_needed())
r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
- entry_pointer p_e = get_entry(r_val, traits_base::m_no_throw_copies_indicator);
+ entry_pointer p_e = get_entry(r_val,
+ traits_base::m_no_throw_copies_indicator);
// At this point no exceptions can be thrown.
p_e->m_hash = r_pos_hash_pair.second;
}
inline pointer
- find_key_pointer(const_key_reference r_key, false_type)
+ find_key_pointer(key_const_reference r_key, false_type)
{
entry_pointer p_e = m_entries[ranged_hash_fn_base::operator()(r_key)];
resize_base::notify_find_search_start();
- while (p_e != 0 &&
+ while (p_e != 0 &&
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
{
resize_base::notify_find_search_collision();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
PB_DS_CHECK_KEY_EXISTS(r_key)
-#endif
+#endif
return &p_e->m_value;
}
inline pointer
- find_key_pointer(const_key_reference r_key, true_type)
+ find_key_pointer(key_const_reference r_key, true_type)
{
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_find_search_start();
- while (p_e != 0 &&
+ while (p_e != 0 &&
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
p_e->m_hash,
r_key, pos_hash_pair.second))
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
else
PB_DS_CHECK_KEY_EXISTS(r_key)
-#endif
+#endif
return &p_e->m_value;
}
inline bool
- erase_in_pos_imp(const_key_reference, size_type);
+ erase_in_pos_imp(key_const_reference, size_type);
inline bool
- erase_in_pos_imp(const_key_reference, const comp_hash&);
+ erase_in_pos_imp(key_const_reference, const comp_hash&);
inline void
erase_entry_pointer(entry_pointer&);
#ifdef PB_DS_DATA_TRUE_INDICATOR
void
- inc_it_state(pointer& r_p_value,
+ inc_it_state(pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
- inc_it_state((const_mapped_pointer& )r_p_value, r_pos);
+ inc_it_state((mapped_const_pointer& )r_p_value, r_pos);
}
-#endif
+#endif
void
- inc_it_state(const_pointer& r_p_value,
+ inc_it_state(const_pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
_GLIBCXX_DEBUG_ASSERT(r_p_value != 0);
}
void
- get_start_it_state(pointer& r_p_value,
+ get_start_it_state(pointer& r_p_value,
std::pair<entry_pointer, size_type>& r_pos) const
{
for (r_pos.second = 0; r_pos.second < m_num_e; ++r_pos.second)
#ifdef _GLIBCXX_DEBUG
void
assert_entry_pointer_array_valid(const entry_pointer_array,
- const char* file, int line) const;
+ const char*, int) const;
void
assert_entry_pointer_valid(const entry_pointer, true_type,
- const char* file, int line) const;
+ const char*, int) const;
void
assert_entry_pointer_valid(const entry_pointer, false_type,
- const char* file, int line) const;
-#endif
+ const char*, int) const;
+#endif
#ifdef PB_DS_HT_MAP_TRACE_
void
trace_list(const_entry_pointer) const;
-#endif
+#endif
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
-#endif
+#endif
friend class const_iterator_;
static iterator s_end_it;
static const_iterator s_const_end_it;
static point_iterator s_find_end_it;
- static const_point_iterator s_const_find_end_it;
+ static point_const_iterator s_const_find_end_it;
size_type m_num_e;
size_type m_num_used_e;
enum
{
- store_hash_ok = !Store_Hash
- || !is_same<Hash_Fn, __gnu_pbds::null_hash_fn>::value
+ store_hash_ok = !Store_Hash
+ || !is_same<Hash_Fn, __gnu_pbds::null_type>::value
};
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
#undef PB_DS_RANGED_HASH_FN_C_DEC
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_CC_HASH_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_V2F
-#undef PB_DS_V2S
-
+#undef PB_DS_CC_HASH_NAME
} // namespace detail
} // namespace __gnu_pbds
-
// warranty.
/**
- * @file cmp_fn_imps.hpp
+ * @file cc_hash_table_map_/cmp_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container comparison related
* functions.
*/
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
- const_key_reference r_key = const_key_reference(PB_DS_V2F(*it));
+ key_const_reference r_key = key_const_reference(PB_DS_V2F(*it));
- const_mapped_pointer p_mapped_value =
+ mapped_const_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 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
// warranty.
/**
- * @file cond_key_dtor_entry_dealtor.hpp
+ * @file cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp
* Contains a conditional key destructor, used for exception handling.
*/
{
namespace detail
{
-
-#define PB_DS_CLASS_T_DEC template<typename HT_Map>
-#define PB_DS_CLASS_C_DEC PB_DS_CKDED_CLASS_NAME<HT_Map>
-
- /**
- * A conditional key destructor, used for exception handling.
- **/
+ /// Conditional dey destructor, cc_hash.
template<typename HT_Map>
- class PB_DS_CKDED_CLASS_NAME
+ class cond_dealtor
{
public:
- typedef typename HT_Map::entry entry;
- typedef typename HT_Map::entry_allocator entry_allocator;
- typedef typename HT_Map::key_type key_type;
+ typedef typename HT_Map::entry entry;
+ typedef typename HT_Map::entry_allocator entry_allocator;
+ typedef typename HT_Map::key_type key_type;
- inline
- PB_DS_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e);
+ cond_dealtor(entry_allocator* p_a, entry* p_e)
+ : m_p_a(p_a), m_p_e(p_e), m_key_destruct(false),
+ m_no_action_destructor(false)
+ { }
inline
- ~PB_DS_CKDED_CLASS_NAME();
+ ~cond_dealtor();
- inline void
- set_key_destruct();
+ void
+ set_key_destruct()
+ { m_key_destruct = true; }
- inline void
- set_no_action_destructor();
+ void
+ set_no_action_destructor()
+ { m_no_action_destructor = true; }
protected:
- entry_allocator* const m_p_a;
- entry* const m_p_e;
+ entry_allocator* const m_p_a;
+ entry* const m_p_e;
- bool m_key_destruct;
- bool m_no_action_destructor;
+ bool m_key_destruct;
+ bool m_no_action_destructor;
};
- PB_DS_CLASS_T_DEC
- inline
- PB_DS_CLASS_C_DEC::
- PB_DS_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e)
- : m_p_a(p_a), m_p_e(p_e), m_key_destruct(false),
- m_no_action_destructor(false)
- { }
-
- PB_DS_CLASS_T_DEC
- inline void
- PB_DS_CLASS_C_DEC::
- set_key_destruct()
- { m_key_destruct = true; }
-
- PB_DS_CLASS_T_DEC
- inline void
- PB_DS_CLASS_C_DEC::
- set_no_action_destructor()
- { m_no_action_destructor = true; }
-
- PB_DS_CLASS_T_DEC
+ template<typename HT_Map>
inline
- PB_DS_CLASS_C_DEC::
- ~PB_DS_CKDED_CLASS_NAME()
+ cond_dealtor<HT_Map>::
+ ~cond_dealtor()
{
if (m_no_action_destructor)
return;
m_p_e->m_value.first.~key_type();
m_p_a->deallocate(m_p_e, 1);
}
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
} // namespace detail
} // namespace __gnu_pbds
-
// warranty.
/**
- * @file constructor_destructor_fn_imps.hpp
+ * @file cc_hash_table_map_/constructor_destructor_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
- * and related functions.
+ * and related functions.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME() :
+PB_DS_CC_HASH_NAME() :
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) :
+PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn) :
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
+PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) :
+PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
+ const Comb_Hash_Fn& r_comb_hash_fn) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
r_hash_fn, r_comb_hash_fn),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn, const Resize_Policy& r_resize_policy) :
+PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
+ const Comb_Hash_Fn& r_comb_hash_fn,
+ const Resize_Policy& r_resize_policy) :
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
Resize_Policy(r_resize_policy),
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
PB_DS_HASH_EQ_FN_C_DEC(other),
resize_base(other), ranged_hash_fn_base(other),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
PB_DS_ASSERT_VALID((*this))
__try
{
- copy_from_range(other.begin(), other.end());
+ copy_from_range(other.begin(), other.end());
}
__catch(...)
{
- deallocate_all();
- __throw_exception_again;
+ deallocate_all();
+ __throw_exception_again;
}
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~PB_DS_CLASS_NAME()
+~PB_DS_CC_HASH_NAME()
{ deallocate_all(); }
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file constructor_destructor_no_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
+constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
false_type)
{
// Following lines might throw an exception.
// warranty.
/**
- * @file constructor_destructor_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s constructors, destructor,
- * and related functions.
+ * and related functions.
*/
PB_DS_CLASS_T_DEC
// At this point no exceptions can be thrown.
p->m_p_next = m_entries[pos];
- p->m_hash = ranged_hash_fn_base::operator()((const_key_reference)(PB_DS_V2F(p->m_value))).second;
+ p->m_hash = ranged_hash_fn_base::operator()((key_const_reference)(PB_DS_V2F(p->m_value))).second;
m_entries[pos] = p;
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);)
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file cc_hash_table_map_/debug_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
// warranty.
/**
- * @file debug_no_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
const char* __file, int __line) const
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); }
-#endif
+#endif
// warranty.
/**
- * @file debug_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/debug_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
// warranty.
/**
- * @file entry_list_fn_imps.hpp
+ * @file cc_hash_table_map_/entry_list_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entry-list related functions.
*/
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file cc_hash_table_map_/erase_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions.
*/
// warranty.
/**
- * @file erase_no_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase_in_pos_imp(const_key_reference r_key, size_type pos)
+erase_in_pos_imp(key_const_reference r_key, size_type pos)
{
PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[pos];
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == 0)
- {
+ {
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
- PB_DS_ASSERT_VALID((*this))
- return false;
- }
+ PB_DS_ASSERT_VALID((*this))
+ return false;
+ }
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
- {
+ {
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
- erase_entry_pointer(p_e->m_p_next);
+ erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
- return true;
- }
+ return true;
+ }
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
-
// warranty.
/**
- * @file erase_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/erase_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair)
+erase_in_pos_imp(key_const_reference r_key, const comp_hash& r_pos_hash_pair)
{
PB_DS_ASSERT_VALID((*this))
entry_pointer p_e = m_entries[r_pos_hash_pair.first];
{
entry_pointer p_next_e = p_e->m_p_next;
if (p_next_e == 0)
- {
+ {
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
- PB_DS_ASSERT_VALID((*this))
- return false;
- }
+ PB_DS_ASSERT_VALID((*this))
+ return false;
+ }
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value),
p_next_e->m_hash, r_key,
r_pos_hash_pair.second))
- {
+ {
resize_base::notify_erase_search_end();
PB_DS_CHECK_KEY_EXISTS(r_key)
- erase_entry_pointer(p_e->m_p_next);
+ erase_entry_pointer(p_e->m_p_next);
do_resize_if_needed_no_throw();
PB_DS_ASSERT_VALID((*this))
- return true;
- }
+ return true;
+ }
resize_base::notify_erase_search_collision();
p_e = p_next_e;
}
}
-
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file cc_hash_table_map_/find_fn_imps.hpp
* Contains implementations of cc_ht_map_'s find related functions.
*/
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_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
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_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key,
{ return 0; }
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_end() const
{ return 0; }
// warranty.
/**
- * @file find_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/find_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s find related functions,
* when the hash value is stored.
*/
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file cc_hash_table_map_/info_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container info related
* functions.
*/
for (typename Other_Map_Type::const_iterator it = other.begin();
it != other.end(); ++it)
{
- const_key_reference r_key =(const_key_reference)PB_DS_V2F(*it);
- const_mapped_pointer p_mapped_value =
+ key_const_reference r_key =(key_const_reference)PB_DS_V2F(*it);
+ mapped_const_pointer p_mapped_value =
const_cast<PB_DS_CLASS_C_DEC& >(*this).
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file cc_hash_table_map_/insert_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions.
*/
// warranty.
/**
- * @file insert_no_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
insert_imp(const_reference r_val, false_type)
{
PB_DS_ASSERT_VALID((*this))
- const_key_reference r_key = PB_DS_V2F(r_val);
+ key_const_reference r_key = PB_DS_V2F(r_val);
const size_type pos = ranged_hash_fn_base::operator()(r_key);
entry_pointer p_e = m_entries[pos];
resize_base::notify_insert_search_start();
// warranty.
/**
- * @file insert_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/insert_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s insert related functions,
* when the hash value is stored.
*/
insert_imp(const_reference r_val, true_type)
{
PB_DS_ASSERT_VALID((*this))
- const_key_reference key = PB_DS_V2F(r_val);
+ key_const_reference key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key);
entry_pointer p_e = m_entries[pos_hash_pair.first];
resize_base::notify_insert_search_start();
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file cc_hash_table_map_/iterators_fn_imps.hpp
* Contains implementations of cc_ht_map_'s iterators related functions, e.g.,
* begin().
*/
// warranty.
/**
- * @file policy_access_fn_imps.hpp
+ * @file cc_hash_table_map_/policy_access_fn_imps.hpp
* Contains implementations of cc_ht_map_'s policy access
* functions.
*/
// warranty.
/**
- * @file resize_fn_imps.hpp
+ * @file cc_hash_table_map_/resize_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions.
*/
// warranty.
/**
- * @file resize_no_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions, when the
- * hash value is not stored.
+ * hash value is not stored.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file resize_store_hash_fn_imps.hpp
+ * @file cc_hash_table_map_/resize_store_hash_fn_imps.hpp
* Contains implementations of cc_ht_map_'s resize related functions, when the
- * hash value is stored.
+ * hash value is stored.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file size_fn_imps.hpp
+ * @file cc_hash_table_map_/size_fn_imps.hpp
* Contains implementations of cc_ht_map_'s entire container size related
- * functions.
+ * functions.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file standard_policies.hpp
+ * @file cc_hash_table_map_/standard_policies.hpp
* Contains standard policies for cc_ht_map types.
*/
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file cc_hash_table_map_/trace_fn_imps.hpp
* Contains implementations of cc_ht_map_'s trace-mode functions.
*/
// -*- 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
// warranty.
/**
- * @file cond_dealtor.hpp
+ * @file detail/cond_dealtor.hpp
* Contains a conditional deallocator.
*/
namespace __gnu_pbds
{
-
namespace detail
{
-
-#define PB_DS_COND_DEALTOR_CLASS_T_DEC \
- template<typename Entry, class Allocator>
-
-#define PB_DS_COND_DEALTOR_CLASS_C_DEC \
- cond_dealtor< \
- Entry, \
- Allocator>
-
- template<typename Entry, class Allocator>
- class cond_dealtor
- {
- public:
- typedef
- typename Allocator::template rebind<Entry>::other
- entry_allocator;
-
- typedef typename entry_allocator::pointer entry_pointer;
-
- public:
- inline
- cond_dealtor(entry_pointer p_e);
-
- inline
- ~cond_dealtor();
-
- inline void
- set_no_action();
-
- private:
- entry_pointer m_p_e;
-
- bool m_no_action_destructor;
-
- static entry_allocator s_alloc;
- };
-
- PB_DS_COND_DEALTOR_CLASS_T_DEC
- typename PB_DS_COND_DEALTOR_CLASS_C_DEC::entry_allocator
- PB_DS_COND_DEALTOR_CLASS_C_DEC::s_alloc;
-
- PB_DS_COND_DEALTOR_CLASS_T_DEC
- inline
- PB_DS_COND_DEALTOR_CLASS_C_DEC::
- cond_dealtor(entry_pointer p_e) :
- m_p_e(p_e),
- m_no_action_destructor(false)
- { }
-
- PB_DS_COND_DEALTOR_CLASS_T_DEC
- inline void
- PB_DS_COND_DEALTOR_CLASS_C_DEC::
- set_no_action()
- {
- m_no_action_destructor = true;
- }
-
- PB_DS_COND_DEALTOR_CLASS_T_DEC
- inline
- PB_DS_COND_DEALTOR_CLASS_C_DEC::
- ~cond_dealtor()
- {
- if (m_no_action_destructor)
- return;
-
- s_alloc.deallocate(m_p_e, 1);
- }
-
-#undef PB_DS_COND_DEALTOR_CLASS_T_DEC
-#undef PB_DS_COND_DEALTOR_CLASS_C_DEC
-
+ /// Conditional deallocate constructor argument.
+ template<typename Entry, typename _Alloc>
+ class cond_dealtor
+ {
+ typedef typename _Alloc::template rebind<Entry> __rebind_e;
+
+ public:
+ typedef typename __rebind_e::other entry_allocator;
+ typedef typename entry_allocator::pointer entry_pointer;
+
+ cond_dealtor(entry_pointer p_e)
+ : m_p_e(p_e), m_no_action_destructor(false) { }
+
+ ~cond_dealtor()
+ {
+ if (m_no_action_destructor)
+ return;
+ s_alloc.deallocate(m_p_e, 1);
+ }
+
+ void
+ set_no_action()
+ { m_no_action_destructor = true; }
+
+ private:
+ entry_pointer m_p_e;
+ bool m_no_action_destructor;
+ static entry_allocator s_alloc;
+ };
+
+ template<typename Entry, class _Alloc>
+ typename cond_dealtor<Entry, _Alloc>::entry_allocator
+ cond_dealtor<Entry, _Alloc>::s_alloc;
} // namespace detail
-
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_COND_DEALTOR_HPP
-
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file detail/constructors_destructor_fn_imps.hpp
* Contains constructors_destructor_fn_imps applicable to different containers.
*/
// -*- 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
/**
* @file container_base_dispatch.hpp
- * Contains an associative container dispatching base.
+ * Contains associative container dispatching.
*/
#ifndef PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
__FILE__, __LINE__);)
#define PB_DS_DATA_TRUE_INDICATOR
+#define PB_DS_V2F(X) (X).first
+#define PB_DS_V2S(X) (X).second
+#define PB_DS_EP2VP(X)& ((X)->m_value)
#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
-#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
+#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
-#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
-#undef PB_DS_DATA_TRUE_INDICATOR
-
-#define PB_DS_DATA_FALSE_INDICATOR
#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
-#undef PB_DS_DATA_FALSE_INDICATOR
-
-#define PB_DS_DATA_TRUE_INDICATOR
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
#undef PB_DS_DATA_TRUE_INDICATOR
+#undef PB_DS_V2F
+#undef PB_DS_V2S
+#undef PB_DS_EP2VP
#define PB_DS_DATA_FALSE_INDICATOR
+#define PB_DS_V2F(X) (X)
+#define PB_DS_V2S(X) Mapped_Data()
+#define PB_DS_EP2VP(X)& ((X)->m_value.first)
+#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
+#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
+#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
+#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
+#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
+#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
+#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
#undef PB_DS_DATA_FALSE_INDICATOR
+#undef PB_DS_V2F
+#undef PB_DS_V2S
+#undef PB_DS_EP2VP
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
#undef PB_DS_CHECK_KEY_EXISTS
{
namespace detail
{
- // Primary template.
- template<typename Key, typename Mapped, typename Data_Structure_Taq,
- typename Policy_Tl, typename Alloc>
- struct container_base_dispatch;
-
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, list_update_tag,
- Policy_Tl, Alloc>
+ /// Specialization for list-update map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, list_update_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at0::type at0t;
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
-
+
public:
- typedef lu_map_data_<Key, Mapped, at0t, Alloc, at1t> type;
+ /// Dispatched type.
+ typedef lu_map<Key, Mapped, at0t, _Alloc, at1t> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, list_update_tag,
- Policy_Tl, Alloc>
+ /// Specialization for list-update set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, list_update_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef lu_map_no_data_<Key, null_mapped_type, at0t, Alloc, at1t> type;
+ /// Dispatched type.
+ typedef lu_set<Key, null_type, at0t, _Alloc, at1t> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, pat_trie_tag, Policy_Tl, Alloc>
+ /// Specialization for PATRICIA trie map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, pat_trie_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
- typedef pat_trie_data_<Key, Mapped, at1t, Alloc> type;
+ typedef pat_trie_map<Key, Mapped, at1t, _Alloc> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, pat_trie_tag,
- Policy_Tl, Alloc>
+ /// Specialization for PATRICIA trie set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, pat_trie_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
typedef typename at1::type at1t;
public:
- typedef pat_trie_no_data_<Key, null_mapped_type, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef pat_trie_set<Key, null_type, at1t, _Alloc> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, rb_tree_tag, Policy_Tl, Alloc>
+ /// Specialization for R-B tree map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, rb_tree_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef rb_tree_data_<Key, Mapped, at0t, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef rb_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, rb_tree_tag,
- Policy_Tl, Alloc>
+ /// Specialization for R-B tree set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, rb_tree_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef rb_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
+ typedef rb_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, splay_tree_tag,
- Policy_Tl, Alloc>
+ /// Specialization splay tree map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, splay_tree_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef splay_tree_data_<Key, Mapped, at0t, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef splay_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, splay_tree_tag,
- Policy_Tl, Alloc>
+ /// Specialization splay tree set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, splay_tree_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef splay_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef splay_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, ov_tree_tag, Policy_Tl, Alloc>
+ /// Specialization ordered-vector tree map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, ov_tree_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef ov_tree_data_<Key, Mapped, at0t, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef ov_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, ov_tree_tag,
- Policy_Tl, Alloc>
+ /// Specialization ordered-vector tree set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, ov_tree_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at1::type at1t;
public:
- typedef ov_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
+ /// Dispatched type.
+ typedef ov_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, cc_hash_tag, Policy_Tl, Alloc>
+ /// Specialization colision-chaining hash map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, cc_hash_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at4::type at4t;
public:
- typedef cc_ht_map_data_<Key, Mapped, at0t, at1t, Alloc, at3t::value,
- at4t, at2t> type;
+ /// Dispatched type.
+ typedef cc_ht_map<Key, Mapped, at0t, at1t, _Alloc,
+ at3t::value, at4t, at2t> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, cc_hash_tag,
- Policy_Tl, Alloc>
+ /// Specialization colision-chaining hash set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, cc_hash_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at4::type at4t;
public:
- typedef cc_ht_map_no_data_<Key, null_mapped_type, at0t, at1t, Alloc,
+ /// Dispatched type.
+ typedef cc_ht_set<Key, null_type, at0t, at1t, _Alloc,
at3t::value, at4t, at2t> type;
};
- template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, Mapped, gp_hash_tag, Policy_Tl, Alloc>
+ /// Specialization general-probe hash map.
+ template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, Mapped, _Alloc, gp_hash_tag, Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at5::type at5t;
public:
- typedef gp_ht_map_data_<Key, Mapped, at0t, at1t, Alloc, at3t::value,
- at4t, at5t, at2t> type;
+ /// Dispatched type.
+ typedef gp_ht_map<Key, Mapped, at0t, at1t, _Alloc,
+ at3t::value, at4t, at5t, at2t> type;
};
- template<typename Key, typename Policy_Tl, typename Alloc>
- struct container_base_dispatch<Key, null_mapped_type, gp_hash_tag,
- Policy_Tl, Alloc>
+ /// Specialization general-probe hash set.
+ template<typename Key, typename _Alloc, typename Policy_Tl>
+ struct container_base_dispatch<Key, null_type, _Alloc, gp_hash_tag,
+ Policy_Tl>
{
private:
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
typedef typename at5::type at5t;
public:
- typedef gp_ht_map_no_data_<Key, null_mapped_type, at0t, at1t, Alloc,
- at3t::value, at4t, at5t, at2t> type;
+ /// Dispatched type.
+ typedef gp_ht_set<Key, null_type, at0t, at1t, _Alloc,
+ at3t::value, at4t, at5t, at2t> type;
};
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// warranty.
/**
- * @file debug_map_base.hpp
+ * @file detail/debug_map_base.hpp
* Contains a debug-mode base for all maps.
*/
{ return (__out << '(' << p.first << ',' << p.second << ')'); }
#define PB_DS_CLASS_T_DEC \
- template<typename Key, class Eq_Fn, typename Const_Key_Reference>
+ template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
#define PB_DS_CLASS_C_DEC \
debug_map_base<Key, Eq_Fn, Const_Key_Reference>
- template<typename Key, class Eq_Fn, typename Const_Key_Reference>
+ /// Debug base class.
+ template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
class debug_map_base
{
private:
- typedef typename std::allocator<Key> key_allocator;
- typedef typename key_allocator::size_type size_type;
- typedef Const_Key_Reference const_key_reference;
- typedef std::_GLIBCXX_STD_C::list<Key> key_set;
- typedef typename key_set::iterator key_set_iterator;
- typedef typename key_set::const_iterator const_key_set_iterator;
- typedef __gnu_cxx::throw_allocator_random<Key> key_db_allocator;
- typedef typename key_db_allocator::never_adjustor never_adjustor;
+ typedef Const_Key_Reference key_const_reference;
+ typedef std::_GLIBCXX_STD_C::list<Key> key_repository;
+ typedef typename key_repository::size_type size_type;
+ typedef typename key_repository::iterator iterator;
+ typedef typename key_repository::const_iterator const_iterator;
protected:
debug_map_base();
- debug_map_base(const PB_DS_CLASS_C_DEC& other);
+ debug_map_base(const PB_DS_CLASS_C_DEC&);
~debug_map_base();
inline void
- insert_new(const_key_reference r_key);
+ insert_new(key_const_reference);
inline void
- erase_existing(const_key_reference r_key);
+ erase_existing(key_const_reference);
void
clear();
inline void
- check_key_exists(const_key_reference r_key,
- const char* file, int line) const;
+ check_key_exists(key_const_reference, const char*, int) const;
inline void
- check_key_does_not_exist(const_key_reference r_key,
- const char* file, int line) const;
+ check_key_does_not_exist(key_const_reference, const char*, int) const;
inline void
- check_size(size_type size, const char* file, int line) const;
+ check_size(size_type, const char*, int) const;
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
template<typename Cmp_Fn>
void
- split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
+ split(key_const_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
void
- join(PB_DS_CLASS_C_DEC& other, bool with_cleanup = true);
+ join(PB_DS_CLASS_C_DEC&, bool with_cleanup = true);
private:
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
- const_key_set_iterator
- find(const_key_reference r_key) const;
+ const_iterator
+ find(key_const_reference) const;
- key_set_iterator
- find(const_key_reference r_key);
+ iterator
+ find(key_const_reference);
- key_set m_key_set;
- Eq_Fn m_eq;
+ key_repository m_keys;
+ Eq_Fn m_eq;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
- debug_map_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set)
+ debug_map_base(const PB_DS_CLASS_C_DEC& other)
+ : m_keys(other.m_keys), m_eq(other.m_eq)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
- insert_new(const_key_reference r_key)
+ insert_new(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
- if (find(r_key) != m_key_set.end())
+ if (find(r_key) != m_keys.end())
{
std::cerr << "insert_new key already present " << r_key << std::endl;
- std::abort;
+ std::abort();
}
- never_adjustor never;
__try
{
- m_key_set.push_back(r_key);
+ m_keys.push_back(r_key);
}
__catch(...)
{
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
- erase_existing(const_key_reference r_key)
+ erase_existing(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
- key_set_iterator it = find(r_key);
- if (it == m_key_set.end())
+ iterator it = find(r_key);
+ if (it == m_keys.end())
{
std::cerr << "erase_existing" << r_key << std::endl;
std::abort();
}
- m_key_set.erase(it);
+ m_keys.erase(it);
PB_DS_ASSERT_VALID((*this))
}
clear()
{
PB_DS_ASSERT_VALID((*this))
- m_key_set.clear();
+ m_keys.clear();
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
- check_key_exists(const_key_reference r_key,
+ check_key_exists(key_const_reference r_key,
const char* __file, int __line) const
{
assert_valid(__file, __line);
- if (find(r_key) == m_key_set.end())
+ if (find(r_key) == m_keys.end())
{
std::cerr << __file << ':' << __line << ": check_key_exists "
<< r_key << std::endl;
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
- check_key_does_not_exist(const_key_reference r_key,
+ check_key_does_not_exist(key_const_reference r_key,
const char* __file, int __line) const
{
assert_valid(__file, __line);
- if (find(r_key) != m_key_set.end())
+ if (find(r_key) != m_keys.end())
{
using std::cerr;
using std::endl;
check_size(size_type size, const char* __file, int __line) const
{
assert_valid(__file, __line);
- const size_type key_set_size = m_key_set.size();
- if (size != key_set_size)
+ const size_type keys_size = m_keys.size();
+ if (size != keys_size)
{
- std::cerr << __file << ':' << __line << ": check_size " << size
- << " != " << key_set_size << std::endl;
+ std::cerr << __file << ':' << __line << ": check_size "
+ << size << " != " << keys_size << std::endl;
std::abort();
}
}
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
- m_key_set.swap(other.m_key_set);
+ m_keys.swap(other.m_keys);
+ std::swap(m_eq, other.m_eq);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_key_set_iterator
+ typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
- find(const_key_reference r_key) const
+ find(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
- typedef const_key_set_iterator iterator_type;
- for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it)
+ typedef const_iterator iterator_type;
+ for (iterator_type it = m_keys.begin(); it != m_keys.end(); ++it)
if (m_eq(*it, r_key))
return it;
- return m_key_set.end();
+ return m_keys.end();
}
PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::key_set_iterator
+ typename PB_DS_CLASS_C_DEC::iterator
PB_DS_CLASS_C_DEC::
- find(const_key_reference r_key)
+ find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
- key_set_iterator it = m_key_set.begin();
- while (it != m_key_set.end())
+ iterator it = m_keys.begin();
+ while (it != m_keys.end())
{
if (m_eq(*it, r_key))
return it;
PB_DS_CLASS_C_DEC::
assert_valid(const char* __file, int __line) const
{
- const_key_set_iterator prime_it = m_key_set.begin();
- while (prime_it != m_key_set.end())
+ const_iterator prime_it = m_keys.begin();
+ while (prime_it != m_keys.end())
{
- const_key_set_iterator sec_it = prime_it;
+ const_iterator sec_it = prime_it;
++sec_it;
- while (sec_it != m_key_set.end())
+ while (sec_it != m_keys.end())
{
PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it));
PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it));
template<typename Cmp_Fn>
void
PB_DS_CLASS_C_DEC::
- split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
+ split(key_const_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
{
other.clear();
- key_set_iterator it = m_key_set.begin();
- while (it != m_key_set.end())
- if (cmp_fn(r_key, * it))
+ iterator it = m_keys.begin();
+ while (it != m_keys.end())
+ if (cmp_fn(r_key, *it))
{
other.insert_new(*it);
- it = m_key_set.erase(it);
+ it = m_keys.erase(it);
}
else
++it;
PB_DS_CLASS_C_DEC::
join(PB_DS_CLASS_C_DEC& other, bool with_cleanup)
{
- key_set_iterator it = other.m_key_set.begin();
- while (it != other.m_key_set.end())
+ iterator it = other.m_keys.begin();
+ while (it != other.m_keys.end())
{
insert_new(*it);
if (with_cleanup)
- it = other.m_key_set.erase(it);
+ it = other.m_keys.erase(it);
else
++it;
}
- _GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_key_set.empty());
+ _GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_keys.empty());
}
#undef PB_DS_CLASS_T_DEC
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
{
namespace detail
{
+ /// Equivalence function.
template<typename Key, class Cmp_Fn>
struct eq_by_less : private Cmp_Fn
{
// -*- 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
/**
* @file hash_eq_fn.hpp
* Contains 2 eqivalence functions, one employing a hash value,
- * and one ignoring it.
+ * and one ignoring it.
*/
#ifndef PB_DS_HASH_EQ_FN_HPP
{
namespace detail
{
- template<typename Key, class Eq_Fn, class Allocator, bool Store_Hash>
- struct hash_eq_fn;
+ template<typename Key, typename Eq_Fn, typename _Alloc, bool Store_Hash>
+ struct hash_eq_fn;
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, class Eq_Fn, class Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- hash_eq_fn<Key, Eq_Fn, Allocator, false>
-
- /**
- * Specialization 1- The client requests that hash values not be stored.
- **/
- template<typename Key, class Eq_Fn, class Allocator>
- struct hash_eq_fn<Key, Eq_Fn, Allocator, false> : public Eq_Fn
+ /// Specialization 1 - The client requests that hash values not be stored.
+ template<typename Key, typename Eq_Fn, typename _Alloc>
+ struct hash_eq_fn<Key, Eq_Fn, _Alloc, false> : public Eq_Fn
{
- typedef Eq_Fn eq_fn_base;
-
- typedef typename Allocator::template rebind<Key>::other key_allocator;
-
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef Eq_Fn eq_fn_base;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
- hash_eq_fn();
+ hash_eq_fn() { }
- hash_eq_fn(const Eq_Fn& r_eq_fn);
+ hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
- inline bool
- operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const;
+ bool
+ operator()(key_const_reference r_lhs_key,
+ key_const_reference r_rhs_key) const
+ { return eq_fn_base::operator()(r_lhs_key, r_rhs_key); }
- inline void
- swap(const PB_DS_CLASS_C_DEC& other);
+ void
+ swap(const hash_eq_fn& other)
+ { std::swap((Eq_Fn&)(*this), (Eq_Fn&)other); }
};
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- hash_eq_fn()
- { }
-
- PB_DS_CLASS_T_DEC
- inline void
- PB_DS_CLASS_C_DEC::
- swap(const PB_DS_CLASS_C_DEC& other)
- { std::swap((Eq_Fn& )(*this), (Eq_Fn& )other); }
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- hash_eq_fn(const Eq_Fn& r_eq_fn) :
- Eq_Fn(r_eq_fn)
- { }
-
- PB_DS_CLASS_T_DEC
- inline bool
- PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
- { return (eq_fn_base::operator()(r_lhs_key, r_rhs_key)); }
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, class Eq_Fn, class Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- hash_eq_fn<Key, Eq_Fn, Allocator, true>
-
- /**
- * Specialization 2- The client requests that hash values be stored.
- **/
- template<typename Key, class Eq_Fn, class Allocator>
- struct hash_eq_fn<Key, Eq_Fn, Allocator, true> :
- public Eq_Fn
- {
- typedef typename Allocator::size_type size_type;
-
- typedef Eq_Fn eq_fn_base;
- typedef typename Allocator::template rebind<Key>::other key_allocator;
+ /// Specialization 2 - The client requests that hash values be stored.
+ template<typename Key, class Eq_Fn, class _Alloc>
+ struct hash_eq_fn<Key, Eq_Fn, _Alloc, true> : public Eq_Fn
+ {
+ typedef typename _Alloc::size_type size_type;
+ typedef Eq_Fn eq_fn_base;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
- typedef typename key_allocator::const_reference const_key_reference;
+ hash_eq_fn() { }
- hash_eq_fn();
+ hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
- hash_eq_fn(const Eq_Fn& r_eq_fn);
+ bool
+ operator()(key_const_reference r_lhs_key, size_type lhs_hash,
+ key_const_reference r_rhs_key, size_type rhs_hash) const
+ {
+ _GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
+ || lhs_hash == rhs_hash);
- inline bool
- operator()(const_key_reference r_lhs_key, size_type lhs_hash,
- const_key_reference r_rhs_key, size_type rhs_hash) const;
+ return (lhs_hash == rhs_hash &&
+ eq_fn_base::operator()(r_lhs_key, r_rhs_key));
+ }
- inline void
- swap(const PB_DS_CLASS_C_DEC& other);
+ void
+ swap(const hash_eq_fn& other)
+ { std::swap((Eq_Fn&)(*this), (Eq_Fn&)(other)); }
};
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- hash_eq_fn()
- { }
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- hash_eq_fn(const Eq_Fn& r_eq_fn) :
- Eq_Fn(r_eq_fn)
- { }
-
- PB_DS_CLASS_T_DEC
- inline bool
- PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_lhs_key, size_type lhs_hash,
- const_key_reference r_rhs_key, size_type rhs_hash) const
- {
- _GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
- || lhs_hash == rhs_hash);
-
- return (lhs_hash == rhs_hash &&
- eq_fn_base::operator()(r_lhs_key, r_rhs_key));
- }
-
- PB_DS_CLASS_T_DEC
- inline void
- PB_DS_CLASS_C_DEC::
- swap(const PB_DS_CLASS_C_DEC& other)
- { std::swap((Eq_Fn& )(*this), (Eq_Fn& )(other)); }
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file constructor_destructor_fn_imps.hpp
+ * @file gp_hash_table_map_/constructor_destructor_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
- * and related functions.
+ * and related functions.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME()
+PB_DS_GP_HASH_NAME()
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn)
+PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn)
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
m_entries(s_entry_allocator.allocate(m_num_e))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn)
+PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
+PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& r_comb_hash_fn)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
+PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober)
: hash_eq_fn_base(r_eq_fn),
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
+PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober,
const Resize_Policy& r_resize_policy)
: hash_eq_fn_base(r_eq_fn), resize_base(r_resize_policy),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~PB_DS_CLASS_NAME()
+~PB_DS_GP_HASH_NAME()
{ deallocate_all(); }
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file constructor_destructor_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
+constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
false_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status)k;
// warranty.
/**
- * @file constructor_destructor_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s constructors, destructor,
* and related functions.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
+constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
true_type)
{
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file gp_hash_table_map_/debug_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
// warranty.
/**
- * @file debug_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
break;
case valid_entry_status:
{
- const_key_reference r_key = PB_DS_V2F(p_e->m_value);
+ key_const_reference r_key = PB_DS_V2F(p_e->m_value);
debug_base::check_key_exists(r_key, __file, __line);
++iterated_num_used_e;
break;
// warranty.
/**
- * @file debug_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/debug_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s debug-mode functions.
*/
break;
case valid_entry_status:
{
- const_key_reference r_key = PB_DS_V2F(p_e->m_value);
+ key_const_reference r_key = PB_DS_V2F(p_e->m_value);
debug_base::check_key_exists(r_key, __file, __line);
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file gp_hash_table_map_/erase_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{ return erase_imp(r_key, traits_base::m_store_extra_indicator); }
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp>
// warranty.
/**
- * @file erase_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase_imp(const_key_reference r_key, false_type)
+erase_imp(key_const_reference r_key, false_type)
{
PB_DS_ASSERT_VALID((*this))
size_type hash = ranged_probe_fn_base::operator()(r_key);
// warranty.
/**
- * @file erase_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/erase_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s erase related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase_imp(const_key_reference r_key, true_type)
+erase_imp(key_const_reference r_key, true_type)
{
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
size_type i;
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file gp_hash_table_map_/find_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions.
*/
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_ASSERT_VALID((*this))
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
}
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_ASSERT_VALID((*this))
return const_cast<PB_DS_CLASS_C_DEC&>(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator);
{ return 0; }
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_end() const
{ return 0; }
// warranty.
/**
- * @file find_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/find_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::pointer
PB_DS_CLASS_C_DEC::
-find_key_pointer(const_key_reference r_key, false_type)
+find_key_pointer(key_const_reference r_key, false_type)
// warranty.
/**
- * @file find_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/find_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is stored.
*/
// warranty.
/**
- * @file gp_ht_map_.hpp
- * Contains an implementation class for gp_ht_map_.
+ * @file gp_hash_table_map_/gp_ht_map_.hpp
+ * Contains an implementation class for general probing hash.
*/
#include <ext/pb_ds/tag_and_trait.hpp>
#include <utility>
#ifdef PB_DS_HT_MAP_TRACE_
#include <iostream>
-#endif
+#endif
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
#endif
{
namespace detail
{
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, typename Hash_Fn, typename Eq_Fn, \
- typename Allocator, bool Store_Hash, typename Comb_Probe_Fn, \
- typename Probe_Fn, typename Resize_Policy>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME gp_ht_map_data_
+#define PB_DS_GP_HASH_NAME gp_ht_map
#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME gp_ht_map_no_data_
-#endif
+#define PB_DS_GP_HASH_NAME gp_ht_set
+#endif
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Hash_Fn, typename Eq_Fn, \
+ typename _Alloc, bool Store_Hash, typename Comb_Probe_Fn, \
+ typename Probe_Fn, typename Resize_Policy>
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Hash_Fn, Eq_Fn, Allocator, \
- Store_Hash, Comb_Probe_Fn, Probe_Fn, Resize_Policy>
+ PB_DS_GP_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
+ Store_Hash, Comb_Probe_Fn, Probe_Fn, Resize_Policy>
#define PB_DS_HASH_EQ_FN_C_DEC \
- hash_eq_fn<Key, Eq_Fn, Allocator, Store_Hash>
+ hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
#define PB_DS_RANGED_PROBE_FN_C_DEC \
- ranged_probe_fn<Key, Hash_Fn, Allocator, Comb_Probe_Fn, Probe_Fn, Store_Hash>
+ ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, Store_Hash>
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits<Key, Mapped, Allocator, Store_Hash>
+#define PB_DS_GP_HASH_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, Store_Hash>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
- debug_map_base<Key, Eq_Fn, typename Allocator::template rebind<Key>::other::const_reference>
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped()
+ debug_map_base<Key, Eq_Fn, \
+ typename _Alloc::template rebind<Key>::other::const_reference>
#endif
+
+ /// General probing hash.
template<typename Key,
typename Mapped,
typename Hash_Fn,
typename Eq_Fn,
- typename Allocator,
+ typename _Alloc,
bool Store_Hash,
typename Comb_Probe_Fn,
typename Probe_Fn,
typename Resize_Policy>
- class PB_DS_CLASS_NAME :
+ class PB_DS_GP_HASH_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
+#endif
public PB_DS_HASH_EQ_FN_C_DEC,
public Resize_Policy,
public PB_DS_RANGED_PROBE_FN_C_DEC,
- public PB_DS_TYPES_TRAITS_C_DEC
+ public PB_DS_GP_HASH_TRAITS_BASE
{
private:
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
- typedef typename traits_base::value_type value_type_;
- typedef typename traits_base::pointer pointer_;
+ typedef PB_DS_GP_HASH_TRAITS_BASE traits_base;
+ typedef typename traits_base::value_type value_type_;
+ typedef typename traits_base::pointer pointer_;
typedef typename traits_base::const_pointer const_pointer_;
- typedef typename traits_base::reference reference_;
+ typedef typename traits_base::reference reference_;
typedef typename traits_base::const_reference const_reference_;
- typedef typename traits_base::comp_hash comp_hash;
+ typedef typename traits_base::comp_hash comp_hash;
enum entry_status
{
erased_entry_status
} __attribute__ ((packed));
- struct entry : public traits_base::stored_value_type
+ struct entry : public traits_base::stored_data_type
{
entry_status m_stat;
};
- typedef typename Allocator::template rebind<entry>::other entry_allocator;
+ typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
typedef typename entry_allocator::pointer entry_array;
- typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base;
+ typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base;
#ifdef _GLIBCXX_DEBUG
- typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+ typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
+#endif
- typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
- typedef Resize_Policy resize_base;
+ typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
+ typedef Resize_Policy resize_base;
-#define PB_DS_GEN_POS typename Allocator::size_type
+#define PB_DS_GEN_POS typename _Alloc::size_type
-#include <ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#undef PB_DS_GEN_POS
public:
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
- typedef Hash_Fn hash_fn;
- typedef Eq_Fn eq_fn;
- typedef Probe_Fn probe_fn;
- typedef Comb_Probe_Fn comb_probe_fn;
- typedef Resize_Policy resize_policy;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef Hash_Fn hash_fn;
+ typedef Eq_Fn eq_fn;
+ typedef Probe_Fn probe_fn;
+ typedef Comb_Probe_Fn comb_probe_fn;
+ typedef Resize_Policy resize_policy;
enum
{
store_hash = Store_Hash
};
- typedef typename traits_base::key_type key_type;
+ typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
- typedef typename traits_base::const_key_pointer const_key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
- typedef typename traits_base::const_key_reference const_key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
- typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
- typedef typename traits_base::const_mapped_reference const_mapped_reference;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef point_iterator_ point_iterator;
-#endif
+ typedef point_iterator_ point_iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_point_iterator_ point_iterator;
-#endif
+ typedef point_const_iterator_ point_iterator;
+#endif
- typedef const_point_iterator_ const_point_iterator;
+ typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef iterator_ iterator;
-#endif
+ typedef iterator_ iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_iterator_ iterator;
-#endif
+ typedef const_iterator_ iterator;
+#endif
- typedef const_iterator_ const_iterator;
+ typedef const_iterator_ const_iterator;
- PB_DS_CLASS_NAME();
+ PB_DS_GP_HASH_NAME();
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC&);
- PB_DS_CLASS_NAME(const Hash_Fn&);
+ PB_DS_GP_HASH_NAME(const Hash_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&);
+ PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&);
+ PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
+ PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&);
- PB_DS_CLASS_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
+ PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&,
const Probe_Fn&, const Resize_Policy&);
template<typename It>
void
- copy_from_range(It first_it, It last_it);
+ copy_from_range(It, It);
virtual
- ~PB_DS_CLASS_NAME();
+ ~PB_DS_GP_HASH_NAME();
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
inline size_type
size() const;
inline bool
empty() const;
- Hash_Fn&
+ Hash_Fn&
get_hash_fn();
- const Hash_Fn&
+ const Hash_Fn&
get_hash_fn() const;
- Eq_Fn&
+ Eq_Fn&
get_eq_fn();
- const Eq_Fn&
+ const Eq_Fn&
get_eq_fn() const;
- Probe_Fn&
+ Probe_Fn&
get_probe_fn();
- const Probe_Fn&
+ const Probe_Fn&
get_probe_fn() const;
- Comb_Probe_Fn&
+ Comb_Probe_Fn&
get_comb_probe_fn();
- const Comb_Probe_Fn&
+ const Comb_Probe_Fn&
get_comb_probe_fn() const;
- Resize_Policy&
+ Resize_Policy&
get_resize_policy();
- const Resize_Policy&
+ const Resize_Policy&
get_resize_policy() const;
inline std::pair<point_iterator, bool>
insert(const_reference r_val)
{
- _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);)
- return insert_imp(r_val, traits_base::m_store_extra_indicator);
+ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);)
+ return insert_imp(r_val, traits_base::m_store_extra_indicator);
}
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return subscript_imp(r_key, traits_base::m_store_extra_indicator);
-#else
+#else
insert(r_key);
- return traits_base::s_null_mapped;
+ return traits_base::s_null_type;
#endif
}
inline point_iterator
- find(const_key_reference r_key);
+ find(key_const_reference);
- inline const_point_iterator
- find(const_key_reference r_key) const;
+ inline point_const_iterator
+ find(key_const_reference) const;
inline point_iterator
find_end();
- inline const_point_iterator
+ inline point_const_iterator
find_end() const;
inline bool
- erase(const_key_reference r_key);
+ erase(key_const_reference);
template<typename Pred>
inline size_type
- erase_if(Pred prd);
+ erase_if(Pred);
void
clear();
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
-#endif
+ assert_valid(const char*, int) const;
+#endif
#ifdef PB_DS_HT_MAP_TRACE_
void
trace() const;
-#endif
+#endif
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
-#endif
+#endif
friend class const_iterator_;
resize_imp_reassign(entry_pointer, entry_array, true_type);
inline size_type
- find_ins_pos(const_key_reference, false_type);
+ find_ins_pos(key_const_reference, false_type);
inline comp_hash
- find_ins_pos(const_key_reference, true_type);
+ find_ins_pos(key_const_reference, true_type);
inline std::pair<point_iterator, bool>
insert_imp(const_reference, false_type);
traits_base::m_store_extra_indicator);
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status);
-
entry* const p_e = m_entries + pos;
new (&p_e->m_value) value_type(r_val);
p_e->m_stat = valid_entry_status;
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
-
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
resize_base::notify_inserted(++m_num_used_e);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));)
-
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return &p_e->m_value;
}
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline mapped_reference
- subscript_imp(const_key_reference key, false_type)
+ subscript_imp(key_const_reference key, false_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
- const size_type pos = find_ins_pos(key,
+ const size_type pos = find_ins_pos(key,
traits_base::m_store_extra_indicator);
entry_pointer p_e = &m_entries[pos];
}
inline mapped_reference
- subscript_imp(const_key_reference key, true_type)
+ subscript_imp(key_const_reference key, true_type)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
- comp_hash pos_hash_pair =
- find_ins_pos(key, traits_base::m_store_extra_indicator);
+ comp_hash pos_hash_pair = find_ins_pos(key,
+ traits_base::m_store_extra_indicator);
if (m_entries[pos_hash_pair.first].m_stat != valid_entry_status)
return insert_new_imp(value_type(key, mapped_type()),
#endif
inline pointer
- find_key_pointer(const_key_reference key, false_type)
+ find_key_pointer(key_const_reference key, false_type)
{
const size_type hash = ranged_probe_fn_base::operator()(key);
- size_type i;
resize_base::notify_find_search_start();
// Loop until entry is found or until all possible entries accessed.
- for (i = 0; i < m_num_e; ++i)
+ for (size_type i = 0; i < m_num_e; ++i)
{
- const size_type pos = ranged_probe_fn_base::operator()(key, hash, i);
+ const size_type pos = ranged_probe_fn_base::operator()(key,
+ hash, i);
entry* const p_e = m_entries + pos;
switch (p_e->m_stat)
}
inline pointer
- find_key_pointer(const_key_reference key, true_type)
+ find_key_pointer(key_const_reference key, true_type)
{
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(key);
- size_type i;
resize_base::notify_find_search_start();
// Loop until entry is found or until all possible entries accessed.
- for (i = 0; i < m_num_e; ++i)
+ for (size_type i = 0; i < m_num_e; ++i)
{
const size_type pos =
ranged_probe_fn_base::operator()(key, pos_hash_pair.second, i);
}
inline bool
- erase_imp(const_key_reference, true_type);
+ erase_imp(key_const_reference, true_type);
inline bool
- erase_imp(const_key_reference, false_type);
+ erase_imp(key_const_reference, false_type);
inline void
- erase_entry(entry_pointer p_e);
+ erase_entry(entry_pointer);
#ifdef PB_DS_DATA_TRUE_INDICATOR
void
inc_it_state(pointer& r_p_value, size_type& r_pos) const
- { inc_it_state((const_mapped_pointer& )r_p_value, r_pos); }
-#endif
+ { inc_it_state((mapped_const_pointer& )r_p_value, r_pos); }
+#endif
void
inc_it_state(const_pointer& r_p_value, size_type& r_pos) const
#ifdef _GLIBCXX_DEBUG
void
assert_entry_array_valid(const entry_array, false_type,
- const char* file, int line) const;
+ const char*, int) const;
void
assert_entry_array_valid(const entry_array, true_type,
- const char* file, int line) const;
-#endif
+ const char*, int) const;
+#endif
static entry_allocator s_entry_allocator;
static iterator s_end_it;
enum
{
- store_hash_ok = !Store_Hash
- || !is_same<Hash_Fn, __gnu_pbds::null_hash_fn>::value
+ store_hash_ok = !Store_Hash
+ || !is_same<Hash_Fn, __gnu_pbds::null_type>::value
};
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_HASH_EQ_FN_C_DEC
#undef PB_DS_RANGED_PROBE_FN_C_DEC
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_GP_HASH_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_V2F
-#undef PB_DS_V2S
-
+#undef PB_DS_GP_HASH_NAME
} // namespace detail
} // namespace __gnu_pbds
-
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file gp_hash_table_map_/info_fn_imps.hpp
* Contains implementations of gp_ht_map_'s entire container info related
- * functions.
+ * functions.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file gp_hash_table_map_/insert_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions.
*/
// warranty.
/**
- * @file insert_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s insert related functions,
* when the hash value is not stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-find_ins_pos(const_key_reference r_key, false_type)
+find_ins_pos(key_const_reference r_key, false_type)
{
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, false_type)
{
- const_key_reference r_key = PB_DS_V2F(r_val);
+ key_const_reference r_key = PB_DS_V2F(r_val);
const size_type pos = find_ins_pos(r_key,
traits_base::m_store_extra_indicator);
// warranty.
/**
- * @file insert_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/insert_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s find related functions,
* when the hash value is stored.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
-find_ins_pos(const_key_reference r_key, true_type)
+find_ins_pos(key_const_reference r_key, true_type)
{
PB_DS_ASSERT_VALID((*this))
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key);
PB_DS_CLASS_C_DEC::
insert_imp(const_reference r_val, true_type)
{
- const_key_reference r_key = PB_DS_V2F(r_val);
+ key_const_reference r_key = PB_DS_V2F(r_val);
comp_hash pos_hash_pair = find_ins_pos(r_key,
traits_base::m_store_extra_indicator);
// warranty.
/**
- * @file iterator_fn_imps.hpp
+ * @file gp_hash_table_map_/iterator_fn_imps.hpp
* Contains implementations of gp_ht_map_'s iterators related functions, e.g.,
- * begin().
+ * begin().
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file policy_access_fn_imps.hpp
+ * @file gp_hash_table_map_/policy_access_fn_imps.hpp
* Contains implementations of gp_ht_map_'s policy agpess
- * functions.
+ * functions.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file resize_fn_imps.hpp
+ * @file gp_hash_table_map_/resize_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions.
*/
resize_imp(size_type new_size)
{
#ifdef PB_DS_REGRESSION
- typename Allocator::group_adjustor adjust(m_num_e);
+ typename _Alloc::group_adjustor adjust(m_num_e);
#endif
if (new_size == m_num_e)
// warranty.
/**
- * @file resize_no_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions, when the
- * hash value is not stored.
+ * hash value is not stored.
*/
PB_DS_CLASS_T_DEC
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
false_type)
{
- const_key_reference r_key = PB_DS_V2F(p_e->m_value);
+ key_const_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash = ranged_probe_fn_base::operator()(r_key);
size_type i;
for (i = 0; i < m_num_e; ++i)
// warranty.
/**
- * @file resize_store_hash_fn_imps.hpp
+ * @file gp_hash_table_map_/resize_store_hash_fn_imps.hpp
* Contains implementations of gp_ht_map_'s resize related functions, when the
- * hash value is stored.
+ * hash value is stored.
*/
PB_DS_CLASS_T_DEC
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
true_type)
{
- const_key_reference r_key = PB_DS_V2F(p_e->m_value);
+ key_const_reference r_key = PB_DS_V2F(p_e->m_value);
size_type hash = ranged_probe_fn_base::operator()(r_key, p_e->m_hash);
size_type i;
// warranty.
/**
- * @file standard_policies.hpp
+ * @file gp_hash_table_map_/standard_policies.hpp
* Contains standard policies for gp_ht_map types.
*/
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file gp_hash_table_map_/trace_fn_imps.hpp
* Contains implementations of gp_ht_map_'s trace-mode functions.
*/
{
namespace detail
{
- template<typename Allocator>
+ template<typename _Alloc>
class probe_fn_base
{
protected:
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
#ifndef PB_DS_RANGED_HASH_FN_HPP
#define PB_DS_RANGED_HASH_FN_HPP
-#include <ext/pb_ds/detail/basic_types.hpp>
#include <utility>
#include <debug/debug.h>
{
namespace detail
{
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn, bool Store_Hash>
class ranged_hash_fn;
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Hash_Fn, typename Allocator, \
+ template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, false>
+ ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false>
/**
* Specialization 1
* The client supplies a hash function and a ranged hash function,
* and requests that hash values not be stored.
**/
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn>
- class ranged_hash_fn< Key, Hash_Fn, Allocator, Comb_Hash_Fn, false>
+ class ranged_hash_fn< Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false>
: public Hash_Fn, public Comb_Hash_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
- typedef typename Allocator::template rebind< Key>::other key_allocator;
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef typename _Alloc::template rebind< Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
ranged_hash_fn(size_type);
notify_resized(size_type);
inline size_type
- operator()(const_key_reference) const;
+ operator()(key_const_reference) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_key) const
+ operator()(key_const_reference r_key) const
{ return (comb_hash_fn_base::operator()(hash_fn_base::operator()(r_key)));}
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Hash_Fn, typename Allocator, \
+ template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_hash_fn<Key,Hash_Fn, Allocator, Comb_Hash_Fn, true>
+ ranged_hash_fn<Key,Hash_Fn, _Alloc, Comb_Hash_Fn, true>
/**
* Specialization 2
* The client supplies a hash function and a ranged hash function,
* and requests that hash values be stored.
**/
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Hash_Fn>
- class ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, true>
+ class ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, true>
: public Hash_Fn, public Comb_Hash_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef std::pair<size_type, size_type> comp_hash;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
- typedef typename Allocator::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
ranged_hash_fn(size_type);
notify_resized(size_type);
inline comp_hash
- operator()(const_key_reference) const;
+ operator()(key_const_reference) const;
inline comp_hash
- operator()(const_key_reference, size_type) const;
+ operator()(key_const_reference, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_key) const
+ operator()(key_const_reference r_key) const
{
const size_type hash = hash_fn_base::operator()(r_key);
return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
PB_DS_CLASS_C_DEC::
operator()
#ifdef _GLIBCXX_DEBUG
- (const_key_reference r_key, size_type hash) const
+ (key_const_reference r_key, size_type hash) const
#else
- (const_key_reference /*r_key*/, size_type hash) const
+ (key_const_reference /*r_key*/, size_type hash) const
#endif
{
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Allocator, typename Comb_Hash_Fn>
+ template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_hash_fn<Key, null_hash_fn, Allocator, Comb_Hash_Fn, false>
+ ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false>
/**
* Specialization 3
* The client does not supply a hash function (by specifying
- * null_hash_fn as the Hash_Fn parameter), and requests that hash
+ * null_type as the Hash_Fn parameter), and requests that hash
* values not be stored.
**/
- template<typename Key, typename Allocator, typename Comb_Hash_Fn>
- class ranged_hash_fn<Key, null_hash_fn, Allocator, Comb_Hash_Fn, false>
- : public null_hash_fn, public Comb_Hash_Fn
+ template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
+ class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false>
+ : public Comb_Hash_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef Comb_Hash_Fn comb_hash_fn_base;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Comb_Hash_Fn&);
- ranged_hash_fn(size_type, const null_hash_fn&, const Comb_Hash_Fn&);
+ ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
- ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn,
+ ranged_hash_fn(size_type size, const null_type& r_null_type,
const Comb_Hash_Fn& r_comb_hash_fn)
: Comb_Hash_Fn(r_comb_hash_fn)
{ }
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Allocator, typename Comb_Hash_Fn>
+ template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_hash_fn<Key, null_hash_fn, Allocator, Comb_Hash_Fn, true>
+ ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true>
/**
* Specialization 4
* The client does not supply a hash function (by specifying
- * null_hash_fn as the Hash_Fn parameter), and requests that hash
+ * null_type as the Hash_Fn parameter), and requests that hash
* values be stored.
**/
- template<typename Key, typename Allocator, typename Comb_Hash_Fn>
- class ranged_hash_fn<Key, null_hash_fn, Allocator, Comb_Hash_Fn, true>
- : public null_hash_fn, public Comb_Hash_Fn
+ template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
+ class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true>
+ : public Comb_Hash_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef Comb_Hash_Fn comb_hash_fn_base;
ranged_hash_fn(size_type);
ranged_hash_fn(size_type, const Comb_Hash_Fn&);
- ranged_hash_fn(size_type, const null_hash_fn&, const Comb_Hash_Fn&);
+ ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&);
void
swap(PB_DS_CLASS_C_DEC&);
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
- ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn,
+ ranged_hash_fn(size_type size, const null_type& r_null_type,
const Comb_Hash_Fn& r_comb_hash_fn)
: Comb_Hash_Fn(r_comb_hash_fn)
{ }
#ifndef PB_DS_RANGED_PROBE_FN_HPP
#define PB_DS_RANGED_PROBE_FN_HPP
-#include <ext/pb_ds/detail/basic_types.hpp>
#include <utility>
#include <debug/debug.h>
{
namespace detail
{
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn, bool Store_Hash>
class ranged_probe_fn;
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Hash_Fn, typename Allocator, \
+ template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Probe_Fn, typename Probe_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_probe_fn<Key, Hash_Fn, Allocator, Comb_Probe_Fn, Probe_Fn, false>
+ ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, false>
/**
* Specialization 1
* The client supplies a probe function and a ranged probe
* function, and requests that hash values not be stored.
**/
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn>
- class ranged_probe_fn<Key, Hash_Fn, Allocator, Comb_Probe_Fn,
+ class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn,
Probe_Fn, false>
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
- typedef typename Allocator::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type);
notify_resized(size_type);
inline size_type
- operator()(const_key_reference) const;
+ operator()(key_const_reference) const;
inline size_type
- operator()(const_key_reference, size_type, size_type) const;
+ operator()(key_const_reference, size_type, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_key) const
+ operator()(key_const_reference r_key) const
{ return comb_probe_fn_base::operator()(hash_fn_base::operator()(r_key)); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference, size_type hash, size_type i) const
+ operator()(key_const_reference, size_type hash, size_type i) const
{
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i));
}
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Hash_Fn, typename Allocator, \
+ template<typename Key, typename Hash_Fn, typename _Alloc, \
typename Comb_Probe_Fn, typename Probe_Fn>
#define PB_DS_CLASS_C_DEC \
- ranged_probe_fn<Key, Hash_Fn, Allocator, Comb_Probe_Fn, Probe_Fn, true>
+ ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, true>
/**
* Specialization 2- The client supplies a probe function and a ranged
* probe function, and requests that hash values not be stored.
**/
- template<typename Key, typename Hash_Fn, typename Allocator,
+ template<typename Key, typename Hash_Fn, typename _Alloc,
typename Comb_Probe_Fn, typename Probe_Fn>
- class ranged_probe_fn<Key, Hash_Fn, Allocator, Comb_Probe_Fn,
+ class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn,
Probe_Fn, true>
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef std::pair<size_type, size_type> comp_hash;
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
- typedef typename Allocator::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type);
notify_resized(size_type);
inline comp_hash
- operator()(const_key_reference) const;
+ operator()(key_const_reference) const;
inline size_type
- operator()(const_key_reference, size_type, size_type) const;
+ operator()(key_const_reference, size_type, size_type) const;
inline size_type
- operator()(const_key_reference, size_type) const;
+ operator()(key_const_reference, size_type) const;
};
PB_DS_CLASS_T_DEC
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::comp_hash
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference r_key) const
+ operator()(key_const_reference r_key) const
{
const size_type hash = hash_fn_base::operator()(r_key);
return std::make_pair(comb_probe_fn_base::operator()(hash), hash);
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
- operator()(const_key_reference, size_type hash, size_type i) const
+ operator()(key_const_reference, size_type hash, size_type i) const
{
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i));
}
PB_DS_CLASS_C_DEC::
operator()
#ifdef _GLIBCXX_DEBUG
- (const_key_reference r_key, size_type hash) const
+ (key_const_reference r_key, size_type hash) const
#else
- (const_key_reference /*r_key*/, size_type hash) const
+ (key_const_reference /*r_key*/, size_type hash) const
#endif
{
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
* The client does not supply a hash function or probe function,
* and requests that hash values not be stored.
**/
- template<typename Key, typename Allocator, typename Comb_Probe_Fn>
- class ranged_probe_fn<Key, null_hash_fn, Allocator, Comb_Probe_Fn,
- null_probe_fn, false>
- : public Comb_Probe_Fn, public null_hash_fn, public null_probe_fn
+ template<typename Key, typename _Alloc, typename Comb_Probe_Fn>
+ class ranged_probe_fn<Key, null_type, _Alloc, Comb_Probe_Fn,
+ null_type, false>
+ : public Comb_Probe_Fn
{
protected:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef Comb_Probe_Fn comb_probe_fn_base;
- typedef typename Allocator::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference const_key_reference;
+ typedef typename _Alloc::template rebind<Key>::other key_allocator;
+ typedef typename key_allocator::const_reference key_const_reference;
ranged_probe_fn(size_type size)
{ Comb_Probe_Fn::notify_resized(size); }
: Comb_Probe_Fn(r_comb_probe_fn)
{ }
- ranged_probe_fn(size_type, const null_hash_fn&,
+ ranged_probe_fn(size_type, const null_type&,
const Comb_Probe_Fn& r_comb_probe_fn,
- const null_probe_fn&)
+ const null_type&)
: Comb_Probe_Fn(r_comb_probe_fn)
{ }
#ifndef PB_DS_SAMPLE_PROBE_FN_HPP
#define PB_DS_SAMPLE_PROBE_FN_HPP
-// A sample probe policy.
-class sample_probe_fn
+namespace __gnu_pbds
{
-
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
-public:
-
- // Default constructor.
- sample_probe_fn();
-
- // Copy constructor.
- sample_probe_fn(const sample_probe_fn& other);
-
- // Swaps content.
- inline void
- swap(sample_probe_fn& other);
-
-protected:
-
- // Returns the i-th offset from the hash value of some key r_key.
- inline size_type
- operator()(const_key_reference r_key, size_type i) const;
-
-};
-
+ /// A sample probe policy.
+ class sample_probe_fn
+ {
+ public:
+ typedef std::size_t size_type;
+
+ // Default constructor.
+ sample_probe_fn();
+
+ // Copy constructor.
+ sample_probe_fn(const sample_probe_fn&);
+
+ // Swaps content.
+ inline void
+ swap(sample_probe_fn&);
+
+ protected:
+ // Returns the i-th offset from the hash value of some key r_key.
+ inline size_type
+ operator()(key_const_reference r_key, size_type i) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_PROBE_FN_HPP
#ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP
#define PB_DS_SAMPLE_RANGE_HASHING_HPP
-// A sample range-hashing functor.
-class sample_range_hashing
+namespace __gnu_pbds
{
-
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
-public:
-
- // Default constructor.
- sample_range_hashing();
-
- // Copy constructor.
- sample_range_hashing(const sample_range_hashing& other);
-
- // Swaps content.
- inline void
- swap(sample_range_hashing& other);
-
-protected:
-
- // Notifies the policy object that the container's __size has changed to size.
- void
- notify_resized(size_type size);
-
- // Transforms the __hash value hash into a ranged-hash value.
- inline size_type
- operator()(size_type hash) const;
-
-};
-
+ /// A sample range-hashing functor.
+ class sample_range_hashing
+ {
+ public:
+ // Size type.
+ typedef std::size_t size_type;
+
+ // Default constructor.
+ sample_range_hashing();
+
+ // Copy constructor.
+ sample_range_hashing(const sample_range_hashing& other);
+
+ // Swaps content.
+ inline void
+ swap(sample_range_hashing& other);
+
+ protected:
+ // Notifies the policy object that the container's __size has
+ // changed to size.
+ void
+ notify_resized(size_type);
+
+ // Transforms the __hash value hash into a ranged-hash value.
+ inline size_type
+ operator()(size_type ) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP
#ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP
#define PB_DS_SAMPLE_RANGED_HASH_FN_HPP
-// A sample ranged-hash functor.
-class sample_ranged_hash_fn
+namespace __gnu_pbds
{
+ /// A sample ranged-hash functor.
+ class sample_ranged_hash_fn
+ {
+ public:
+ typedef std::size_t size_type;
-public:
+ // Default constructor.
+ sample_ranged_hash_fn();
- // Size type.
- typedef std::size_t size_type;
+ // Copy constructor.
+ sample_ranged_hash_fn(const sample_ranged_hash_fn&);
-public:
+ // Swaps content.
+ inline void
+ swap(sample_ranged_hash_fn&);
- // Default constructor.
- sample_ranged_hash_fn();
+ protected:
- // Copy constructor.
- sample_ranged_hash_fn(const sample_ranged_hash_fn& other);
+ // Notifies the policy object that the container's __size has
+ // changed to size.
+ void
+ notify_resized(size_type);
- // Swaps content.
- inline void
- swap(sample_ranged_hash_fn& other);
-
-protected:
-
- // Notifies the policy object that the container's __size has changed to size.
- void
- notify_resized(size_type size);
-
- // Transforms r_key into a position within the table.
- inline size_type
- operator()(const_key_reference r_key) const;
-
-};
+ // Transforms key_const_reference into a position within the table.
+ inline size_type
+ operator()(key_const_reference) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP
#ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
#define PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
-// A sample ranged-probe functor.
-class sample_ranged_probe_fn
+namespace __gnu_pbds
{
+ /// A sample ranged-probe functor.
+ class sample_ranged_probe_fn
+ {
+ public:
+ typedef std::size_t size_type;
-public:
+ // Default constructor.
+ sample_ranged_probe_fn();
- // Size type.
- typedef std::size_t size_type;
+ // Copy constructor.
+ sample_ranged_probe_fn(const sample_ranged_probe_fn&);
-public:
+ // Swaps content.
+ inline void
+ swap(sample_ranged_probe_fn&);
- // Default constructor.
- sample_ranged_probe_fn();
+ protected:
- // Copy constructor.
- sample_ranged_probe_fn(const sample_ranged_probe_fn& other);
+ // Notifies the policy object that the container's __size has
+ // changed to size.
+ void
+ notify_resized(size_type);
- // Swaps content.
- inline void
- swap(sample_ranged_probe_fn& other);
-
-protected:
-
- // Notifies the policy object that the container's __size has changed to size.
- void
- notify_resized(size_type size);
-
- // Transforms the const key reference r_key into the i-th position within the table. This method is called for each collision within the probe sequence.
- inline size_type
- operator()(const_key_reference r_key, std::size_t hash, size_type i) const;
-
-};
+ // Transforms the const key reference r_key into the i-th position
+ // within the table. This method is called for each collision within
+ // the probe sequence.
+ inline size_type
+ operator()(key_const_reference, std::size_t, size_type) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP
// warranty.
/**
- * @file const_iterator.hpp
+ * @file left_child_next_sibling_heap_/const_iterator.hpp
* Contains an iterator class returned by the table's const find and insert
- * methods.
+ * methods.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP
-#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
+#define PB_DS_CLASS_C_DEC \
+ left_child_next_sibling_heap_const_iterator_<Node, _Alloc>
-#define PB_DS_CLASS_C_DEC \
- left_child_next_sibling_heap_const_iterator_<Node, Allocator>
+#define PB_DS_BASIC_HEAP_CIT_BASE \
+ left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc>
-#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_node_const_point_iterator_<Node, Allocator>
-
- // Const point-type iterator.
- template<typename Node, class Allocator>
- class left_child_next_sibling_heap_const_iterator_ : public PB_DS_BASE_C_DEC
+ /// Const point-type iterator.
+ template<typename Node, typename _Alloc>
+ class left_child_next_sibling_heap_const_iterator_
+ : public PB_DS_BASIC_HEAP_CIT_BASE
{
-
private:
- typedef typename PB_DS_BASE_C_DEC::node_pointer node_pointer;
-
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_BASIC_HEAP_CIT_BASE base_type;
+ typedef typename base_type::node_pointer node_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
- left_child_next_sibling_heap_const_iterator_(node_pointer p_nd) : base_type(p_nd)
+ left_child_next_sibling_heap_const_iterator_(node_pointer p_nd)
+ : base_type(p_nd)
{ }
// Default constructor.
operator!=(const PB_DS_CLASS_C_DEC& other) const
{ return (base_type::m_p_nd != other.m_p_nd); }
- inline PB_DS_CLASS_C_DEC&
+ inline PB_DS_CLASS_C_DEC&
operator++()
{
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != 0);
{
node_pointer p_next = base_type::m_p_nd;
base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent;
- if (base_type::m_p_nd == 0 || base_type::m_p_nd->m_p_l_child == p_next)
+ if (base_type::m_p_nd == 0
+ || base_type::m_p_nd->m_p_l_child == p_next)
return;
}
}
};
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_BASIC_HEAP_CIT_BASE
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 const_point_iterator.hpp
- * Contains an iterator class returned by the table's const find and insert
- * methods.
- */
-
-#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
-#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
-
-#include <ext/pb_ds/tag_and_trait.hpp>
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
-#define PB_DS_CLASS_T_DEC \
- template<typename Node, class Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- left_child_next_sibling_heap_node_const_point_iterator_<Node, Allocator>
-
- // Const point-type iterator.
- template<typename Node, class Allocator>
- class left_child_next_sibling_heap_node_const_point_iterator_
- {
-
- protected:
- typedef typename Allocator::template rebind<Node>::other::pointer node_pointer;
-
- public:
-
- // Category.
- typedef trivial_iterator_tag iterator_category;
-
- // Difference type.
- typedef trivial_iterator_difference_type difference_type;
-
- // Iterator's value type.
- typedef typename Node::value_type value_type;
-
- // Iterator's pointer type.
- typedef
- typename Allocator::template rebind<
- value_type>::other::pointer
- pointer;
-
- // Iterator's const pointer type.
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_pointer
- const_pointer;
-
- // Iterator's reference type.
- typedef
- typename Allocator::template rebind<
- value_type>::other::reference
- reference;
-
- // Iterator's const reference type.
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_reference
- const_reference;
-
- public:
-
- inline
- left_child_next_sibling_heap_node_const_point_iterator_(node_pointer p_nd) : m_p_nd(p_nd)
- { }
-
- // Default constructor.
- inline
- left_child_next_sibling_heap_node_const_point_iterator_() : m_p_nd(0)
- { }
-
- // Copy constructor.
- inline
- left_child_next_sibling_heap_node_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd)
- { }
-
- // Access.
- inline const_pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
- return &m_p_nd->m_value;
- }
-
- // Access.
- inline const_reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
- return m_p_nd->m_value;
- }
-
- // Compares content to a different iterator object.
- inline bool
- operator==(const PB_DS_CLASS_C_DEC& other) const
- { return m_p_nd == other.m_p_nd; }
-
- // Compares content (negatively) to a different iterator object.
- inline bool
- operator!=(const PB_DS_CLASS_C_DEC& other) const
- { return m_p_nd != other.m_p_nd; }
-
- public:
- node_pointer m_p_nd;
- };
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-left_child_next_sibling_heap_() :
+left_child_next_sibling_heap() :
m_p_root(0),
m_size(0)
{
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
+left_child_next_sibling_heap(const Cmp_Fn& r_cmp_fn) :
Cmp_Fn(r_cmp_fn),
m_p_root(0),
m_size(0)
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other)
+left_child_next_sibling_heap(const PB_DS_CLASS_C_DEC& other)
: Cmp_Fn(other), m_p_root(0), m_size(0)
{
m_size = other.m_size;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~left_child_next_sibling_heap_()
+~left_child_next_sibling_heap()
{
clear();
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-recursive_copy_node(const_node_pointer p_nd)
+recursive_copy_node(node_const_pointer p_nd)
{
if (p_nd == 0)
return (0);
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/debug_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_node_consistent(const_node_pointer p_nd, bool single_link,
+assert_node_consistent(node_const_pointer p_nd, bool single_link,
const char* __file, int __line) const
{
if (p_nd == 0)
if (p_nd->m_p_l_child == 0)
return;
- const_node_pointer p_child = p_nd->m_p_l_child;
+ node_const_pointer p_child = p_nd->m_p_l_child;
while (p_child != 0)
{
- const_node_pointer p_next_child = p_child->m_p_next_sibling;
+ node_const_pointer p_next_child = p_child->m_p_next_sibling;
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value));
p_child = p_next_child;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-size_under_node(const_node_pointer p_nd)
+size_under_node(node_const_pointer p_nd)
{ return 1 + size_from_node(p_nd->m_p_l_child); }
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-size_from_node(const_node_pointer p_nd)
+size_from_node(node_const_pointer p_nd)
{
size_type ret = 0;
while (p_nd != 0)
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-degree(const_node_pointer p_nd)
+degree(node_const_pointer p_nd)
{
size_type ret = 0;
- const_node_pointer p_child = p_nd->m_p_l_child;
+ node_const_pointer p_child = p_nd->m_p_l_child;
while (p_child != 0)
{
++ret;
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/erase_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
p_cur = p_cur->m_p_next_sibling;
#ifdef _GLIBCXX_DEBUG
- const_node_pointer p_counter = m_p_root;
+ node_const_pointer p_counter = m_p_root;
size_type count = 0;
while (p_counter != 0)
{
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/info_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/insert_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/iterators_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
// warranty.
/**
- * @file left_child_next_sibling_heap_.hpp
+ * @file left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp
* Contains an implementation class for a basic heap.
*/
#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_/node.hpp>
-#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp>
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp>
#ifdef PB_DS_LC_NS_HEAP_TRACE_
#include <iostream>
-#endif
+#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
-
-#ifdef _GLIBCXX_DEBUG
-#define PB_DS_CLASS_T_DEC \
- template< \
- typename Value_Type, \
- class Cmp_Fn, \
- typename Node_Metadata, \
- class Allocator, \
- bool Single_Link_Roots>
-#else
-#define PB_DS_CLASS_T_DEC \
- template< \
- typename Value_Type, \
- class Cmp_Fn, \
- typename Node_Metadata, \
- class Allocator>
-#endif
-
-#ifdef _GLIBCXX_DEBUG
-#define PB_DS_CLASS_C_DEC \
- left_child_next_sibling_heap_< \
- Value_Type, \
- Cmp_Fn, \
- Node_Metadata, \
- Allocator, \
- Single_Link_Roots>
-#else
-#define PB_DS_CLASS_C_DEC \
- left_child_next_sibling_heap_< \
- Value_Type, \
- Cmp_Fn, \
- Node_Metadata, \
- Allocator>
-#endif
-
- /**
- * class description = "Base class for some types of h3ap$">
- **/
#ifdef _GLIBCXX_DEBUG
+#define PB_DS_CLASS_T_DEC \
+ template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \
+ typename _Alloc, bool Single_Link_Roots>
+
+#define PB_DS_CLASS_C_DEC \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, \
+ _Alloc, Single_Link_Roots>
+#else
+#define PB_DS_CLASS_T_DEC \
+ template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \
+ typename _Alloc>
+
+#define PB_DS_CLASS_C_DEC \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, _Alloc>
+#endif
+
+ /// Base class for a basic heap.
template<typename Value_Type,
- class Cmp_Fn,
+ typename Cmp_Fn,
typename Node_Metadata,
- class Allocator,
- bool Single_Link_Roots>
-#else
- template<typename Value_Type,
- class Cmp_Fn,
- typename Node_Metadata,
- class Allocator>
-#endif
- class left_child_next_sibling_heap_ : public Cmp_Fn
+ typename _Alloc
+#ifdef _GLIBCXX_DEBUG
+ ,bool Single_Link_Roots>
+#else
+ >
+#endif
+ class left_child_next_sibling_heap : public Cmp_Fn
{
-
protected:
typedef
- typename Allocator::template rebind<
- left_child_next_sibling_heap_node_<
- Value_Type,
- Node_Metadata,
- Allocator> >::other
+ typename _Alloc::template rebind<
+ left_child_next_sibling_heap_node_<Value_Type, Node_Metadata,
+ _Alloc> >::other
node_allocator;
- typedef typename node_allocator::value_type node;
-
- typedef typename node_allocator::pointer node_pointer;
-
- typedef typename node_allocator::const_pointer const_node_pointer;
-
+ typedef typename node_allocator::value_type node;
+ typedef typename node_allocator::pointer node_pointer;
+ typedef typename node_allocator::const_pointer node_const_pointer;
typedef Node_Metadata node_metadata;
-
- typedef std::pair< node_pointer, node_pointer> node_pointer_pair;
+ typedef std::pair< node_pointer, node_pointer> node_pointer_pair;
private:
- typedef cond_dealtor< node, Allocator> cond_dealtor_t;
+ typedef cond_dealtor< node, _Alloc> cond_dealtor_t;
enum
{
simple_value = is_simple<Value_Type>::value
};
- typedef integral_constant<int, simple_value> no_throw_copies_t;
+ typedef integral_constant<int, simple_value> no_throw_copies_t;
+ typedef typename _Alloc::template rebind<Value_Type> __rebind_v;
public:
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef Value_Type value_type;
- typedef typename Allocator::size_type size_type;
-
- typedef typename Allocator::difference_type difference_type;
+ typedef typename __rebind_v::other::pointer pointer;
+ typedef typename __rebind_v::other::const_pointer const_pointer;
+ typedef typename __rebind_v::other::reference reference;
+ typedef typename __rebind_v::other::const_reference const_reference;
- typedef Value_Type value_type;
+ typedef left_child_next_sibling_heap_node_point_const_iterator_<node, _Alloc>
+ point_const_iterator;
- typedef
- typename Allocator::template rebind<
- value_type>::other::pointer
- pointer;
-
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_pointer
- const_pointer;
+ typedef point_const_iterator point_iterator;
- typedef
- typename Allocator::template rebind<
- value_type>::other::reference
- reference;
-
- typedef
- typename Allocator::template rebind<
- value_type>::other::const_reference
- const_reference;
-
- typedef
- left_child_next_sibling_heap_node_const_point_iterator_<
- node,
- Allocator>
- const_point_iterator;
-
- typedef const_point_iterator point_iterator;
-
- typedef
- left_child_next_sibling_heap_const_iterator_<
- node,
- Allocator>
+ typedef left_child_next_sibling_heap_const_iterator_<node, _Alloc>
const_iterator;
- typedef const_iterator iterator;
-
- typedef Cmp_Fn cmp_fn;
-
- typedef Allocator allocator_type;
+ typedef const_iterator iterator;
+ typedef Cmp_Fn cmp_fn;
+ typedef _Alloc allocator_type;
public:
- left_child_next_sibling_heap_();
-
- left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn);
-
- left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other);
+ left_child_next_sibling_heap();
+ left_child_next_sibling_heap(const Cmp_Fn&);
+ left_child_next_sibling_heap(const left_child_next_sibling_heap&);
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
- ~left_child_next_sibling_heap_();
+ ~left_child_next_sibling_heap();
inline bool
empty() const;
inline size_type
max_size() const;
- Cmp_Fn&
+ Cmp_Fn&
get_cmp_fn();
- const Cmp_Fn&
+ const Cmp_Fn&
get_cmp_fn() const;
inline iterator
#ifdef PB_DS_LC_NS_HEAP_TRACE_
void
trace() const;
-#endif
+#endif
protected:
inline node_pointer
- get_new_node_for_insert(const_reference r_val);
+ get_new_node_for_insert(const_reference);
inline static void
- make_child_of(node_pointer p_nd, node_pointer p_new_parent);
+ make_child_of(node_pointer, node_pointer);
void
- value_swap(PB_DS_CLASS_C_DEC& other);
+ value_swap(left_child_next_sibling_heap&);
inline static node_pointer
- parent(node_pointer p_nd);
+ parent(node_pointer);
inline void
- swap_with_parent(node_pointer p_nd, node_pointer p_parent);
+ swap_with_parent(node_pointer, node_pointer);
void
- bubble_to_top(node_pointer p_nd);
+ bubble_to_top(node_pointer);
inline void
- actual_erase_node(node_pointer p_nd);
+ actual_erase_node(node_pointer);
void
- clear_imp(node_pointer p_nd);
+ clear_imp(node_pointer);
void
to_linked_list();
template<typename Pred>
node_pointer
- prune(Pred pred);
+ prune(Pred);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
void
- assert_node_consistent(const_node_pointer p_nd, bool single_link,
- const char* file, int line) const;
+ assert_node_consistent(node_const_pointer, bool, const char*, int) const;
static size_type
- size_under_node(const_node_pointer p_nd);
+ size_under_node(node_const_pointer);
static size_type
- degree(const_node_pointer p_nd);
-#endif
+ degree(node_const_pointer);
+#endif
#ifdef PB_DS_LC_NS_HEAP_TRACE_
static void
- trace_node(const_node_pointer, size_type level);
-#endif
-
- protected:
- node_pointer m_p_root;
-
- size_type m_size;
+ trace_node(node_const_pointer, size_type);
+#endif
private:
#ifdef _GLIBCXX_DEBUG
void
- assert_iterators(const char* file, int line) const;
+ assert_iterators(const char*, int) const;
void
- assert_size(const char* file, int line) const;
+ assert_size(const char*, int) const;
static size_type
- size_from_node(const_node_pointer p_nd);
-#endif
+ size_from_node(node_const_pointer);
+#endif
node_pointer
- recursive_copy_node(const_node_pointer p_nd);
+ recursive_copy_node(node_const_pointer);
inline node_pointer
- get_new_node_for_insert(const_reference r_val, false_type);
+ get_new_node_for_insert(const_reference, false_type);
inline node_pointer
- get_new_node_for_insert(const_reference r_val, true_type);
+ get_new_node_for_insert(const_reference, true_type);
#ifdef PB_DS_LC_NS_HEAP_TRACE_
template<typename Metadata_>
static void
- trace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>);
+ trace_node_metadata(node_const_pointer, type_to_type<Metadata_>);
static void
- trace_node_metadata(const_node_pointer, type_to_type<null_left_child_next_sibling_heap_node_metadata>);
-#endif
+ trace_node_metadata(node_const_pointer,
+ type_to_type<null_type>);
+#endif
+ protected:
+ node_pointer m_p_root;
+ size_type m_size;
private:
- static node_allocator s_node_allocator;
-
- static no_throw_copies_t s_no_throw_copies_ind;
+ static node_allocator s_node_allocator;
+ static no_throw_copies_t s_no_throw_copies_ind;
};
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp>
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// warranty.
/**
- * @file node.hpp
+ * @file left_child_next_sibling_heap_/node.hpp
* Contains an implementation struct for this type of heap's node.
*/
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
-#include <ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp>
-
namespace __gnu_pbds
{
namespace detail
{
-
- template<typename Value_Type, typename Metadata_Type, class Allocator>
+ /// Node.
+ template<typename _Value, typename _Metadata, typename _Alloc>
struct left_child_next_sibling_heap_node_
{
private:
- typedef
- left_child_next_sibling_heap_node_<
- Value_Type,
- Metadata_Type,
- Allocator>
- this_type;
-
- public:
- typedef typename Allocator::size_type size_type;
-
- typedef
- typename Allocator::template rebind<
- this_type>::other::pointer
- node_pointer;
-
- typedef Value_Type value_type;
-
- typedef Metadata_Type metadata_type;
+ typedef left_child_next_sibling_heap_node_<_Value, _Metadata, _Alloc> this_type;
public:
- value_type m_value;
+ typedef _Value value_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef _Metadata metadata_type;
- metadata_type m_metadata;
+ typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
- node_pointer m_p_l_child;
-
- node_pointer m_p_next_sibling;
-
- node_pointer m_p_prev_or_parent;
+ value_type m_value;
+ metadata_type m_metadata;
+ node_pointer m_p_l_child;
+ node_pointer m_p_next_sibling;
+ node_pointer m_p_prev_or_parent;
};
- template<typename Value_Type, class Allocator>
- struct left_child_next_sibling_heap_node_<
- Value_Type,
- null_left_child_next_sibling_heap_node_metadata,
- Allocator>
+ template<typename _Value, typename _Alloc>
+ struct left_child_next_sibling_heap_node_<_Value, null_type, _Alloc>
{
private:
- typedef
- left_child_next_sibling_heap_node_<
- Value_Type,
- null_left_child_next_sibling_heap_node_metadata,
- Allocator>
- this_type;
+ typedef left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> this_type;
public:
- typedef typename Allocator::size_type size_type;
-
- typedef
- typename Allocator::template rebind<
- this_type>::other::pointer
- node_pointer;
-
- typedef Value_Type value_type;
-
- public:
- value_type m_value;
-
- node_pointer m_p_l_child;
+ typedef _Value value_type;
+ typedef typename _Alloc::size_type size_type;
- node_pointer m_p_next_sibling;
+ typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
- node_pointer m_p_prev_or_parent;
+ value_type m_value;
+ node_pointer m_p_l_child;
+ node_pointer m_p_next_sibling;
+ node_pointer m_p_prev_or_parent;
};
} // namespace detail
+++ /dev/null
-// -*- C++ -*-
-
-// Copyright (C) 2005, 2006, 2008, 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
-// 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 null_metadata.hpp
- * Contains an implementation struct for this type of heap's node.
- */
-
-#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
-#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
- struct null_left_child_next_sibling_heap_node_metadata
- { };
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_0_METADATA_HPP
--- /dev/null
+// -*- C++ -*-
+
+// 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
+// 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 left_child_next_sibling_heap_/point_const_iterator.hpp
+ * Contains an iterator class returned by the table's const find and insert
+ * methods.
+ */
+
+#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
+#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
+
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <debug/debug.h>
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Node, typename _Alloc>
+
+#define PB_DS_CLASS_C_DEC \
+ left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc>
+
+ /// Const point-type iterator.
+ template<typename Node, typename _Alloc>
+ class left_child_next_sibling_heap_node_point_const_iterator_
+ {
+
+ protected:
+ typedef typename _Alloc::template rebind<Node>::other::pointer node_pointer;
+
+ public:
+
+ // Category.
+ typedef trivial_iterator_tag iterator_category;
+
+ // Difference type.
+ typedef trivial_iterator_difference_type difference_type;
+
+ // Iterator's value type.
+ typedef typename Node::value_type value_type;
+
+ // Iterator's pointer type.
+ typedef
+ typename _Alloc::template rebind<
+ value_type>::other::pointer
+ pointer;
+
+ // Iterator's const pointer type.
+ typedef
+ typename _Alloc::template rebind<
+ value_type>::other::const_pointer
+ const_pointer;
+
+ // Iterator's reference type.
+ typedef
+ typename _Alloc::template rebind<
+ value_type>::other::reference
+ reference;
+
+ // Iterator's const reference type.
+ typedef
+ typename _Alloc::template rebind<
+ value_type>::other::const_reference
+ const_reference;
+
+ public:
+
+ inline
+ left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd)
+ { }
+
+ // Default constructor.
+ inline
+ left_child_next_sibling_heap_node_point_const_iterator_() : m_p_nd(0)
+ { }
+
+ // Copy constructor.
+ inline
+ left_child_next_sibling_heap_node_point_const_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd)
+ { }
+
+ // Access.
+ inline const_pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
+ return &m_p_nd->m_value;
+ }
+
+ // Access.
+ inline const_reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
+ return m_p_nd->m_value;
+ }
+
+ // Compares content to a different iterator object.
+ inline bool
+ operator==(const PB_DS_CLASS_C_DEC& other) const
+ { return m_p_nd == other.m_p_nd; }
+
+ // Compares content (negatively) to a different iterator object.
+ inline bool
+ operator!=(const PB_DS_CLASS_C_DEC& other) const
+ { return m_p_nd != other.m_p_nd; }
+
+ public:
+ node_pointer m_p_nd;
+ };
+
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_CLASS_C_DEC
+
+ } // namespace detail
+} // namespace __gnu_pbds
+
+#endif
// warranty.
/**
- * @file policy_access_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/policy_access_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file left_child_next_sibling_heap_/trace_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
trace() const
{
std::cerr << std::endl;
-
trace_node(m_p_root, 0);
-
std::cerr << std::endl;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-trace_node(const_node_pointer p_nd, size_type level)
+trace_node(node_const_pointer p_nd, size_type level)
{
while (p_nd != 0)
{
" left = " << p_nd->m_p_l_child << " ";
trace_node_metadata(p_nd, type_to_type<node_metadata>());
-
std::cerr << p_nd->m_value << std::endl;
-
trace_node(p_nd->m_p_l_child, level + 1);
-
p_nd = p_nd->m_p_next_sibling;
}
}
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
-trace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>)
+trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>)
{
std::cerr << "(" << p_nd->m_metadata << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-trace_node_metadata(const_node_pointer, type_to_type<null_left_child_next_sibling_heap_node_metadata>)
+trace_node_metadata(node_const_pointer, type_to_type<null_type>)
{ }
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_
// warranty.
/**
- * @file constructor_destructor_fn_imps.hpp
- * Contains implementations of PB_DS_CLASS_NAME.
+ * @file list_update_map_/constructor_destructor_fn_imps.hpp
*/
PB_DS_CLASS_T_DEC
Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn;
PB_DS_CLASS_T_DEC
-null_lu_metadata PB_DS_CLASS_C_DEC::s_null_lu_metadata;
+null_type PB_DS_CLASS_C_DEC::s_null_type;
PB_DS_CLASS_T_DEC
Update_Policy PB_DS_CLASS_C_DEC::s_update_policy;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME() : m_p_l(0)
+PB_DS_LU_NAME() : m_p_l(0)
{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
template<typename It>
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0)
+PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0)
{
copy_from_range(first_it, last_it);
PB_DS_ASSERT_VALID((*this));
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) :
m_p_l(0)
{
__try
{
for (const_iterator it = other.begin(); it != other.end(); ++it)
- {
- entry_pointer p_l = allocate_new_entry(*it,
- PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator);
+ {
+ entry_pointer p_l = allocate_new_entry(*it,
+ traits_base::m_no_throw_copies_indicator);
p_l->m_p_next = m_p_l;
m_p_l = p_l;
- }
+ }
}
__catch(...)
{
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~PB_DS_CLASS_NAME()
+~PB_DS_LU_NAME()
{ deallocate_all(); }
-
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file list_update_map_/debug_fn_imps.hpp
* Contains implementations of cc_ht_map_'s debug-mode functions.
*/
// warranty.
/**
- * @file entry_metadata_base.hpp
+ * @file list_update_map_/entry_metadata_base.hpp
* Contains an implementation for a list update map.
*/
};
template<>
- struct lu_map_entry_metadata_base<null_lu_metadata>
+ struct lu_map_entry_metadata_base<null_type>
{ };
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file list_update_map_/erase_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
if (m_p_l == 0)
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file list_update_map_/find_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::entry_pointer
PB_DS_CLASS_C_DEC::
-find_imp(const_key_reference r_key) const
+find_imp(key_const_reference r_key) const
{
if (m_p_l == 0)
return 0;
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-apply_update(entry_pointer, type_to_type<null_lu_metadata>)
-{ return s_update_policy(s_null_lu_metadata); }
+apply_update(entry_pointer, type_to_type<null_type>)
+{ return s_update_policy(s_null_type); }
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file list_update_map_/info_fn_imps.hpp
* Contains implementations of lu_map_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file list_update_map_/insert_fn_imps.hpp
* Contains implementations of lu_map_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-init_entry_metadata(entry_pointer, type_to_type<null_lu_metadata>)
+init_entry_metadata(entry_pointer, type_to_type<null_type>)
{ }
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file list_update_map_/iterators_fn_imps.hpp
* Contains implementations of lu_map_.
*/
// warranty.
/**
- * @file lu_map_.hpp
+ * @file list_update_map_/lu_map_.hpp
* Contains a list update map.
*/
#include <ext/pb_ds/exception.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
-#endif
+#endif
#ifdef PB_DS_LU_MAP_TRACE_
#include <iostream>
-#endif
+#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, class Eq_Fn, \
- class Allocator, class Update_Policy>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME lu_map_data_
-#endif
+#define PB_DS_LU_NAME lu_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME lu_map_no_data_
-#endif
+#define PB_DS_LU_NAME lu_set
+#endif
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Eq_Fn, \
+ typename _Alloc, typename Update_Policy>
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Eq_Fn, Allocator, Update_Policy>
+ PB_DS_LU_NAME<Key, Mapped, Eq_Fn, _Alloc, Update_Policy>
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits<Key, Mapped, Allocator, false>
+#define PB_DS_LU_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
- typename Allocator::template rebind<Key>::other::const_reference>
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
+ typename _Alloc::template rebind<Key>::other::const_reference>
+#endif
- /* Skip to the lu, my darling. */
- // list-based (with updates) associative container.
+ /// list-based (with updates) associative container.
+ /// Skip to the lu, my darling.
template<typename Key,
typename Mapped,
- class Eq_Fn,
- class Allocator,
- class Update_Policy>
- class PB_DS_CLASS_NAME :
+ typename Eq_Fn,
+ typename _Alloc,
+ typename Update_Policy>
+ class PB_DS_LU_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
- public PB_DS_TYPES_TRAITS_C_DEC
+#endif
+ public PB_DS_LU_TRAITS_BASE
{
private:
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
+ typedef PB_DS_LU_TRAITS_BASE traits_base;
- struct entry
+ struct entry
: public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
{
typename traits_base::value_type m_value;
- typename Allocator::template rebind<entry>::other::pointer m_p_next;
+ typename _Alloc::template rebind<entry>::other::pointer m_p_next;
};
- typedef typename Allocator::template rebind<entry>::other entry_allocator;
+ typedef typename _Alloc::template rebind<entry>::other entry_allocator;
typedef typename entry_allocator::pointer entry_pointer;
typedef typename entry_allocator::const_pointer const_entry_pointer;
typedef typename entry_allocator::reference entry_reference;
typedef typename entry_allocator::const_reference const_entry_reference;
- typedef typename Allocator::template rebind<entry_pointer>::other entry_pointer_allocator;
+ typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
typedef typename traits_base::value_type value_type_;
#define PB_DS_GEN_POS entry_pointer
-#include <ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp>
+#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+#endif
- typedef cond_dealtor<entry, Allocator> cond_dealtor_t;
+ typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
public:
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
typedef Eq_Fn eq_fn;
typedef Update_Policy update_policy;
typedef typename Update_Policy::metadata_type update_metadata;
typedef typename traits_base::key_type key_type;
typedef typename traits_base::key_pointer key_pointer;
- typedef typename traits_base::const_key_pointer const_key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
typedef typename traits_base::key_reference key_reference;
- typedef typename traits_base::const_key_reference const_key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
typedef typename traits_base::mapped_type mapped_type;
typedef typename traits_base::mapped_pointer mapped_pointer;
- typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
typedef typename traits_base::mapped_reference mapped_reference;
- typedef typename traits_base::const_mapped_reference const_mapped_reference;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
typedef typename traits_base::value_type value_type;
typedef typename traits_base::pointer pointer;
typedef typename traits_base::const_pointer const_pointer;
typedef typename traits_base::const_reference const_reference;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef point_iterator_ point_iterator;
-#endif
+ typedef point_iterator_ point_iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_point_iterator_ point_iterator;
-#endif
+ typedef point_const_iterator_ point_iterator;
+#endif
- typedef const_point_iterator_ const_point_iterator;
+ typedef point_const_iterator_ point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef iterator_ iterator;
-#endif
+ typedef iterator_ iterator;
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
- typedef const_iterator_ iterator;
-#endif
+ typedef const_iterator_ iterator;
+#endif
- typedef const_iterator_ const_iterator;
+ typedef const_iterator_ const_iterator;
public:
- PB_DS_CLASS_NAME();
+ PB_DS_LU_NAME();
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC&);
virtual
- ~PB_DS_CLASS_NAME();
+ ~PB_DS_LU_NAME();
template<typename It>
- PB_DS_CLASS_NAME(It first_it, It last_it);
+ PB_DS_LU_NAME(It, It);
void
swap(PB_DS_CLASS_C_DEC&);
empty() const;
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return insert(std::make_pair(r_key, mapped_type())).first->second;
-#else
+#else
insert(r_key);
- return traits_base::s_null_mapped;
-#endif
+ return traits_base::s_null_type;
+#endif
}
inline std::pair<point_iterator, bool>
insert(const_reference);
inline point_iterator
- find(const_key_reference r_key)
+ find(key_const_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key);
return point_iterator(p_e == 0 ? 0: &p_e->m_value);
}
- inline const_point_iterator
- find(const_key_reference r_key) const
+ inline point_const_iterator
+ find(key_const_reference r_key) const
{
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
entry_pointer p_e = find_imp(r_key);
- return const_point_iterator(p_e == 0 ? 0: &p_e->m_value);
+ return point_const_iterator(p_e == 0 ? 0: &p_e->m_value);
}
inline bool
- erase(const_key_reference);
+ erase(key_const_reference);
template<typename Pred>
inline size_type
#ifdef _GLIBCXX_DEBUG
void
assert_valid(const char* file, int line) const;
-#endif
+#endif
#ifdef PB_DS_LU_MAP_TRACE_
void
private:
#ifdef PB_DS_DATA_TRUE_INDICATOR
friend class iterator_;
-#endif
+#endif
friend class const_iterator_;
init_entry_metadata(entry_pointer, type_to_type<Metadata>);
inline static void
- init_entry_metadata(entry_pointer, type_to_type<null_lu_metadata>);
+ init_entry_metadata(entry_pointer, type_to_type<null_type>);
void
deallocate_all();
apply_update(entry_pointer, type_to_type<Metadata>);
inline static bool
- apply_update(entry_pointer, type_to_type<null_lu_metadata>);
+ apply_update(entry_pointer, type_to_type<null_type>);
inline entry_pointer
- find_imp(const_key_reference) const;
+ find_imp(key_const_reference) const;
- static entry_allocator s_entry_allocator;
- static Eq_Fn s_eq_fn;
- static Update_Policy s_update_policy;
- static type_to_type<update_metadata> s_metadata_type_indicator;
- static null_lu_metadata s_null_lu_metadata;
+ static entry_allocator s_entry_allocator;
+ static Eq_Fn s_eq_fn;
+ static Update_Policy s_update_policy;
+ static type_to_type<update_metadata> s_metadata_type_indicator;
+ static null_type s_null_type;
- mutable entry_pointer m_p_l;
+ mutable entry_pointer m_p_l;
};
#include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_LU_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
-
+#undef PB_DS_LU_NAME
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file list_update_map_/trace_fn_imps.hpp
* Contains implementations of lu_map_.
*/
+++ /dev/null
-// -*- C++ -*-
-
-// Copyright (C) 2005, 2006, 2007, 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
-// 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 counter_lu_metadata.hpp
- * Contains implementation of a lu counter policy's metadata.
- */
-
-namespace __gnu_pbds
-{
- namespace detail
- {
- template<typename Size_Type>
- class counter_lu_policy_base;
-
- // A list-update metadata type that moves elements to the front of
- // the list based on the counter algorithm.
- template<typename Size_Type = std::size_t>
- class counter_lu_metadata
- {
- public:
- typedef Size_Type size_type;
-
- private:
- counter_lu_metadata(size_type init_count) : m_count(init_count)
- { }
-
- friend class counter_lu_policy_base<size_type>;
-
- mutable size_type m_count;
- };
-
- template<typename Size_Type>
- class counter_lu_policy_base
- {
- protected:
- typedef Size_Type size_type;
-
- counter_lu_metadata<size_type>
- operator()(size_type max_size) const
- { return counter_lu_metadata<Size_Type>(std::rand() % max_size); }
-
- template<typename Metadata_Reference>
- bool
- operator()(Metadata_Reference r_data, size_type m_max_count) const
- {
- if (++r_data.m_count != m_max_count)
- return false;
- r_data.m_count = 0;
- return true;
- }
- };
- } // namespace detail
-} // namespace __gnu_pbds
+++ /dev/null
-// -*- 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 counter_lu_policy_imp.hpp
- * Contains a lu counter policy implementation.
- */
-
-PB_DS_CLASS_T_DEC
-detail::counter_lu_metadata<typename Allocator::size_type>
-PB_DS_CLASS_C_DEC::
-operator()() const
-{ return (base_type::operator()(max_count)); }
-
-PB_DS_CLASS_T_DEC
-bool
-PB_DS_CLASS_C_DEC::
-operator()(metadata_reference r_data) const
-{ return (base_type::operator()(r_data, max_count)); }
--- /dev/null
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 lu_counter_metadata.hpp
+ * Contains implementation of a lu counter policy's metadata.
+ */
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+ template<typename Size_Type>
+ class lu_counter_policy_base;
+
+ /// A list-update metadata type that moves elements to the front of
+ /// the list based on the counter algorithm.
+ template<typename Size_Type = std::size_t>
+ class lu_counter_metadata
+ {
+ public:
+ typedef Size_Type size_type;
+
+ private:
+ lu_counter_metadata(size_type init_count) : m_count(init_count)
+ { }
+
+ friend class lu_counter_policy_base<size_type>;
+
+ mutable size_type m_count;
+ };
+
+ /// Base class for list-update counter policy.
+ template<typename Size_Type>
+ class lu_counter_policy_base
+ {
+ protected:
+ typedef Size_Type size_type;
+
+ lu_counter_metadata<size_type>
+ operator()(size_type max_size) const
+ { return lu_counter_metadata<Size_Type>(std::rand() % max_size); }
+
+ template<typename Metadata_Reference>
+ bool
+ operator()(Metadata_Reference r_data, size_type m_max_count) const
+ {
+ if (++r_data.m_count != m_max_count)
+ return false;
+ r_data.m_count = 0;
+ return true;
+ }
+ };
+ } // namespace detail
+} // namespace __gnu_pbds
+++ /dev/null
-// -*- 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 mtf_lu_policy_imp.hpp
- * Contains a move-to-front policy implementation.
- */
-
-PB_DS_CLASS_T_DEC
-null_lu_metadata PB_DS_CLASS_C_DEC::s_metadata;
-
-PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::metadata_type
-PB_DS_CLASS_C_DEC::
-operator()() const
-{ return s_metadata; }
-
-PB_DS_CLASS_T_DEC
-inline bool
-PB_DS_CLASS_C_DEC::
-operator()(metadata_reference /*r_data*/) const
-{ return true; }
-
#ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP
#define PB_DS_SAMPLE_UPDATE_POLICY_HPP
-// A sample list-update policy.
-struct sample_update_policy
+namespace __gnu_pbds
{
- // Default constructor.
- sample_update_policy();
+ /// A sample list-update policy.
+ struct sample_update_policy
+ {
+ // Default constructor.
+ sample_update_policy();
- // Copy constructor.
- sample_update_policy(const sample_update_policy&);
+ // Copy constructor.
+ sample_update_policy(const sample_update_policy&);
- // Swaps content.
- inline void
- swap(sample_update_policy& other);
+ // Swaps content.
+ inline void
+ swap(sample_update_policy& other);
-protected:
- // Metadata on which this functor operates.
- typedef some_metadata_type metadata_type;
+ protected:
+ // Metadata on which this functor operates.
+ typedef some_metadata_type metadata_type;
- // Creates a metadata object.
- metadata_type
- operator()() const;
+ // Creates a metadata object.
+ metadata_type
+ operator()() const;
- // Decides whether a metadata object should be moved to the front of
- // the list. A list-update based containers object will call this
- // method to decide whether to move a node to the front of the
- // list. The method shoule return true if the node should be moved
- // to the front of the list.
- bool
- operator()(metadata_reference) const;
-};
-
-#endif
+ // Decides whether a metadata object should be moved to the front of
+ // the list. A list-update based containers object will call this
+ // method to decide whether to move a node to the front of the
+ // list. The method shoule return true if the node should be moved
+ // to the front of the list.
+ bool
+ operator()(metadata_reference) const;
+ };
+}
+#endif
+++ /dev/null
-// -*- 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.hpp
- * Contains a conditional destructor
- */
-
-template<typename Size_Type>
-class cond_dtor
-{
-public:
- cond_dtor(value_vector a_vec, iterator& r_last_it, Size_Type total_size)
- : m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size),
- m_no_action(false)
- { }
-
- ~cond_dtor()
- {
- if (m_no_action)
- return;
- iterator it = m_a_vec;
- while (it != m_r_last_it)
- {
- it->~value_type();
- ++it;
- }
-
- if (m_max_size > 0)
- value_allocator().deallocate(m_a_vec, m_max_size);
- }
-
- inline void
- set_no_action()
- { m_no_action = true; }
-
-protected:
- value_vector m_a_vec;
- iterator& m_r_last_it;
- const Size_Type m_max_size;
- bool m_no_action;
-};
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file ov_tree_map_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_OV_TREE_CLASS_NAME() :
+PB_DS_OV_TREE_NAME() :
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
- cmp_fn_base(r_cmp_fn),
+PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
+ cmp_fn(r_cmp_fn),
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
- cmp_fn_base(r_cmp_fn),
- node_update(r_node_update),
+PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_nodeu) :
+ cmp_fn(r_cmp_fn),
+ node_update(r_nodeu),
m_a_values(0),
m_a_metadata(0),
m_end_it(0),
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef PB_DS_TREE_TRACE
- PB_DS_TREE_TRACE_BASE_C_DEC(other),
-#endif
- cmp_fn_base(other),
+ trace_base(other),
+#endif
+ cmp_fn(other),
node_update(other),
m_a_values(0),
m_a_metadata(0),
copy_from_range(It first_it, It last_it)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef
- std::map<
- key_type,
- mapped_type,
- Cmp_Fn,
- typename Allocator::template rebind<
- value_type>::other>
+ typedef std::map<key_type, mapped_type, Cmp_Fn,
+ typename _Alloc::template rebind<value_type>::other>
map_type;
-#else
- typedef
- std::set<
- key_type,
- Cmp_Fn,
- typename Allocator::template rebind<
- Key>::other>
+#else
+ typedef std::set<key_type, Cmp_Fn,
+ typename _Alloc::template rebind<Key>::other>
map_type;
-#endif
+#endif
map_type m(first_it, last_it);
copy_from_ordered_range(m.begin(), m.end());
cond_dtor<size_type> cd(a_values, target_it, len);
while (source_it != source_end_it)
{
- new (const_cast<void* >(static_cast<const void* >(target_it)))
- value_type(*source_it++);
-
+ void* __v = const_cast<void*>(static_cast<const void*>(target_it));
+ new (__v) value_type(*source_it++);
++target_it;
}
- reallocate_metadata((node_update* )this, len);
+ reallocate_metadata((node_update*)this, len);
cd.set_no_action();
m_a_values = a_values;
m_size = len;
m_end_it = m_a_values + m_size;
- update(PB_DS_node_begin_imp(), (node_update* )this);
+ update(PB_DS_node_begin_imp(), (node_update*)this);
#ifdef _GLIBCXX_DEBUG
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
- {
- debug_base::insert_new(PB_DS_V2F(*dbg_it));
- }
+ debug_base::insert_new(PB_DS_V2F(*dbg_it));
#endif
}
template<typename It>
void
PB_DS_CLASS_C_DEC::
-copy_from_ordered_range(It first_it, It last_it, It other_first_it,
+copy_from_ordered_range(It first_it, It last_it, It other_first_it,
It other_last_it)
{
clear();
- const size_type len = std::distance(first_it, last_it)
- + std::distance(other_first_it, other_last_it);
+ const size_type len = std::distance(first_it, last_it)
+ + std::distance(other_first_it, other_last_it);
value_vector a_values = s_value_alloc.allocate(len);
#ifdef _GLIBCXX_DEBUG
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it)
- {
- debug_base::insert_new(PB_DS_V2F(*dbg_it));
- }
+ debug_base::insert_new(PB_DS_V2F(*dbg_it));
#endif
}
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
- std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
+ std::swap(static_cast<cmp_fn&>(*this),
+ static_cast<cmp_fn&>(other));
+ std::swap(static_cast<traits_base&>(*this),
+ static_cast<traits_base&>(other));
PB_DS_ASSERT_VALID(other)
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other)
{
+ _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
std::swap(m_a_values, other.m_a_values);
std::swap(m_a_metadata, other.m_a_metadata);
std::swap(m_size, other.m_size);
std::swap(m_end_it, other.m_end_it);
- _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~PB_DS_OV_TREE_CLASS_NAME()
+~PB_DS_OV_TREE_NAME()
{
- //PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID((*this))
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size);
reallocate_metadata((node_update*)this, 0);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-update(node_iterator /*it*/, null_node_update_pointer)
+update(node_iterator, null_node_update_pointer)
{ }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
update(node_iterator nd_it, Node_Update* p_update)
{
- const_node_iterator end_it = PB_DS_node_end_imp();
- if (nd_it == end_it)
- return;
- update(nd_it.get_l_child(), p_update);
- update(nd_it.get_r_child(), p_update);
- node_update::operator()(nd_it, end_it);
+ node_const_iterator end_it = PB_DS_node_end_imp();
+ if (nd_it != end_it)
+ {
+ update(nd_it.get_l_child(), p_update);
+ update(nd_it.get_r_child(), p_update);
+ node_update::operator()(nd_it, end_it);
+ }
}
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file ov_tree_map_/debug_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_DEBUG_VERIFY(iterated_num == m_size);
}
-#endif
-
+#endif
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file ov_tree_map_/erase_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_ASSERT_VALID((*this))
#ifdef PB_DS_REGRESSION
- typename Allocator::group_adjustor adjust(m_size);
-#endif
+ typename _Alloc::group_adjustor adjust(m_size);
+#endif
size_type new_size = 0;
size_type num_val_ersd = 0;
+
for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
if (!pred(*source_it))
++new_size;
for (iterator source_it = begin(); source_it != m_end_it; ++source_it)
{
if (!pred(*source_it))
- {
- new (const_cast<void*>(static_cast<const void* >(target_it)))
+ {
+ new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it);
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(*source_it)));
++target_it;
- }
+ }
}
- reallocate_metadata((node_update* )this, new_size);
+ reallocate_metadata((node_update*)this, new_size);
cd.set_no_action();
{
m_a_values = a_new_values;
m_size = new_size;
m_end_it = target_it;
- update(node_begin(), (node_update* )this);
+ update(node_begin(), (node_update*)this);
PB_DS_ASSERT_VALID((*this))
return num_val_ersd;
}
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it))
#ifdef PB_DS_REGRESSION
- typename Allocator::group_adjustor adjust(m_size);
-#endif
+ typename _Alloc::group_adjustor adjust(m_size);
+#endif
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
value_vector a_values = s_value_alloc.allocate(m_size - 1);
{
if (source_it != it)
{
- _GLIBCXX_DEBUG_ONLY(++cnt;)
+ _GLIBCXX_DEBUG_ONLY(++cnt;)
_GLIBCXX_DEBUG_ASSERT(cnt != m_size);
- new (const_cast<void* >(static_cast<const void* >(target_it)))
+ new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it);
- ++target_it;
+ ++target_it;
}
else
ret_it = target_it;
}
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
- reallocate_metadata((node_update* )this, m_size - 1);
+ reallocate_metadata((node_update*)this, m_size - 1);
cd.set_no_action();
- _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::erase_existing(PB_DS_V2F(*it));)
+ _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(*it));)
{
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size);
}
m_a_values = a_values;
--m_size;
m_end_it = m_a_values + m_size;
- update(node_begin(), (node_update* )this);
+ update(node_begin(), (node_update*)this);
PB_DS_ASSERT_VALID((*this))
return It(ret_it);
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
point_iterator it = find(r_key);
if (it == end())
erase(it);
return true;
}
-
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file ov_tree_map_/info_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file ov_tree_map_/insert_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
// warranty.
/**
- * @file iterators_fn_imps.hpp
+ * @file ov_tree_map_/iterators_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
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 PB_DS_node_begin_imp(); }
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 PB_DS_node_end_imp(); }
{ return PB_DS_node_end_imp(); }
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_node_iterator
+inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
PB_DS_node_begin_imp() const
{
- return const_node_iterator(const_cast<pointer>(mid_pointer(begin(), end())),
+ return node_const_iterator(const_cast<pointer>(mid_pointer(begin(), end())),
const_cast<pointer>(begin()),
const_cast<pointer>(end()),(m_a_metadata == 0)?
0 :
}
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::
PB_DS_node_end_imp() const
{
- return const_node_iterator(end(), end(), end(),
+ return node_const_iterator(end(), end(), end(),
(m_a_metadata == 0) ? 0 : m_a_metadata + m_size);
}
// warranty.
/**
- * @file node_iterators.hpp
+ * @file ov_tree_map_/node_iterators.hpp
* Contains an implementation class for ov_tree_.
*/
{
namespace detail
{
-
#define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \
- ov_tree_node_const_it_<Value_Type, Metadata_Type, Allocator>
+ ov_tree_node_const_it_<Value_Type, Metadata_Type, _Alloc>
- // Const node reference.
- template<typename Value_Type, typename Metadata_Type, class Allocator>
+ /// Const node reference.
+ template<typename Value_Type, typename Metadata_Type, typename _Alloc>
class ov_tree_node_const_it_
{
protected:
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
Value_Type>::other::pointer
pointer;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
Value_Type>::other::const_pointer
const_pointer;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
Metadata_Type>::other::const_pointer
const_metadata_pointer;
typedef trivial_iterator_difference_type difference_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
Value_Type>::other::const_pointer
value_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::const_pointer
reference;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::const_pointer
const_reference;
typedef Metadata_Type metadata_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
metadata_type>::other::const_reference
- const_metadata_reference;
+ metadata_const_reference;
public:
inline
operator*() const
{ return m_p_value; }
- inline const_metadata_reference
+ inline metadata_const_reference
get_metadata() const
{
enum
{
- has_metadata = !is_same<Metadata_Type, null_node_metadata>::value
+ has_metadata = !is_same<Metadata_Type, null_type>::value
};
PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata);
};
#define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \
- ov_tree_node_it_<Value_Type, Metadata_Type, Allocator>
+ ov_tree_node_it_<Value_Type, Metadata_Type, _Alloc>
- // Node reference.
- template<typename Value_Type, typename Metadata_Type, class Allocator>
+ /// Node reference.
+ template<typename Value_Type, typename Metadata_Type, typename _Alloc>
class ov_tree_node_it_ : public PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC
{
typedef trivial_iterator_difference_type difference_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
Value_Type>::other::pointer
value_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::pointer
reference;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
typename remove_const<
Value_Type>::type>::other::pointer
const_reference;
get_r_child() const
{
if (base_type::m_p_value == base_type::m_p_end_value)
- return (this_type(base_type::m_p_end_value, base_type::m_p_end_value, base_type::m_p_end_value));
+ return this_type(base_type::m_p_end_value,
+ base_type::m_p_end_value,
+ base_type::m_p_end_value);
const_metadata_pointer p_end_metadata =
base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value);
// warranty.
/**
- * @file ov_tree_map_.hpp
+ * @file ov_tree_map_/ov_tree_map_.hpp
* Contains an implementation class for ov_tree_.
*/
#include <map>
#include <set>
+#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
-#include <ext/pb_ds/detail/debug_map_base.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <ext/pb_ds/exception.hpp>
#include <ext/pb_ds/detail/tree_trace_base.hpp>
+#ifdef _GLIBCXX_DEBUG
+#include <ext/pb_ds/detail/debug_map_base.hpp>
+#endif
#include <utility>
#include <functional>
#include <algorithm>
{
namespace detail
{
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, class Cmp_Fn, \
- class Node_And_It_Traits, class Allocator>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_OV_TREE_CLASS_NAME ov_tree_data_
-#endif
+#define PB_DS_OV_TREE_NAME ov_tree_map
+#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_OV_TREE_CLASS_NAME ov_tree_no_data_
-#endif
+#define PB_DS_OV_TREE_NAME ov_tree_set
+#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_set
+#endif
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_data_
-#else
-#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_const_node_iterator_no_data_
-#endif
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Cmp_Fn, \
+ typename Node_And_It_Traits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- PB_DS_OV_TREE_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
+ PB_DS_OV_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits<Key, Mapped, Allocator, false>
+#define PB_DS_OV_TREE_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
- typename Allocator::template rebind<Key>::other::const_reference>
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
+ typename _Alloc::template rebind<Key>::other::const_reference>
+#endif
#ifdef PB_DS_TREE_TRACE
#define PB_DS_TREE_TRACE_BASE_C_DEC \
- tree_trace_base<typename Node_And_It_Traits::const_node_iterator, \
+ tree_trace_base<typename Node_And_It_Traits::node_const_iterator, \
typename Node_And_It_Traits::node_iterator, \
- Cmp_Fn, false, Allocator>
+ Cmp_Fn, false, _Alloc>
#endif
#ifndef PB_DS_CHECK_KEY_EXISTS
# error Missing definition
#endif
- // Ordered-vector tree associative-container.
- template<typename Key, typename Mapped, class Cmp_Fn,
- class Node_And_It_Traits, class Allocator>
- class PB_DS_OV_TREE_CLASS_NAME :
+ /// Ordered-vector tree associative-container.
+ template<typename Key, typename Mapped, typename Cmp_Fn,
+ typename Node_And_It_Traits, typename _Alloc>
+ class PB_DS_OV_TREE_NAME :
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
+#endif
#ifdef PB_DS_TREE_TRACE
public PB_DS_TREE_TRACE_BASE_C_DEC,
-#endif
+#endif
public Cmp_Fn,
public Node_And_It_Traits::node_update,
- public PB_DS_TYPES_TRAITS_C_DEC
+ public PB_DS_OV_TREE_TRAITS_BASE
{
private:
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
+ typedef PB_DS_OV_TREE_TRAITS_BASE traits_base;
+ typedef Node_And_It_Traits traits_type;
typedef typename remove_const<typename traits_base::value_type>::type non_const_value_type;
- typedef typename Allocator::template rebind<non_const_value_type>::other value_allocator;
- typedef typename value_allocator::pointer value_vector;
-
-
- typedef Cmp_Fn cmp_fn_base;
+ typedef typename _Alloc::template rebind<non_const_value_type>::other value_allocator;
+ typedef typename value_allocator::pointer value_vector;
#ifdef _GLIBCXX_DEBUG
- typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+ typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
+#endif
+
+#ifdef PB_DS_TREE_TRACE
+ typedef PB_DS_TREE_TRACE_BASE_C_DEC trace_base;
+#endif
- typedef typename traits_base::pointer mapped_pointer_;
- typedef typename traits_base::const_pointer const_mapped_pointer_;
+ typedef typename traits_base::pointer mapped_pointer_;
+ typedef typename traits_base::const_pointer mapped_const_pointer_;
- typedef typename Node_And_It_Traits::metadata_type metadata_type;
+ typedef typename traits_type::metadata_type metadata_type;
- typedef typename Allocator::template rebind<metadata_type>::other metadata_allocator;
- typedef typename metadata_allocator::pointer metadata_pointer;
- typedef typename metadata_allocator::const_reference const_metadata_reference;
- typedef typename metadata_allocator::reference metadata_reference;
+ typedef typename _Alloc::template rebind<metadata_type>::other metadata_allocator;
+ typedef typename metadata_allocator::pointer metadata_pointer;
+ typedef typename metadata_allocator::const_reference metadata_const_reference;
+ typedef typename metadata_allocator::reference metadata_reference;
- typedef
- typename Node_And_It_Traits::null_node_update_pointer
+ typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
public:
-
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
-
- typedef Cmp_Fn cmp_fn;
-
- typedef typename Node_And_It_Traits::node_update node_update;
-
- typedef typename traits_base::key_type key_type;
- typedef typename traits_base::key_pointer key_pointer;
- typedef typename traits_base::const_key_pointer const_key_pointer;
- typedef typename traits_base::key_reference key_reference;
- typedef typename traits_base::const_key_reference const_key_reference;
- typedef typename traits_base::mapped_type mapped_type;
- typedef typename traits_base::mapped_pointer mapped_pointer;
- typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
- typedef typename traits_base::mapped_reference mapped_reference;
- typedef typename traits_base::const_mapped_reference const_mapped_reference;
- typedef typename traits_base::value_type value_type;
- typedef typename traits_base::pointer pointer;
- typedef typename traits_base::const_pointer const_pointer;
- typedef typename traits_base::reference reference;
- typedef typename traits_base::const_reference const_reference;
-
- typedef const_pointer const_point_iterator;
-
+ typedef ov_tree_tag container_category;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef Cmp_Fn cmp_fn;
+
+ typedef typename traits_base::key_type key_type;
+ typedef typename traits_base::key_pointer key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
+ typedef typename traits_base::key_reference key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
+ typedef typename traits_base::mapped_type mapped_type;
+ typedef typename traits_base::mapped_pointer mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
+ typedef typename traits_base::mapped_reference mapped_reference;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
+ typedef typename traits_base::value_type value_type;
+ typedef typename traits_base::pointer pointer;
+ typedef typename traits_base::const_pointer const_pointer;
+ typedef typename traits_base::reference reference;
+ typedef typename traits_base::const_reference const_reference;
+
+ typedef const_pointer point_const_iterator;
#ifdef PB_DS_DATA_TRUE_INDICATOR
- typedef pointer point_iterator;
-#else
- typedef const_point_iterator point_iterator;
-#endif
-
- typedef const_point_iterator const_iterator;
-
- typedef point_iterator iterator;
-
-#include <ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp>
+ typedef pointer point_iterator;
+#else
+ typedef point_const_iterator point_iterator;
+#endif
- typedef
- typename Node_And_It_Traits::const_node_iterator
- const_node_iterator;
+ typedef point_iterator iterator;
+ typedef point_const_iterator const_iterator;
+
+ /// Conditional destructor.
+ template<typename Size_Type>
+ class cond_dtor
+ {
+ public:
+ cond_dtor(value_vector a_vec, iterator& r_last_it,
+ Size_Type total_size)
+ : m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size),
+ m_no_action(false)
+ { }
+
+ ~cond_dtor()
+ {
+ if (m_no_action)
+ return;
+ iterator it = m_a_vec;
+ while (it != m_r_last_it)
+ {
+ it->~value_type();
+ ++it;
+ }
+
+ if (m_max_size > 0)
+ value_allocator().deallocate(m_a_vec, m_max_size);
+ }
- typedef typename Node_And_It_Traits::node_iterator node_iterator;
+ inline void
+ set_no_action()
+ { m_no_action = true; }
+
+ protected:
+ value_vector m_a_vec;
+ iterator& m_r_last_it;
+ const Size_Type m_max_size;
+ bool m_no_action;
+ };
+
+ typedef typename traits_type::node_update node_update;
+ typedef typename traits_type::node_iterator node_iterator;
+ typedef typename traits_type::node_const_iterator node_const_iterator;
- public:
- PB_DS_OV_TREE_CLASS_NAME();
+ PB_DS_OV_TREE_NAME();
- PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn&);
+ PB_DS_OV_TREE_NAME(const Cmp_Fn&);
- PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn&, const node_update&);
+ PB_DS_OV_TREE_NAME(const Cmp_Fn&, const node_update&);
- PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC&);
- ~PB_DS_OV_TREE_CLASS_NAME();
+ ~PB_DS_OV_TREE_NAME();
void
swap(PB_DS_CLASS_C_DEC&);
inline size_type
size() const;
- Cmp_Fn&
+ Cmp_Fn&
get_cmp_fn();
- const Cmp_Fn&
+ const Cmp_Fn&
get_cmp_fn() const;
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID((*this))
return it->second;
}
-
- return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second);
-#else
+ return insert_new_val(it, std::make_pair(r_key, mapped_type()))->second;
+#else
insert(r_key);
- return traits_base::s_null_mapped;
-#endif
+ return traits_base::s_null_type;
+#endif
}
inline std::pair<point_iterator, bool>
insert(const_reference r_value)
{
PB_DS_ASSERT_VALID((*this))
- const_key_reference r_key = PB_DS_V2F(r_value);
+ key_const_reference r_key = PB_DS_V2F(r_value);
point_iterator it = lower_bound(r_key);
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it)))
}
inline point_iterator
- lower_bound(const_key_reference r_key)
+ lower_bound(key_const_reference r_key)
{
pointer it = m_a_values;
pointer e_it = m_a_values + m_size;
while (it != e_it)
{
pointer mid_it = it + ((e_it - it) >> 1);
- if (cmp_fn_base::operator()(PB_DS_V2F(*mid_it), r_key))
+ if (cmp_fn::operator()(PB_DS_V2F(*mid_it), r_key))
it = ++mid_it;
else
e_it = mid_it;
return it;
}
- inline const_point_iterator
- lower_bound(const_key_reference r_key) const
+ inline point_const_iterator
+ lower_bound(key_const_reference r_key) const
{ return const_cast<PB_DS_CLASS_C_DEC& >(*this).lower_bound(r_key); }
inline point_iterator
- upper_bound(const_key_reference r_key)
+ upper_bound(key_const_reference r_key)
{
iterator pot_it = lower_bound(r_key);
- if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
+ if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it)))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return ++pot_it;
return pot_it;
}
- inline const_point_iterator
- upper_bound(const_key_reference r_key) const
+ inline point_const_iterator
+ upper_bound(key_const_reference r_key) const
{ return const_cast<PB_DS_CLASS_C_DEC&>(*this).upper_bound(r_key); }
inline point_iterator
- find(const_key_reference r_key)
+ find(key_const_reference r_key)
{
PB_DS_ASSERT_VALID((*this))
iterator pot_it = lower_bound(r_key);
return end();
}
- inline const_point_iterator
- find(const_key_reference r_key) const
- { return (const_cast<PB_DS_CLASS_C_DEC& >(*this).find(r_key)); }
+ inline point_const_iterator
+ find(key_const_reference r_key) const
+ { return (const_cast<PB_DS_CLASS_C_DEC&>(*this).find(r_key)); }
bool
- erase(const_key_reference);
+ erase(key_const_reference);
template<typename Pred>
inline size_type
join(PB_DS_CLASS_C_DEC&);
void
- split(const_key_reference, PB_DS_CLASS_C_DEC&);
+ split(key_const_reference, PB_DS_CLASS_C_DEC&);
inline iterator
begin()
end() const
{ return m_end_it; }
- inline const_node_iterator
+ inline node_const_iterator
node_begin() const;
- inline const_node_iterator
+ inline node_const_iterator
node_end() const;
inline node_iterator
private:
inline void
- update(node_iterator /*it*/, null_node_update_pointer);
+ update(node_iterator, null_node_update_pointer);
template<typename Node_Update>
void
insert_new_val(iterator it, const_reference r_value)
{
#ifdef PB_DS_REGRESSION
- typename Allocator::group_adjustor adjust(m_size);
-#endif
+ typename _Alloc::group_adjustor adjust(m_size);
+#endif
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
cond_dtor<size_type> cd(a_values, target_it, m_size + 1);
while (source_it != it)
{
- new (const_cast<void* >(static_cast<const void* >(target_it)))
+ new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it++);
++target_it;
}
- new (const_cast<void* >(static_cast<const void* >(ret_it = target_it)))
+ new (const_cast<void*>(static_cast<const void*>(ret_it = target_it)))
value_type(r_value);
++target_it;
while (source_it != source_end_it)
{
- new (const_cast<void* >(static_cast<const void* >(target_it)))
+ new (const_cast<void*>(static_cast<const void*>(target_it)))
value_type(*source_it++);
++target_it;
}
- reallocate_metadata((node_update* )this, m_size + 1);
+ reallocate_metadata((node_update*)this, m_size + 1);
cd.set_no_action();
if (m_size != 0)
{
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
void
- assert_iterators(const char* file, int line) const;
-#endif
+ assert_iterators(const char*, int) const;
+#endif
template<typename It>
It
- erase_imp(It it);
+ erase_imp(It);
- inline const_node_iterator
+ inline node_const_iterator
PB_DS_node_begin_imp() const;
- inline const_node_iterator
+ inline node_const_iterator
PB_DS_node_end_imp() const;
inline node_iterator
PB_DS_node_end_imp();
private:
- static value_allocator s_value_alloc;
+ static value_allocator s_value_alloc;
static metadata_allocator s_metadata_alloc;
- value_vector m_a_values;
- metadata_pointer m_a_metadata;
- iterator m_end_it;
- size_type m_size;
+ value_vector m_a_values;
+ metadata_pointer m_a_metadata;
+ iterator m_end_it;
+ size_type m_size;
};
#include <ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_OV_TREE_CLASS_NAME
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_OV_TREE_NAME
+#undef PB_DS_OV_TREE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
#ifdef PB_DS_TREE_TRACE
#undef PB_DS_TREE_TRACE_BASE_C_DEC
-#endif
-
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
+#endif
#undef PB_DS_CONST_NODE_ITERATOR_NAME
-
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file policy_access_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file ov_tree_map_/policy_access_fn_imps.hpp
+ * Contains an implementation class for ov_tree.
*/
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file ov_tree_map_/split_join_fn_imps.hpp
* Contains an implementation class for ov_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
+split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
return;
}
- _GLIBCXX_DEBUG_ONLY(debug_base::join(other);)
iterator it = upper_bound(r_key);
PB_DS_CLASS_C_DEC new_other(other, other);
new_other.copy_from_ordered_range(it, end());
- PB_DS_CLASS_C_DEC new_this(*this, * this);
+ PB_DS_CLASS_C_DEC new_this(*this, *this);
new_this.copy_from_ordered_range(begin(), it);
// No exceptions from this point.
- _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
- other.update(other.node_begin(), (node_update* )(&other));
- update(node_begin(), (node_update* )this);
+ other.update(other.node_begin(), (node_update*)(&other));
+ update(node_begin(), (node_update*)this);
other.value_swap(new_other);
value_swap(new_this);
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_C_DEC new_this(*this, *this);
if (greater)
- new_this.copy_from_ordered_range(begin(), end(),
+ new_this.copy_from_ordered_range(begin(), end(),
other.begin(), other.end());
else
new_this.copy_from_ordered_range(other.begin(), other.end(),
begin(), end());
// No exceptions from this point.
- _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);)
value_swap(new_this);
other.clear();
PB_DS_ASSERT_VALID((*this))
// warranty.
/**
- * @file traits.hpp
+ * @file ov_tree_map_/traits.hpp
* Contains an implementation class for ov_tree_.
*/
{
namespace detail
{
-
+ /// Tree traits.
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 Allocator>
+ typename _Alloc>
struct tree_traits<
Key,
Mapped,
Cmp_Fn,
Node_Update,
ov_tree_tag,
- Allocator>
+ _Alloc>
{
private:
typedef
typename types_traits<
Key,
Mapped,
- Allocator,
+ _Alloc,
false>::value_type
value_type;
public:
typedef
- typename tree_node_metadata_selector<
+ typename tree_node_metadata_dispatch<
Key,
Mapped,
Cmp_Fn,
Node_Update,
- Allocator>::type
+ _Alloc>::type
metadata_type;
typedef
ov_tree_node_const_it_<
value_type,
metadata_type,
- Allocator>
- const_node_iterator;
+ _Alloc>
+ node_const_iterator;
typedef
ov_tree_node_it_<
value_type,
metadata_type,
- 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 Allocator>
+ typename _Alloc>
struct tree_traits<
Key,
- null_mapped_type,
+ null_type,
Cmp_Fn,
Node_Update,
ov_tree_tag,
- Allocator>
+ _Alloc>
{
private:
typedef
typename types_traits<
Key,
- null_mapped_type,
- Allocator,
+ null_type,
+ _Alloc,
false>::value_type
value_type;
public:
typedef
- typename tree_node_metadata_selector<
+ typename tree_node_metadata_dispatch<
Key,
- null_mapped_type,
+ null_type,
Cmp_Fn,
Node_Update,
- Allocator>::type
+ _Alloc>::type
metadata_type;
typedef
ov_tree_node_const_it_<
value_type,
metadata_type,
- 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,
- const_node_iterator,
+ node_const_iterator,
+ node_const_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;
};
-
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file pairing_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
{
while (first_it != last_it)
push(*(first_it++));
-
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-pairing_heap_()
-{
- PB_DS_ASSERT_VALID((*this))
-}
+pairing_heap()
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-pairing_heap_(const Cmp_Fn& r_cmp_fn) :
- PB_DS_BASE_C_DEC(r_cmp_fn)
-{
- PB_DS_ASSERT_VALID((*this))
-}
+pairing_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::
-pairing_heap_(const PB_DS_CLASS_C_DEC& other) :
- PB_DS_BASE_C_DEC(other)
-{
- PB_DS_ASSERT_VALID((*this))
-}
+pairing_heap(const PB_DS_CLASS_C_DEC& other)
+: base_type(other)
+{ PB_DS_ASSERT_VALID((*this)) }
PB_DS_CLASS_T_DEC
void
swap(PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
-
- PB_DS_BASE_C_DEC::swap(other);
-
+ base_type::swap(other);
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~pairing_heap_()
+~pairing_heap()
{ }
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file pairing_heap_/debug_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file pairing_heap_/erase_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file pairing_heap_/find_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
-
return base_type::m_p_root->m_value;
}
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file pairing_heap_/insert_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
-
node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
-
push_imp(p_new_nd);
-
PB_DS_ASSERT_VALID((*this))
-
return point_iterator(p_new_nd);
}
push_imp(node_pointer p_nd)
{
p_nd->m_p_l_child = 0;
-
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
-
base_type::m_p_root = p_nd;
}
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
{
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
-
base_type::make_child_of(base_type::m_p_root, p_nd);
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
-
base_type::m_p_root = p_nd;
}
else
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
-
remove_node(it.m_p_nd);
-
it.m_p_nd->m_value = r_new_val;
-
push_imp(it.m_p_nd);
-
PB_DS_ASSERT_VALID((*this))
}
-
// warranty.
/**
- * @file pairing_heap_.hpp
+ * @file pairing_heap_/pairing_heap_.hpp
* Contains an implementation class for a pairing heap.
*/
#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>
#include <debug/debug.h>
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 \
- pairing_heap_<Value_Type, Cmp_Fn, Allocator>
+ pairing_heap<Value_Type, Cmp_Fn, _Alloc>
#ifdef _GLIBCXX_DEBUG
-#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_<Value_Type, \
- Cmp_Fn, \
- null_left_child_next_sibling_heap_node_metadata, \
- Allocator, \
- false>
-#else
-#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_<Value_Type, \
- Cmp_Fn, \
- null_left_child_next_sibling_heap_node_metadata, \
- Allocator>
-#endif
-
- /**
- * class description = "P4ri|\|g h3ap$">
- **/
- template<typename Value_Type, class Cmp_Fn, class Allocator>
- class pairing_heap_ : public PB_DS_BASE_C_DEC
- {
+#define PB_DS_P_HEAP_BASE \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc, false>
+#else
+#define PB_DS_P_HEAP_BASE \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc>
+#endif
+ /// Pairing heap.
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+ class pairing_heap : public PB_DS_P_HEAP_BASE
+ {
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_P_HEAP_BASE base_type;
+ typedef typename base_type::node_pointer node_pointer;
- typedef typename base_type::node_pointer node_pointer;
+ typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
public:
+ 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 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 typename __rebind_a::pointer pointer;
+ typedef typename __rebind_a::const_pointer const_pointer;
+ typedef typename __rebind_a::reference reference;
+ typedef typename __rebind_a::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;
- pairing_heap_();
+ pairing_heap();
- pairing_heap_(const Cmp_Fn& r_cmp_fn);
+ pairing_heap(const Cmp_Fn&);
- pairing_heap_(const PB_DS_CLASS_C_DEC& other);
+ pairing_heap(const pairing_heap&);
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(pairing_heap&);
- ~pairing_heap_();
+ ~pairing_heap();
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;
pop();
void
- erase(point_iterator it);
+ erase(point_iterator);
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, pairing_heap&);
void
- join(PB_DS_CLASS_C_DEC& other);
+ join(pairing_heap&);
protected:
template<typename It>
void
- copy_from_range(It first_it, It last_it);
+ copy_from_range(It, It);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
#endif
private:
inline void
- push_imp(node_pointer p_nd);
+ push_imp(node_pointer);
node_pointer
- join_node_children(node_pointer p_nd);
+ join_node_children(node_pointer);
node_pointer
- forward_join(node_pointer p_nd, node_pointer p_next);
+ forward_join(node_pointer, node_pointer);
node_pointer
- back_join(node_pointer p_nd, node_pointer p_next);
+ back_join(node_pointer, node_pointer);
void
- remove_node(node_pointer p_nd);
+ remove_node(node_pointer);
};
-#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
- _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
- __FILE__, __LINE__);)
+#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
+ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
+ __FILE__, __LINE__);)
#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp>
#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp>
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_P_HEAP_BASE
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file pairing_heap_/split_join_fn_imps.hpp
* Contains an implementation class for a pairing heap.
*/
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
-
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_next_sibling = p_out->m_p_prev_or_parent = 0;
other.push_imp(p_out);
-
p_out = p_next;
}
PB_DS_ASSERT_VALID(other)
-
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_next_sibling = p_cur->m_p_prev_or_parent = 0;
push_imp(p_cur);
-
p_cur = p_next;
}
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
-
return;
}
{
base_type::make_child_of(base_type::m_p_root, other.m_p_root);
PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false)
-
base_type::m_p_root = other.m_p_root;
}
else
}
base_type::m_size += other.m_size;
-
other.m_p_root = 0;
other.m_size = 0;
-
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
-
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 child_iterator.hpp
- * Contains a iterator for a patricia tree.
- */
-
-struct iterator : public const_iterator
-{
-public:
- typedef std::forward_iterator_tag iterator_category;
- typedef typename Allocator::difference_type difference_type;
- typedef node_pointer value_type;
- typedef node_pointer_pointer pointer;
- typedef node_pointer_reference reference;
-
- inline
- iterator(node_pointer_pointer p_p_cur = 0,
- node_pointer_pointer p_p_end = 0)
- : const_iterator(p_p_cur, p_p_end)
- { }
-
- inline bool
- operator==(const iterator& other) const
- { return const_iterator::m_p_p_cur == other.m_p_p_cur; }
-
- inline bool
- operator!=(const iterator& other) const
- { return const_iterator::m_p_p_cur != other.m_p_p_cur; }
-
- inline iterator&
- operator++()
- {
- const_iterator::operator++();
- return *this;
- }
-
- inline iterator
- operator++(int)
- {
- iterator ret_it(*this);
- operator++();
- return ret_it;
- }
-
- node_pointer_pointer
- operator->()
- {
- _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
- return const_iterator::m_p_p_cur;
- }
-
- node_pointer
- operator*()
- {
- _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
- return *const_iterator::m_p_p_cur;
- }
-};
-
+++ /dev/null
-// -*- 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 cond_dealtor
-{
-public:
- inline
- cond_dealtor(leaf_pointer p_nd) : m_p_nd(p_nd),
- m_no_action_dtor(false),
- m_call_destructor(false)
- { }
-
- inline void
- set_no_action_dtor()
- {
- m_no_action_dtor = true;
- }
-
- inline void
- set_call_destructor()
- {
- m_call_destructor = true;
- }
-
- inline
- ~cond_dealtor()
- {
- if (m_no_action_dtor)
- return;
-
- if (m_call_destructor)
- m_p_nd->~leaf();
-
- s_leaf_allocator.deallocate(m_p_nd, 1);
- }
-
-protected:
- leaf_pointer m_p_nd;
- bool m_no_action_dtor;
- bool m_call_destructor;
-};
-
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 const_child_iterator.hpp
- * Contains a const_iterator for a patricia tree.
- */
-
-struct const_iterator
-{
-public:
- typedef std::forward_iterator_tag iterator_category;
-
- typedef typename Allocator::difference_type difference_type;
-
- typedef node_pointer value_type;
-
- typedef node_pointer_pointer pointer;
-
- typedef node_pointer_reference reference;
-
-public:
- inline
- const_iterator(node_pointer_pointer p_p_cur = 0,
- node_pointer_pointer p_p_end = 0)
- : m_p_p_cur(p_p_cur), m_p_p_end(p_p_end)
- { }
-
- inline bool
- operator==(const const_iterator& other) const
- { return m_p_p_cur == other.m_p_p_cur; }
-
- inline bool
- operator!=(const const_iterator& other) const
- { return m_p_p_cur != other.m_p_p_cur; }
-
- inline const_iterator&
- operator++()
- {
- do
- ++m_p_p_cur;
- while (m_p_p_cur != m_p_p_end&& * m_p_p_cur == 0);
- return *this;
- }
-
- inline const_iterator
- operator++(int)
- {
- const_iterator ret_it(*this);
- operator++();
- return ret_it;
- }
-
- const node_pointer_pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ONLY(assert_referencible();)
- return (m_p_p_cur);
- }
-
- const_node_pointer
- operator*() const
- {
- _GLIBCXX_DEBUG_ONLY(assert_referencible();)
- return (*m_p_p_cur);
- }
-
-protected:
-#ifdef _GLIBCXX_DEBUG
- void
- assert_referencible() const
- { _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end&& * m_p_p_cur != 0); }
-#endif
-
-public:
- node_pointer_pointer m_p_p_cur;
- node_pointer_pointer m_p_p_end;
-};
-
-// -*- C++ -*-
+ // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/constructors_destructor_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::s_head_allocator;
PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::internal_node_allocator
-PB_DS_CLASS_C_DEC::s_internal_node_allocator;
+typename PB_DS_CLASS_C_DEC::inode_allocator
+PB_DS_CLASS_C_DEC::s_inode_allocator;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_allocator
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME() :
+PB_DS_PAT_TRIE_NAME() :
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
{
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) :
- synth_e_access_traits(r_e_access_traits),
+PB_DS_PAT_TRIE_NAME(const access_traits& r_access_traits) :
+ synth_access_traits(r_access_traits),
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
{
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC& other) :
#ifdef _GLIBCXX_DEBUG
debug_base(other),
#endif
- synth_e_access_traits(other),
+ synth_access_traits(other),
node_update(other),
m_p_head(s_head_allocator.allocate(1)),
m_size(0)
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
value_swap(other);
- std::swap((e_access_traits& )(*this), (e_access_traits& )other);
+ std::swap((access_traits& )(*this), (access_traits& )other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~PB_DS_CLASS_NAME()
+~PB_DS_PAT_TRIE_NAME()
{
clear();
s_head_allocator.deallocate(m_p_head, 1);
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-recursive_copy_node(const_node_pointer p_other_nd)
+recursive_copy_node(node_const_pointer p_ncp)
{
- _GLIBCXX_DEBUG_ASSERT(p_other_nd != 0);
- if (p_other_nd->m_type == pat_trie_leaf_node_type)
+ _GLIBCXX_DEBUG_ASSERT(p_ncp != 0);
+ if (p_ncp->m_type == leaf_node)
{
- const_leaf_pointer p_other_leaf = static_cast<const_leaf_pointer>(p_other_nd);
-
+ leaf_const_pointer p_other_lf = static_cast<leaf_const_pointer>(p_ncp);
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1);
cond_dealtor cond(p_new_lf);
- new (p_new_lf) leaf(p_other_leaf->value());
- apply_update(p_new_lf, (node_update* )this);
+ new (p_new_lf) leaf(p_other_lf->value());
+ apply_update(p_new_lf, (node_update*)this);
cond.set_no_action_dtor();
return (p_new_lf);
}
- _GLIBCXX_DEBUG_ASSERT(p_other_nd->m_type == pat_trie_internal_node_type);
- node_pointer a_p_children[internal_node::arr_size];
+ _GLIBCXX_DEBUG_ASSERT(p_ncp->m_type == i_node);
+ node_pointer a_p_children[inode::arr_size];
size_type child_i = 0;
- const_internal_node_pointer p_other_internal_nd =
- static_cast<const_internal_node_pointer>(p_other_nd);
+ inode_const_pointer p_icp = static_cast<inode_const_pointer>(p_ncp);
- typename internal_node::const_iterator child_it =
- p_other_internal_nd->begin();
+ typename inode::const_iterator child_it = p_icp->begin();
- internal_node_pointer p_ret;
+ inode_pointer p_ret;
__try
{
- while (child_it != p_other_internal_nd->end())
+ while (child_it != p_icp->end())
a_p_children[child_i++] = recursive_copy_node(*(child_it++));
- p_ret = s_internal_node_allocator.allocate(1);
+ p_ret = s_inode_allocator.allocate(1);
}
__catch(...)
{
__throw_exception_again;
}
- new (p_ret) internal_node(p_other_internal_nd->get_e_ind(),
- pref_begin(a_p_children[0]));
+ new (p_ret) inode(p_icp->get_e_ind(), pref_begin(a_p_children[0]));
--child_i;
_GLIBCXX_DEBUG_ASSERT(child_i >= 1);
p_ret->add_child(a_p_children[child_i], pref_begin(a_p_children[child_i]),
pref_end(a_p_children[child_i]), this);
while (child_i-- > 0);
- apply_update(p_ret, (node_update* )this);
+ apply_update(p_ret, (node_update*)this);
return p_ret;
}
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file pat_trie_/debug_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
return;
}
- PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type);
- PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == leaf_node);
+ PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == leaf_node);
PB_DS_DEBUG_VERIFY(!empty());
}
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
{
++calc_size;
- const_node_pointer p_nd =
- const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(PB_DS_V2F(*it));
+ node_const_pointer p_nd =
+ const_cast<PB_DS_CLASS_C_DEC*>(this)->find_imp(PB_DS_V2F(*it));
PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd);
}
PB_DS_DEBUG_VERIFY(calc_size == m_size);
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-recursive_count_leafs(const_node_pointer p_nd,
- const char* __file, int __line)
+recursive_count_leafs(node_const_pointer p_nd, const char* __file, int __line)
{
if (p_nd == 0)
return (0);
- if (p_nd->m_type == pat_trie_leaf_node_type)
+ if (p_nd->m_type == leaf_node)
return (1);
- PB_DS_DEBUG_VERIFY(p_nd->m_type == pat_trie_internal_node_type);
+ PB_DS_DEBUG_VERIFY(p_nd->m_type == i_node);
size_type ret = 0;
- for (typename internal_node::const_iterator it =
- static_cast<const_internal_node_pointer>(p_nd)->begin();
- it != static_cast<const_internal_node_pointer>(p_nd)->end();
+ for (typename inode::const_iterator it = static_cast<inode_const_pointer>(p_nd)->begin();
+ it != static_cast<inode_const_pointer>(p_nd)->end();
++it)
ret += recursive_count_leafs(*it, __file, __line);
return ret;
}
-#endif
-
+#endif
// warranty.
/**
- * @file erase_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/erase_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
node_pointer p_nd = find_imp(r_key);
- if (p_nd == 0 || p_nd->m_type == pat_trie_internal_node_type)
+ if (p_nd == 0 || p_nd->m_type == i_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
}
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
- if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
+ if (!synth_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return false;
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-erase_fixup(internal_node_pointer p_nd)
+erase_fixup(inode_pointer p_nd)
{
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1);
if (std::distance(p_nd->begin(), p_nd->end()) == 1)
{
node_pointer p_parent = p_nd->m_p_parent;
if (p_parent == m_p_head)
- m_p_head->m_p_parent =* p_nd->begin();
+ m_p_head->m_p_parent = *p_nd->begin();
else
- {
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type);
- node_pointer p_new_child =* p_nd->begin();
- static_cast<internal_node_pointer>(p_parent)->replace_child(
- p_new_child,
- pref_begin(p_new_child),
- pref_end(p_new_child),
- this);
- }
+ {
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
+ node_pointer p_new_child = *p_nd->begin();
+
+ typedef inode_pointer inode_ptr;
+ inode_ptr p_internal = static_cast<inode_ptr>(p_parent);
+ p_internal->replace_child(p_new_child, pref_begin(p_new_child),
+ pref_end(p_new_child), this);
+ }
(*p_nd->begin())->m_p_parent = p_nd->m_p_parent;
- p_nd->~internal_node();
- s_internal_node_allocator.deallocate(p_nd, 1);
+ p_nd->~inode();
+ s_inode_allocator.deallocate(p_nd, 1);
if (p_parent == m_p_head)
return;
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == pat_trie_internal_node_type);
- p_nd = static_cast<internal_node_pointer>(p_parent);
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node);
+ p_nd = static_cast<inode_pointer>(p_parent);
}
while (true)
{
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1);
p_nd->update_prefixes(this);
- apply_update(p_nd, (node_update* )this);
+ apply_update(p_nd, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(p_nd)
- if (p_nd->m_p_parent->m_type == pat_trie_head_node_type)
- return;
+ if (p_nd->m_p_parent->m_type == head_node)
+ return;
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type ==
- pat_trie_internal_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == i_node);
- p_nd = static_cast<internal_node_pointer>(p_nd->m_p_parent);
+ p_nd = static_cast<inode_pointer>(p_nd->m_p_parent);
}
}
{
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
--m_size;
- _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_l->value())));
+ _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->value())));
p_l->~leaf();
s_leaf_allocator.deallocate(p_l, 1);
}
PB_DS_CLASS_C_DEC::
clear()
{
- PB_DS_ASSERT_VALID((*this))
- if (empty())
- return;
-
- clear_imp(m_p_head->m_p_parent);
- m_size = 0;
- initialize();
- _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
- PB_DS_ASSERT_VALID((*this))
+ if (!empty())
+ {
+ clear_imp(m_p_head->m_p_parent);
+ m_size = 0;
+ initialize();
+ _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
+ PB_DS_ASSERT_VALID((*this))
+ }
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
clear_imp(node_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_internal_node_type)
+ if (p_nd->m_type == i_node)
{
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
- for (typename internal_node::iterator it =
- static_cast<internal_node_pointer>(p_nd)->begin();
- it != static_cast<internal_node_pointer>(p_nd)->end();
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
+ for (typename inode::iterator it =
+ static_cast<inode_pointer>(p_nd)->begin();
+ it != static_cast<inode_pointer>(p_nd)->end();
++it)
- {
+ {
node_pointer p_child =* it;
clear_imp(p_child);
- }
- s_internal_node_allocator.deallocate(static_cast<internal_node_pointer>(p_nd), 1);
+ }
+ s_inode_allocator.deallocate(static_cast<inode_pointer>(p_nd), 1);
return;
}
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
static_cast<leaf_pointer>(p_nd)->~leaf();
s_leaf_allocator.deallocate(static_cast<leaf_pointer>(p_nd), 1);
}
const_iterator ret_it = it;
++ret_it;
- _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
return it;
iterator ret_it = it;
++ret_it;
- _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
const_reverse_iterator ret_it = it;
++ret_it;
- _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
reverse_iterator ret_it = it;
++ret_it;
- _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node);
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd));
PB_DS_ASSERT_VALID((*this))
return ret_it;
PB_DS_ASSERT_VALID((*this))
if (pred(*it))
{
- ++num_ersd;
- it = erase(it);
+ ++num_ersd;
+ it = erase(it);
}
else
++it;
erase_leaf(leaf_pointer p_l)
{
update_min_max_for_erased_leaf(p_l);
- if (p_l->m_p_parent->m_type == pat_trie_head_node_type)
+ if (p_l->m_p_parent->m_type == head_node)
{
_GLIBCXX_DEBUG_ASSERT(size() == 1);
clear();
}
_GLIBCXX_DEBUG_ASSERT(size() > 1);
- _GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type ==
- pat_trie_internal_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == i_node);
- internal_node_pointer p_parent =
- static_cast<internal_node_pointer>(p_l->m_p_parent);
+ inode_pointer p_parent = static_cast<inode_pointer>(p_l->m_p_parent);
p_parent->remove_child(p_l);
erase_fixup(p_parent);
return;
}
- if (p_l == static_cast<const_leaf_pointer>(m_p_head->m_p_min))
+ if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_min))
{
iterator it(p_l);
++it;
return;
}
- if (p_l == static_cast<const_leaf_pointer>(m_p_head->m_p_max))
+ if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_max))
{
iterator it(p_l);
--it;
// warranty.
/**
- * @file find_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/find_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
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_ASSERT_VALID((*this))
node_pointer p_nd = find_imp(r_key);
- if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
+ if (p_nd == 0 || p_nd->m_type != leaf_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
- if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
+ if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return iterator(p_nd);
}
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_ASSERT_VALID((*this))
- const_node_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
+ node_const_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key);
- if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type)
+ if (p_nd == 0 || p_nd->m_type != leaf_node)
{
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
return end();
}
- if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
+ if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
{
PB_DS_CHECK_KEY_EXISTS(r_key)
return const_iterator(const_cast<node_pointer>(p_nd));
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-find_imp(const_key_reference r_key)
+find_imp(key_const_reference r_key)
{
if (empty())
- return (0);
+ return 0;
- typename synth_e_access_traits::const_iterator b_it =
- synth_e_access_traits::begin(r_key);
- typename synth_e_access_traits::const_iterator e_it =
- synth_e_access_traits::end(r_key);
+ typename synth_access_traits::const_iterator b_it =
+ synth_access_traits::begin(r_key);
+ typename synth_access_traits::const_iterator e_it =
+ synth_access_traits::end(r_key);
node_pointer p_nd = m_p_head->m_p_parent;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
- while (p_nd->m_type != pat_trie_leaf_node_type)
+ while (p_nd->m_type != leaf_node)
{
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
- node_pointer p_next_nd = static_cast<internal_node_pointer>(p_nd)->get_child_node(b_it, e_it, this);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
+ node_pointer p_next_nd = static_cast<inode_pointer>(p_nd)->get_child_node(b_it, e_it, this);
if (p_next_nd == 0)
return p_nd;
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-lower_bound_imp(const_key_reference r_key)
+lower_bound_imp(key_const_reference r_key)
{
if (empty())
return (m_p_head);
node_pointer p_nd = m_p_head->m_p_parent;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
- typename PB_DS_CLASS_C_DEC::const_e_iterator b_it =
- synth_e_access_traits::begin(r_key);
+ typename PB_DS_CLASS_C_DEC::a_const_iterator b_it =
+ synth_access_traits::begin(r_key);
- typename PB_DS_CLASS_C_DEC::const_e_iterator e_it =
- synth_e_access_traits::end(r_key);
+ typename PB_DS_CLASS_C_DEC::a_const_iterator e_it =
+ synth_access_traits::end(r_key);
size_type checked_ind = 0;
while (true)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
+ if (p_nd->m_type == leaf_node)
{
- if (!synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value()), r_key))
+ if (!synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key))
return p_nd;
iterator it(p_nd);
++it;
return it.m_p_nd;
}
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
const size_type new_checked_ind =
- static_cast<internal_node_pointer>(p_nd)->get_e_ind();
+ static_cast<inode_pointer>(p_nd)->get_e_ind();
p_nd =
- static_cast<internal_node_pointer>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this);
+ static_cast<inode_pointer>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this);
checked_ind = new_checked_ind;
}
}
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)
{ return point_iterator(lower_bound_imp(r_key)); }
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
{
- return const_point_iterator(const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key));
+ return point_const_iterator(const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key));
}
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)
{
point_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
- !synth_e_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
+ !synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
- synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
+ synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
-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
{
- const_point_iterator l_bound_it = lower_bound(r_key);
+ point_const_iterator l_bound_it = lower_bound(r_key);
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() ||
- !synth_e_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
+ !synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it),
r_key));
if (l_bound_it == end() ||
- synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
+ synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it)))
return l_bound_it;
return ++l_bound_it;
}
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_e_iterator
+inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
-pref_begin(const_node_pointer p_nd)
+pref_begin(node_const_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return (synth_e_access_traits::begin(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
+ if (p_nd->m_type == leaf_node)
+ return (synth_access_traits::begin(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
- return static_cast<const_internal_node_pointer>(p_nd)->pref_b_it();
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
+ return static_cast<inode_const_pointer>(p_nd)->pref_b_it();
}
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_e_iterator
+inline typename PB_DS_CLASS_C_DEC::a_const_iterator
PB_DS_CLASS_C_DEC::
-pref_end(const_node_pointer p_nd)
+pref_end(node_const_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return (synth_e_access_traits::end(PB_DS_V2F(static_cast<const_leaf_pointer>(p_nd)->value())));
+ if (p_nd->m_type == leaf_node)
+ return (synth_access_traits::end(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value())));
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
- return static_cast<const_internal_node_pointer>(p_nd)->pref_e_it();
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
+ return static_cast<inode_const_pointer>(p_nd)->pref_e_it();
}
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_leaf_pointer
+inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
-leftmost_descendant(const_node_pointer p_nd)
+leftmost_descendant(node_const_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return static_cast<const_leaf_pointer>(p_nd);
- return static_cast<const_internal_node_pointer>(p_nd)->leftmost_descendant();
+ if (p_nd->m_type == leaf_node)
+ return static_cast<leaf_const_pointer>(p_nd);
+ return static_cast<inode_const_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
leftmost_descendant(node_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
+ if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
- return static_cast<internal_node_pointer>(p_nd)->leftmost_descendant();
+ return static_cast<inode_pointer>(p_nd)->leftmost_descendant();
}
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_leaf_pointer
+inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer
PB_DS_CLASS_C_DEC::
-rightmost_descendant(const_node_pointer p_nd)
+rightmost_descendant(node_const_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return static_cast<const_leaf_pointer>(p_nd);
- return static_cast<const_internal_node_pointer>(p_nd)->rightmost_descendant();
+ if (p_nd->m_type == leaf_node)
+ return static_cast<leaf_const_pointer>(p_nd);
+ return static_cast<inode_const_pointer>(p_nd)->rightmost_descendant();
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
rightmost_descendant(node_pointer p_nd)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
+ if (p_nd->m_type == leaf_node)
return static_cast<leaf_pointer>(p_nd);
- return static_cast<internal_node_pointer>(p_nd)->rightmost_descendant();
+ return static_cast<inode_pointer>(p_nd)->rightmost_descendant();
}
+++ /dev/null
-// -*- 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 head.hpp
- * Contains a leaf for a patricia tree.
- */
-
-#ifndef PB_DS_PAT_TRIE_IHEAD_HPP
-#define PB_DS_PAT_TRIE_IHEAD_HPP
-
-#include <ext/pb_ds/detail/pat_trie_/node_base.hpp>
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-#define PB_DS_CLASS_T_DEC \
- template<typename Type_Traits, typename E_Access_Traits, \
- typename Metadata, typename Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- pat_trie_head<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
-#define PB_DS_BASE_C_DEC \
- pat_trie_node_base<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
- template<typename Type_Traits,
- typename E_Access_Traits,
- typename Metadata,
- typename Allocator>
- struct pat_trie_head : public PB_DS_BASE_C_DEC
- {
- private:
- typedef E_Access_Traits e_access_traits;
-
- typedef
- typename Allocator::template rebind<
- e_access_traits>::other::const_pointer
- const_e_access_traits_pointer;
-
- typedef
- typename Allocator::template rebind<
- PB_DS_BASE_C_DEC>::other::pointer
- node_pointer;
-
-#ifdef _GLIBCXX_DEBUG
- typedef
- typename PB_DS_BASE_C_DEC::subtree_debug_info
- subtree_debug_info;
-#endif
-
- public:
- pat_trie_head();
-
-#ifdef _GLIBCXX_DEBUG
- virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits,
- const char* file, int line) const;
-#endif
-
- public:
- node_pointer m_p_min;
-
- node_pointer m_p_max;
- };
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- pat_trie_head() : PB_DS_BASE_C_DEC(pat_trie_head_node_type)
- { }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::subtree_debug_info
- PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer /*p_traits*/,
- const char* __file, int __line) const
- {
- _GLIBCXX_DEBUG_VERIFY_AT(false,
- _M_message("Assertion from %1;:%2;")
- ._M_string(__FILE__)._M_integer(__LINE__),
- __file, __line);
- return subtree_debug_info();
- }
-#endif
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
-
// warranty.
/**
- * @file info_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/info_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
max_size() const
-{ return s_internal_node_allocator.max_size(); }
+{ return s_inode_allocator.max_size(); }
// warranty.
/**
- * @file insert_join_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/insert_join_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- split_join_branch_bag bag;
+ branch_bag bag;
if (!join_prep(other, bag))
{
PB_DS_ASSERT_VALID((*this))
return;
}
- m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent,
+ m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent,
other.m_p_head->m_p_parent, 0, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
-join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
+join_prep(PB_DS_CLASS_C_DEC& other, branch_bag& r_bag)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
}
const bool greater =
- synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value()),
- PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_min)->value()));
+ synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()),
+ PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_min)->value()));
const bool lesser =
- synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(other.m_p_head->m_p_max)->value()),
- PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value()));
+ synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_max)->value()),
+ PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value()));
if (!greater && !lesser)
__throw_join_error();
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-rec_join_prep(const_node_pointer p_l, const_node_pointer p_r, split_join_branch_bag& r_bag)
+rec_join_prep(node_const_pointer p_l, node_const_pointer p_r,
+ branch_bag& r_bag)
{
- if (p_l->m_type == pat_trie_leaf_node_type)
+ if (p_l->m_type == leaf_node)
{
- if (p_r->m_type == pat_trie_leaf_node_type)
- {
- rec_join_prep(static_cast<const_leaf_pointer>(p_l),
- static_cast<const_leaf_pointer>(p_r), r_bag);
+ if (p_r->m_type == leaf_node)
+ {
+ rec_join_prep(static_cast<leaf_const_pointer>(p_l),
+ static_cast<leaf_const_pointer>(p_r), r_bag);
return;
- }
+ }
- _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type);
- rec_join_prep(static_cast<const_leaf_pointer>(p_l),
- static_cast<const_internal_node_pointer>(p_r), r_bag);
+ _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
+ rec_join_prep(static_cast<leaf_const_pointer>(p_l),
+ static_cast<inode_const_pointer>(p_r), r_bag);
return;
}
- _GLIBCXX_DEBUG_ASSERT(p_l->m_type == pat_trie_internal_node_type);
- if (p_r->m_type == pat_trie_leaf_node_type)
+ _GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node);
+ if (p_r->m_type == leaf_node)
{
- rec_join_prep(static_cast<const_internal_node_pointer>(p_l),
- static_cast<const_leaf_pointer>(p_r), r_bag);
+ rec_join_prep(static_cast<inode_const_pointer>(p_l),
+ static_cast<leaf_const_pointer>(p_r), r_bag);
return;
}
- _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
- rec_join_prep(static_cast<const_internal_node_pointer>(p_l),
- static_cast<const_internal_node_pointer>(p_r), r_bag);
+ rec_join_prep(static_cast<inode_const_pointer>(p_l),
+ static_cast<inode_const_pointer>(p_r), r_bag);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-rec_join_prep(const_leaf_pointer /*p_l*/, const_leaf_pointer /*p_r*/,
- split_join_branch_bag& r_bag)
+rec_join_prep(leaf_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/,
+ branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-rec_join_prep(const_leaf_pointer /*p_l*/, const_internal_node_pointer /*p_r*/,
- split_join_branch_bag& r_bag)
+rec_join_prep(leaf_const_pointer /*p_l*/, inode_const_pointer /*p_r*/,
+ branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-rec_join_prep(const_internal_node_pointer /*p_l*/, const_leaf_pointer /*p_r*/,
- split_join_branch_bag& r_bag)
+rec_join_prep(inode_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/,
+ branch_bag& r_bag)
{ r_bag.add_branch(); }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-rec_join_prep(const_internal_node_pointer p_l, const_internal_node_pointer p_r,
- split_join_branch_bag& r_bag)
+rec_join_prep(inode_const_pointer p_l, inode_const_pointer p_r,
+ branch_bag& r_bag)
{
- if (p_l->get_e_ind() == p_r->get_e_ind() &&
- synth_e_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
+ if (p_l->get_e_ind() == p_r->get_e_ind() &&
+ synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
p_r->pref_b_it(), p_r->pref_e_it()))
{
- for (typename internal_node::const_iterator it = p_r->begin();
+ for (typename inode::const_iterator it = p_r->begin();
it != p_r->end(); ++ it)
- {
- const_node_pointer p_l_join_child = p_l->get_join_child(*it, this);
+ {
+ node_const_pointer p_l_join_child = p_l->get_join_child(*it, this);
if (p_l_join_child != 0)
rec_join_prep(p_l_join_child, * it, r_bag);
- }
+ }
return;
}
- if (p_r->get_e_ind() < p_l->get_e_ind() &&
+ if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
- const_node_pointer p_r_join_child = p_r->get_join_child(p_l, this);
+ node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this);
if (p_r_join_child != 0)
rec_join_prep(p_r_join_child, p_l, r_bag);
return;
}
- if (p_r->get_e_ind() < p_l->get_e_ind() &&
+ if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
- const_node_pointer p_r_join_child = p_r->get_join_child(p_l, this);
+ node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this);
if (p_r_join_child != 0)
rec_join_prep(p_r_join_child, p_l, r_bag);
return;
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag)
+rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind,
+ branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
if (p_l == 0)
{
- apply_update(p_r, (node_update* )this);
+ apply_update(p_r, (node_update*)this);
return (p_r);
}
- if (p_l->m_type == pat_trie_leaf_node_type)
+ if (p_l->m_type == leaf_node)
{
- if (p_r->m_type == pat_trie_leaf_node_type)
- {
+ if (p_r->m_type == leaf_node)
+ {
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l),
static_cast<leaf_pointer>(p_r), r_bag);
- apply_update(p_ret, (node_update* )this);
+ apply_update(p_ret, (node_update*)this);
return p_ret;
- }
+ }
- _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l),
- static_cast<internal_node_pointer>(p_r),
+ static_cast<inode_pointer>(p_r),
checked_ind, r_bag);
- apply_update(p_ret, (node_update* )this);
+ apply_update(p_ret, (node_update*)this);
return p_ret;
}
- _GLIBCXX_DEBUG_ASSERT(p_l->m_type == pat_trie_internal_node_type);
- if (p_r->m_type == pat_trie_leaf_node_type)
+ _GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node);
+ if (p_r->m_type == leaf_node)
{
- node_pointer p_ret = rec_join(static_cast<internal_node_pointer>(p_l),
+ node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l),
static_cast<leaf_pointer>(p_r),
checked_ind, r_bag);
- apply_update(p_ret, (node_update* )this);
+ apply_update(p_ret, (node_update*)this);
return p_ret;
}
- _GLIBCXX_DEBUG_ASSERT(p_r->m_type == pat_trie_internal_node_type);
- node_pointer p_ret = rec_join(static_cast<internal_node_pointer>(p_l),
- static_cast<internal_node_pointer>(p_r),
+ _GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node);
+ node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l),
+ static_cast<inode_pointer>(p_r),
r_bag);
- apply_update(p_ret, (node_update* )this);
+ apply_update(p_ret, (node_update*)this);
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_join(leaf_pointer p_l, leaf_pointer p_r, split_join_branch_bag& r_bag)
+rec_join(leaf_pointer p_l, leaf_pointer p_r, branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
if (p_l == 0)
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind,
- split_join_branch_bag& r_bag)
+rec_join(leaf_pointer p_l, inode_pointer p_r, size_type checked_ind,
+ branch_bag& r_bag)
{
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
-#endif
+#endif
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag);
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag)
+rec_join(inode_pointer p_l, leaf_pointer p_r, size_type checked_ind, branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
-#endif
+#endif
if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this))
{
node_pointer p_ret = insert_branch(p_l, p_r, r_bag);
PB_DS_ASSERT_NODE_VALID(p_ret)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) ==
- lhs_leafs + rhs_leafs);
+ lhs_leafs + rhs_leafs);
return p_ret;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch_bag& r_bag)
+rec_join(inode_pointer p_l, inode_pointer p_r,
+ branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(p_l != 0);
_GLIBCXX_DEBUG_ASSERT(p_r != 0);
#ifdef _GLIBCXX_DEBUG
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l);
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r);
-#endif
+#endif
- if (p_l->get_e_ind() == p_r->get_e_ind() &&
- synth_e_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
+ if (p_l->get_e_ind() == p_r->get_e_ind() &&
+ synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(),
p_r->pref_b_it(), p_r->pref_e_it()))
{
- for (typename internal_node::iterator it = p_r->begin();
+ for (typename inode::iterator it = p_r->begin();
it != p_r->end(); ++ it)
- {
+ {
node_pointer p_new_child = rec_join(p_l->get_join_child(*it, this),
* it, 0, r_bag);
p_l->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
- }
+ }
- p_r->~internal_node();
- s_internal_node_allocator.deallocate(p_r, 1);
+ p_r->~inode();
+ s_inode_allocator.deallocate(p_r, 1);
PB_DS_ASSERT_NODE_VALID(p_l)
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs);
return p_l;
}
- if (p_l->get_e_ind() < p_r->get_e_ind() &&
+ if (p_l->get_e_ind() < p_r->get_e_ind() &&
p_l->should_be_mine(p_r->pref_b_it(), p_r->pref_e_it(), 0, this))
{
node_pointer p_new_child = rec_join(p_l->get_join_child(p_r, this),
return p_l;
}
- if (p_r->get_e_ind() < p_l->get_e_ind() &&
+ if (p_r->get_e_ind() < p_l->get_e_ind() &&
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this))
{
node_pointer p_new_child = rec_join(p_r->get_join_child(p_l, this), p_l,
0, r_bag);
- p_r->replace_child(p_new_child, pref_begin(p_new_child),
+ p_r->replace_child(p_new_child, pref_begin(p_new_child),
pref_end(p_new_child), this);
PB_DS_ASSERT_NODE_VALID(p_r)
insert(const_reference r_val)
{
node_pointer p_lf = find_imp(PB_DS_V2F(r_val));
- if (p_lf != 0 && p_lf->m_type == pat_trie_leaf_node_type &&
- synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val)))
+ if (p_lf != 0 && p_lf->m_type == leaf_node &&
+ synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val)))
{
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val))
PB_DS_ASSERT_VALID((*this))
cond_dealtor cond(p_new_lf);
new (p_new_lf) leaf(r_val);
- apply_update(p_new_lf, (node_update* )this);
+ apply_update(p_new_lf, (node_update*)this);
cond.set_call_destructor();
- split_join_branch_bag bag;
+ branch_bag bag;
bag.add_branch();
m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
cond.set_no_action_dtor();
++m_size;
update_min_max_for_inserted_leaf(p_new_lf);
- _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
+ _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
PB_DS_ASSERT_VALID((*this))
return std::make_pair(point_iterator(p_new_lf), true);
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-keys_diff_ind(typename e_access_traits::const_iterator b_l,
- typename e_access_traits::const_iterator e_l,
- typename e_access_traits::const_iterator b_r,
- typename e_access_traits::const_iterator e_r)
+keys_diff_ind(typename access_traits::const_iterator b_l,
+ typename access_traits::const_iterator e_l,
+ typename access_traits::const_iterator b_r,
+ typename access_traits::const_iterator e_r)
{
size_type diff_pos = 0;
while (b_l != e_l)
{
if (b_r == e_r)
return (diff_pos);
- if (e_access_traits::e_pos(*b_l) != e_access_traits::e_pos(*b_r))
+ if (access_traits::e_pos(*b_l) != access_traits::e_pos(*b_r))
return (diff_pos);
++b_l;
++b_r;
}
PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::internal_node_pointer
+typename PB_DS_CLASS_C_DEC::inode_pointer
PB_DS_CLASS_C_DEC::
-insert_branch(node_pointer p_l, node_pointer p_r, split_join_branch_bag& r_bag)
+insert_branch(node_pointer p_l, node_pointer p_r, branch_bag& r_bag)
{
- typename synth_e_access_traits::const_iterator left_b_it = pref_begin(p_l);
- typename synth_e_access_traits::const_iterator left_e_it = pref_end(p_l);
- typename synth_e_access_traits::const_iterator right_b_it = pref_begin(p_r);
- typename synth_e_access_traits::const_iterator right_e_it = pref_end(p_r);
+ typename synth_access_traits::const_iterator left_b_it = pref_begin(p_l);
+ typename synth_access_traits::const_iterator left_e_it = pref_end(p_l);
+ typename synth_access_traits::const_iterator right_b_it = pref_begin(p_r);
+ typename synth_access_traits::const_iterator right_e_it = pref_end(p_r);
- const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it,
+ const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it,
right_b_it, right_e_it);
- internal_node_pointer p_new_nd = r_bag.get_branch();
- new (p_new_nd) internal_node(diff_ind, left_b_it);
+ inode_pointer p_new_nd = r_bag.get_branch();
+ new (p_new_nd) inode(diff_ind, left_b_it);
p_new_nd->add_child(p_l, left_b_it, left_e_it, this);
p_new_nd->add_child(p_r, right_b_it, right_e_it, this);
p_l->m_p_parent = p_new_nd;
update_min_max_for_inserted_leaf(leaf_pointer p_new_lf)
{
if (m_p_head->m_p_min == m_p_head ||
- synth_e_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()),
- PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value())))
+ synth_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()),
+ PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
m_p_head->m_p_min = p_new_lf;
if (m_p_head->m_p_max == m_p_head ||
- synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value())))
+ synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value())))
m_p_head->m_p_max = p_new_lf;
}
+++ /dev/null
-// -*- C++ -*-
-
-// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
-// Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// 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 internal_node.hpp
- * Contains an internal PB_DS_BASE_C_DEC for a patricia tree.
- */
-
-#ifndef PB_DS_PAT_TRIE_INTERNAL_NODE_HPP
-#define PB_DS_PAT_TRIE_INTERNAL_NODE_HPP
-
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-#define PB_DS_CLASS_T_DEC \
- template<typename Type_Traits, typename E_Access_Traits, \
- typename Metadata, typename Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- pat_trie_internal_node<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
-#define PB_DS_BASE_C_DEC \
- pat_trie_node_base<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
-#define PB_DS_LEAF_C_DEC \
- pat_trie_leaf<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
- template<typename Type_Traits,
- typename E_Access_Traits,
- typename Metadata,
- typename Allocator>
- struct pat_trie_internal_node : public PB_DS_BASE_C_DEC
- {
- private:
- typedef PB_DS_BASE_C_DEC base_type;
- typedef Type_Traits type_traits;
- typedef typename type_traits::value_type value_type;
- typedef typename Allocator::size_type size_type;
-
- typedef E_Access_Traits e_access_traits;
- typedef typename e_access_traits::const_iterator const_e_iterator;
- typedef typename Allocator::template rebind<e_access_traits>::other access_rebind;
- typedef typename access_rebind::const_pointer const_e_access_traits_pointer;
-
- typedef typename Allocator::template rebind<base_type>::other base_rebind;
- typedef typename base_rebind::pointer node_pointer;
- typedef typename base_rebind::const_pointer const_node_pointer;
-
- typedef PB_DS_LEAF_C_DEC leaf;
- typedef typename Allocator::template rebind<leaf>::other leaf_rebind;
- typedef typename leaf_rebind::pointer leaf_pointer;
- typedef typename leaf_rebind::const_pointer const_leaf_pointer;
-
- typedef typename Allocator::template rebind<pat_trie_internal_node>::other internal_node_rebind;
- typedef typename internal_node_rebind::pointer internal_node_pointer;
- typedef typename internal_node_rebind::const_pointer const_internal_node_pointer;
-
-#ifdef _GLIBCXX_DEBUG
- typedef typename base_type::subtree_debug_info subtree_debug_info;
-
- virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer,
- const char* file, int line) const;
-#endif
-
- inline size_type
- get_pref_pos(const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer) const;
-
- public:
- typedef typename Allocator::template rebind<node_pointer>::other node_pointer_rebind;
- typedef typename node_pointer_rebind::pointer node_pointer_pointer;
- typedef typename node_pointer_rebind::reference node_pointer_reference;
-
- enum
- {
- arr_size = E_Access_Traits::max_size + 1
- };
- PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2);
-
-#include <ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp>
-#include <ext/pb_ds/detail/pat_trie_/child_iterator.hpp>
-
- pat_trie_internal_node(size_type, const const_e_iterator);
-
- void
- update_prefixes(const_e_access_traits_pointer);
-
- const_iterator
- begin() const;
-
- iterator
- begin();
-
- const_iterator
- end() const;
-
- iterator
- end();
-
- inline node_pointer
- get_child_node(const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer);
-
- inline const_node_pointer
- get_child_node(const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer) const;
-
- inline iterator
- get_child_it(const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer);
-
- inline node_pointer
- get_lower_bound_child_node(const_e_iterator, const_e_iterator,
- size_type, const_e_access_traits_pointer);
-
- inline node_pointer
- add_child(node_pointer, const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer);
-
- inline const_node_pointer
- get_join_child(const_node_pointer, const_e_access_traits_pointer) const;
-
- inline node_pointer
- get_join_child(node_pointer, const_e_access_traits_pointer);
-
- void
- remove_child(node_pointer p_nd);
-
- iterator
- remove_child(iterator it);
-
- void
- replace_child(node_pointer, const_e_iterator, const_e_iterator,
- const_e_access_traits_pointer);
-
- inline const_e_iterator
- pref_b_it() const;
-
- inline const_e_iterator
- pref_e_it() const;
-
- inline size_type
- get_e_ind() const;
-
- bool
- should_be_mine(const_e_iterator, const_e_iterator, size_type,
- const_e_access_traits_pointer) const;
-
- leaf_pointer
- leftmost_descendant();
-
- const_leaf_pointer
- leftmost_descendant() const;
-
- leaf_pointer
- rightmost_descendant();
-
- const_leaf_pointer
- rightmost_descendant() const;
-
-#ifdef _GLIBCXX_DEBUG
- size_type
- e_ind() const;
-#endif
-
- private:
- pat_trie_internal_node(const pat_trie_internal_node&);
-
- size_type
- get_begin_pos() const;
-
- const size_type m_e_ind;
- const_e_iterator m_pref_b_it;
- const_e_iterator m_pref_e_it;
- node_pointer m_a_p_children[arr_size];
- static leaf_rebind s_leaf_alloc;
- static internal_node_rebind s_internal_node_alloc;
- };
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::leaf_rebind
- PB_DS_CLASS_C_DEC::s_leaf_alloc;
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::internal_node_rebind
- PB_DS_CLASS_C_DEC::s_internal_node_alloc;
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::size_type
- PB_DS_CLASS_C_DEC::
- get_pref_pos(const_e_iterator b_it, const_e_iterator e_it,
- const_e_access_traits_pointer p_traits) const
- {
- if (static_cast<std::size_t>(std::distance(b_it, e_it)) <= m_e_ind)
- return 0;
- std::advance(b_it, m_e_ind);
- return 1 + p_traits->e_pos(*b_it);
- }
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- pat_trie_internal_node(size_type len, const const_e_iterator it) :
- PB_DS_BASE_C_DEC(pat_trie_internal_node_type),
- m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it)
- {
- std::advance(m_pref_e_it, m_e_ind);
- std::fill(m_a_p_children, m_a_p_children + arr_size,
- static_cast<node_pointer>(0));
- }
-
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- update_prefixes(const_e_access_traits_pointer p_traits)
- {
- node_pointer p_first = *begin();
- if (p_first->m_type == pat_trie_leaf_node_type)
- {
- const_leaf_pointer p = static_cast<const_leaf_pointer>(p_first);
- m_pref_b_it = p_traits->begin(e_access_traits::extract_key(p->value()));
- }
- else
- {
- _GLIBCXX_DEBUG_ASSERT(p_first->m_type == pat_trie_internal_node_type);
- m_pref_b_it = static_cast<internal_node_pointer>(p_first)->pref_b_it();
- }
- m_pref_e_it = m_pref_b_it;
- std::advance(m_pref_e_it, m_e_ind);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_iterator
- PB_DS_CLASS_C_DEC::
- begin() const
- {
- typedef node_pointer_pointer pointer_type;
- pointer_type p = const_cast<pointer_type>(m_a_p_children);
- return const_iterator(p + get_begin_pos(), p + arr_size);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::iterator
- PB_DS_CLASS_C_DEC::
- begin()
- {
- return iterator(m_a_p_children + get_begin_pos(),
- m_a_p_children + arr_size);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_iterator
- PB_DS_CLASS_C_DEC::
- end() const
- {
- typedef node_pointer_pointer pointer_type;
- pointer_type p = const_cast<pointer_type>(m_a_p_children) + arr_size;
- return const_iterator(p, p);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::iterator
- PB_DS_CLASS_C_DEC::
- end()
- { return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::node_pointer
- PB_DS_CLASS_C_DEC::
- get_child_node(const_e_iterator b_it, const_e_iterator e_it,
- const_e_access_traits_pointer p_traits)
- {
- const size_type i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
- return m_a_p_children[i];
- }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::iterator
- PB_DS_CLASS_C_DEC::
- get_child_it(const_e_iterator b_it, const_e_iterator e_it,
- const_e_access_traits_pointer p_traits)
- {
- const size_type i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
- _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0);
- return iterator(m_a_p_children + i, m_a_p_children + i);
- }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::const_node_pointer
- PB_DS_CLASS_C_DEC::
- get_child_node(const_e_iterator b_it, const_e_iterator e_it,
- const_e_access_traits_pointer p_traits) const
- { return const_cast<node_pointer>(get_child_node(b_it, e_it, p_traits)); }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::node_pointer
- PB_DS_CLASS_C_DEC::
- get_lower_bound_child_node(const_e_iterator b_it, const_e_iterator e_it,
- size_type checked_ind,
- const_e_access_traits_pointer p_traits)
- {
- if (!should_be_mine(b_it, e_it, checked_ind, p_traits))
- {
- if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it, m_pref_e_it, true))
- return leftmost_descendant();
- return rightmost_descendant();
- }
-
- size_type i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
-
- if (m_a_p_children[i] != 0)
- return m_a_p_children[i];
-
- while (++i < arr_size)
- if (m_a_p_children[i] != 0)
- {
- if (m_a_p_children[i]->m_type == pat_trie_leaf_node_type)
- return m_a_p_children[i];
-
- _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i]->m_type == pat_trie_internal_node_type);
-
- return static_cast<internal_node_pointer>(m_a_p_children[i])->leftmost_descendant();
- }
-
- return rightmost_descendant();
- }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::node_pointer
- PB_DS_CLASS_C_DEC::
- add_child(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it,
- const_e_access_traits_pointer p_traits)
- {
- const size_type i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
- if (m_a_p_children[i] == 0)
- {
- m_a_p_children[i] = p_nd;
- p_nd->m_p_parent = this;
- return p_nd;
- }
- return m_a_p_children[i];
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_node_pointer
- PB_DS_CLASS_C_DEC::
- get_join_child(const_node_pointer p_nd, const_e_access_traits_pointer p_traits) const
- {
- node_pointer p = const_cast<node_pointer>(p_nd);
- return const_cast<internal_node_pointer>(this)->get_join_child(p, p_traits);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::node_pointer
- PB_DS_CLASS_C_DEC::
- get_join_child(node_pointer p_nd, const_e_access_traits_pointer p_traits)
- {
- size_type i;
- const_e_iterator b_it;
- const_e_iterator e_it;
- if (p_nd->m_type == pat_trie_leaf_node_type)
- {
- typename Type_Traits::const_key_reference r_key =
- e_access_traits::extract_key(static_cast<const_leaf_pointer>(p_nd)->value());
-
- b_it = p_traits->begin(r_key);
- e_it = p_traits->end(r_key);
- }
- else
- {
- b_it = static_cast<internal_node_pointer>(p_nd)->pref_b_it();
- e_it = static_cast<internal_node_pointer>(p_nd)->pref_e_it();
- }
- i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
- return m_a_p_children[i];
- }
-
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- remove_child(node_pointer p_nd)
- {
- size_type i = 0;
- for (; i < arr_size; ++i)
- if (m_a_p_children[i] == p_nd)
- {
- m_a_p_children[i] = 0;
- return;
- }
- _GLIBCXX_DEBUG_ASSERT(i != arr_size);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::iterator
- PB_DS_CLASS_C_DEC::
- remove_child(iterator it)
- {
- iterator ret = it;
- ++ret;
- * it.m_p_p_cur = 0;
- return ret;
- }
-
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- replace_child(node_pointer p_nd, const_e_iterator b_it,
- const_e_iterator e_it,
- const_e_access_traits_pointer p_traits)
- {
- const size_type i = get_pref_pos(b_it, e_it, p_traits);
- _GLIBCXX_DEBUG_ASSERT(i < arr_size);
- m_a_p_children[i] = p_nd;
- p_nd->m_p_parent = this;
- }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::const_e_iterator
- PB_DS_CLASS_C_DEC::
- pref_b_it() const
- { return m_pref_b_it; }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::const_e_iterator
- PB_DS_CLASS_C_DEC::
- pref_e_it() const
- { return m_pref_e_it; }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::size_type
- PB_DS_CLASS_C_DEC::
- get_e_ind() const
- { return m_e_ind; }
-
- PB_DS_CLASS_T_DEC
- bool
- PB_DS_CLASS_C_DEC::
- should_be_mine(const_e_iterator b_it, const_e_iterator e_it,
- size_type checked_ind,
- const_e_access_traits_pointer p_traits) const
- {
- if (m_e_ind == 0)
- return true;
-
- const size_type num_es = std::distance(b_it, e_it);
- if (num_es < m_e_ind)
- return false;
-
- const_e_iterator key_b_it = b_it;
- std::advance(key_b_it, checked_ind);
- const_e_iterator key_e_it = b_it;
- std::advance(key_e_it, m_e_ind);
-
- const_e_iterator value_b_it = m_pref_b_it;
- std::advance(value_b_it, checked_ind);
- const_e_iterator value_e_it = m_pref_b_it;
- std::advance(value_e_it, m_e_ind);
-
- return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it,
- value_e_it);
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::leaf_pointer
- PB_DS_CLASS_C_DEC::
- leftmost_descendant()
- {
- node_pointer p_pot =* begin();
- if (p_pot->m_type == pat_trie_leaf_node_type)
- return (static_cast<leaf_pointer>(p_pot));
- _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == pat_trie_internal_node_type);
- return static_cast<internal_node_pointer>(p_pot)->leftmost_descendant();
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_leaf_pointer
- PB_DS_CLASS_C_DEC::
- leftmost_descendant() const
- {
- return const_cast<internal_node_pointer>(this)->leftmost_descendant();
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::leaf_pointer
- PB_DS_CLASS_C_DEC::
- rightmost_descendant()
- {
- const size_type num_children = std::distance(begin(), end());
- _GLIBCXX_DEBUG_ASSERT(num_children >= 2);
-
- iterator it = begin();
- std::advance(it, num_children - 1);
- node_pointer p_pot =* it;
- if (p_pot->m_type == pat_trie_leaf_node_type)
- return static_cast<leaf_pointer>(p_pot);
- _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == pat_trie_internal_node_type);
- return static_cast<internal_node_pointer>(p_pot)->rightmost_descendant();
- }
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::const_leaf_pointer
- PB_DS_CLASS_C_DEC::
- rightmost_descendant() const
- {
- return const_cast<internal_node_pointer>(this)->rightmost_descendant();
- }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::size_type
- PB_DS_CLASS_C_DEC::
- e_ind() const
- { return m_e_ind; }
-#endif
-
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::size_type
- PB_DS_CLASS_C_DEC::
- get_begin_pos() const
- {
- size_type i;
- for (i = 0; i < arr_size && m_a_p_children[i] == 0; ++i)
- ;
- return i;
- }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::subtree_debug_info
- PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer p_traits,
- const char* __file, int __line) const
- {
- PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_internal_node_type);
- PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
- PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2);
-
- for (typename pat_trie_internal_node::const_iterator it = begin();
- it != end(); ++it)
- {
- const_node_pointer p_nd =* it;
- PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this);
- subtree_debug_info child_ret =
- p_nd->assert_valid_imp(p_traits, __file, __line);
-
- PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
- PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
- PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
- }
- return std::make_pair(pref_b_it(), pref_e_it());
- }
-#endif
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_LEAF_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
// warranty.
/**
- * @file iterators_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/iterators_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
{ return const_reverse_iterator(m_p_head); }
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, this); }
+{ return node_const_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
{ return node_iterator(m_p_head->m_p_parent, this); }
PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_node_iterator
+inline typename PB_DS_CLASS_C_DEC::node_const_iterator
PB_DS_CLASS_C_DEC::
node_end() const
-{ return const_node_iterator(0, this); }
+{ return node_const_iterator(0, this); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_iterator
+++ /dev/null
-// -*- 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 leaf.hpp
- * Contains a pat_trie_leaf for a patricia tree.
- */
-
-#ifndef PB_DS_PAT_TRIE_LEAF_HPP
-#define PB_DS_PAT_TRIE_LEAF_HPP
-
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
-#define PB_DS_CLASS_T_DEC \
- template<class Type_Traits, \
- class E_Access_Traits, \
- class Metadata, \
- class Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- pat_trie_leaf<Type_Traits, \
- E_Access_Traits, \
- Metadata, \
- Allocator>
-
-#define PB_DS_BASE_C_DEC \
- pat_trie_node_base<Type_Traits, \
- E_Access_Traits, \
- Metadata, \
- Allocator>
-
-#define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \
- pat_trie_subtree_debug_info<Type_Traits, \
- E_Access_Traits, \
- Allocator>
-
- template<typename Type_Traits,
- class E_Access_Traits,
- class Metadata,
- class Allocator>
- struct pat_trie_leaf : public PB_DS_BASE_C_DEC
- {
- private:
- typedef typename Type_Traits::value_type value_type;
-
- typedef typename Type_Traits::const_reference const_reference;
-
- typedef typename Type_Traits::reference reference;
-
- typedef
- typename Allocator::template rebind<
- E_Access_Traits>::other::const_pointer
- const_e_access_traits_pointer;
-
-#ifdef _GLIBCXX_DEBUG
- typedef
- typename PB_DS_BASE_C_DEC::subtree_debug_info
- subtree_debug_info;
-#endif
-
- typedef PB_DS_BASE_C_DEC base_type;
-
- public:
- pat_trie_leaf(const_reference r_val);
-
- inline reference
- value();
-
- inline const_reference
- value() const;
-
-#ifdef _GLIBCXX_DEBUG
- virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits,
- const char* file, int line) const;
-
- virtual
- ~pat_trie_leaf();
-#endif
-
- private:
- pat_trie_leaf(const PB_DS_CLASS_C_DEC& other);
-
- value_type m_value;
- };
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- pat_trie_leaf(const_reference r_val) :
- PB_DS_BASE_C_DEC(pat_trie_leaf_node_type), m_value(r_val)
- { }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::reference
- PB_DS_CLASS_C_DEC::
- value()
- { return m_value; }
-
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::const_reference
- PB_DS_CLASS_C_DEC::
- value() const
- { return m_value; }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
- typename PB_DS_CLASS_C_DEC::subtree_debug_info
- PB_DS_CLASS_C_DEC::
- assert_valid_imp(const_e_access_traits_pointer p_traits,
- const char* __file, int __line) const
- {
- PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_leaf_node_type);
- subtree_debug_info ret;
- const_reference r_val = value();
- return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
- p_traits->end(p_traits->extract_key(r_val)));
- }
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- ~pat_trie_leaf() { }
-#endif
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
+++ /dev/null
-// -*- 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 node_base.hpp
- * Contains a pat_trie_node_base base for a patricia tree.
- */
-
-#ifndef PB_DS_PAT_TRIE_NODE_BASE_HPP
-#define PB_DS_PAT_TRIE_NODE_BASE_HPP
-
-#include <ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-#define PB_DS_CLASS_T_DEC \
- template<typename Type_Traits, typename E_Access_Traits, \
- typename Metadata, typename Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- pat_trie_node_base<Type_Traits, E_Access_Traits, Metadata, Allocator>
-
-#define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \
- pat_trie_subtree_debug_info<Type_Traits, E_Access_Traits, Allocator>
-
- enum pat_trie_node_type
- {
- pat_trie_internal_node_type,
- pat_trie_leaf_node_type,
- pat_trie_head_node_type
- };
-
- template<typename Type_Traits,
- typename E_Access_Traits,
- typename Metadata,
- typename Allocator>
- struct pat_trie_node_base : public pat_trie_node_metadata_base<
- Metadata,
- Allocator>
- {
- public:
- typedef
- typename Allocator::template rebind<
- pat_trie_node_base>::other::pointer
- node_pointer;
-
- typedef
- typename Allocator::template rebind<
- E_Access_Traits>::other::const_pointer
- const_e_access_traits_pointer;
-
-#ifdef _GLIBCXX_DEBUG
- typedef
- std::pair<
- typename E_Access_Traits::const_iterator,
- typename E_Access_Traits::const_iterator>
- subtree_debug_info;
-#endif
-
- pat_trie_node_base(pat_trie_node_type type);
-
-#ifdef _GLIBCXX_DEBUG
- void
- assert_valid(const_e_access_traits_pointer p_traits,
- const char* file, int line) const;
-
- virtual subtree_debug_info
- assert_valid_imp(const_e_access_traits_pointer p_traits,
- const char* file, int line) const = 0;
-#endif
-
- node_pointer m_p_parent;
- const pat_trie_node_type m_type;
- };
-
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- pat_trie_node_base(pat_trie_node_type type) : m_type(type)
- { }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- assert_valid(const_e_access_traits_pointer p_traits,
- const char* __file, int __line) const
- { assert_valid_imp(p_traits, __file, __line); }
-#endif
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 node_iterators.hpp
- * Contains an implementation class for pat_trie_.
- */
-
-#ifndef PB_DS_PAT_TRIE_NODE_ITERATORS_HPP
-#define PB_DS_PAT_TRIE_NODE_ITERATORS_HPP
-
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
-#define PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC \
- pat_trie_const_node_it_< \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- Const_Iterator, \
- Iterator, \
- E_Access_Traits, \
- Allocator>
-
-#define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \
- pat_trie_node_it_< \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- Const_Iterator, \
- Iterator, \
- E_Access_Traits, \
- Allocator>
-
- // Const node iterator.
- template<typename Node,
- class Leaf,
- class Head,
- class Internal_Node,
- class Const_Iterator,
- class Iterator,
- class E_Access_Traits,
- class Allocator>
- class pat_trie_const_node_it_
- {
- protected:
- typedef
- typename Allocator::template rebind<
- Node>::other::pointer
- node_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::const_pointer
- const_leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::pointer
- leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Internal_Node>::other::pointer
- internal_node_pointer;
-
- typedef
- typename Allocator::template rebind<
- Internal_Node>::other::const_pointer
- const_internal_node_pointer;
-
- typedef
- typename Allocator::template rebind<
- E_Access_Traits>::other::const_pointer
- const_e_access_traits_pointer;
-
- private:
- inline typename E_Access_Traits::const_iterator
- pref_begin() const
- {
- if (m_p_nd->m_type == pat_trie_leaf_node_type)
- return (m_p_traits->begin(
- m_p_traits->extract_key(
- static_cast<const_leaf_pointer>(m_p_nd)->value())));
-
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type);
-
- return (static_cast<const_internal_node_pointer>(m_p_nd)->pref_b_it());
- }
-
- inline typename E_Access_Traits::const_iterator
- pref_end() const
- {
- if (m_p_nd->m_type == pat_trie_leaf_node_type)
- return (m_p_traits->end(
- m_p_traits->extract_key(
- static_cast<const_leaf_pointer>(m_p_nd)->value())));
-
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type);
-
- return (static_cast<const_internal_node_pointer>(m_p_nd)->pref_e_it());
- }
-
- public:
-
- // Size type.
- typedef typename Allocator::size_type size_type;
-
- // Category.
- typedef trivial_iterator_tag iterator_category;
-
- // Difference type.
- typedef trivial_iterator_difference_type difference_type;
-
- // __Iterator's value type.
- typedef Const_Iterator value_type;
-
- // __Iterator's reference type.
- typedef value_type reference;
-
- // __Iterator's __const reference type.
- typedef value_type const_reference;
-
- // Element access traits.
- typedef E_Access_Traits e_access_traits;
-
- // A key's element __const iterator.
- typedef typename e_access_traits::const_iterator const_e_iterator;
-
- // Metadata type.
- typedef typename Node::metadata_type metadata_type;
-
- // Const metadata reference type.
- typedef
- typename Allocator::template rebind<
- metadata_type>::other::const_reference
- const_metadata_reference;
-
- // Default constructor.
- /*
- inline
- pat_trie_const_node_it_()
- */
- inline
- pat_trie_const_node_it_(node_pointer p_nd = 0,
- const_e_access_traits_pointer p_traits = 0)
- : m_p_nd(const_cast<node_pointer>(p_nd)), m_p_traits(p_traits)
- { }
-
- // Subtree valid prefix.
- inline std::pair<const_e_iterator, const_e_iterator>
- valid_prefix() const
- { return std::make_pair(pref_begin(), pref_end()); }
-
- // Const access; returns the __const iterator* associated with
- // the current leaf.
- inline const_reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(num_children() == 0);
- return Const_Iterator(m_p_nd);
- }
-
- // Metadata access.
- inline const_metadata_reference
- get_metadata() const
- { return m_p_nd->get_metadata(); }
-
- // Returns the number of children in the corresponding node.
- inline size_type
- num_children() const
- {
- if (m_p_nd->m_type == pat_trie_leaf_node_type)
- return 0;
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type);
- return std::distance(static_cast<internal_node_pointer>(m_p_nd)->begin(), static_cast<internal_node_pointer>(m_p_nd)->end());
- }
-
- // Returns a __const node __iterator to the corresponding node's
- // i-th child.
- PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC
- get_child(size_type i) const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_internal_node_type);
- typename Internal_Node::iterator it =
- static_cast<internal_node_pointer>(m_p_nd)->begin();
-
- std::advance(it, i);
- return PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC(*it, m_p_traits);
- }
-
- // Compares content to a different iterator object.
- inline bool
- operator==(const PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC& other) const
- { return (m_p_nd == other.m_p_nd); }
-
- // Compares content (negatively) to a different iterator object.
- inline bool
- operator!=(const PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC& other) const
- { return m_p_nd != other.m_p_nd; }
-
- private:
-
- friend class PB_DS_CLASS_C_DEC;
-
- public:
- node_pointer m_p_nd;
-
- const_e_access_traits_pointer m_p_traits;
- };
-
- // Node iterator.
- template<typename Node,
- class Leaf,
- class Head,
- class Internal_Node,
- class Const_Iterator,
- class Iterator,
- class E_Access_Traits,
- class Allocator>
- class pat_trie_node_it_ :
- public PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC
-
- {
- private:
- typedef
- typename Allocator::template rebind<
- Node>::other::pointer
- node_pointer;
-
- typedef Iterator iterator;
-
- typedef PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC base_type;
-
- typedef
- typename base_type::const_e_access_traits_pointer
- const_e_access_traits_pointer;
-
- typedef typename base_type::internal_node_pointer internal_node_pointer;
-
- public:
-
- // Size type.
- typedef
- typename PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC::size_type
- size_type;
-
- // __Iterator's value type.
- typedef Iterator value_type;
-
- // __Iterator's reference type.
- typedef value_type reference;
-
- // __Iterator's __const reference type.
- typedef value_type const_reference;
-
- // Default constructor.
- /*
- inline
- pat_trie_node_it_() ;
- */
-
- inline
- pat_trie_node_it_(node_pointer p_nd = 0, const_e_access_traits_pointer p_traits = 0) : base_type(p_nd, p_traits)
- { }
-
- // Access; returns the iterator* associated with the current leaf.
- inline reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0);
- return Iterator(base_type::m_p_nd);
-
- }
-
- // Returns a node __iterator to the corresponding node's i-th child.
- PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC
- get_child(size_type i) const
- {
- _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == pat_trie_internal_node_type);
-
- typename Internal_Node::iterator it =
- static_cast<internal_node_pointer>(base_type::m_p_nd)->begin();
-
- std::advance(it, i);
- return PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC(*it, base_type::m_p_traits);
- }
-
- private:
- friend class PB_DS_CLASS_C_DEC;
- };
-
-#undef PB_DS_PAT_TRIE_CONST_NODE_ITERATOR_C_DEC
-#undef PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
-
+++ /dev/null
-// -*- 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 node_metadata_base.hpp
- * Contains an internal PB_DS_BASE_C_DEC for a patricia tree.
- */
-
-#ifndef PB_DS_PAT_TRIE_NODE_METADATA_BASE_HPP
-#define PB_DS_PAT_TRIE_NODE_METADATA_BASE_HPP
-
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
- template<typename Metadata, class Allocator>
- struct pat_trie_node_metadata_base
- {
- public:
- typedef Metadata metadata_type;
-
- typedef
- typename Allocator::template rebind<
- metadata_type>::other::const_reference
- const_metadata_reference;
-
- public:
- inline const_metadata_reference
- get_metadata() const
- {
- return (m_metadata);
- }
-
- public:
- metadata_type m_metadata;
- };
-
- template<typename Allocator>
- struct pat_trie_node_metadata_base<
- null_node_metadata,
- Allocator>
- {
- public:
- typedef null_node_metadata metadata_type;
- };
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif // #ifndef PB_DS_PAT_TRIE_NODE_BASE_HPP
-
// warranty.
/**
- * @file pat_trie_.hpp
+ * @file pat_trie_/pat_trie_.hpp
* Contains an implementation class for a patricia tree.
*/
-/**
- * This implementation loosely borrows ideas from:
- * 1) Fast Mergeable Integer Maps, Okasaki, Gill 1998
- * 2) Ptset: Sets of integers implemented as Patricia trees,
- * Jean-Christophe Filliatr, 2000
- **/
-
-#include <ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp>
-#include <ext/pb_ds/detail/pat_trie_/node_base.hpp>
-#include <ext/pb_ds/exception.hpp>
-#include <ext/pb_ds/tag_and_trait.hpp>
-#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
-#include <ext/pb_ds/detail/types_traits.hpp>
-#include <ext/pb_ds/tree_policy.hpp>
-#include <ext/pb_ds/detail/cond_dealtor.hpp>
-#include <ext/pb_ds/detail/type_utils.hpp>
#include <iterator>
#include <utility>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <list>
+#include <ext/pb_ds/exception.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
+#include <ext/pb_ds/detail/cond_dealtor.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/types_traits.hpp>
+#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
+#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp>
+#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp>
#ifdef _GLIBCXX_DEBUG
#include <ext/pb_ds/detail/debug_map_base.hpp>
-#endif
+#endif
#include <debug/debug.h>
namespace __gnu_pbds
{
namespace detail
{
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, typename Node_And_It_Traits, \
- typename Allocator>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME pat_trie_data_
-#endif
+#define PB_DS_PAT_TRIE_NAME pat_trie_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME pat_trie_no_data_
-#endif
+#define PB_DS_PAT_TRIE_NAME pat_trie_set
+#endif
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Node_And_It_Traits, \
+ typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Node_And_It_Traits, Allocator>
+ PB_DS_PAT_TRIE_NAME<Key, Mapped, Node_And_It_Traits, _Alloc>
-#define PB_DS_TYPES_TRAITS_C_DEC \
- types_traits<Key, Mapped, Allocator, false>
+#define PB_DS_PAT_TRIE_TRAITS_BASE \
+ types_traits<Key, Mapped, _Alloc, false>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
- debug_map_base<Key, eq_by_less<Key, \
- std::less<Key> >, typename Allocator::template rebind<Key>::other::const_reference>
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
+ debug_map_base<Key, eq_by_less<Key, std::less<Key> >, \
+ typename _Alloc::template rebind<Key>::other::const_reference>
+#endif
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
/**
- * class description = PATRICIA trie implementation.">
- **/
- template<typename Key,
- typename Mapped,
- typename Node_And_It_Traits,
- typename Allocator>
- class PB_DS_CLASS_NAME :
+ * @brief PATRICIA trie.
+ *
+ * This implementation loosely borrows ideas from:
+ * 1) Fast Mergeable Integer Maps, Okasaki, Gill 1998
+ * 2) Ptset: Sets of integers implemented as Patricia trees,
+ * Jean-Christophe Filliatr, 2000
+ */
+ template<typename Key, typename Mapped, typename Node_And_It_Traits,
+ typename _Alloc>
+ class PB_DS_PAT_TRIE_NAME :
#ifdef _GLIBCXX_DEBUG
public PB_DS_DEBUG_MAP_BASE_C_DEC,
-#endif
- public Node_And_It_Traits::synth_e_access_traits,
+#endif
+ public Node_And_It_Traits::synth_access_traits,
public Node_And_It_Traits::node_update,
- public PB_DS_TYPES_TRAITS_C_DEC
+ public PB_DS_PAT_TRIE_TRAITS_BASE,
+ public pat_trie_base
{
private:
- typedef PB_DS_TYPES_TRAITS_C_DEC traits_base;
+ typedef pat_trie_base base_type;
+ typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base;
+ typedef Node_And_It_Traits traits_type;
+
+ typedef typename traits_type::synth_access_traits synth_access_traits;
+ typedef typename synth_access_traits::const_iterator a_const_iterator;
+
+ typedef typename traits_type::node node;
+ typedef typename _Alloc::template rebind<node> __rebind_n;
+ typedef typename __rebind_n::other::const_pointer node_const_pointer;
+ typedef typename __rebind_n::other::pointer node_pointer;
+
+ typedef typename traits_type::head head;
+ typedef typename _Alloc::template rebind<head> __rebind_h;
+ typedef typename __rebind_h::other head_allocator;
+ typedef typename head_allocator::pointer head_pointer;
+
+ typedef typename traits_type::leaf leaf;
+ typedef typename _Alloc::template rebind<leaf> __rebind_l;
+ typedef typename __rebind_l::other leaf_allocator;
+ typedef typename leaf_allocator::pointer leaf_pointer;
+ typedef typename leaf_allocator::const_pointer leaf_const_pointer;
+
+ typedef typename traits_type::inode inode;
+ typedef typename inode::iterator inode_iterator;
+ typedef typename _Alloc::template rebind<inode> __rebind_in;
+ typedef typename __rebind_in::other __rebind_ina;
+ typedef typename __rebind_in::other inode_allocator;
+ typedef typename __rebind_ina::pointer inode_pointer;
+ typedef typename __rebind_ina::const_pointer inode_const_pointer;
+
+
+ /// Conditional deallocator.
+ class cond_dealtor
+ {
+ protected:
+ leaf_pointer m_p_nd;
+ bool m_no_action_dtor;
+ bool m_call_destructor;
+
+ public:
+ cond_dealtor(leaf_pointer p_nd)
+ : m_p_nd(p_nd), m_no_action_dtor(false), m_call_destructor(false)
+ { }
- typedef typename Node_And_It_Traits::synth_e_access_traits synth_e_access_traits;
- typedef typename Allocator::template rebind<synth_e_access_traits>::other::const_pointer const_e_access_traits_pointer;
- typedef typename synth_e_access_traits::const_iterator const_e_iterator;
+ void
+ set_no_action_dtor()
+ { m_no_action_dtor = true; }
- typedef typename Node_And_It_Traits::node node;
- typedef typename Allocator::template rebind<node>::other::const_pointer const_node_pointer;
+ void
+ set_call_destructor()
+ { m_call_destructor = true; }
- typedef typename Allocator::template rebind<node>::other::pointer node_pointer;
+ ~cond_dealtor()
+ {
+ if (m_no_action_dtor)
+ return;
- typedef typename Node_And_It_Traits::head head;
- typedef typename Allocator::template rebind<head>::other head_allocator;
- typedef typename head_allocator::pointer head_pointer;
+ if (m_call_destructor)
+ m_p_nd->~leaf();
- typedef typename Node_And_It_Traits::leaf leaf;
- typedef typename Allocator::template rebind<leaf>::other leaf_allocator;
- typedef typename leaf_allocator::const_pointer const_leaf_pointer;
- typedef typename leaf_allocator::pointer leaf_pointer;
+ s_leaf_allocator.deallocate(m_p_nd, 1);
+ }
+ };
- typedef typename Node_And_It_Traits::internal_node internal_node;
- typedef typename Allocator::template rebind<internal_node>::other internal_node_allocator;
- typedef typename internal_node_allocator::const_pointer const_internal_node_pointer;
- typedef typename internal_node_allocator::pointer internal_node_pointer;
-#include <ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp>
+ /// Branch bag, for split-join.
+ class branch_bag
+ {
+ private:
+ typedef inode_pointer __inp;
+ typedef typename _Alloc::template rebind<__inp>::other __rebind_inp;
#ifdef _GLIBCXX_DEBUG
- typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
-#endif
+ typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type;
+#else
+ typedef std::list<__inp, __rebind_inp> bag_type;
+#endif
+
+ bag_type m_bag;
+ public:
+ void
+ add_branch()
+ {
+ inode_pointer p_nd = s_inode_allocator.allocate(1);
+ __try
+ {
+ m_bag.push_back(p_nd);
+ }
+ __catch(...)
+ {
+ s_inode_allocator.deallocate(p_nd, 1);
+ __throw_exception_again;
+ }
+ }
+
+ inode_pointer
+ get_branch()
+ {
+ _GLIBCXX_DEBUG_ASSERT(!m_bag.empty());
+ inode_pointer p_nd = *m_bag.begin();
+ m_bag.pop_front();
+ return p_nd;
+ }
+
+ ~branch_bag()
+ {
+ while (!m_bag.empty())
+ {
+ inode_pointer p_nd = *m_bag.begin();
+ s_inode_allocator.deallocate(p_nd, 1);
+ m_bag.pop_front();
+ }
+ }
+
+ inline bool
+ empty() const
+ { return m_bag.empty(); }
+ };
-#include <ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp>
+#ifdef _GLIBCXX_DEBUG
+ typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
+#endif
- typedef typename Node_And_It_Traits::null_node_update_pointer null_node_update_pointer;
+ typedef typename traits_type::null_node_update_pointer null_node_update_pointer;
public:
- typedef pat_trie_tag container_category;
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
-
- typedef typename traits_base::key_type key_type;
- typedef typename traits_base::key_pointer key_pointer;
- typedef typename traits_base::const_key_pointer const_key_pointer;
- typedef typename traits_base::key_reference key_reference;
- typedef typename traits_base::const_key_reference const_key_reference;
- typedef typename traits_base::mapped_type mapped_type;
- typedef typename traits_base::mapped_pointer mapped_pointer;
- typedef typename traits_base::const_mapped_pointer const_mapped_pointer;
- typedef typename traits_base::mapped_reference mapped_reference;
- typedef typename traits_base::const_mapped_reference const_mapped_reference;
- typedef typename traits_base::value_type value_type;
- typedef typename traits_base::pointer pointer;
- typedef typename traits_base::const_pointer const_pointer;
- typedef typename traits_base::reference reference;
- typedef typename traits_base::const_reference const_reference;
-
- typedef typename Node_And_It_Traits::const_iterator const_point_iterator;
- typedef typename Node_And_It_Traits::iterator point_iterator;
- typedef const_point_iterator const_iterator;
- typedef point_iterator iterator;
-
- typedef typename Node_And_It_Traits::const_reverse_iterator const_reverse_iterator;
- typedef typename Node_And_It_Traits::reverse_iterator reverse_iterator;
- typedef typename Node_And_It_Traits::const_node_iterator const_node_iterator;
- typedef typename Node_And_It_Traits::node_iterator node_iterator;
- typedef typename Node_And_It_Traits::e_access_traits e_access_traits;
- typedef typename Node_And_It_Traits::node_update node_update;
-
- PB_DS_CLASS_NAME();
-
- PB_DS_CLASS_NAME(const e_access_traits&);
-
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ typedef pat_trie_tag container_category;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+
+ typedef typename traits_base::key_type key_type;
+ typedef typename traits_base::key_pointer key_pointer;
+ typedef typename traits_base::key_const_pointer key_const_pointer;
+ typedef typename traits_base::key_reference key_reference;
+ typedef typename traits_base::key_const_reference key_const_reference;
+ typedef typename traits_base::mapped_type mapped_type;
+ typedef typename traits_base::mapped_pointer mapped_pointer;
+ typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
+ typedef typename traits_base::mapped_reference mapped_reference;
+ typedef typename traits_base::mapped_const_reference mapped_const_reference;
+ typedef typename traits_base::value_type value_type;
+ typedef typename traits_base::pointer pointer;
+ typedef typename traits_base::const_pointer const_pointer;
+ typedef typename traits_base::reference reference;
+ typedef typename traits_base::const_reference const_reference;
+
+ typedef typename traits_type::access_traits access_traits;
+ typedef typename traits_type::const_iterator point_const_iterator;
+ typedef typename traits_type::iterator point_iterator;
+ typedef point_const_iterator const_iterator;
+ typedef point_iterator iterator;
+
+ typedef typename traits_type::reverse_iterator reverse_iterator;
+ typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
+ typedef typename traits_type::node_const_iterator node_const_iterator;
+ typedef typename traits_type::node_iterator node_iterator;
+ typedef typename traits_type::node_update node_update;
+
+ PB_DS_PAT_TRIE_NAME();
+
+ PB_DS_PAT_TRIE_NAME(const access_traits&);
+
+ PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
- ~PB_DS_CLASS_NAME();
+ ~PB_DS_PAT_TRIE_NAME();
inline bool
empty() const;
inline size_type
max_size() const;
- e_access_traits&
- get_e_access_traits();
+ access_traits&
+ get_access_traits();
- const e_access_traits&
- get_e_access_traits() const;
+ const access_traits&
+ get_access_traits() const;
- node_update&
+ node_update&
get_node_update();
- const node_update&
+ const node_update&
get_node_update() const;
inline std::pair<point_iterator, bool>
insert(const_reference);
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
return insert(std::make_pair(r_key, mapped_type())).first->second;
-#else
+#else
insert(r_key);
- return traits_base::s_null_mapped;
-#endif
+ return traits_base::s_null_type;
+#endif
}
inline point_iterator
- find(const_key_reference);
+ find(key_const_reference);
- inline const_point_iterator
- find(const_key_reference) const;
+ inline point_const_iterator
+ find(key_const_reference) const;
inline point_iterator
- lower_bound(const_key_reference);
+ lower_bound(key_const_reference);
- inline const_point_iterator
- lower_bound(const_key_reference) const;
+ inline point_const_iterator
+ lower_bound(key_const_reference) const;
inline point_iterator
- upper_bound(const_key_reference);
+ upper_bound(key_const_reference);
- inline const_point_iterator
- upper_bound(const_key_reference) const;
+ inline point_const_iterator
+ upper_bound(key_const_reference) const;
void
clear();
inline bool
- erase(const_key_reference);
+ erase(key_const_reference);
inline const_iterator
erase(const_iterator);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline iterator
erase(iterator);
-#endif
+#endif
inline const_reverse_iterator
erase(const_reverse_iterator);
#ifdef PB_DS_DATA_TRUE_INDICATOR
inline reverse_iterator
erase(reverse_iterator);
-#endif
+#endif
template<typename Pred>
inline size_type
join(PB_DS_CLASS_C_DEC&);
void
- split(const_key_reference, PB_DS_CLASS_C_DEC&);
+ split(key_const_reference, PB_DS_CLASS_C_DEC&);
inline iterator
begin();
inline const_reverse_iterator
rend() const;
- inline const_node_iterator
+ inline node_const_iterator
node_begin() const;
inline node_iterator
node_begin();
- inline const_node_iterator
+ inline node_const_iterator
node_end() const;
inline node_iterator
#ifdef PB_DS_PAT_TRIE_TRACE_
void
trace() const;
-#endif
+#endif
protected:
-
template<typename It>
void
copy_from_range(It, It);
value_swap(PB_DS_CLASS_C_DEC&);
node_pointer
- recursive_copy_node(const_node_pointer);
+ recursive_copy_node(node_const_pointer);
private:
-
void
initialize();
apply_update(node_pointer, Node_Update_*);
bool
- join_prep(PB_DS_CLASS_C_DEC&, split_join_branch_bag&);
+ join_prep(PB_DS_CLASS_C_DEC&, branch_bag&);
void
- rec_join_prep(const_node_pointer, const_node_pointer,
- split_join_branch_bag&);
+ rec_join_prep(node_const_pointer, node_const_pointer, branch_bag&);
void
- rec_join_prep(const_leaf_pointer, const_leaf_pointer,
- split_join_branch_bag&);
+ rec_join_prep(leaf_const_pointer, leaf_const_pointer, branch_bag&);
void
- rec_join_prep(const_leaf_pointer, const_internal_node_pointer,
- split_join_branch_bag&);
+ rec_join_prep(leaf_const_pointer, inode_const_pointer, branch_bag&);
void
- rec_join_prep(const_internal_node_pointer, const_leaf_pointer,
- split_join_branch_bag&);
+ rec_join_prep(inode_const_pointer, leaf_const_pointer, branch_bag&);
void
- rec_join_prep(const_internal_node_pointer, const_internal_node_pointer,
- split_join_branch_bag&);
+ rec_join_prep(inode_const_pointer, inode_const_pointer, branch_bag&);
node_pointer
- rec_join(node_pointer, node_pointer, size_type, split_join_branch_bag&);
+ rec_join(node_pointer, node_pointer, size_type, branch_bag&);
node_pointer
- rec_join(leaf_pointer, leaf_pointer, split_join_branch_bag&);
+ rec_join(leaf_pointer, leaf_pointer, branch_bag&);
node_pointer
- rec_join(leaf_pointer, internal_node_pointer, size_type,
- split_join_branch_bag&);
+ rec_join(leaf_pointer, inode_pointer, size_type, branch_bag&);
node_pointer
- rec_join(internal_node_pointer, leaf_pointer, size_type,
- split_join_branch_bag&);
+ rec_join(inode_pointer, leaf_pointer, size_type, branch_bag&);
node_pointer
- rec_join(internal_node_pointer, internal_node_pointer,
- split_join_branch_bag&);
+ rec_join(inode_pointer, inode_pointer, branch_bag&);
size_type
- keys_diff_ind(typename e_access_traits::const_iterator,
- typename e_access_traits::const_iterator,
- typename e_access_traits::const_iterator,
- typename e_access_traits::const_iterator);
+ keys_diff_ind(typename access_traits::const_iterator,
+ typename access_traits::const_iterator,
+ typename access_traits::const_iterator,
+ typename access_traits::const_iterator);
- internal_node_pointer
- insert_branch(node_pointer, node_pointer, split_join_branch_bag&);
+ inode_pointer
+ insert_branch(node_pointer, node_pointer, branch_bag&);
void
update_min_max_for_inserted_leaf(leaf_pointer);
clear_imp(node_pointer);
void
- erase_fixup(internal_node_pointer);
+ erase_fixup(inode_pointer);
void
update_min_max_for_erased_leaf(leaf_pointer);
- static inline const_e_iterator
- pref_begin(const_node_pointer);
+ static inline a_const_iterator
+ pref_begin(node_const_pointer);
- static inline const_e_iterator
- pref_end(const_node_pointer);
+ static inline a_const_iterator
+ pref_end(node_const_pointer);
inline node_pointer
- find_imp(const_key_reference);
+ find_imp(key_const_reference);
inline node_pointer
- lower_bound_imp(const_key_reference);
+ lower_bound_imp(key_const_reference);
inline node_pointer
- upper_bound_imp(const_key_reference);
+ upper_bound_imp(key_const_reference);
- inline static const_leaf_pointer
- leftmost_descendant(const_node_pointer);
+ inline static leaf_const_pointer
+ leftmost_descendant(node_const_pointer);
inline static leaf_pointer
leftmost_descendant(node_pointer);
- inline static const_leaf_pointer
- rightmost_descendant(const_node_pointer);
+ inline static leaf_const_pointer
+ rightmost_descendant(node_const_pointer);
inline static leaf_pointer
rightmost_descendant(node_pointer);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
void
- assert_iterators(const char* file, int line) const;
+ assert_iterators(const char*, int) const;
void
- assert_reverse_iterators(const char* file, int line) const;
+ assert_reverse_iterators(const char*, int) const;
static size_type
- recursive_count_leafs(const_node_pointer,
- const char* file, int line);
-#endif
+ recursive_count_leafs(node_const_pointer, const char*, int);
+#endif
#ifdef PB_DS_PAT_TRIE_TRACE_
static void
- trace_node(const_node_pointer, size_type);
+ trace_node(node_const_pointer, size_type);
template<typename Metadata_>
static void
- trace_node_metadata(const_node_pointer, type_to_type<Metadata_>);
+ trace_node_metadata(node_const_pointer, type_to_type<Metadata_>);
static void
- trace_node_metadata(const_node_pointer, type_to_type<null_node_metadata>);
-#endif
+ trace_node_metadata(node_const_pointer, type_to_type<null_type>);
+#endif
leaf_pointer
- split_prep(const_key_reference, PB_DS_CLASS_C_DEC&,
- split_join_branch_bag&);
+ split_prep(key_const_reference, PB_DS_CLASS_C_DEC&, branch_bag&);
node_pointer
- rec_split(node_pointer, const_e_iterator, const_e_iterator,
- PB_DS_CLASS_C_DEC&, split_join_branch_bag&);
+ rec_split(node_pointer, a_const_iterator, a_const_iterator,
+ PB_DS_CLASS_C_DEC&, branch_bag&);
void
- split_insert_branch(size_type, const_e_iterator,
- typename internal_node::iterator,
- size_type, split_join_branch_bag&);
+ split_insert_branch(size_type, a_const_iterator, inode_iterator,
+ size_type, branch_bag&);
- static head_allocator s_head_allocator;
- static internal_node_allocator s_internal_node_allocator;
- static leaf_allocator s_leaf_allocator;
+ static head_allocator s_head_allocator;
+ static inode_allocator s_inode_allocator;
+ static leaf_allocator s_leaf_allocator;
- head_pointer m_p_head;
- size_type m_size;
+ head_pointer m_p_head;
+ size_type m_size;
};
-#define PB_DS_ASSERT_NODE_VALID(X) \
+#define PB_DS_ASSERT_NODE_VALID(X) \
_GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);)
-#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
+#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
recursive_count_leafs(X, __FILE__, __LINE__)
#include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp>
#undef PB_DS_ASSERT_NODE_VALID
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_TYPES_TRAITS_C_DEC
+#undef PB_DS_PAT_TRIE_NAME
+#undef PB_DS_PAT_TRIE_TRAITS_BASE
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
-
} // namespace detail
} // namespace __gnu_pbds
--- /dev/null
+// -*- 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 pat_trie_/pat_trie_base.hpp
+ * Contains the base class for a patricia tree.
+ */
+
+#ifndef PB_DS_PAT_TRIE_BASE
+#define PB_DS_PAT_TRIE_BASE
+
+#include <debug/debug.h>
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+ /// Base type for PATRICIA trees.
+ struct pat_trie_base
+ {
+ /// Three types of nodes.
+ enum node_type
+ {
+ i_node,
+ leaf_node,
+ head_node
+ };
+
+ /// Metadata base primary template.
+ template<typename Metadata, typename _Alloc>
+ struct _Metadata
+ {
+ typedef Metadata metadata_type;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::template rebind<Metadata> __rebind_m;
+ typedef typename __rebind_m::other::const_reference const_reference;
+
+ const_reference
+ get_metadata() const
+ { return m_metadata; }
+
+ metadata_type m_metadata;
+ };
+
+ /// Specialization for null metadata.
+ template<typename _Alloc>
+ struct _Metadata<null_type, _Alloc>
+ {
+ typedef null_type metadata_type;
+ typedef _Alloc allocator_type;
+ };
+
+
+ /// Node base.
+ template<typename _ATraits, typename Metadata>
+ struct _Node_base
+ : public Metadata
+ {
+ private:
+ typedef typename Metadata::allocator_type _Alloc;
+
+ public:
+ typedef _Alloc allocator_type;
+ typedef _ATraits access_traits;
+ typedef typename _ATraits::type_traits type_traits;
+ typedef typename _Alloc::template rebind<_Node_base> __rebind_n;
+ typedef typename __rebind_n::other::pointer node_pointer;
+
+ node_pointer m_p_parent;
+ const node_type m_type;
+
+ _Node_base(node_type type) : m_type(type)
+ { }
+
+ typedef typename _Alloc::template rebind<_ATraits> __rebind_at;
+ typedef typename __rebind_at::other::const_pointer a_const_pointer;
+ typedef typename _ATraits::const_iterator a_const_iterator;
+
+#ifdef _GLIBCXX_DEBUG
+ typedef std::pair<a_const_iterator, a_const_iterator> node_debug_info;
+
+ void
+ assert_valid(a_const_pointer p_traits,
+ const char* __file, int __line) const
+ { assert_valid_imp(p_traits, __file, __line); }
+
+ virtual node_debug_info
+ assert_valid_imp(a_const_pointer, const char*, int) const = 0;
+#endif
+ };
+
+
+ /// Head node for PATRICIA tree.
+ template<typename _ATraits, typename Metadata>
+ struct _Head
+ : public _Node_base<_ATraits, Metadata>
+ {
+ typedef _Node_base<_ATraits, Metadata> base_type;
+ typedef typename base_type::type_traits type_traits;
+ typedef typename base_type::node_pointer node_pointer;
+
+ node_pointer m_p_min;
+ node_pointer m_p_max;
+
+ _Head() : base_type(head_node) { }
+
+#ifdef _GLIBCXX_DEBUG
+ typedef typename base_type::node_debug_info node_debug_info;
+ typedef typename base_type::a_const_pointer a_const_pointer;
+
+ virtual node_debug_info
+ assert_valid_imp(a_const_pointer, const char* __file, int __line) const
+ {
+ _GLIBCXX_DEBUG_VERIFY_AT(false,
+ _M_message("Assertion from %1;:%2;")
+ ._M_string(__FILE__)._M_integer(__LINE__),
+ __file, __line);
+ return node_debug_info();
+ }
+#endif
+ };
+
+
+ /// Leaf node for PATRICIA tree.
+ template<typename _ATraits, typename Metadata>
+ struct _Leaf
+ : public _Node_base<_ATraits, Metadata>
+ {
+ typedef _Node_base<_ATraits, Metadata> base_type;
+ typedef typename base_type::type_traits type_traits;
+ typedef typename type_traits::value_type value_type;
+ typedef typename type_traits::reference reference;
+ typedef typename type_traits::const_reference const_reference;
+
+ private:
+ value_type m_value;
+
+ _Leaf(const _Leaf&);
+
+ public:
+ _Leaf(const_reference other)
+ : base_type(leaf_node), m_value(other) { }
+
+ reference
+ value()
+ { return m_value; }
+
+ const_reference
+ value() const
+ { return m_value; }
+
+#ifdef _GLIBCXX_DEBUG
+ typedef typename base_type::node_debug_info node_debug_info;
+ typedef typename base_type::a_const_pointer a_const_pointer;
+
+ virtual node_debug_info
+ assert_valid_imp(a_const_pointer p_traits,
+ const char* __file, int __line) const
+ {
+ PB_DS_DEBUG_VERIFY(base_type::m_type == leaf_node);
+ node_debug_info ret;
+ const_reference r_val = value();
+ return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)),
+ p_traits->end(p_traits->extract_key(r_val)));
+ }
+
+ virtual
+ ~_Leaf() { }
+#endif
+ };
+
+
+ /// Internal node type, PATRICIA tree.
+ template<typename _ATraits, typename Metadata>
+ struct _Inode
+ : public _Node_base<_ATraits, Metadata>
+ {
+ typedef _Node_base<_ATraits, Metadata> base_type;
+ typedef typename base_type::type_traits type_traits;
+ typedef typename base_type::access_traits access_traits;
+ typedef typename type_traits::value_type value_type;
+ typedef typename base_type::allocator_type _Alloc;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+
+ private:
+ typedef typename base_type::a_const_pointer a_const_pointer;
+ typedef typename base_type::a_const_iterator a_const_iterator;
+
+ typedef typename base_type::node_pointer node_pointer;
+ typedef typename _Alloc::template rebind<base_type> __rebind_n;
+ typedef typename __rebind_n::other::const_pointer node_const_pointer;
+
+ typedef _Leaf<_ATraits, Metadata> leaf;
+ typedef typename _Alloc::template rebind<leaf>::other __rebind_l;
+ typedef typename __rebind_l::pointer leaf_pointer;
+ typedef typename __rebind_l::const_pointer leaf_const_pointer;
+
+ typedef typename _Alloc::template rebind<_Inode>::other __rebind_in;
+ typedef typename __rebind_in::pointer inode_pointer;
+ typedef typename __rebind_in::const_pointer inode_const_pointer;
+
+ inline size_type
+ get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer) const;
+
+ public:
+ typedef typename _Alloc::template rebind<node_pointer>::other __rebind_np;
+ typedef typename __rebind_np::pointer node_pointer_pointer;
+ typedef typename __rebind_np::reference node_pointer_reference;
+
+ enum
+ {
+ arr_size = _ATraits::max_size + 1
+ };
+ PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2);
+
+
+ /// Constant child iterator.
+ struct const_iterator
+ {
+ node_pointer_pointer m_p_p_cur;
+ node_pointer_pointer m_p_p_end;
+
+ typedef std::forward_iterator_tag iterator_category;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef node_pointer value_type;
+ typedef node_pointer_pointer pointer;
+ typedef node_pointer_reference reference;
+
+ const_iterator(node_pointer_pointer p_p_cur = 0,
+ node_pointer_pointer p_p_end = 0)
+ : m_p_p_cur(p_p_cur), m_p_p_end(p_p_end)
+ { }
+
+ bool
+ operator==(const const_iterator& other) const
+ { return m_p_p_cur == other.m_p_p_cur; }
+
+ bool
+ operator!=(const const_iterator& other) const
+ { return m_p_p_cur != other.m_p_p_cur; }
+
+ const_iterator&
+ operator++()
+ {
+ do
+ ++m_p_p_cur;
+ while (m_p_p_cur != m_p_p_end && *m_p_p_cur == 0);
+ return *this;
+ }
+
+ const_iterator
+ operator++(int)
+ {
+ const_iterator ret_it(*this);
+ operator++();
+ return ret_it;
+ }
+
+ const node_pointer_pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ONLY(assert_referencible();)
+ return m_p_p_cur;
+ }
+
+ node_const_pointer
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ONLY(assert_referencible();)
+ return *m_p_p_cur;
+ }
+
+ protected:
+#ifdef _GLIBCXX_DEBUG
+ void
+ assert_referencible() const
+ { _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end && *m_p_p_cur != 0); }
+#endif
+ };
+
+
+ /// Child iterator.
+ struct iterator : public const_iterator
+ {
+ public:
+ typedef std::forward_iterator_tag iterator_category;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef node_pointer value_type;
+ typedef node_pointer_pointer pointer;
+ typedef node_pointer_reference reference;
+
+ inline
+ iterator(node_pointer_pointer p_p_cur = 0,
+ node_pointer_pointer p_p_end = 0)
+ : const_iterator(p_p_cur, p_p_end) { }
+
+ bool
+ operator==(const iterator& other) const
+ { return const_iterator::m_p_p_cur == other.m_p_p_cur; }
+
+ bool
+ operator!=(const iterator& other) const
+ { return const_iterator::m_p_p_cur != other.m_p_p_cur; }
+
+ iterator&
+ operator++()
+ {
+ const_iterator::operator++();
+ return *this;
+ }
+
+ iterator
+ operator++(int)
+ {
+ iterator ret_it(*this);
+ operator++();
+ return ret_it;
+ }
+
+ node_pointer_pointer
+ operator->()
+ {
+ _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
+ return const_iterator::m_p_p_cur;
+ }
+
+ node_pointer
+ operator*()
+ {
+ _GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();)
+ return *const_iterator::m_p_p_cur;
+ }
+ };
+
+
+ _Inode(size_type, const a_const_iterator);
+
+ void
+ update_prefixes(a_const_pointer);
+
+ const_iterator
+ begin() const;
+
+ iterator
+ begin();
+
+ const_iterator
+ end() const;
+
+ iterator
+ end();
+
+ inline node_pointer
+ get_child_node(a_const_iterator, a_const_iterator, a_const_pointer);
+
+ inline node_const_pointer
+ get_child_node(a_const_iterator, a_const_iterator, a_const_pointer) const;
+
+ inline iterator
+ get_child_it(a_const_iterator, a_const_iterator, a_const_pointer);
+
+ inline node_pointer
+ get_lower_bound_child_node(a_const_iterator, a_const_iterator,
+ size_type, a_const_pointer);
+
+ inline node_pointer
+ add_child(node_pointer, a_const_iterator, a_const_iterator,
+ a_const_pointer);
+
+ inline node_const_pointer
+ get_join_child(node_const_pointer, a_const_pointer) const;
+
+ inline node_pointer
+ get_join_child(node_pointer, a_const_pointer);
+
+ void
+ remove_child(node_pointer);
+
+ void
+ remove_child(iterator);
+
+ void
+ replace_child(node_pointer, a_const_iterator, a_const_iterator,
+ a_const_pointer);
+
+ inline a_const_iterator
+ pref_b_it() const;
+
+ inline a_const_iterator
+ pref_e_it() const;
+
+ bool
+ should_be_mine(a_const_iterator, a_const_iterator, size_type,
+ a_const_pointer) const;
+
+ leaf_pointer
+ leftmost_descendant();
+
+ leaf_const_pointer
+ leftmost_descendant() const;
+
+ leaf_pointer
+ rightmost_descendant();
+
+ leaf_const_pointer
+ rightmost_descendant() const;
+
+#ifdef _GLIBCXX_DEBUG
+ typedef typename base_type::node_debug_info node_debug_info;
+
+ virtual node_debug_info
+ assert_valid_imp(a_const_pointer, const char*, int) const;
+#endif
+
+ size_type
+ get_e_ind() const
+ { return m_e_ind; }
+
+ private:
+ _Inode(const _Inode&);
+
+ size_type
+ get_begin_pos() const;
+
+ static __rebind_l s_leaf_alloc;
+ static __rebind_in s_inode_alloc;
+
+ const size_type m_e_ind;
+ a_const_iterator m_pref_b_it;
+ a_const_iterator m_pref_e_it;
+ node_pointer m_a_p_children[arr_size];
+ };
+
+#define PB_DS_CONST_IT_C_DEC \
+ _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
+
+#define PB_DS_CONST_ODIR_IT_C_DEC \
+ _CIter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
+
+#define PB_DS_IT_C_DEC \
+ _Iter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
+
+#define PB_DS_ODIR_IT_C_DEC \
+ _Iter<Node, Leaf, Head, Inode, !Is_Forward_Iterator>
+
+
+ /// Const iterator.
+ template<typename Node, typename Leaf, typename Head, typename Inode,
+ bool Is_Forward_Iterator>
+ class _CIter
+ {
+ public:
+ // These types are all the same for the first four template arguments.
+ typedef typename Node::allocator_type allocator_type;
+ typedef typename Node::type_traits type_traits;
+
+ typedef std::bidirectional_iterator_tag iterator_category;
+ typedef typename allocator_type::difference_type difference_type;
+ typedef typename type_traits::value_type value_type;
+ typedef typename type_traits::pointer pointer;
+ typedef typename type_traits::reference reference;
+ typedef typename type_traits::const_pointer const_pointer;
+ typedef typename type_traits::const_reference const_reference;
+
+ typedef allocator_type _Alloc;
+ typedef typename _Alloc::template rebind<Node> __rebind_n;
+ typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename _Alloc::template rebind<Leaf> __rebind_l;
+ typedef typename __rebind_l::other::pointer leaf_pointer;
+ typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
+ typedef typename _Alloc::template rebind<Head> __rebind_h;
+ typedef typename __rebind_h::other::pointer head_pointer;
+
+ typedef typename _Alloc::template rebind<Inode> __rebind_in;
+ typedef typename __rebind_in::other::pointer inode_pointer;
+ typedef typename Inode::iterator inode_iterator;
+
+ node_pointer m_p_nd;
+
+ _CIter(node_pointer p_nd = 0) : m_p_nd(p_nd)
+ { }
+
+ _CIter(const PB_DS_CONST_ODIR_IT_C_DEC& other)
+ : m_p_nd(other.m_p_nd)
+ { }
+
+ _CIter&
+ operator=(const _CIter& other)
+ {
+ m_p_nd = other.m_p_nd;
+ return *this;
+ }
+
+ _CIter&
+ operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other)
+ {
+ m_p_nd = other.m_p_nd;
+ return *this;
+ }
+
+ const_pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
+ return &static_cast<leaf_pointer>(m_p_nd)->value();
+ }
+
+ const_reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node);
+ return static_cast<leaf_pointer>(m_p_nd)->value();
+ }
+
+ bool
+ operator==(const _CIter& other) const
+ { return m_p_nd == other.m_p_nd; }
+
+ bool
+ operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
+ { return m_p_nd == other.m_p_nd; }
+
+ bool
+ operator!=(const _CIter& other) const
+ { return m_p_nd != other.m_p_nd; }
+
+ bool
+ operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
+ { return m_p_nd != other.m_p_nd; }
+
+ _CIter&
+ operator++()
+ {
+ inc(integral_constant<int, Is_Forward_Iterator>());
+ return *this;
+ }
+
+ _CIter
+ operator++(int)
+ {
+ _CIter ret_it(m_p_nd);
+ operator++();
+ return ret_it;
+ }
+
+ _CIter&
+ operator--()
+ {
+ dec(integral_constant<int, Is_Forward_Iterator>());
+ return *this;
+ }
+
+ _CIter
+ operator--(int)
+ {
+ _CIter ret_it(m_p_nd);
+ operator--();
+ return ret_it;
+ }
+
+ protected:
+ void
+ inc(false_type)
+ { dec(true_type()); }
+
+ void
+ inc(true_type)
+ {
+ if (m_p_nd->m_type == head_node)
+ {
+ m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_min;
+ return;
+ }
+
+ node_pointer p_y = m_p_nd->m_p_parent;
+ while (p_y->m_type != head_node && get_larger_sibling(m_p_nd) == 0)
+ {
+ m_p_nd = p_y;
+ p_y = p_y->m_p_parent;
+ }
+
+ if (p_y->m_type == head_node)
+ {
+ m_p_nd = p_y;
+ return;
+ }
+ m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd));
+ }
+
+ void
+ dec(false_type)
+ { inc(true_type()); }
+
+ void
+ dec(true_type)
+ {
+ if (m_p_nd->m_type == head_node)
+ {
+ m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_max;
+ return;
+ }
+
+ node_pointer p_y = m_p_nd->m_p_parent;
+ while (p_y->m_type != head_node && get_smaller_sibling(m_p_nd) == 0)
+ {
+ m_p_nd = p_y;
+ p_y = p_y->m_p_parent;
+ }
+
+ if (p_y->m_type == head_node)
+ {
+ m_p_nd = p_y;
+ return;
+ }
+ m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd));
+ }
+
+ static node_pointer
+ get_larger_sibling(node_pointer p_nd)
+ {
+ inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent);
+
+ inode_iterator it = p_parent->begin();
+ while (*it != p_nd)
+ ++it;
+
+ inode_iterator next_it = it;
+ ++next_it;
+ return (next_it == p_parent->end())? 0 : *next_it;
+ }
+
+ static node_pointer
+ get_smaller_sibling(node_pointer p_nd)
+ {
+ inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent);
+
+ inode_iterator it = p_parent->begin();
+ if (*it == p_nd)
+ return 0;
+
+ inode_iterator prev_it;
+ do
+ {
+ prev_it = it;
+ ++it;
+ if (*it == p_nd)
+ return *prev_it;
+ }
+ while (true);
+
+ _GLIBCXX_DEBUG_ASSERT(false);
+ return 0;
+ }
+
+ static leaf_pointer
+ leftmost_descendant(node_pointer p_nd)
+ {
+ if (p_nd->m_type == leaf_node)
+ return static_cast<leaf_pointer>(p_nd);
+ return static_cast<inode_pointer>(p_nd)->leftmost_descendant();
+ }
+
+ static leaf_pointer
+ rightmost_descendant(node_pointer p_nd)
+ {
+ if (p_nd->m_type == leaf_node)
+ return static_cast<leaf_pointer>(p_nd);
+ return static_cast<inode_pointer>(p_nd)->rightmost_descendant();
+ }
+ };
+
+
+ /// Iterator.
+ template<typename Node, typename Leaf, typename Head, typename Inode,
+ bool Is_Forward_Iterator>
+ class _Iter
+ : public _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
+ {
+ public:
+ typedef _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator>
+ base_type;
+ typedef typename base_type::allocator_type allocator_type;
+ typedef typename base_type::type_traits type_traits;
+ typedef typename type_traits::value_type value_type;
+ typedef typename type_traits::pointer pointer;
+ typedef typename type_traits::reference reference;
+
+ typedef typename base_type::node_pointer node_pointer;
+ typedef typename base_type::leaf_pointer leaf_pointer;
+ typedef typename base_type::leaf_const_pointer leaf_const_pointer;
+ typedef typename base_type::head_pointer head_pointer;
+ typedef typename base_type::inode_pointer inode_pointer;
+
+ _Iter(node_pointer p_nd = 0)
+ : base_type(p_nd) { }
+
+ _Iter(const PB_DS_ODIR_IT_C_DEC& other)
+ : base_type(other.m_p_nd) { }
+
+ _Iter&
+ operator=(const _Iter& other)
+ {
+ base_type::m_p_nd = other.m_p_nd;
+ return *this;
+ }
+
+ _Iter&
+ operator=(const PB_DS_ODIR_IT_C_DEC& other)
+ {
+ base_type::m_p_nd = other.m_p_nd;
+ return *this;
+ }
+
+ pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
+ return &static_cast<leaf_pointer>(base_type::m_p_nd)->value();
+ }
+
+ reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node);
+ return static_cast<leaf_pointer>(base_type::m_p_nd)->value();
+ }
+
+ _Iter&
+ operator++()
+ {
+ base_type::operator++();
+ return *this;
+ }
+
+ _Iter
+ operator++(int)
+ {
+ _Iter ret(base_type::m_p_nd);
+ operator++();
+ return ret;
+ }
+
+ _Iter&
+ operator--()
+ {
+ base_type::operator--();
+ return *this;
+ }
+
+ _Iter
+ operator--(int)
+ {
+ _Iter ret(base_type::m_p_nd);
+ operator--();
+ return ret;
+ }
+ };
+
+#undef PB_DS_CONST_ODIR_IT_C_DEC
+#undef PB_DS_ODIR_IT_C_DEC
+
+
+#define PB_DS_PAT_TRIE_NODE_CONST_ITERATOR_C_DEC \
+ _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
+
+#define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \
+ _Node_iter<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc>
+
+ /// Node const iterator.
+ template<typename Node,
+ typename Leaf,
+ typename Head,
+ typename Inode,
+ typename _CIterator,
+ typename Iterator,
+ typename _Alloc>
+ class _Node_citer
+ {
+ protected:
+ typedef typename _Alloc::template rebind<Node> __rebind_n;
+ typedef typename __rebind_n::other::pointer node_pointer;
+
+ typedef typename _Alloc::template rebind<Leaf> __rebind_l;
+ typedef typename __rebind_l::other::pointer leaf_pointer;
+ typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
+
+ typedef typename _Alloc::template rebind<Inode> __rebind_in;
+ typedef typename __rebind_in::other::pointer inode_pointer;
+ typedef typename __rebind_in::other::const_pointer inode_const_pointer;
+
+ typedef typename Node::a_const_pointer a_const_pointer;
+ typedef typename Node::a_const_iterator a_const_iterator;
+
+ private:
+ a_const_iterator
+ pref_begin() const
+ {
+ if (m_p_nd->m_type == leaf_node)
+ {
+ leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd);
+ return m_p_traits->begin(m_p_traits->extract_key(lcp->value()));
+ }
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
+ return static_cast<inode_const_pointer>(m_p_nd)->pref_b_it();
+ }
+
+ a_const_iterator
+ pref_end() const
+ {
+ if (m_p_nd->m_type == leaf_node)
+ {
+ leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd);
+ return m_p_traits->end(m_p_traits->extract_key(lcp->value()));
+ }
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
+ return static_cast<inode_const_pointer>(m_p_nd)->pref_e_it();
+ }
+
+ public:
+ typedef trivial_iterator_tag iterator_category;
+ typedef trivial_iterator_difference_type difference_type;
+ typedef typename _Alloc::size_type size_type;
+
+ typedef _CIterator value_type;
+ typedef value_type reference;
+ typedef value_type const_reference;
+
+ // Metadata type.
+ typedef typename Node::metadata_type metadata_type;
+
+ // Const metadata reference type.
+ typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef typename __rebind_ma::const_reference metadata_const_reference;
+
+ inline
+ _Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
+ : m_p_nd(const_cast<node_pointer>(p_nd)), m_p_traits(p_traits)
+ { }
+
+ // Subtree valid prefix.
+ std::pair<a_const_iterator, a_const_iterator>
+ valid_prefix() const
+ { return std::make_pair(pref_begin(), pref_end()); }
+
+ // Const access; returns the __const iterator* associated with
+ // the current leaf.
+ const_reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(num_children() == 0);
+ return _CIterator(m_p_nd);
+ }
+
+ // Metadata access.
+ metadata_const_reference
+ get_metadata() const
+ { return m_p_nd->get_metadata(); }
+
+ // Returns the number of children in the corresponding node.
+ size_type
+ num_children() const
+ {
+ if (m_p_nd->m_type == leaf_node)
+ return 0;
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
+ inode_pointer inp = static_cast<inode_pointer>(m_p_nd);
+ return std::distance(inp->begin(), inp->end());
+ }
+
+ // Returns a __const node __iterator to the corresponding node's
+ // i-th child.
+ _Node_citer
+ get_child(size_type i) const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node);
+ inode_pointer inp = static_cast<inode_pointer>(m_p_nd);
+ typename Inode::iterator it = inp->begin();
+ std::advance(it, i);
+ return _Node_citer(*it, m_p_traits);
+ }
+
+ // Compares content to a different iterator object.
+ bool
+ operator==(const _Node_citer& other) const
+ { return m_p_nd == other.m_p_nd; }
+
+ // Compares content (negatively) to a different iterator object.
+ bool
+ operator!=(const _Node_citer& other) const
+ { return m_p_nd != other.m_p_nd; }
+
+ node_pointer m_p_nd;
+ a_const_pointer m_p_traits;
+ };
+
+
+ /// Node iterator.
+ template<typename Node,
+ typename Leaf,
+ typename Head,
+ typename Inode,
+ typename _CIterator,
+ typename Iterator,
+ typename _Alloc>
+ class _Node_iter
+ : public _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc>
+ {
+ private:
+ typedef _Node_citer<Node, Leaf, Head, Inode,
+ _CIterator, Iterator, _Alloc> base_type;
+ typedef typename _Alloc::template rebind<Node> __rebind_n;
+ typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename base_type::inode_pointer inode_pointer;
+ typedef typename base_type::a_const_pointer a_const_pointer;
+ typedef Iterator iterator;
+
+ public:
+ typedef typename base_type::size_type size_type;
+
+ typedef Iterator value_type;
+ typedef value_type reference;
+ typedef value_type const_reference;
+
+ _Node_iter(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
+ : base_type(p_nd, p_traits)
+ { }
+
+ // Access; returns the iterator* associated with the current leaf.
+ reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0);
+ return iterator(base_type::m_p_nd);
+ }
+
+ // Returns a node __iterator to the corresponding node's i-th child.
+ _Node_iter
+ get_child(size_type i) const
+ {
+ _GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == i_node);
+
+ typename Inode::iterator it =
+ static_cast<inode_pointer>(base_type::m_p_nd)->begin();
+
+ std::advance(it, i);
+ return _Node_iter(*it, base_type::m_p_traits);
+ }
+ };
+ };
+
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename _ATraits, typename Metadata>
+
+#define PB_DS_CLASS_C_DEC \
+ pat_trie_base::_Inode<_ATraits, Metadata>
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::__rebind_l
+ PB_DS_CLASS_C_DEC::s_leaf_alloc;
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::__rebind_in
+ PB_DS_CLASS_C_DEC::s_inode_alloc;
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::size_type
+ PB_DS_CLASS_C_DEC::
+ get_pref_pos(a_const_iterator b_it, a_const_iterator e_it,
+ a_const_pointer p_traits) const
+ {
+ if (static_cast<std::size_t>(std::distance(b_it, e_it)) <= m_e_ind)
+ return 0;
+ std::advance(b_it, m_e_ind);
+ return 1 + p_traits->e_pos(*b_it);
+ }
+
+ PB_DS_CLASS_T_DEC
+ PB_DS_CLASS_C_DEC::
+ _Inode(size_type len, const a_const_iterator it)
+ : base_type(i_node), m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it)
+ {
+ std::advance(m_pref_e_it, m_e_ind);
+ std::fill(m_a_p_children, m_a_p_children + arr_size,
+ static_cast<node_pointer>(0));
+ }
+
+ PB_DS_CLASS_T_DEC
+ void
+ PB_DS_CLASS_C_DEC::
+ update_prefixes(a_const_pointer p_traits)
+ {
+ node_pointer p_first = *begin();
+ if (p_first->m_type == leaf_node)
+ {
+ leaf_const_pointer p = static_cast<leaf_const_pointer>(p_first);
+ m_pref_b_it = p_traits->begin(access_traits::extract_key(p->value()));
+ }
+ else
+ {
+ inode_pointer p = static_cast<inode_pointer>(p_first);
+ _GLIBCXX_DEBUG_ASSERT(p_first->m_type == i_node);
+ m_pref_b_it = p->pref_b_it();
+ }
+ m_pref_e_it = m_pref_b_it;
+ std::advance(m_pref_e_it, m_e_ind);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::const_iterator
+ PB_DS_CLASS_C_DEC::
+ begin() const
+ {
+ typedef node_pointer_pointer pointer_type;
+ pointer_type p = const_cast<pointer_type>(m_a_p_children);
+ return const_iterator(p + get_begin_pos(), p + arr_size);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::iterator
+ PB_DS_CLASS_C_DEC::
+ begin()
+ {
+ return iterator(m_a_p_children + get_begin_pos(),
+ m_a_p_children + arr_size);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::const_iterator
+ PB_DS_CLASS_C_DEC::
+ end() const
+ {
+ typedef node_pointer_pointer pointer_type;
+ pointer_type p = const_cast<pointer_type>(m_a_p_children) + arr_size;
+ return const_iterator(p, p);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::iterator
+ PB_DS_CLASS_C_DEC::
+ end()
+ { return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::node_pointer
+ PB_DS_CLASS_C_DEC::
+ get_child_node(a_const_iterator b_it, a_const_iterator e_it,
+ a_const_pointer p_traits)
+ {
+ const size_type i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+ return m_a_p_children[i];
+ }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::iterator
+ PB_DS_CLASS_C_DEC::
+ get_child_it(a_const_iterator b_it, a_const_iterator e_it,
+ a_const_pointer p_traits)
+ {
+ const size_type i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+ _GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0);
+ return iterator(m_a_p_children + i, m_a_p_children + i);
+ }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::node_const_pointer
+ PB_DS_CLASS_C_DEC::
+ get_child_node(a_const_iterator b_it, a_const_iterator e_it,
+ a_const_pointer p_traits) const
+ { return const_cast<node_pointer>(get_child_node(b_it, e_it, p_traits)); }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::node_pointer
+ PB_DS_CLASS_C_DEC::
+ get_lower_bound_child_node(a_const_iterator b_it, a_const_iterator e_it,
+ size_type checked_ind,
+ a_const_pointer p_traits)
+ {
+ if (!should_be_mine(b_it, e_it, checked_ind, p_traits))
+ {
+ if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it,
+ m_pref_e_it, true))
+ return leftmost_descendant();
+ return rightmost_descendant();
+ }
+
+ size_type i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+
+ if (m_a_p_children[i] != 0)
+ return m_a_p_children[i];
+
+ while (++i < arr_size)
+ if (m_a_p_children[i] != 0)
+ {
+ const node_type& __nt = m_a_p_children[i]->m_type;
+ node_pointer ret = m_a_p_children[i];
+
+ if (__nt == leaf_node)
+ return ret;
+
+ _GLIBCXX_DEBUG_ASSERT(__nt == i_node);
+ inode_pointer inp = static_cast<inode_pointer>(ret);
+ return inp->leftmost_descendant();
+ }
+
+ return rightmost_descendant();
+ }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::node_pointer
+ PB_DS_CLASS_C_DEC::
+ add_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
+ a_const_pointer p_traits)
+ {
+ const size_type i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+ if (m_a_p_children[i] == 0)
+ {
+ m_a_p_children[i] = p_nd;
+ p_nd->m_p_parent = this;
+ return p_nd;
+ }
+ return m_a_p_children[i];
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::node_const_pointer
+ PB_DS_CLASS_C_DEC::
+ get_join_child(node_const_pointer p_nd,
+ a_const_pointer p_tr) const
+ {
+ node_pointer p = const_cast<node_pointer>(p_nd);
+ return const_cast<inode_pointer>(this)->get_join_child(p, p_tr);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::node_pointer
+ PB_DS_CLASS_C_DEC::
+ get_join_child(node_pointer p_nd, a_const_pointer p_traits)
+ {
+ size_type i;
+ a_const_iterator b_it;
+ a_const_iterator e_it;
+ if (p_nd->m_type == leaf_node)
+ {
+ leaf_const_pointer p = static_cast<leaf_const_pointer>(p_nd);
+
+ typedef typename type_traits::key_const_reference kcr;
+ kcr r_key = access_traits::extract_key(p->value());
+ b_it = p_traits->begin(r_key);
+ e_it = p_traits->end(r_key);
+ }
+ else
+ {
+ b_it = static_cast<inode_pointer>(p_nd)->pref_b_it();
+ e_it = static_cast<inode_pointer>(p_nd)->pref_e_it();
+ }
+ i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+ return m_a_p_children[i];
+ }
+
+ PB_DS_CLASS_T_DEC
+ void
+ PB_DS_CLASS_C_DEC::
+ remove_child(node_pointer p_nd)
+ {
+ size_type i = 0;
+ for (; i < arr_size; ++i)
+ if (m_a_p_children[i] == p_nd)
+ {
+ m_a_p_children[i] = 0;
+ return;
+ }
+ _GLIBCXX_DEBUG_ASSERT(i != arr_size);
+ }
+
+ PB_DS_CLASS_T_DEC
+ void
+ PB_DS_CLASS_C_DEC::
+ remove_child(iterator it)
+ { *it.m_p_p_cur = 0; }
+
+ PB_DS_CLASS_T_DEC
+ void
+ PB_DS_CLASS_C_DEC::
+ replace_child(node_pointer p_nd, a_const_iterator b_it,
+ a_const_iterator e_it,
+ a_const_pointer p_traits)
+ {
+ const size_type i = get_pref_pos(b_it, e_it, p_traits);
+ _GLIBCXX_DEBUG_ASSERT(i < arr_size);
+ m_a_p_children[i] = p_nd;
+ p_nd->m_p_parent = this;
+ }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::a_const_iterator
+ PB_DS_CLASS_C_DEC::
+ pref_b_it() const
+ { return m_pref_b_it; }
+
+ PB_DS_CLASS_T_DEC
+ inline typename PB_DS_CLASS_C_DEC::a_const_iterator
+ PB_DS_CLASS_C_DEC::
+ pref_e_it() const
+ { return m_pref_e_it; }
+
+ PB_DS_CLASS_T_DEC
+ bool
+ PB_DS_CLASS_C_DEC::
+ should_be_mine(a_const_iterator b_it, a_const_iterator e_it,
+ size_type checked_ind,
+ a_const_pointer p_traits) const
+ {
+ if (m_e_ind == 0)
+ return true;
+
+ const size_type num_es = std::distance(b_it, e_it);
+ if (num_es < m_e_ind)
+ return false;
+
+ a_const_iterator key_b_it = b_it;
+ std::advance(key_b_it, checked_ind);
+ a_const_iterator key_e_it = b_it;
+ std::advance(key_e_it, m_e_ind);
+
+ a_const_iterator value_b_it = m_pref_b_it;
+ std::advance(value_b_it, checked_ind);
+ a_const_iterator value_e_it = m_pref_b_it;
+ std::advance(value_e_it, m_e_ind);
+
+ return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it,
+ value_e_it);
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::leaf_pointer
+ PB_DS_CLASS_C_DEC::
+ leftmost_descendant()
+ {
+ node_pointer p_pot = *begin();
+ if (p_pot->m_type == leaf_node)
+ return (static_cast<leaf_pointer>(p_pot));
+ _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
+ return static_cast<inode_pointer>(p_pot)->leftmost_descendant();
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::leaf_const_pointer
+ PB_DS_CLASS_C_DEC::
+ leftmost_descendant() const
+ { return const_cast<inode_pointer>(this)->leftmost_descendant(); }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::leaf_pointer
+ PB_DS_CLASS_C_DEC::
+ rightmost_descendant()
+ {
+ const size_type num_children = std::distance(begin(), end());
+ _GLIBCXX_DEBUG_ASSERT(num_children >= 2);
+
+ iterator it = begin();
+ std::advance(it, num_children - 1);
+ node_pointer p_pot =* it;
+ if (p_pot->m_type == leaf_node)
+ return static_cast<leaf_pointer>(p_pot);
+ _GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node);
+ return static_cast<inode_pointer>(p_pot)->rightmost_descendant();
+ }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::leaf_const_pointer
+ PB_DS_CLASS_C_DEC::
+ rightmost_descendant() const
+ { return const_cast<inode_pointer>(this)->rightmost_descendant(); }
+
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::size_type
+ PB_DS_CLASS_C_DEC::
+ get_begin_pos() const
+ {
+ size_type i = 0;
+ for (i; i < arr_size && m_a_p_children[i] == 0; ++i)
+ ;
+ return i;
+ }
+
+#ifdef _GLIBCXX_DEBUG
+ PB_DS_CLASS_T_DEC
+ typename PB_DS_CLASS_C_DEC::node_debug_info
+ PB_DS_CLASS_C_DEC::
+ assert_valid_imp(a_const_pointer p_traits,
+ const char* __file, int __line) const
+ {
+ PB_DS_DEBUG_VERIFY(base_type::m_type == i_node);
+ PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind);
+ PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2);
+
+ for (typename _Inode::const_iterator it = begin(); it != end(); ++it)
+ {
+ node_const_pointer p_nd = *it;
+ PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this);
+ node_debug_info child_ret = p_nd->assert_valid_imp(p_traits,
+ __file, __line);
+
+ PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind);
+ PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits));
+ PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children));
+ }
+ return std::make_pair(pref_b_it(), pref_e_it());
+ }
+#endif
+
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_CLASS_C_DEC
+ } // namespace detail
+} // namespace __gnu_pbds
+
+#endif
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 point_iterators.hpp
- * Contains an implementation class for bin_search_tree_.
- */
-
-#ifndef PB_DS_PAT_TRIE_FIND_ITERATORS_HPP
-#define PB_DS_PAT_TRIE_FIND_ITERATORS_HPP
-
-#include <debug/debug.h>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
-#define PB_DS_CONST_IT_C_DEC \
- pat_trie_const_it_< \
- Type_Traits, \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- Is_Forward_Iterator, \
- Allocator>
-
-#define PB_DS_CONST_ODIR_IT_C_DEC \
- pat_trie_const_it_< \
- Type_Traits, \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- !Is_Forward_Iterator, \
- Allocator>
-
-#define PB_DS_IT_C_DEC \
- pat_trie_it_< \
- Type_Traits, \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- Is_Forward_Iterator, \
- Allocator>
-
-#define PB_DS_ODIR_IT_C_DEC \
- pat_trie_it_< \
- Type_Traits, \
- Node, \
- Leaf, \
- Head, \
- Internal_Node, \
- !Is_Forward_Iterator, \
- Allocator>
-
-
- // Const iterator.
- template<typename Type_Traits,
- class Node,
- class Leaf,
- class Head,
- class Internal_Node,
- bool Is_Forward_Iterator,
- class Allocator>
- class pat_trie_const_it_
- {
-
- private:
- typedef
- typename Allocator::template rebind<
- Node>::other::pointer
- node_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::const_pointer
- const_leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::pointer
- leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Head>::other::pointer
- head_pointer;
-
- typedef
- typename Allocator::template rebind<
- Internal_Node>::other::pointer
- internal_node_pointer;
-
- public:
-
- typedef std::bidirectional_iterator_tag iterator_category;
-
- typedef typename Allocator::difference_type difference_type;
-
- typedef typename Type_Traits::value_type value_type;
-
- typedef typename Type_Traits::pointer pointer;
-
- typedef typename Type_Traits::const_pointer const_pointer;
-
- typedef typename Type_Traits::reference reference;
-
- typedef typename Type_Traits::const_reference const_reference;
-
- public:
-
- inline
- pat_trie_const_it_(node_pointer p_nd = 0) : m_p_nd(p_nd)
- { }
-
- inline
- pat_trie_const_it_(const PB_DS_CONST_ODIR_IT_C_DEC& other)
- : m_p_nd(other.m_p_nd)
- { }
-
- inline
- PB_DS_CONST_IT_C_DEC&
- operator=(const PB_DS_CONST_IT_C_DEC& other)
- {
- m_p_nd = other.m_p_nd;
- return *this;
- }
-
- inline
- PB_DS_CONST_IT_C_DEC&
- operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other)
- {
- m_p_nd = other.m_p_nd;
- return *this;
- }
-
- inline const_pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type);
- return &static_cast<leaf_pointer>(m_p_nd)->value();
- }
-
- inline const_reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == pat_trie_leaf_node_type);
- return static_cast<leaf_pointer>(m_p_nd)->value();
- }
-
- inline bool
- operator==(const PB_DS_CONST_IT_C_DEC& other) const
- { return (m_p_nd == other.m_p_nd); }
-
- inline bool
- operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
- { return (m_p_nd == other.m_p_nd); }
-
- inline bool
- operator!=(const PB_DS_CONST_IT_C_DEC& other) const
- { return (m_p_nd != other.m_p_nd); }
-
- inline bool
- operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const
- { return (m_p_nd != other.m_p_nd); }
-
- inline PB_DS_CONST_IT_C_DEC&
- operator++()
- {
- inc(integral_constant<int,Is_Forward_Iterator>());
- return *this;
- }
-
- inline PB_DS_CONST_IT_C_DEC
- operator++(int)
- {
- PB_DS_CONST_IT_C_DEC ret_it(m_p_nd);
- operator++();
- return ret_it;
- }
-
- inline PB_DS_CONST_IT_C_DEC&
- operator--()
- {
- dec(integral_constant<int,Is_Forward_Iterator>());
- return *this;
- }
-
- inline PB_DS_CONST_IT_C_DEC
- operator--(int)
- {
- PB_DS_CONST_IT_C_DEC ret_it(m_p_nd);
- operator--();
- return ret_it;
- }
-
- protected:
- inline void
- inc(false_type)
- { dec(true_type()); }
-
- void
- inc(true_type)
- {
- if (m_p_nd->m_type == pat_trie_head_node_type)
- {
- m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_min;
- return;
- }
-
- node_pointer p_y = m_p_nd->m_p_parent;
- while (p_y->m_type != pat_trie_head_node_type &&
- get_larger_sibling(m_p_nd) == 0)
- {
- m_p_nd = p_y;
- p_y = p_y->m_p_parent;
- }
-
- if (p_y->m_type == pat_trie_head_node_type)
- {
- m_p_nd = p_y;
- return;
- }
- m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd));
- }
-
- inline void
- dec(false_type)
- { inc(true_type()); }
-
- void
- dec(true_type)
- {
- if (m_p_nd->m_type == pat_trie_head_node_type)
- {
- m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_max;
- return;
- }
-
- node_pointer p_y = m_p_nd->m_p_parent;
- while (p_y->m_type != pat_trie_head_node_type &&
- get_smaller_sibling(m_p_nd) == 0)
- {
- m_p_nd = p_y;
- p_y = p_y->m_p_parent;
- }
-
- if (p_y->m_type == pat_trie_head_node_type)
- {
- m_p_nd = p_y;
- return;
- }
- m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd));
- }
-
- inline static node_pointer
- get_larger_sibling(node_pointer p_nd)
- {
- internal_node_pointer p_parent =
- static_cast<internal_node_pointer>(p_nd->m_p_parent);
-
- typename Internal_Node::iterator it = p_parent->begin();
- while (*it != p_nd)
- ++it;
-
- typename Internal_Node::iterator next_it = it;
- ++next_it;
- return ((next_it == p_parent->end())? 0 :* next_it);
- }
-
- inline static node_pointer
- get_smaller_sibling(node_pointer p_nd)
- {
- internal_node_pointer p_parent =
- static_cast<internal_node_pointer>(p_nd->m_p_parent);
-
- typename Internal_Node::iterator it = p_parent->begin();
-
- if (*it == p_nd)
- return (0);
- typename Internal_Node::iterator prev_it;
- do
- {
- prev_it = it;
- ++it;
- if (*it == p_nd)
- return (*prev_it);
- }
- while (true);
-
- _GLIBCXX_DEBUG_ASSERT(false);
- return (0);
- }
-
- inline static leaf_pointer
- leftmost_descendant(node_pointer p_nd)
- {
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return static_cast<leaf_pointer>(p_nd);
- return static_cast<internal_node_pointer>(p_nd)->leftmost_descendant();
- }
-
- inline static leaf_pointer
- rightmost_descendant(node_pointer p_nd)
- {
- if (p_nd->m_type == pat_trie_leaf_node_type)
- return static_cast<leaf_pointer>(p_nd);
- return static_cast<internal_node_pointer>(p_nd)->rightmost_descendant();
- }
-
- public:
- node_pointer m_p_nd;
- };
-
- // Iterator.
- template<typename Type_Traits,
- class Node,
- class Leaf,
- class Head,
- class Internal_Node,
- bool Is_Forward_Iterator,
- class Allocator>
- class pat_trie_it_ :
- public PB_DS_CONST_IT_C_DEC
-
- {
- private:
- typedef
- typename Allocator::template rebind<
- Node>::other::pointer
- node_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::const_pointer
- const_leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Leaf>::other::pointer
- leaf_pointer;
-
- typedef
- typename Allocator::template rebind<
- Head>::other::pointer
- head_pointer;
-
- typedef
- typename Allocator::template rebind<
- Internal_Node>::other::pointer
- internal_node_pointer;
-
- public:
- typedef typename Type_Traits::value_type value_type;
-
- typedef typename Type_Traits::const_pointer const_pointer;
-
- typedef typename Type_Traits::pointer pointer;
-
- typedef typename Type_Traits::const_reference const_reference;
-
- typedef typename Type_Traits::reference reference;
-
- inline
- pat_trie_it_(node_pointer p_nd = 0) : PB_DS_CONST_IT_C_DEC((node_pointer)p_nd)
- { }
-
- inline
- pat_trie_it_(const PB_DS_ODIR_IT_C_DEC& other) : PB_DS_CONST_IT_C_DEC(other.m_p_nd)
- { }
-
- inline
- PB_DS_IT_C_DEC&
- operator=(const PB_DS_IT_C_DEC& other)
- {
- base_it_type::m_p_nd = other.m_p_nd;
- return *this;
- }
-
- inline
- PB_DS_IT_C_DEC&
- operator=(const PB_DS_ODIR_IT_C_DEC& other)
- {
- base_it_type::m_p_nd = other.m_p_nd;
- return *this;
- }
-
- inline pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type);
-
- return &static_cast<leaf_pointer>(base_it_type::m_p_nd)->value();
- }
-
- inline reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd->m_type == pat_trie_leaf_node_type);
- return static_cast<leaf_pointer>(base_it_type::m_p_nd)->value();
- }
-
- inline PB_DS_IT_C_DEC&
- operator++()
- {
- PB_DS_CONST_IT_C_DEC::
- operator++();
- return *this;
- }
-
- inline PB_DS_IT_C_DEC
- operator++(int)
- {
- PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd);
- operator++();
- return ret_it;
- }
-
- inline PB_DS_IT_C_DEC&
- operator--()
- {
- PB_DS_CONST_IT_C_DEC::operator--();
- return *this;
- }
-
- inline PB_DS_IT_C_DEC
- operator--(int)
- {
- PB_DS_IT_C_DEC ret_it(base_it_type::m_p_nd);
- operator--();
- return ret_it;
- }
-
- protected:
- typedef PB_DS_CONST_IT_C_DEC base_it_type;
-
- friend class PB_DS_CLASS_C_DEC;
- };
-
-#undef PB_DS_CONST_IT_C_DEC
-#undef PB_DS_CONST_ODIR_IT_C_DEC
-#undef PB_DS_IT_C_DEC
-#undef PB_DS_ODIR_IT_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
-
// warranty.
/**
- * @file policy_access_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/policy_access_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::e_access_traits&
+typename PB_DS_CLASS_C_DEC::access_traits&
PB_DS_CLASS_C_DEC::
-get_e_access_traits()
+get_access_traits()
{ return *this; }
PB_DS_CLASS_T_DEC
-const typename PB_DS_CLASS_C_DEC::e_access_traits&
+const typename PB_DS_CLASS_C_DEC::access_traits&
PB_DS_CLASS_C_DEC::
-get_e_access_traits() const
+get_access_traits() const
{ return *this; }
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file r_erase_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/r_erase_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
{
_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);
}
// warranty.
/**
- * @file rotate_fn_imps.hpp
+ * @file pat_trie_/rotate_fn_imps.hpp
* Contains imps for rotating nodes.
*/
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
- apply_update(p_x, (Node_Update* )this);
- apply_update(p_x->m_p_parent, (Node_Update* )this);
+ apply_update(p_x, (Node_Update*)this);
+ apply_update(p_x->m_p_parent, (Node_Update*)this);
}
PB_DS_CLASS_T_DEC
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);)
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);)
- apply_update(p_x, (Node_Update* )this);
- apply_update(p_x->m_p_parent, (Node_Update* )this);
+ apply_update(p_x, (Node_Update*)this);
+ apply_update(p_x->m_p_parent, (Node_Update*)this);
}
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file split_fn_imps.hpp
- * Contains an implementation class for bin_search_tree_.
+ * @file pat_trie_/split_fn_imps.hpp
+ * Contains an implementation class for pat_trie.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
+split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- split_join_branch_bag bag;
+ branch_bag bag;
leaf_pointer p_split_lf = split_prep(r_key, other, bag);
if (p_split_lf == 0)
{
_GLIBCXX_DEBUG_ASSERT(!bag.empty());
other.clear();
- m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent,
- pref_begin(p_split_lf),
- pref_end(p_split_lf),
- other,
- bag);
+
+ m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf),
+ pref_end(p_split_lf), other, bag);
m_p_head->m_p_parent->m_p_parent = m_p_head;
- other.m_p_head->m_p_max = m_p_head->m_p_max;
+ head_pointer __ohead = other.m_p_head;
+ __ohead->m_p_max = m_p_head->m_p_max;
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent);
- other.m_p_head->m_p_min =
- other.leftmost_descendant(other.m_p_head->m_p_parent);
+ __ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent);
other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(),
other.PB_DS_CLASS_C_DEC::end());
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::leaf_pointer
PB_DS_CLASS_C_DEC::
-split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
+split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other,
+ branch_bag& r_bag)
{
_GLIBCXX_DEBUG_ASSERT(r_bag.empty());
if (m_size == 0)
other.clear();
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- return (0);
+ return 0;
}
- if (synth_e_access_traits::cmp_keys(r_key,
- PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value())))
+ if (synth_access_traits::cmp_keys(r_key,
+ PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())))
{
other.clear();
value_swap(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- return (0);
+ return 0;
}
- if (!synth_e_access_traits::cmp_keys(r_key,
- PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_max)->value())))
+ if (!synth_access_traits::cmp_keys(r_key,
+ PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value())))
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- return (0);
+ return 0;
}
iterator it = lower_bound(r_key);
- if (!synth_e_access_traits::equal_keys(PB_DS_V2F(*it), r_key))
+ if (!synth_access_traits::equal_keys(PB_DS_V2F(*it), r_key))
--it;
node_pointer p_nd = it.m_p_nd;
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node);
leaf_pointer p_ret_l = static_cast<leaf_pointer>(p_nd);
- while (p_nd->m_type != pat_trie_head_node_type)
+ while (p_nd->m_type != head_node)
{
r_bag.add_branch();
p_nd = p_nd->m_p_parent;
}
- _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_e_access_traits& )(*this), other);)
+ _GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_access_traits&)(*this), other);)
- return (p_ret_l);
+ return p_ret_l;
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
+rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it,
+ PB_DS_CLASS_C_DEC& other, branch_bag& r_bag)
{
- if (p_nd->m_type == pat_trie_leaf_node_type)
+ if (p_nd->m_type == leaf_node)
{
_GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == 0);
- return (p_nd);
+ return p_nd;
}
- _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type);
- internal_node_pointer p_internal_nd = static_cast<internal_node_pointer>(p_nd);
-
- node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node);
+ inode_pointer p_ind = static_cast<inode_pointer>(p_nd);
+ node_pointer pfirst = p_ind->get_child_node(b_it, e_it, this);
+ node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag);
PB_DS_ASSERT_NODE_VALID(p_child_ret)
- p_internal_nd->replace_child(p_child_ret, b_it, e_it, this);
- apply_update(p_internal_nd, (node_update* )this);
-
- typename internal_node::iterator child_it =
- p_internal_nd->get_child_it(b_it, e_it, this);
-
- const size_type lhs_num_children =
- std::distance(p_internal_nd->begin(), child_it) + 1;
+ p_ind->replace_child(p_child_ret, b_it, e_it, this);
+ apply_update(p_ind, (node_update*)this);
+ inode_iterator child_it = p_ind->get_child_it(b_it, e_it, this);
+ const size_type lhs_dist = std::distance(p_ind->begin(), child_it);
+ const size_type lhs_num_children = lhs_dist + 1;
_GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0);
- size_type rhs_num_children =
- std::distance(p_internal_nd->begin(), p_internal_nd->end()) -
- lhs_num_children;
-
+ const size_type rhs_dist = std::distance(p_ind->begin(), p_ind->end());
+ size_type rhs_num_children = rhs_dist - lhs_num_children;
if (rhs_num_children == 0)
{
- apply_update(p_internal_nd, (node_update* )this);
- return (p_internal_nd);
+ apply_update(p_ind, (node_update*)this);
+ return p_ind;
}
- ++child_it;
- other.split_insert_branch(p_internal_nd->get_e_ind(),
- b_it, child_it, rhs_num_children, r_bag);
+ other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it,
+ rhs_num_children, r_bag);
- child_it = p_internal_nd->get_child_it(b_it, e_it, this);
- ++child_it;
+ child_it = p_ind->get_child_it(b_it, e_it, this);
while (rhs_num_children != 0)
{
- child_it = p_internal_nd->remove_child(child_it);
+ ++child_it;
+ p_ind->remove_child(child_it);
--rhs_num_children;
}
+ apply_update(p_ind, (node_update*)this);
- apply_update(p_internal_nd, (node_update* )this);
- _GLIBCXX_DEBUG_ASSERT(std::distance(p_internal_nd->begin(),
- p_internal_nd->end()) >= 1);
-
- if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1)
+ const size_type int_dist = std::distance(p_ind->begin(), p_ind->end());
+ _GLIBCXX_DEBUG_ASSERT(int_dist >= 1);
+ if (int_dist > 1)
{
- p_internal_nd->update_prefixes(this);
- PB_DS_ASSERT_NODE_VALID(p_internal_nd)
- apply_update(p_internal_nd, (node_update* )this);
- return (p_internal_nd);
+ p_ind->update_prefixes(this);
+ PB_DS_ASSERT_NODE_VALID(p_ind)
+ apply_update(p_ind, (node_update*)this);
+ return p_ind;
}
- node_pointer p_ret =* p_internal_nd->begin();
- p_internal_nd->~internal_node();
- s_internal_node_allocator.deallocate(p_internal_nd, 1);
- apply_update(p_ret, (node_update* )this);
- return (p_ret);
+ node_pointer p_ret = *p_ind->begin();
+ p_ind->~inode();
+ s_inode_allocator.deallocate(p_ind, 1);
+ apply_update(p_ret, (node_update*)this);
+ return p_ret;
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_node::iterator child_b_it, size_type num_children, split_join_branch_bag& r_bag)
+split_insert_branch(size_type e_ind, a_const_iterator b_it,
+ inode_iterator child_b_it,
+ size_type num_children, branch_bag& r_bag)
{
#ifdef _GLIBCXX_DEBUG
if (m_p_head->m_p_parent != 0)
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
-#endif
-
- const size_type total_num_children =((m_p_head->m_p_parent == 0)? 0 : 1) + num_children;
+#endif
+ const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1;
+ const size_type total_num_children = start + num_children;
if (total_num_children == 0)
{
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
if (total_num_children == 1)
{
if (m_p_head->m_p_parent != 0)
- {
+ {
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
- return;
- }
+ return;
+ }
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0);
- m_p_head->m_p_parent =* child_b_it;
+ ++child_b_it;
+ m_p_head->m_p_parent = *child_b_it;
m_p_head->m_p_parent->m_p_parent = m_p_head;
- apply_update(m_p_head->m_p_parent, (node_update* )this);
+ apply_update(m_p_head->m_p_parent, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
return;
}
_GLIBCXX_DEBUG_ASSERT(total_num_children > 1);
- internal_node_pointer p_new_root = r_bag.get_branch();
- new (p_new_root) internal_node(e_ind, b_it);
+ inode_pointer p_new_root = r_bag.get_branch();
+ new (p_new_root) inode(e_ind, b_it);
size_type num_inserted = 0;
while (num_inserted++ < num_children)
{
- PB_DS_ASSERT_NODE_VALID((*child_b_it))
- p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
- pref_end(*child_b_it), this);
++child_b_it;
+ PB_DS_ASSERT_NODE_VALID((*child_b_it))
+ p_new_root->add_child(*child_b_it, pref_begin(*child_b_it),
+ pref_end(*child_b_it), this);
}
if (m_p_head->m_p_parent != 0)
- p_new_root->add_child(m_p_head->m_p_parent,
+ p_new_root->add_child(m_p_head->m_p_parent,
pref_begin(m_p_head->m_p_parent),
pref_end(m_p_head->m_p_parent), this);
m_p_head->m_p_parent = p_new_root;
p_new_root->m_p_parent = m_p_head;
- apply_update(m_p_head->m_p_parent, (node_update* )this);
+ apply_update(m_p_head->m_p_parent, (node_update*)this);
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent)
}
+++ /dev/null
-// -*- C++ -*-
-
-// Copyright (C) 2005, 2006, 2007, 2008, 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 split_join_branch_bag.hpp
- * Contains an implementation class for pat_trie_.
- */
-
-class split_join_branch_bag
-{
-private:
- typedef
- std::list<
- internal_node_pointer,
- typename Allocator::template rebind<
- internal_node_pointer>::other>
- bag_t;
-
-public:
-
- void
- add_branch()
- {
- internal_node_pointer p_nd = s_internal_node_allocator.allocate(1);
- __try
- {
- m_bag.push_back(p_nd);
- }
- __catch(...)
- {
- s_internal_node_allocator.deallocate(p_nd, 1);
- __throw_exception_again;
- }
- }
-
- internal_node_pointer
- get_branch()
- {
- _GLIBCXX_DEBUG_ASSERT(!m_bag.empty());
- internal_node_pointer p_nd =* m_bag.begin();
- m_bag.pop_front();
- return p_nd;
- }
-
- ~split_join_branch_bag()
- {
- while (!m_bag.empty())
- {
- internal_node_pointer p_nd =* m_bag.begin();
- s_internal_node_allocator.deallocate(p_nd, 1);
- m_bag.pop_front();
- }
- }
-
- inline bool
- empty() const
- { return m_bag.empty(); }
-
-private:
- bag_t m_bag;
-};
--- /dev/null
+// -*- 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 pat_trie_/synth_access_traits.hpp
+ * Contains an implementation class for a patricia tree.
+ */
+
+#ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
+#define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
+
+#include <ext/pb_ds/detail/type_utils.hpp>
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+
+#define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \
+ template<typename Type_Traits, bool Set, typename _ATraits>
+
+#define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \
+ synth_access_traits<Type_Traits, Set, _ATraits>
+
+ /// Synthetic element access traits.
+ template<typename Type_Traits, bool Set, typename _ATraits>
+ struct synth_access_traits : public _ATraits
+ {
+ typedef _ATraits base_type;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef Type_Traits type_traits;
+ typedef typename type_traits::const_reference const_reference;
+ typedef typename type_traits::key_const_reference key_const_reference;
+
+ synth_access_traits();
+
+ synth_access_traits(const base_type&);
+
+ inline bool
+ equal_prefixes(const_iterator, const_iterator, const_iterator,
+ const_iterator, bool compare_after = true) const;
+
+ bool
+ equal_keys(key_const_reference, key_const_reference) const;
+
+ bool
+ cmp_prefixes(const_iterator, const_iterator, const_iterator,
+ const_iterator, bool compare_after = false) const;
+
+ bool
+ cmp_keys(key_const_reference, key_const_reference) const;
+
+ inline static key_const_reference
+ extract_key(const_reference);
+
+#ifdef _GLIBCXX_DEBUG
+ bool
+ operator()(key_const_reference, key_const_reference);
+#endif
+
+ private:
+ inline static key_const_reference
+ extract_key(const_reference, true_type);
+
+ inline static key_const_reference
+ extract_key(const_reference, false_type);
+
+ static integral_constant<int, Set> s_set_ind;
+ };
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ integral_constant<int,Set>
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind;
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ synth_access_traits()
+ { }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ synth_access_traits(const _ATraits& r_traits)
+ : _ATraits(r_traits)
+ { }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ inline bool
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ equal_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r,
+ const_iterator e_r, bool compare_after /*= false */) const
+ {
+ while (b_l != e_l)
+ {
+ if (b_r == e_r)
+ return false;
+ if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r))
+ return false;
+ ++b_l;
+ ++b_r;
+ }
+ return (!compare_after || b_r == e_r);
+ }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ bool
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ equal_keys(key_const_reference r_lhs_key,
+ key_const_reference r_rhs_key) const
+ {
+ return equal_prefixes(base_type::begin(r_lhs_key),
+ base_type::end(r_lhs_key),
+ base_type::begin(r_rhs_key),
+ base_type::end(r_rhs_key),
+ true);
+ }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ bool
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ cmp_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r,
+ const_iterator e_r, bool compare_after /* = false*/) const
+ {
+ while (b_l != e_l)
+ {
+ if (b_r == e_r)
+ return false;
+
+ const typename base_type::size_type l_pos = base_type::e_pos(*b_l);
+ const typename base_type::size_type r_pos = base_type::e_pos(*b_r);
+ if (l_pos != r_pos)
+ return l_pos < r_pos;
+ ++b_l;
+ ++b_r;
+ }
+
+ if (!compare_after)
+ return false;
+ return b_r != e_r;
+ }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ bool
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ cmp_keys(key_const_reference r_lhs_key,
+ key_const_reference r_rhs_key) const
+ {
+ return cmp_prefixes(base_type::begin(r_lhs_key),
+ base_type::end(r_lhs_key),
+ base_type::begin(r_rhs_key),
+ base_type::end(r_rhs_key),
+ true);
+ }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ extract_key(const_reference r_val)
+ { return extract_key(r_val, s_set_ind); }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ extract_key(const_reference r_val, true_type)
+ { return r_val; }
+
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ extract_key(const_reference r_val, false_type)
+ { return r_val.first; }
+
+#ifdef _GLIBCXX_DEBUG
+ PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+ bool
+ PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
+ operator()(key_const_reference r_lhs, key_const_reference r_rhs)
+ { return cmp_keys(r_lhs, r_rhs); }
+#endif
+
+#undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
+#undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC
+
+ } // namespace detail
+} // namespace __gnu_pbds
+
+#endif
+++ /dev/null
-// -*- 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 synth_e_access_traits.hpp
- * Contains an implementation class for a patricia tree.
- */
-
-#ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
-#define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
-
-#include <ext/pb_ds/detail/type_utils.hpp>
-
-namespace __gnu_pbds
-{
- namespace detail
- {
-
-#define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \
- template<typename Type_Traits, bool Set, class E_Access_Traits>
-
-#define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \
- synth_e_access_traits< \
- Type_Traits, \
- Set, \
- E_Access_Traits>
-
- template<typename Type_Traits, bool Set, class E_Access_Traits>
- struct synth_e_access_traits : public E_Access_Traits
- {
-
- private:
- typedef E_Access_Traits base_type;
-
- typedef Type_Traits type_traits;
-
- typedef typename type_traits::const_key_reference const_key_reference;
-
- typedef typename type_traits::const_reference const_reference;
-
- public:
- synth_e_access_traits();
-
- synth_e_access_traits(const E_Access_Traits& r_traits);
-
- inline bool
- equal_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after = true) const;
-
- bool
- equal_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const;
-
- bool
- cmp_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after = false) const;
-
- bool
- cmp_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const;
-
- inline static const_key_reference
- extract_key(const_reference r_val);
-
-#ifdef _GLIBCXX_DEBUG
- bool
- operator()(const_key_reference r_lhs, const_key_reference r_rhs);
-#endif
-
- private:
- inline static const_key_reference
- extract_key(const_reference r_val, true_type);
-
- inline static const_key_reference
- extract_key(const_reference r_val, false_type);
-
- private:
- static integral_constant<int,Set> s_set_ind;
- };
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- integral_constant<int,Set>
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind;
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- synth_e_access_traits()
- { }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- synth_e_access_traits(const E_Access_Traits& r_traits) :
- E_Access_Traits(r_traits)
- { }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- inline bool
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- equal_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after /*= false */) const
- {
- while (b_l != e_l)
- {
- if (b_r == e_r)
- return (false);
- if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r))
- return (false);
- ++b_l;
- ++b_r;
- }
- return (!compare_after || b_r == e_r);
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- bool
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- equal_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
- {
- return (equal_prefixes(base_type::begin(r_lhs_key),
- base_type::end(r_lhs_key),
- base_type::begin(r_rhs_key),
- base_type::end(r_rhs_key),
- true));
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- bool
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- cmp_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after /* = false*/) const
- {
- while (b_l != e_l)
- {
- if (b_r == e_r)
- return (false);
- const typename base_type::size_type l_pos =
- base_type::e_pos(*b_l);
- const typename base_type::size_type r_pos =
- base_type::e_pos(*b_r);
- if (l_pos != r_pos)
- return (l_pos < r_pos);
- ++b_l;
- ++b_r;
- }
-
- if (!compare_after)
- return (false);
- return (b_r != e_r);
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- bool
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- cmp_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
- {
- return (cmp_prefixes(base_type::begin(r_lhs_key),
- base_type::end(r_lhs_key),
- base_type::begin(r_rhs_key),
- base_type::end(r_rhs_key),
- true));
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- extract_key(const_reference r_val)
- {
- return (extract_key(r_val, s_set_ind));
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- extract_key(const_reference r_val, true_type)
- {
- return (r_val);
- }
-
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- extract_key(const_reference r_val, false_type)
- {
- return (r_val.first);
- }
-
-#ifdef _GLIBCXX_DEBUG
- PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
- bool
- PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
- operator()(const_key_reference r_lhs, const_key_reference r_rhs)
- {
- return (cmp_keys(r_lhs, r_rhs));
- }
-#endif
-
-#undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
-#undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC
-
- } // namespace detail
-} // namespace __gnu_pbds
-
-#endif
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file pat_trie_/trace_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-trace_node(const_node_pointer p_nd, size_type level)
+trace_node(node_const_pointer p_nd, size_type level)
{
for (size_type i = 0; i < level; ++i)
std::cerr << ' ';
std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i ");
trace_node_metadata(p_nd, type_to_type<typename node::metadata_type>());
- typename e_access_traits::const_iterator el_it = pref_begin(p_nd);
+ typename access_traits::const_iterator el_it = pref_begin(p_nd);
while (el_it != pref_end(p_nd))
{
std::cerr <<* el_it;
return;
}
- const_internal_node_pointer p_internal =
- static_cast<const_internal_node_pointer>(p_nd);
+ inode_const_pointer p_internal = static_cast<inode_const_pointer>(p_nd);
std::cerr << " " <<
static_cast<unsigned long>(p_internal->get_e_ind()) << std::endl;
for (size_type child_i = 0; child_i < num_children; ++child_i)
{
- typename internal_node::const_iterator child_it =
- p_internal->begin();
+ typename inode::const_iterator child_it = p_internal->begin();
std::advance(child_it, num_children - child_i - 1);
trace_node(*child_it, level + 1);
}
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
-trace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>)
+trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>)
{
std::cerr << "(" << static_cast<unsigned long>(p_nd->get_metadata()) << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-trace_node_metadata(const_node_pointer, type_to_type<null_node_metadata>)
+trace_node_metadata(node_const_pointer, type_to_type<null_type>)
{ }
#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
// warranty.
/**
- * @file traits.hpp
+ * @file pat_trie_/traits.hpp
* Contains an implementation class for pat_trie_.
*/
#ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
#define PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
-#include <ext/pb_ds/detail/pat_trie_/node_base.hpp>
-#include <ext/pb_ds/detail/pat_trie_/head.hpp>
-#include <ext/pb_ds/detail/pat_trie_/leaf.hpp>
-#include <ext/pb_ds/detail/pat_trie_/internal_node.hpp>
-#include <ext/pb_ds/detail/pat_trie_/point_iterators.hpp>
-#include <ext/pb_ds/detail/pat_trie_/node_iterators.hpp>
-#include <ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp>
+#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp>
+#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
-
+ /// Specialization.
template<typename Key,
typename Mapped,
- class E_Access_Traits,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct trie_traits<
- Key,
- Mapped,
- E_Access_Traits,
- Node_Update,
- pat_trie_tag,
- Allocator>
+ typename _ATraits,
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct trie_traits<Key, Mapped, _ATraits, Node_Update, pat_trie_tag, _Alloc>
{
private:
- typedef types_traits< Key, Mapped, Allocator, false> type_traits;
+ typedef pat_trie_base base_type;
+ typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
public:
- typedef
- typename trie_node_metadata_selector<
- Key,
- Mapped,
- E_Access_Traits,
- Node_Update,
- Allocator>::type
- metadata_type;
-
- typedef E_Access_Traits e_access_traits;
-
- typedef
- __gnu_pbds::detail::synth_e_access_traits<
- type_traits,
- false,
- e_access_traits>
- synth_e_access_traits;
-
- typedef
- pat_trie_node_base<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- node;
+ typedef typename trie_node_metadata_dispatch<Key, Mapped, _ATraits, Node_Update, _Alloc>::type metadata_type;
+ typedef base_type::_Metadata<metadata_type, _Alloc> metadata;
+ typedef _ATraits access_traits;
- typedef
- pat_trie_leaf<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- leaf;
+ typedef __gnu_pbds::detail::synth_access_traits<type_traits, false, access_traits> synth_access_traits;
- typedef
- pat_trie_head<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- head;
+ typedef base_type::_Node_base<synth_access_traits, metadata> node;
+ typedef base_type::_Head<synth_access_traits, metadata> head;
+ typedef base_type::_Leaf<synth_access_traits, metadata> leaf;
+ typedef base_type::_Inode<synth_access_traits, metadata> inode;
- typedef
- pat_trie_internal_node<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- internal_node;
+ typedef base_type::_Iter<node, leaf, head, inode, true> iterator;
+ typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator;
+ typedef base_type::_Iter<node, leaf, head, inode, false> reverse_iterator;
+ typedef base_type::_CIter<node, leaf, head, inode, false> const_reverse_iterator;
- typedef
- pat_trie_const_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- true,
- Allocator>
- const_iterator;
- typedef
- pat_trie_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- true,
- Allocator>
- iterator;
+ typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
- typedef
- pat_trie_const_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- false,
- Allocator>
- const_reverse_iterator;
+ typedef base_type::_Node_iter<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_iterator;
- typedef
- pat_trie_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- false,
- Allocator>
- reverse_iterator;
+ typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update;
- typedef
- pat_trie_const_node_it_<
- node,
- leaf,
- head,
- internal_node,
- const_iterator,
- iterator,
- synth_e_access_traits,
- Allocator>
- const_node_iterator;
-
- typedef
- pat_trie_node_it_<
- node,
- leaf,
- head,
- internal_node,
- const_iterator,
- iterator,
- synth_e_access_traits,
- Allocator>
- node_iterator;
-
- typedef
- Node_Update<
- const_node_iterator,
- node_iterator,
- E_Access_Traits,
- Allocator>
- node_update;
-
- typedef
- __gnu_pbds::null_trie_node_update<
- const_node_iterator,
- node_iterator,
- E_Access_Traits,
- Allocator>*
- null_node_update_pointer;
+ typedef null_node_update<node_const_iterator, node_iterator, _ATraits, _Alloc>* null_node_update_pointer;
};
+ /// Specialization.
template<typename Key,
- class E_Access_Traits,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct trie_traits<
- Key,
- null_mapped_type,
- E_Access_Traits,
- Node_Update,
- pat_trie_tag,
- Allocator>
+ typename _ATraits,
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct trie_traits<Key, null_type, _ATraits, Node_Update, pat_trie_tag, _Alloc>
{
private:
- typedef
- types_traits<
- Key,
- null_mapped_type,
- Allocator,
- false>
- type_traits;
+ typedef pat_trie_base base_type;
+ typedef types_traits<Key, null_type, _Alloc, false> type_traits;
public:
- typedef
- typename trie_node_metadata_selector<
- Key,
- null_mapped_type,
- E_Access_Traits,
- Node_Update,
- Allocator>::type
- metadata_type;
-
- typedef E_Access_Traits e_access_traits;
+ typedef typename trie_node_metadata_dispatch<Key, null_type, _ATraits, Node_Update, _Alloc>::type metadata_type;
+ typedef base_type::_Metadata<metadata_type, _Alloc> metadata;
+ typedef _ATraits access_traits;
+ typedef __gnu_pbds::detail::synth_access_traits<type_traits, true, access_traits> synth_access_traits;
- typedef
- __gnu_pbds::detail::synth_e_access_traits<
- type_traits,
- true,
- e_access_traits>
- synth_e_access_traits;
+ typedef base_type::_Node_base<synth_access_traits, metadata> node;
+ typedef base_type::_Head<synth_access_traits, metadata> head;
+ typedef base_type::_Leaf<synth_access_traits, metadata> leaf;
+ typedef base_type::_Inode<synth_access_traits, metadata> inode;
- typedef
- pat_trie_node_base<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- node;
+ typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator;
+ typedef const_iterator iterator;
+ typedef base_type::_CIter<node, leaf, head, inode, false> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
- typedef
- pat_trie_leaf<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- leaf;
- typedef
- pat_trie_head<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- head;
+ typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
- typedef
- pat_trie_internal_node<
- type_traits,
- synth_e_access_traits,
- metadata_type,
- Allocator>
- internal_node;
+ typedef node_const_iterator node_iterator;
- typedef
- pat_trie_const_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- true,
- Allocator>
- const_iterator;
+ typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update;
- typedef const_iterator iterator;
-
- typedef
- pat_trie_const_it_<
- type_traits,
- node,
- leaf,
- head,
- internal_node,
- false,
- Allocator>
- const_reverse_iterator;
-
- typedef const_reverse_iterator reverse_iterator;
-
- typedef
- pat_trie_const_node_it_<
- node,
- leaf,
- head,
- internal_node,
- const_iterator,
- iterator,
- synth_e_access_traits,
- Allocator>
- const_node_iterator;
-
- typedef const_node_iterator node_iterator;
-
- typedef
- Node_Update<
- const_node_iterator,
- node_iterator,
- E_Access_Traits,
- Allocator>
- node_update;
-
- typedef
- __gnu_pbds::null_trie_node_update<
- const_node_iterator,
- const_node_iterator,
- E_Access_Traits,
- Allocator>*
- null_node_update_pointer;
+ typedef null_node_update<node_const_iterator, node_const_iterator, _ATraits, _Alloc>* null_node_update_pointer;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
-
// warranty.
/**
- * @file update_fn_imps.hpp
+ * @file pat_trie_/update_fn_imps.hpp
* Contains an implementation class for pat_trie_.
*/
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-apply_update(node_pointer /*p_nd*/, null_node_update_pointer)
+apply_update(node_pointer, null_node_update_pointer)
{ }
PB_DS_CLASS_T_DEC
template<typename Node_Update_>
inline void
PB_DS_CLASS_C_DEC::
-apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
+apply_update(node_pointer p_nd, Node_Update_*)
{
Node_Update_::operator()(node_iterator(p_nd, this),
- const_node_iterator(0, this));
+ node_const_iterator(0, this));
}
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// warranty.
/**
- * @file priority_queue_base_dispatch.hpp
+ * @file detail/priority_queue_base_dispatch.hpp
* Contains an pqiative container dispatching base.
*/
namespace __gnu_pbds
{
- namespace detail
- {
-
- template<typename Value_Type, typename Cmp_Fn, typename Tag, typename Allocator>
- struct priority_queue_base_dispatch;
-
- template<typename Value_Type, typename Cmp_Fn, typename Allocator>
- struct priority_queue_base_dispatch<Value_Type, Cmp_Fn, pairing_heap_tag, Allocator>
+ namespace detail
+ {
+ /// Specialization for pairing_heap.
+ template<typename _VTp, typename Cmp_Fn, typename _Alloc>
+ struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, pairing_heap_tag,
+ null_type>
{
- typedef pairing_heap_< Value_Type, Cmp_Fn, Allocator> type;
+ /// Dispatched type.
+ typedef pairing_heap<_VTp, Cmp_Fn, _Alloc> type;
};
- template<typename Value_Type, typename Cmp_Fn, typename Allocator>
- struct priority_queue_base_dispatch<Value_Type, Cmp_Fn, binomial_heap_tag, Allocator>
+ /// Specialization for binomial_heap.
+ template<typename _VTp, typename Cmp_Fn, typename _Alloc>
+ struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binomial_heap_tag,
+ null_type>
{
- typedef binomial_heap_< Value_Type, Cmp_Fn, Allocator> type;
+ /// Dispatched type.
+ typedef binomial_heap<_VTp, Cmp_Fn, _Alloc> type;
};
- template<typename Value_Type, typename Cmp_Fn, typename Allocator>
- struct priority_queue_base_dispatch<Value_Type, Cmp_Fn, rc_binomial_heap_tag, Allocator>
+ /// Specialization for rc_binary_heap.
+ template<typename _VTp, typename Cmp_Fn, typename _Alloc>
+ struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, rc_binomial_heap_tag,
+ null_type>
{
- typedef rc_binomial_heap_< Value_Type, Cmp_Fn, Allocator> type;
+ /// Dispatched type.
+ typedef rc_binomial_heap<_VTp, Cmp_Fn, _Alloc> type;
};
- template<typename Value_Type, typename Cmp_Fn, typename Allocator>
- struct priority_queue_base_dispatch<Value_Type, Cmp_Fn, binary_heap_tag, Allocator>
+ /// Specialization for binary_heap.
+ template<typename _VTp, typename Cmp_Fn, typename _Alloc>
+ struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binary_heap_tag,
+ null_type>
{
- typedef binary_heap_< Value_Type, Cmp_Fn, Allocator> type;
+ /// Dispatched type.
+ typedef binary_heap<_VTp, Cmp_Fn, _Alloc> type;
};
- template<typename Value_Type, typename Cmp_Fn, typename Allocator>
- struct priority_queue_base_dispatch<Value_Type, Cmp_Fn, thin_heap_tag, Allocator>
+ /// Specialization for thin_heap.
+ template<typename _VTp, typename Cmp_Fn, typename _Alloc>
+ struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, thin_heap_tag,
+ null_type>
{
- typedef thin_heap_< Value_Type, Cmp_Fn, Allocator> type;
+ /// Dispatched type.
+ typedef thin_heap<_VTp, Cmp_Fn, _Alloc> type;
};
-
- } // namespace detail
+ // @} group pbds
+ } // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file rb_tree_map_/constructors_destructor_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME()
+PB_DS_RB_TREE_NAME()
{
initialize();
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
+PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn)
{
initialize();
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_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update)
{
initialize();
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other)
{
initialize();
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file rb_tree_map_/debug_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file rb_tree_map_/erase_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
point_iterator it = this->find(r_key);
if (it == base_type::end())
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file rb_tree_map_/find_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file rb_tree_map_/info_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file rb_tree_map_/insert_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
// -*- 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
// warranty.
/**
- * @file node.hpp
+ * @file rb_tree_map_/node.hpp
* Contains an implementation for rb_tree_.
*/
#ifndef PB_DS_RB_TREE_NODE_HPP
#define PB_DS_RB_TREE_NODE_HPP
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
namespace __gnu_pbds
{
namespace detail
{
- template<typename Value_Type, class Metadata, class Allocator>
+ /// Node for Red-Black trees.
+ template<typename Value_Type, class Metadata, typename _Alloc>
struct rb_tree_node_
{
public:
- typedef Value_Type value_type;
- typedef Metadata metadata_type;
+ typedef Value_Type value_type;
+ typedef Metadata metadata_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
Metadata,
- Allocator> >::other::pointer
+ _Alloc> >::other::pointer
node_pointer;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
metadata_type>::other::reference
metadata_reference;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
metadata_type>::other::const_reference
- const_metadata_reference;
+ metadata_const_reference;
- inline bool
+ bool
special() const
{ return m_red; }
- inline const_metadata_reference
+ metadata_const_reference
get_metadata() const
{ return m_metadata; }
- inline metadata_reference
+ metadata_reference
get_metadata()
{ return m_metadata; }
}
#endif
- node_pointer m_p_left;
- node_pointer m_p_right;
- node_pointer m_p_parent;
- value_type m_value;
- bool m_red;
- metadata_type m_metadata;
+ node_pointer m_p_left;
+ node_pointer m_p_right;
+ node_pointer m_p_parent;
+ value_type m_value;
+ bool m_red;
+ metadata_type m_metadata;
};
- template<typename Value_Type, class Allocator>
- struct rb_tree_node_<Value_Type, null_node_metadata, Allocator>
+ template<typename Value_Type, typename _Alloc>
+ struct rb_tree_node_<Value_Type, null_type, _Alloc>
{
public:
- typedef Value_Type value_type;
- typedef null_node_metadata metadata_type;
+ typedef Value_Type value_type;
+ typedef null_type metadata_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
- null_node_metadata,
- Allocator> >::other::pointer
+ null_type,
+ _Alloc> >::other::pointer
node_pointer;
- inline bool
+ bool
special() const
{ return m_red; }
{ std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> "); }
#endif
- node_pointer m_p_left;
- node_pointer m_p_right;
- node_pointer m_p_parent;
- value_type m_value;
- bool m_red;
+ node_pointer m_p_left;
+ node_pointer m_p_right;
+ node_pointer m_p_parent;
+ value_type m_value;
+ bool m_red;
};
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file rb_tree_.hpp
- * Contains an implementation for rb_tree_.
+ * @file rb_tree_map_/rb_tree_.hpp
+ * Contains an implementation for Red Black trees.
*/
-/*
- * This implementation uses an idea from the SGI STL (using a @a header node
- * which is needed for efficient iteration).
- */
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR
-#define PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
-#endif
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR
-#define PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR
-#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
-#endif
-#endif
#include <ext/pb_ds/detail/standard_policies.hpp>
-#include <ext/pb_ds/detail/basic_types.hpp>
#include <utility>
#include <vector>
#include <assert.h>
{
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Cmp_Fn, \
- typename Node_And_It_Traits, typename Allocator>
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME rb_tree_data_
-#endif
+ typename Node_And_It_Traits, typename _Alloc>
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_BASE_CLASS_NAME bin_search_tree_data_
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME rb_tree_no_data_
-#endif
+# define PB_DS_RB_TREE_NAME rb_tree_map
+# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_BASE_CLASS_NAME bin_search_tree_no_data_
-#endif
+# define PB_DS_RB_TREE_NAME rb_tree_set
+# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_set
+#endif
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
-
-#define PB_DS_BASE_C_DEC \
- PB_DS_BASE_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
+ PB_DS_RB_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
+#define PB_DS_RB_TREE_BASE \
+ PB_DS_RB_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
+ /*
+ * @brief Red-Black tree.
+ *
+ * This implementation uses an idea from the SGI STL (using a
+ * @a header node which is needed for efficient iteration).
+ */
template<typename Key,
typename Mapped,
typename Cmp_Fn,
typename Node_And_It_Traits,
- typename Allocator>
- class PB_DS_CLASS_NAME : public PB_DS_BASE_C_DEC
+ typename _Alloc>
+ class PB_DS_RB_TREE_NAME : public PB_DS_RB_TREE_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
- typedef typename base_type::node_pointer node_pointer;
+ typedef PB_DS_RB_TREE_BASE base_type;
+ typedef typename base_type::node_pointer node_pointer;
public:
- typedef Cmp_Fn cmp_fn;
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
- typedef typename base_type::key_type key_type;
- typedef typename base_type::key_pointer key_pointer;
- typedef typename base_type::const_key_pointer const_key_pointer;
- typedef typename base_type::key_reference key_reference;
- typedef typename base_type::const_key_reference const_key_reference;
- typedef typename base_type::mapped_type mapped_type;
- typedef typename base_type::mapped_pointer mapped_pointer;
- typedef typename base_type::const_mapped_pointer const_mapped_pointer;
- typedef typename base_type::mapped_reference mapped_reference;
- typedef typename base_type::const_mapped_reference const_mapped_reference;
- typedef typename base_type::value_type value_type;
- typedef typename base_type::pointer pointer;
- typedef typename base_type::const_pointer const_pointer;
- typedef typename base_type::reference reference;
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::point_iterator point_iterator;
- typedef typename base_type::const_iterator const_point_iterator;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef rb_tree_tag container_category;
+ 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 base_type::key_type key_type;
+ typedef typename base_type::key_pointer key_pointer;
+ typedef typename base_type::key_const_pointer key_const_pointer;
+ typedef typename base_type::key_reference key_reference;
+ typedef typename base_type::key_const_reference key_const_reference;
+ typedef typename base_type::mapped_type mapped_type;
+ typedef typename base_type::mapped_pointer mapped_pointer;
+ typedef typename base_type::mapped_const_pointer mapped_const_pointer;
+ typedef typename base_type::mapped_reference mapped_reference;
+ typedef typename base_type::mapped_const_reference mapped_const_reference;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::point_iterator point_iterator;
+ typedef typename base_type::const_iterator point_const_iterator;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
- typedef typename base_type::node_update node_update;
+ typedef typename base_type::node_update node_update;
+ PB_DS_RB_TREE_NAME();
- PB_DS_CLASS_NAME();
+ PB_DS_RB_TREE_NAME(const Cmp_Fn&);
- PB_DS_CLASS_NAME(const Cmp_Fn&);
+ PB_DS_RB_TREE_NAME(const Cmp_Fn&, const node_update&);
- PB_DS_CLASS_NAME(const Cmp_Fn&, const node_update&);
-
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
insert(const_reference);
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
}
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
-#else
+#else
insert(r_key);
- return base_type::s_null_mapped;
-#endif
+ return base_type::s_null_type;
+#endif
}
inline bool
- erase(const_key_reference);
+ erase(key_const_reference);
inline iterator
erase(iterator);
join(PB_DS_CLASS_C_DEC&);
void
- split(const_key_reference, PB_DS_CLASS_C_DEC&);
-
- protected:
+ split(key_const_reference, PB_DS_CLASS_C_DEC&);
private:
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
size_type
- assert_node_consistent(const node_pointer, const char* file,
- int line) const;
-#endif
+ assert_node_consistent(const node_pointer, const char*, int) const;
+#endif
inline static bool
is_effectively_black(const node_pointer);
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_BASE_CLASS_NAME
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
-
+#undef PB_DS_RB_TREE_NAME
+#undef PB_DS_RB_TREE_BASE_NAME
+#undef PB_DS_RB_TREE_BASE
} // namespace detail
} // namespace __gnu_pbds
-
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file rb_tree_map_/split_join_fn_imps.hpp
* Contains an implementation for rb_tree_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
+split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
// warranty.
/**
- * @file traits.hpp
+ * @file rb_tree_map_/traits.hpp
* Contains an implementation for rb_tree_.
*/
{
namespace detail
{
+ /// Specialization.
template<typename Key,
typename Mapped,
typename Cmp_Fn,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- typename Allocator>
- struct tree_traits<
- Key,
- Mapped,
- Cmp_Fn,
- Node_Update,
- rb_tree_tag,
- Allocator> : public bin_search_tree_traits<
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, rb_tree_tag, _Alloc>
+ : public bin_search_tree_traits<
Key,
Mapped,
Cmp_Fn,
Node_Update,
rb_tree_node_<
- typename types_traits<
- Key,
- Mapped,
- Allocator,
- false>::value_type,
- typename tree_node_metadata_selector<
- Key,
- Mapped,
- Cmp_Fn,
- Node_Update,
- Allocator>::type,
- Allocator>,
- Allocator>
+ typename types_traits<Key, Mapped, _Alloc, false>::value_type,
+ typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update,
+ _Alloc>::type,
+ _Alloc>,
+ _Alloc>
{ };
+ /// Specialization.
template<typename Key,
- class Cmp_Fn,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct tree_traits<
- Key,
- null_mapped_type,
- Cmp_Fn,
- Node_Update,
- rb_tree_tag,
- Allocator> : public bin_search_tree_traits<
+ typename Cmp_Fn,
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct tree_traits<Key, null_type, Cmp_Fn, Node_Update, rb_tree_tag, _Alloc>
+ : public bin_search_tree_traits<
Key,
- null_mapped_type,
+ null_type,
Cmp_Fn,
Node_Update,
rb_tree_node_<
- typename types_traits<
- Key,
- null_mapped_type,
- Allocator,
- false>::value_type,
- typename tree_node_metadata_selector<
- Key,
- null_mapped_type,
- Cmp_Fn,
- Node_Update,
- Allocator>::type,
- Allocator>,
- Allocator>
+ typename types_traits<Key, null_type, _Alloc, false>::value_type,
+ typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update,
+ _Alloc>::type,
+ _Alloc>,
+ _Alloc>
{ };
} // namespace detail
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file rc_binomial_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-rc_binomial_heap_()
+rc_binomial_heap()
{
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-rc_binomial_heap_(const Cmp_Fn& r_cmp_fn) :
- PB_DS_BASE_C_DEC(r_cmp_fn)
+rc_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::
-rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other) :
- PB_DS_BASE_C_DEC(other)
+rc_binomial_heap(const PB_DS_CLASS_C_DEC& other)
+: base_type(other)
{
make_binomial_heap();
-
base_type::find_max();
-
PB_DS_ASSERT_VALID((*this))
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~rc_binomial_heap_()
+~rc_binomial_heap()
{ }
PB_DS_CLASS_T_DEC
PB_DS_ASSERT_VALID(other)
base_type::swap(other);
-
m_rc.swap(other.m_rc);
PB_DS_ASSERT_VALID((*this))
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file rc_binomial_heap_/debug_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
return;
}
- const_node_pointer p_nd = next_2_pointer(base_type::m_p_root);
+ node_const_pointer p_nd = next_2_pointer(base_type::m_p_root);
typename rc_t::const_iterator it = m_rc.end();
--it;
while (p_nd != 0)
{
PB_DS_DEBUG_VERIFY(*it == p_nd);
- const_node_pointer p_next = p_nd->m_p_next_sibling;
+ node_const_pointer p_next = p_nd->m_p_next_sibling;
PB_DS_DEBUG_VERIFY(p_next != 0);
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata);
PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 ||
}
PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::const_node_pointer
+typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
-next_2_pointer(const_node_pointer p_nd)
+next_2_pointer(node_const_pointer p_nd)
{
if (p_nd == 0)
return 0;
}
PB_DS_CLASS_T_DEC
-typename PB_DS_CLASS_C_DEC::const_node_pointer
+typename PB_DS_CLASS_C_DEC::node_const_pointer
PB_DS_CLASS_C_DEC::
-next_after_0_pointer(const_node_pointer p_nd)
+next_after_0_pointer(node_const_pointer p_nd)
{
if (p_nd == 0)
return 0;
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file rc_binomial_heap_/erase_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file rc_binomial_heap_/insert_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
// warranty.
/**
- * @file rc.hpp
+ * @file rc_binomial_heap_/rc.hpp
* Contains a redundant (binary counter).
*/
{
namespace detail
{
-
-#define PB_DS_CLASS_T_DEC \
- template<typename Node, class Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- rc<Node, Allocator>
-
- template<typename Node, class Allocator>
+ /// Redundant binary counter.
+ template<typename _Node, typename _Alloc>
class rc
{
private:
- typedef Allocator allocator_type;
-
- typedef typename allocator_type::size_type size_type;
-
- typedef Node node;
+ typedef _Alloc allocator_type;
+ typedef typename allocator_type::size_type size_type;
+ typedef _Node node;
- typedef
- typename allocator_type::template rebind<
- node>::other::pointer
- node_pointer;
+ typedef typename _Alloc::template rebind<node> __rebind_n;
+ typedef typename __rebind_n::other::pointer node_pointer;
- typedef
- typename allocator_type::template rebind<
- node_pointer>::other::pointer
- entry_pointer;
+ typedef typename _Alloc::template rebind<node_pointer> __rebind_np;
- typedef
- typename allocator_type::template rebind<
- node_pointer>::other::const_pointer
- const_entry_pointer;
+ typedef typename __rebind_np::other::pointer entry_pointer;
+ typedef typename __rebind_np::other::const_pointer entry_const_pointer;
enum
{
};
public:
- typedef node_pointer entry;
+ typedef node_pointer entry;
+ typedef entry_const_pointer const_iterator;
- typedef const_entry_pointer const_iterator;
-
- public:
rc();
- rc(const PB_DS_CLASS_C_DEC& other);
+ rc(const rc&);
inline void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(rc&);
inline void
- push(entry p_nd);
+ push(entry);
inline node_pointer
top() const;
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
-#endif
+ assert_valid(const char*, int) const;
+#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
void
trace() const;
-#endif
+#endif
private:
- node_pointer m_a_entries[max_entries];
-
- size_type m_over_top;
+ node_pointer m_a_entries[max_entries];
+ size_type m_over_top;
};
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
+ template<typename _Node, typename _Alloc>
+ rc<_Node, _Alloc>::
rc() : m_over_top(0)
{ PB_DS_ASSERT_VALID((*this)) }
- PB_DS_CLASS_T_DEC
- PB_DS_CLASS_C_DEC::
- rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0)
+ template<typename _Node, typename _Alloc>
+ rc<_Node, _Alloc>::
+ rc(const rc<_Node, _Alloc>& other) : m_over_top(0)
{ PB_DS_ASSERT_VALID((*this)) }
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
inline void
- PB_DS_CLASS_C_DEC::
- swap(PB_DS_CLASS_C_DEC& other)
+ rc<_Node, _Alloc>::
+ swap(rc<_Node, _Alloc>& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
PB_DS_ASSERT_VALID(other)
}
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
inline void
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
push(entry p_nd)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID((*this))
}
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
inline void
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
pop()
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID((*this))
}
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::node_pointer
- PB_DS_CLASS_C_DEC::
+ template<typename _Node, typename _Alloc>
+ inline typename rc<_Node, _Alloc>::node_pointer
+ rc<_Node, _Alloc>::
top() const
{
PB_DS_ASSERT_VALID((*this))
return *(m_a_entries + m_over_top - 1);
}
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
inline bool
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
empty() const
{
PB_DS_ASSERT_VALID((*this))
return m_over_top == 0;
}
- PB_DS_CLASS_T_DEC
- inline typename PB_DS_CLASS_C_DEC::size_type
- PB_DS_CLASS_C_DEC::
+ template<typename _Node, typename _Alloc>
+ inline typename rc<_Node, _Alloc>::size_type
+ rc<_Node, _Alloc>::
size() const
{ return m_over_top; }
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
void
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
clear()
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID((*this))
}
- PB_DS_CLASS_T_DEC
- const typename PB_DS_CLASS_C_DEC::const_iterator
- PB_DS_CLASS_C_DEC::
+ template<typename _Node, typename _Alloc>
+ const typename rc<_Node, _Alloc>::const_iterator
+ rc<_Node, _Alloc>::
begin() const
{ return& m_a_entries[0]; }
- PB_DS_CLASS_T_DEC
- const typename PB_DS_CLASS_C_DEC::const_iterator
- PB_DS_CLASS_C_DEC::
+ template<typename _Node, typename _Alloc>
+ const typename rc<_Node, _Alloc>::const_iterator
+ rc<_Node, _Alloc>::
end() const
{ return& m_a_entries[m_over_top]; }
#ifdef _GLIBCXX_DEBUG
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
void
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
assert_valid(const char* __file, int __line) const
{ PB_DS_DEBUG_VERIFY(m_over_top < max_entries); }
-#endif
+#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
- PB_DS_CLASS_T_DEC
+ template<typename _Node, typename _Alloc>
void
- PB_DS_CLASS_C_DEC::
+ rc<_Node, _Alloc>::
trace() const
{
std::cout << "rc" << std::endl;
std::cerr << m_a_entries[i] << std::endl;
std::cout << std::endl;
}
-#endif
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
+#endif
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// warranty.
/**
- * @file rc_binomial_heap_.hpp
- * Contains an implementation for rc_binomial_heap_.
- */
-
-/*
- * Redundant-counter binomial heap.
+ * @file rc_binomial_heap_/rc_binomial_heap_.hpp
+ * Contains an implementation for redundant-counter binomial heap.
*/
#include <ext/pb_ds/detail/cond_dealtor.hpp>
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 \
- rc_binomial_heap_<Value_Type, Cmp_Fn, Allocator>
-
-#define PB_DS_BASE_C_DEC \
- binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
+ rc_binomial_heap<Value_Type, Cmp_Fn, _Alloc>
#define PB_DS_RC_C_DEC \
- rc<typename PB_DS_BASE_C_DEC::node, Allocator>
+ rc<typename binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>::node, _Alloc>
- /**
- * class description = "8y|\|0|\/|i41 h34p 74813">
- **/
- template<typename Value_Type, class Cmp_Fn, class Allocator>
- class rc_binomial_heap_ : public PB_DS_BASE_C_DEC
+ /// Base class for redundant-counter binomial heap.
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+ class rc_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 PB_DS_RC_C_DEC rc_t;
+ 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;
+ typedef PB_DS_RC_C_DEC rc_t;
public:
+ 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;
- typedef typename Allocator::size_type size_type;
-
- typedef typename Allocator::difference_type difference_type;
-
- typedef Value_Type value_type;
-
- typedef typename base_type::pointer pointer;
-
- typedef typename base_type::const_pointer const_pointer;
-
- typedef typename base_type::reference reference;
+ rc_binomial_heap();
- typedef typename base_type::const_reference const_reference;
+ rc_binomial_heap(const Cmp_Fn&);
- typedef typename base_type::const_point_iterator const_point_iterator;
+ rc_binomial_heap(const PB_DS_CLASS_C_DEC&);
- 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;
-
- public:
-
- rc_binomial_heap_();
-
- rc_binomial_heap_(const Cmp_Fn& r_cmp_fn);
-
- rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other);
-
- ~rc_binomial_heap_();
+ ~rc_binomial_heap();
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
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 void
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&);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
-#endif
+ assert_valid(const char*, int) const;
+#endif
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
void
trace() const;
-#endif
+#endif
private:
inline node_pointer
- link_with_next_sibling(node_pointer p_nd);
+ link_with_next_sibling(node_pointer);
void
make_0_exposed();
make_binomial_heap();
#ifdef _GLIBCXX_DEBUG
- static const_node_pointer
- next_2_pointer(const_node_pointer p_nd);
+ static node_const_pointer
+ next_2_pointer(node_const_pointer);
- static const_node_pointer
- next_after_0_pointer(const_node_pointer p_nd);
-#endif
+ static node_const_pointer
+ next_after_0_pointer(node_const_pointer);
+#endif
- private:
- rc_t m_rc;
+ rc_t m_rc;
};
#include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp>
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_BASE_C_DEC
#undef PB_DS_RC_C_DEC
} // namespace detail
} // namespace __gnu_pbds
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file rc_binomial_heap_/split_join_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
- make_binomial_heap();
+ make_binomial_heap();
other.make_binomial_heap();
-
base_type::split(pred, other);
-
base_type::find_max();
other.find_max();
make_binomial_heap();
other.make_binomial_heap();
-
base_type::join(other);
-
base_type::find_max();
other.find_max();
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file rc_binomial_heap_/trace_fn_imps.hpp
* Contains an implementation for rc_binomial_heap_.
*/
trace() const
{
base_type::trace();
-
m_rc.trace();
}
#ifndef PB_DS_SAMPLE_RESIZE_POLICY_HPP
#define PB_DS_SAMPLE_RESIZE_POLICY_HPP
-// A sample resize policy.
-class sample_resize_policy
+namespace __gnu_pbds
{
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
- // Default constructor.
- sample_resize_policy();
-
- // Copy constructor.
- sample_range_hashing(const sample_resize_policy& other);
-
- // Swaps content.
- inline void
- swap(sample_resize_policy& other);
-
-protected:
-
- // Notifies a search started.
- inline void
- notify_insert_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_insert_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_insert_search_end();
-
- // Notifies a search started.
- inline void
- notify_find_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_find_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_find_search_end();
-
- // Notifies a search started.
- inline void
- notify_erase_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_erase_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_erase_search_end();
-
- // Notifies an element was inserted.
- inline void
- notify_inserted(size_type num_e);
-
- // Notifies an element was erased.
- inline void
- notify_erased(size_type num_e);
-
- // Notifies the table was cleared.
- void
- notify_cleared();
-
- // Notifies the table was resized to new_size.
- void
- notify_resized(size_type new_size);
-
- // Queries whether a resize is needed.
- inline bool
- is_resize_needed() const;
-
- // Queries what the new size should be.
- size_type
- get_new_size(size_type size, size_type num_used_e) const;
-};
-
-#endif
+ /// A sample resize policy.
+ class sample_resize_policy
+ {
+ public:
+ // Size type.
+ typedef std::size_t size_type;
+
+ // Default constructor.
+ sample_resize_policy();
+
+ // Copy constructor.
+ sample_range_hashing(const sample_resize_policy& other);
+
+ // Swaps content.
+ inline void
+ swap(sample_resize_policy& other);
+
+ protected:
+ // Notifies a search started.
+ inline void
+ notify_insert_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_insert_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_insert_search_end();
+
+ // Notifies a search started.
+ inline void
+ notify_find_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_find_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_find_search_end();
+
+ // Notifies a search started.
+ inline void
+ notify_erase_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_erase_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_erase_search_end();
+
+ // Notifies an element was inserted.
+ inline void
+ notify_inserted(size_type num_e);
+
+ // Notifies an element was erased.
+ inline void
+ notify_erased(size_type num_e);
+
+ // Notifies the table was cleared.
+ void
+ notify_cleared();
+
+ // Notifies the table was resized to new_size.
+ void
+ notify_resized(size_type new_size);
+
+ // Queries whether a resize is needed.
+ inline bool
+ is_resize_needed() const;
+
+ // Queries what the new size should be.
+ size_type
+ get_new_size(size_type size, size_type num_used_e) const;
+ };
+}
+#endif
#ifndef PB_DS_SAMPLE_RESIZE_TRIGGER_HPP
#define PB_DS_SAMPLE_RESIZE_TRIGGER_HPP
-// A sample resize trigger policy.
-class sample_resize_trigger
+namespace __gnu_pbds
{
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
- // Default constructor.
- sample_resize_trigger();
-
- // Copy constructor.
- sample_range_hashing(const sample_resize_trigger& other);
-
- // Swaps content.
- inline void
- swap(sample_resize_trigger& other);
-
-protected:
-
- // Notifies a search started.
- inline void
- notify_insert_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_insert_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_insert_search_end();
-
- // Notifies a search started.
- inline void
- notify_find_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_find_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_find_search_end();
-
- // Notifies a search started.
- inline void
- notify_erase_search_start();
-
- // Notifies a search encountered a collision.
- inline void
- notify_erase_search_collision();
-
- // Notifies a search ended.
- inline void
- notify_erase_search_end();
-
- // Notifies an element was inserted. the total number of entries in
- // the table is num_entries.
- inline void
- notify_inserted(size_type num_entries);
-
- // Notifies an element was erased.
- inline void
- notify_erased(size_type num_entries);
-
- // Notifies the table was cleared.
- void
- notify_cleared();
-
- // Notifies the table was resized as a result of this object's
- // signifying that a resize is needed.
- void
- notify_resized(size_type new_size);
-
- // Notifies the table was resized externally.
- void
- notify_externally_resized(size_type new_size);
-
- // Queries whether a resize is needed.
- inline bool
- is_resize_needed() const;
-
- // Queries whether a grow is needed.
- inline bool
- is_grow_needed(size_type size, size_type num_entries) const;
-
-private:
-
- // Resizes to new_size.
- virtual void
- do_resize(size_type new_size);
-};
-
-#endif
+ /// A sample resize trigger policy.
+ class sample_resize_trigger
+ {
+ public:
+ // Size type.
+ typedef std::size_t size_type;
+
+ // Default constructor.
+ sample_resize_trigger();
+
+ // Copy constructor.
+ sample_range_hashing(const sample_resize_trigger&);
+
+ // Swaps content.
+ inline void
+ swap(sample_resize_trigger&);
+
+ protected:
+ // Notifies a search started.
+ inline void
+ notify_insert_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_insert_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_insert_search_end();
+
+ // Notifies a search started.
+ inline void
+ notify_find_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_find_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_find_search_end();
+
+ // Notifies a search started.
+ inline void
+ notify_erase_search_start();
+
+ // Notifies a search encountered a collision.
+ inline void
+ notify_erase_search_collision();
+
+ // Notifies a search ended.
+ inline void
+ notify_erase_search_end();
+
+ // Notifies an element was inserted. the total number of entries in
+ // the table is num_entries.
+ inline void
+ notify_inserted(size_type num_entries);
+
+ // Notifies an element was erased.
+ inline void
+ notify_erased(size_type num_entries);
+
+ // Notifies the table was cleared.
+ void
+ notify_cleared();
+
+ // Notifies the table was resized as a result of this object's
+ // signifying that a resize is needed.
+ void
+ notify_resized(size_type new_size);
+
+ // Notifies the table was resized externally.
+ void
+ notify_externally_resized(size_type new_size);
+
+ // Queries whether a resize is needed.
+ inline bool
+ is_resize_needed() const;
+
+ // Queries whether a grow is needed.
+ inline bool
+ is_grow_needed(size_type size, size_type num_entries) const;
+
+ private:
+ // Resizes to new_size.
+ virtual void
+ do_resize(size_type);
+ };
+}
+#endif
#ifndef PB_DS_SAMPLE_SIZE_POLICY_HPP
#define PB_DS_SAMPLE_SIZE_POLICY_HPP
-// A sample size policy.
-class sample_size_policy
+namespace __gnu_pbds
{
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
- // Default constructor.
- sample_size_policy();
-
- // Copy constructor.
- sample_range_hashing(const sample_size_policy& other);
-
- // Swaps content.
- inline void
- swap(sample_size_policy& other);
-
-protected:
-
- // Given a __size size, returns a __size that is larger.
- inline size_type
- get_nearest_larger_size(size_type size) const;
-
- // Given a __size size, returns a __size that is smaller.
- inline size_type
- get_nearest_smaller_size(size_type size) const;
-};
-
-#endif
+ /// A sample size policy.
+ class sample_size_policy
+ {
+ public:
+ // Size type.
+ typedef std::size_t size_type;
+
+ // Default constructor.
+ sample_size_policy();
+
+ // Copy constructor.
+ sample_range_hashing(const sample_size_policy&);
+
+ // Swaps content.
+ inline void
+ swap(sample_size_policy& other);
+
+ protected:
+ // Given a __size size, returns a __size that is larger.
+ inline size_type
+ get_nearest_larger_size(size_type size) const;
+
+ // Given a __size size, returns a __size that is smaller.
+ inline size_type
+ get_nearest_smaller_size(size_type size) const;
+ };
+}
+#endif
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file splay_tree_/constructors_destructor_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME()
+PB_DS_S_TREE_NAME()
{
initialize();
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) :
+PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
base_type(r_cmp_fn)
{
initialize();
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_S_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
base_type(r_cmp_fn, r_node_update)
{
initialize();
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
+PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
base_type(other)
{
initialize();
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file splay_tree_/debug_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file splay_tree_/erase_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
PB_DS_CLASS_T_DEC
inline bool
PB_DS_CLASS_C_DEC::
-erase(const_key_reference r_key)
+erase(key_const_reference r_key)
{
point_iterator it = find(r_key);
if (it == base_type::end())
if (p_l != 0)
p_l->m_p_parent = p_target_r;
PB_DS_ASSERT_VALID((*this))
- this->apply_update(p_target_r, (node_update* )this);
+ this->apply_update(p_target_r, (node_update*)this);
}
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file splay_tree_/find_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
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)
{
node_pointer p_found = find_imp(r_key);
if (p_found != base_type::m_p_head)
}
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
{
const node_pointer p_found = find_imp(r_key);
if (p_found != base_type::m_p_head)
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-find_imp(const_key_reference r_key)
+find_imp(key_const_reference r_key)
{
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__,
__LINE__);)
PB_DS_CLASS_T_DEC
inline const typename PB_DS_CLASS_C_DEC::node_pointer
PB_DS_CLASS_C_DEC::
-find_imp(const_key_reference r_key) const
+find_imp(key_const_reference r_key) const
{
PB_DS_ASSERT_VALID((*this))
node_pointer p_nd = base_type::m_p_head->m_p_parent;
// warranty.
/**
- * @file info_fn_imps.hpp
+ * @file splay_tree_/info_fn_imps.hpp
* Contains an implementation.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file splay_tree_/insert_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
// warranty.
/**
- * @file node.hpp
+ * @file splay_tree_/node.hpp
* Contains an implementation struct for splay_tree_'s node.
*/
{
namespace detail
{
- template<typename Value_Type, class Metadata, class Allocator>
+ /// Node for splay tree.
+ template<typename Value_Type, class Metadata, typename _Alloc>
struct splay_tree_node_
{
public:
typedef Metadata metadata_type;
typedef
- typename Allocator::template rebind<
- splay_tree_node_<Value_Type, Metadata, Allocator> >::other::pointer
+ typename _Alloc::template rebind<
+ splay_tree_node_<Value_Type, Metadata, _Alloc> >::other::pointer
node_pointer;
typedef
- typename Allocator::template rebind<metadata_type>::other::reference
+ typename _Alloc::template rebind<metadata_type>::other::reference
metadata_reference;
typedef
- typename Allocator::template rebind<metadata_type>::other::const_reference
- const_metadata_reference;
+ typename _Alloc::template rebind<metadata_type>::other::const_reference
+ metadata_const_reference;
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
special() const
{ return m_special; }
- inline const_metadata_reference
+ inline metadata_const_reference
get_metadata() const
{ return m_metadata; }
metadata_type m_metadata;
};
- template<typename Value_Type, typename Allocator>
- struct splay_tree_node_<Value_Type, null_node_metadata, Allocator>
+ template<typename Value_Type, typename _Alloc>
+ struct splay_tree_node_<Value_Type, null_type, _Alloc>
{
public:
typedef Value_Type value_type;
- typedef null_node_metadata metadata_type;
+ typedef null_type metadata_type;
typedef
- typename Allocator::template rebind<
- splay_tree_node_<Value_Type, null_node_metadata, Allocator> >::other::pointer
+ typename _Alloc::template rebind<
+ splay_tree_node_<Value_Type, null_type, _Alloc> >::other::pointer
node_pointer;
inline bool
// warranty.
/**
- * @file splay_fn_imps.hpp
+ * @file splay_tree_/splay_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head)
{
- base_type::rotate_parent(p_nd);
- _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
+ base_type::rotate_parent(p_nd);
+ _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent);
}
else
{
- const node_pointer p_parent = p_nd->m_p_parent;
- const node_pointer p_grandparent = p_parent->m_p_parent;
+ const node_pointer p_parent = p_nd->m_p_parent;
+ const node_pointer p_grandparent = p_parent->m_p_parent;
#ifdef _GLIBCXX_DEBUG
- const size_type total =
+ const size_type total =
base_type::recursive_count(p_grandparent);
- _GLIBCXX_DEBUG_ASSERT(total >= 3);
-#endif
+ _GLIBCXX_DEBUG_ASSERT(total >= 3);
+#endif
- if (p_parent->m_p_left == p_nd &&
+ if (p_parent->m_p_left == p_nd &&
p_grandparent->m_p_right == p_parent)
splay_zig_zag_left(p_nd, p_parent, p_grandparent);
- else if (p_parent->m_p_right == p_nd &&
+ else if (p_parent->m_p_right == p_nd &&
p_grandparent->m_p_left == p_parent)
splay_zig_zag_right(p_nd, p_parent, p_grandparent);
- else if (p_parent->m_p_left == p_nd &&
+ else if (p_parent->m_p_left == p_nd &&
p_grandparent->m_p_left == p_parent)
splay_zig_zig_left(p_nd, p_parent, p_grandparent);
- else
+ else
splay_zig_zig_right(p_nd, p_parent, p_grandparent);
- _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
+ _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd));
}
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent,
+splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
- p_grandparent->m_p_right == p_parent);
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
+ p_grandparent->m_p_right == p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent,
+splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
- p_grandparent->m_p_left == p_parent);
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
+ p_grandparent->m_p_left == p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent,
+splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd &&
p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent,
+splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent);
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent)
- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
- p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent);
+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd &&
+ p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent);
splay_zz_start(p_nd, p_parent, p_grandparent);
if (p_c != 0)
p_c->m_p_parent = p_grandparent;
- base_type::update_to_top(p_grandparent, (node_update* )this);
+ base_type::update_to_top(p_grandparent, (node_update*)this);
splay_zz_end(p_nd, p_parent, p_grandparent);
}
splay_zz_start(node_pointer p_nd,
#ifdef _GLIBCXX_DEBUG
node_pointer p_parent,
-#else
+#else
node_pointer /*p_parent*/,
#endif
node_pointer p_grandparent)
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-splay_zz_end(node_pointer p_nd, node_pointer p_parent,
+splay_zz_end(node_pointer p_nd, node_pointer p_parent,
node_pointer p_grandparent)
{
if (p_nd->m_p_parent == base_type::m_p_head)
base_type::m_p_head->m_p_parent = p_nd;
- this->apply_update(p_grandparent, (node_update* )this);
- this->apply_update(p_parent, (node_update* )this);
- this->apply_update(p_nd, (node_update* )this);
-
+ this->apply_update(p_grandparent, (node_update*)this);
+ this->apply_update(p_parent, (node_update*)this);
+ this->apply_update(p_nd, (node_update*)this);
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd)
}
-
// warranty.
/**
- * @file splay_tree_.hpp
- * Contains an implementation class for splay_tree_.
+ * @file splay_tree_/splay_tree_.hpp
+ * Contains an implementation class for splay trees.
*/
/*
* This implementation uses an idea from the SGI STL (using a @a header node
*
*/
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR
-#define PB_DS_BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR
-#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
-#endif
-#endif
-
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#ifndef PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR
-#define PB_DS_BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR
-#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
-#endif
-#endif
-
#include <utility>
#include <vector>
#include <assert.h>
{
namespace detail
{
-#define PB_DS_CLASS_T_DEC \
- template<typename Key, typename Mapped, typename Cmp_Fn, \
- typename Node_And_It_Traits, typename Allocator>
-
#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_CLASS_NAME splay_tree_data_
-#endif
+# define PB_DS_S_TREE_NAME splay_tree_map
+# define PB_DS_S_TREE_BASE_NAME bin_search_tree_map
+#endif
#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_CLASS_NAME splay_tree_no_data_
-#endif
-
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_BASE_CLASS_NAME bin_search_tree_data_
-#endif
+# define PB_DS_S_TREE_NAME splay_tree_set
+# define PB_DS_S_TREE_BASE_NAME bin_search_tree_set
+#endif
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_BASE_CLASS_NAME bin_search_tree_no_data_
-#endif
+#define PB_DS_CLASS_T_DEC \
+ template<typename Key, typename Mapped, typename Cmp_Fn, \
+ typename Node_And_It_Traits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- PB_DS_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
+ PB_DS_S_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#define PB_DS_BASE_C_DEC \
- PB_DS_BASE_CLASS_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, Allocator>
+#define PB_DS_S_TREE_BASE \
+ PB_DS_S_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
-#ifdef PB_DS_DATA_TRUE_INDICATOR
-#define PB_DS_V2F(X) (X).first
-#define PB_DS_V2S(X) (X).second
-#define PB_DS_EP2VP(X)& ((X)->m_value)
-#endif
-#ifdef PB_DS_DATA_FALSE_INDICATOR
-#define PB_DS_V2F(X) (X)
-#define PB_DS_V2S(X) Mapped_Data()
-#define PB_DS_EP2VP(X)& ((X)->m_value.first)
-#endif
-
- // $p14y 7r33 7481.
+ /// Splay Tree.
template<typename Key, typename Mapped, typename Cmp_Fn,
- typename Node_And_It_Traits, typename Allocator>
- class PB_DS_CLASS_NAME : public PB_DS_BASE_C_DEC
+ typename Node_And_It_Traits, typename _Alloc>
+ class PB_DS_S_TREE_NAME : public PB_DS_S_TREE_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_S_TREE_BASE base_type;
#ifdef _GLIBCXX_DEBUG
typedef base_type debug_base;
#endif
- typedef typename base_type::node_pointer node_pointer;
+ typedef typename base_type::node_pointer node_pointer;
public:
- typedef Allocator allocator_type;
- typedef typename Allocator::size_type size_type;
- typedef typename Allocator::difference_type difference_type;
- typedef Cmp_Fn cmp_fn;
- typedef typename base_type::key_type key_type;
- typedef typename base_type::key_pointer key_pointer;
- typedef typename base_type::const_key_pointer const_key_pointer;
- typedef typename base_type::key_reference key_reference;
- typedef typename base_type::const_key_reference const_key_reference;
- typedef typename base_type::mapped_type mapped_type;
- typedef typename base_type::mapped_pointer mapped_pointer;
- typedef typename base_type::const_mapped_pointer const_mapped_pointer;
- typedef typename base_type::mapped_reference mapped_reference;
- typedef typename base_type::const_mapped_reference const_mapped_reference;
- typedef typename base_type::value_type value_type;
- typedef typename base_type::pointer pointer;
- typedef typename base_type::const_pointer const_pointer;
- typedef typename base_type::reference reference;
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::point_iterator point_iterator;
- typedef typename base_type::const_iterator const_point_iterator;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef splay_tree_tag container_category;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+ typedef Cmp_Fn cmp_fn;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_pointer key_pointer;
+ typedef typename base_type::key_const_pointer key_const_pointer;
+ typedef typename base_type::key_reference key_reference;
+ typedef typename base_type::key_const_reference key_const_reference;
+ typedef typename base_type::mapped_type mapped_type;
+ typedef typename base_type::mapped_pointer mapped_pointer;
+ typedef typename base_type::mapped_const_pointer mapped_const_pointer;
+ typedef typename base_type::mapped_reference mapped_reference;
+ typedef typename base_type::mapped_const_reference mapped_const_reference;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::point_iterator point_iterator;
+ typedef typename base_type::const_iterator point_const_iterator;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
- typedef typename base_type::node_update node_update;
+ typedef typename base_type::node_update node_update;
- PB_DS_CLASS_NAME();
+ PB_DS_S_TREE_NAME();
- PB_DS_CLASS_NAME(const Cmp_Fn&);
+ PB_DS_S_TREE_NAME(const Cmp_Fn&);
- PB_DS_CLASS_NAME(const Cmp_Fn&, const node_update&);
+ PB_DS_S_TREE_NAME(const Cmp_Fn&, const node_update&);
- PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC&);
+ PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC&);
void
swap(PB_DS_CLASS_C_DEC&);
insert(const_reference r_value);
inline mapped_reference
- operator[](const_key_reference r_key)
+ operator[](key_const_reference r_key)
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
splay(ins_pair.first.m_p_nd);
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
return ins_pair.first.m_p_nd->m_value.second;
-#else
+#else
insert(r_key);
- return base_type::s_null_mapped;
+ return base_type::s_null_type;
#endif
}
inline point_iterator
- find(const_key_reference);
+ find(key_const_reference);
- inline const_point_iterator
- find(const_key_reference) const;
+ inline point_const_iterator
+ find(key_const_reference) const;
inline bool
- erase(const_key_reference);
+ erase(key_const_reference);
inline iterator
erase(iterator it);
join(PB_DS_CLASS_C_DEC&);
void
- split(const_key_reference, PB_DS_CLASS_C_DEC&);
+ split(key_const_reference, PB_DS_CLASS_C_DEC&);
private:
inline std::pair<point_iterator, bool>
insert_leaf_imp(const_reference);
inline node_pointer
- find_imp(const_key_reference);
+ find_imp(key_const_reference);
inline const node_pointer
- find_imp(const_key_reference) const;
+ find_imp(key_const_reference) const;
#ifdef _GLIBCXX_DEBUG
void
void
assert_special_imp(const node_pointer, const char* file, int line) const;
-#endif
+#endif
void
splay(node_pointer);
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_CLASS_NAME
-#undef PB_DS_BASE_CLASS_NAME
-#undef PB_DS_BASE_C_DEC
-#undef PB_DS_V2F
-#undef PB_DS_EP2VP
-#undef PB_DS_V2S
+#undef PB_DS_S_TREE_NAME
+#undef PB_DS_S_TREE_BASE_NAME
+#undef PB_DS_S_TREE_BASE
} // namespace detail
} // namespace __gnu_pbds
-
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file splay_tree_/split_join_fn_imps.hpp
* Contains an implementation class for splay_tree_.
*/
base_type::m_p_head->m_p_parent = p_target_r;
p_target_r->m_p_parent = base_type::m_p_head;
- this->apply_update(p_target_r, (node_update* )this);
+ this->apply_update(p_target_r, (node_update*)this);
base_type::join_finish(other);
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
+split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
other.m_p_head->m_p_parent = p_upper_bound;
p_upper_bound->m_p_parent = other.m_p_head;
p_upper_bound->m_p_left = 0;
- this->apply_update(p_upper_bound, (node_update* )this);
+ this->apply_update(p_upper_bound, (node_update*)this);
base_type::split_finish(other);
PB_DS_ASSERT_VALID((*this))
// warranty.
/**
- * @file traits.hpp
+ * @file splay_tree_/traits.hpp
* Contains an implementation for splay_tree_.
*/
{
namespace detail
{
-
+ /// Specialization.
template<typename Key,
typename Mapped,
- class Cmp_Fn,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct tree_traits<
- Key,
- Mapped,
- Cmp_Fn,
- Node_Update,
- splay_tree_tag,
- Allocator> : public bin_search_tree_traits<
- Key,
- Mapped,
- Cmp_Fn,
- Node_Update,
- splay_tree_node_<
- typename types_traits<
- Key,
- Mapped,
- Allocator,
- false>::value_type,
- typename tree_node_metadata_selector<
- Key,
- Mapped,
- Cmp_Fn,
- Node_Update,
- Allocator>::type,
- Allocator>,
- Allocator>
+ typename Cmp_Fn,
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, splay_tree_tag, _Alloc>
+ : public bin_search_tree_traits<Key, Mapped, Cmp_Fn, Node_Update,
+ splay_tree_node_<
+ typename types_traits<Key, Mapped, _Alloc, false>::value_type,
+ typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update,
+ _Alloc>::type,
+ _Alloc>,
+ _Alloc>
{ };
+ /// 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 Allocator>
- struct tree_traits<Key, null_mapped_type, Cmp_Fn, Node_Update,
- splay_tree_tag, Allocator>
- : public bin_search_tree_traits<Key, null_mapped_type, Cmp_Fn,
- Node_Update,
- splay_tree_node_<typename types_traits<Key, null_mapped_type, Allocator, false>::value_type,
- typename tree_node_metadata_selector<
- Key,
- null_mapped_type,
- Cmp_Fn,
- Node_Update,
- Allocator>::type,
- Allocator>,
- Allocator>
+ typename _Alloc>
+ struct tree_traits<Key, null_type, Cmp_Fn, Node_Update,
+ splay_tree_tag, _Alloc>
+ : public bin_search_tree_traits<Key, null_type, Cmp_Fn, Node_Update,
+ splay_tree_node_<
+ typename types_traits<Key, null_type, _Alloc, false>::value_type,
+ typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update,
+ _Alloc>::type,
+ _Alloc>,
+ _Alloc>
{ };
} // namespace detail
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 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
// warranty.
/**
- * @file standard_policies.hpp
+ * @file detail/standard_policies.hpp
* Contains standard policies for containers.
*/
#include <memory>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/list_update_policy.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/tree_policy.hpp>
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <tr1/functional>
{
namespace detail
{
+ /// default_hash_fn
template<typename Key>
struct default_hash_fn
{
typedef std::tr1::hash<Key> type;
};
+ /// default_eq_fn
template<typename Key>
struct default_eq_fn
{
default_store_hash = false
};
+ /// default_comb_hash_fn
struct default_comb_hash_fn
{
typedef __gnu_pbds::direct_mask_range_hashing<> type;
};
+ /// default_resize_policy
template<typename Comb_Hash_Fn>
struct default_resize_policy
{
typedef __gnu_pbds::hash_standard_resize_policy<size_policy_type, trigger, false, size_type> type;
};
+ /// default_update_policy
struct default_update_policy
{
- typedef __gnu_pbds::move_to_front_lu_policy<> type;
+ typedef __gnu_pbds::lu_move_to_front_policy<> type;
};
+ /// default_probe_fn
template<typename Comb_Probe_Fn>
struct default_probe_fn
{
typedef typename cond_type::__type type;
};
+ /// default_trie_access_traits
template<typename Key>
- struct default_trie_e_access_traits;
+ struct default_trie_access_traits;
- template<typename Char, class Char_Traits>
- struct default_trie_e_access_traits<std::basic_string<Char, Char_Traits, std::allocator<char> > >
+ template<typename Char, typename Char_Traits>
+ struct default_trie_access_traits<std::basic_string<Char, Char_Traits, std::allocator<char> > >
{
private:
typedef std::basic_string<Char, Char_Traits, std::allocator<char> > string_type;
public:
- typedef __gnu_pbds::string_trie_e_access_traits<string_type> type;
+ typedef __gnu_pbds::trie_string_access_traits<string_type> type;
};
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_STANDARD_POLICIES_HPP
-
// warranty.
/**
- * @file constructors_destructor_fn_imps.hpp
+ * @file thin_heap_/constructors_destructor_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-thin_heap_() :
- m_p_max(0)
+thin_heap() : m_p_max(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-thin_heap_(const Cmp_Fn& r_cmp_fn) :
- PB_DS_BASE_C_DEC(r_cmp_fn),
- m_p_max(0)
+thin_heap(const Cmp_Fn& r_cmp_fn)
+: base_type(r_cmp_fn), m_p_max(0)
{
initialize();
PB_DS_ASSERT_VALID((*this))
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-thin_heap_(const PB_DS_CLASS_C_DEC& other) :
- PB_DS_BASE_C_DEC(other)
+thin_heap(const PB_DS_CLASS_C_DEC& other)
+: base_type(other)
{
initialize();
m_p_max = base_type::m_p_root;
- for (node_pointer p_nd = base_type::m_p_root; p_nd != 0; p_nd = p_nd->m_p_next_sibling)
+ for (node_pointer p_nd = base_type::m_p_root; p_nd != 0;
+ p_nd = p_nd->m_p_next_sibling)
if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value))
m_p_max = p_nd;
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-~thin_heap_()
+~thin_heap()
{ }
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file debug_fn_imps.hpp
+ * @file thin_heap_/debug_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
-assert_node_consistent(const_node_pointer p_nd, bool root,
+assert_node_consistent(node_const_pointer p_nd, bool root,
const char* __file, int __line) const
{
base_type::assert_node_consistent(p_nd, root, __file, __line);
// warranty.
/**
- * @file erase_fn_imps.hpp
+ * @file thin_heap_/erase_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
{
PB_DS_ASSERT_VALID((*this))
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
-
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
node_pointer p_nd = m_p_max;
-
remove_max_node();
-
base_type::actual_erase_node(p_nd);
-
PB_DS_ASSERT_VALID((*this))
}
remove_max_node()
{
to_aux_except_max();
-
make_from_aux();
}
to_aux_except_max()
{
node_pointer p_add = base_type::m_p_root;
-
while (p_add != m_p_max)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
-
add_to_aux(p_add);
-
p_add = p_next_add;
}
p_add = m_p_max->m_p_l_child;
-
while (p_add != 0)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
-
- p_add->m_metadata = p_add->m_p_l_child == 0?
- 0 :
- p_add->m_p_l_child->m_metadata + 1;
+ p_add->m_metadata = p_add->m_p_l_child == 0 ?
+ 0 : p_add->m_p_l_child->m_metadata + 1;
add_to_aux(p_add);
-
p_add = p_next_add;
}
p_add = m_p_max->m_p_next_sibling;
-
while (p_add != 0)
{
node_pointer p_next_add = p_add->m_p_next_sibling;
-
add_to_aux(p_add);
-
p_add = p_next_add;
}
}
add_to_aux(node_pointer p_nd)
{
size_type r = p_nd->m_metadata;
-
while (m_a_aux[r] != 0)
{
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound());
-
if (Cmp_Fn::operator()(m_a_aux[r]->m_value, p_nd->m_value))
make_child_of(m_a_aux[r], p_nd);
else
- {
+ {
make_child_of(p_nd, m_a_aux[r]);
-
p_nd = m_a_aux[r];
- }
+ }
m_a_aux[r] = 0;
-
++r;
}
m_a_aux[p_nd->m_metadata] == p_new_parent);
++p_new_parent->m_metadata;
-
base_type::make_child_of(p_nd, p_new_parent);
}
make_from_aux()
{
base_type::m_p_root = m_p_max = 0;
-
const size_type rnk_bnd = rank_bound();
-
size_type i = 0;
-
while (i < rnk_bnd)
{
if (m_a_aux[i] != 0)
- {
+ {
make_root_and_link(m_a_aux[i]);
-
m_a_aux[i] = 0;
- }
-
+ }
++i;
}
p_parent = base_type::parent(p_parent);
base_type::bubble_to_top(p_nd);
-
m_p_max = p_nd;
node_pointer p_fix = base_type::m_p_root;
clear()
{
base_type::clear();
-
m_p_max = 0;
}
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
node_pointer p_nd = it.m_p_nd;
-
remove_node(p_nd);
-
base_type::actual_erase_node(p_nd);
-
PB_DS_ASSERT_VALID((*this))
}
erase_if(Pred pred)
{
PB_DS_ASSERT_VALID((*this))
-
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
-
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;
-
m_p_max = base_type::m_p_root = 0;
-
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
-
make_root_and_link(p_cur);
-
p_cur = p_next;
}
PB_DS_ASSERT_VALID((*this))
-
return ersd;
}
return (p_upper - g_a_rank_bounds);
}
-
// warranty.
/**
- * @file find_fn_imps.hpp
+ * @file thin_heap_/find_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
// warranty.
/**
- * @file insert_fn_imps.hpp
+ * @file thin_heap_/insert_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
push(const_reference r_val)
{
PB_DS_ASSERT_VALID((*this))
-
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
-
p_nd->m_metadata = 0;
-
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
-
if (base_type::m_p_root == 0)
{
p_nd->m_p_next_sibling = 0;
-
m_p_max = base_type::m_p_root = p_nd;
-
PB_DS_ASSERT_VALID((*this))
-
return point_iterator(p_nd);
}
p_nd->m_p_next_sibling = base_type::m_p_root;
-
base_type::m_p_root->m_p_prev_or_parent = 0;
-
base_type::m_p_root = p_nd;
-
update_max(p_nd);
-
PB_DS_ASSERT_VALID((*this))
-
return point_iterator(p_nd);
}
PB_DS_CLASS_C_DEC::
make_root(node_pointer p_nd)
{
- p_nd->m_metadata =
- p_nd->m_p_l_child == 0 ?
- 0 :
- 1 + p_nd->m_p_l_child->m_metadata;
+ p_nd->m_metadata = p_nd->m_p_l_child == 0
+ ? 0 : 1 + p_nd->m_p_l_child->m_metadata;
}
PB_DS_CLASS_T_DEC
make_root_and_link(node_pointer p_nd)
{
make_root(p_nd);
-
p_nd->m_p_prev_or_parent = 0;
-
p_nd->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 = 0;
base_type::m_p_root = p_nd;
-
update_max(p_nd);
}
if (p_y->m_p_prev_or_parent == 0)
{
fix_root(p_y);
-
return;
}
else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0)
if (p_y->m_p_l_child != 0)
{
fix_sibling_rank_1_unmarked(p_y);
-
return;
}
fix_sibling_rank_1_marked(p_y);
-
p_y = p_y->m_p_prev_or_parent;
}
else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0);
-
if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2)
{
fix_sibling_general_unmarked(p_y);
-
return;
}
fix_sibling_general_marked(p_y);
-
p_y = p_y->m_p_prev_or_parent;
}
else if ((p_y->m_p_l_child == 0&&
p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3))
{
node_pointer p_z = p_y->m_p_prev_or_parent;
-
fix_child(p_y);
-
p_y = p_z;
}
else
fix_root(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0);
-
make_root(p_y);
-
PB_DS_ASSERT_NODE_CONSISTENT(p_y, true)
}
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0);
p_y->m_p_next_sibling = p_y->m_p_l_child;
-
p_y->m_p_next_sibling->m_p_prev_or_parent = p_y;
-
p_y->m_p_l_child = 0;
-
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0);
-
p_y->m_metadata = 0;
-
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
fix_sibling_general_marked(node_pointer p_y)
{
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0);
-
--p_y->m_metadata;
-
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false)
}
modify(point_iterator it, const_reference r_new_val)
{
PB_DS_ASSERT_VALID((*this))
- node_pointer p_nd = it.m_p_nd;
-
+ node_pointer p_nd = it.m_p_nd;
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
const bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value);
-
p_nd->m_value = r_new_val;
-
if (smaller)
{
remove_node(p_nd);
-
p_nd->m_p_l_child = 0;
-
make_root_and_link(p_nd);
-
PB_DS_ASSERT_VALID((*this))
-
return;
}
if (p_nd->m_p_prev_or_parent == 0)
{
update_max(p_nd);
-
PB_DS_ASSERT_VALID((*this))
-
return;
}
p_y->m_p_next_sibling = p_nd->m_p_next_sibling;
fix(p_y);
-
make_root_and_link(p_nd);
-
PB_DS_ASSERT_VALID((*this))
}
// warranty.
/**
- * @file split_join_fn_imps.hpp
+ * @file thin_heap_/split_join_fn_imps.hpp
* Contains an implementation for thin_heap_.
*/
PB_DS_ASSERT_VALID(other)
other.clear();
-
if (base_type::empty())
{
PB_DS_ASSERT_VALID((*this))
PB_DS_ASSERT_VALID(other)
-
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;
-
other.make_root_and_link(p_out);
-
p_out = p_next;
}
PB_DS_ASSERT_VALID(other)
-
node_pointer p_cur = base_type::m_p_root;
-
m_p_max = 0;
-
base_type::m_p_root = 0;
-
while (p_cur != 0)
{
node_pointer p_next = p_cur->m_p_next_sibling;
-
make_root_and_link(p_cur);
-
p_cur = p_next;
}
PB_DS_ASSERT_VALID(other)
node_pointer p_other = other.m_p_root;
-
while (p_other != 0)
{
node_pointer p_next = p_other->m_p_next_sibling;
-
make_root_and_link(p_other);
-
p_other = p_next;
}
-
base_type::m_size += other.m_size;
-
other.m_p_root = 0;
other.m_size = 0;
other.m_p_max = 0;
// warranty.
/**
- * @file thin_heap_.hpp
+ * @file thin_heap_/thin_heap_.hpp
* Contains an implementation class for a thin heap.
*/
#ifndef PB_DS_THIN_HEAP_HPP
#define PB_DS_THIN_HEAP_HPP
-/*
- * Thin heaps.
- * Tarjan and Kaplan.
- */
-
#include <algorithm>
#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>
#include <debug/debug.h>
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 \
- thin_heap_<Value_Type, Cmp_Fn, Allocator>
+ thin_heap<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, true>
-#else
-#define PB_DS_BASE_C_DEC \
- left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
- typename Allocator::size_type, Allocator>
-#endif
+#define PB_DS_BASE_T_P \
+ <Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc, true>
+#else
+#define PB_DS_BASE_T_P \
+ <Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc>
+#endif
/**
- * class description = "t|-|i|\| h34p">
- **/
- template<typename Value_Type, class Cmp_Fn, class Allocator>
- class thin_heap_ : public PB_DS_BASE_C_DEC
+ * Thin heap.
+ * Base class for @ref priority_queue.
+ *
+ * See Tarjan and Kaplan.
+ */
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+ class thin_heap
+ : public left_child_next_sibling_heap PB_DS_BASE_T_P
{
-
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
+ typedef left_child_next_sibling_heap PB_DS_BASE_T_P 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 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 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 __rebind_a::pointer pointer;
+ typedef typename __rebind_a::const_pointer const_pointer;
+ typedef typename __rebind_a::reference reference;
+ typedef typename __rebind_a::const_reference const_reference;
- typedef
- typename PB_DS_BASE_C_DEC::const_point_iterator
- const_point_iterator;
+ typedef typename base_type::point_iterator point_iterator;
+ typedef typename base_type::point_const_iterator point_const_iterator;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_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;
-
- 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;
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:
+ thin_heap();
- thin_heap_();
+ thin_heap(const Cmp_Fn&);
- thin_heap_(const Cmp_Fn& r_cmp_fn);
-
- thin_heap_(const PB_DS_CLASS_C_DEC& other);
+ thin_heap(const PB_DS_CLASS_C_DEC&);
void
- swap(PB_DS_CLASS_C_DEC& other);
+ swap(PB_DS_CLASS_C_DEC&);
- ~thin_heap_();
+ ~thin_heap();
template<typename It>
void
- copy_from_range(It first_it, It last_it);
+ copy_from_range(It, It);
#ifdef _GLIBCXX_DEBUG
void
- assert_valid(const char* file, int line) const;
+ assert_valid(const char*, int) const;
void
- assert_max(const char* file, int line) const;
-#endif
+ assert_max(const char*, int) const;
+#endif
#ifdef PB_DS_THIN_HEAP_TRACE_
void
trace() const;
-#endif
+#endif
private:
enum
max_rank = (sizeof(size_type) << 4) + 2
};
- private:
-
void
initialize();
inline void
- update_max(node_pointer p_nd);
+ update_max(node_pointer);
inline void
- fix(node_pointer p_nd);
+ fix(node_pointer);
inline void
- fix_root(node_pointer p_y);
+ fix_root(node_pointer);
inline void
- fix_sibling_rank_1_unmarked(node_pointer p_y);
+ fix_sibling_rank_1_unmarked(node_pointer);
inline void
- fix_sibling_rank_1_marked(node_pointer p_y);
+ fix_sibling_rank_1_marked(node_pointer);
inline void
- fix_sibling_general_unmarked(node_pointer p_y);
+ fix_sibling_general_unmarked(node_pointer);
inline void
- fix_sibling_general_marked(node_pointer p_y);
+ fix_sibling_general_marked(node_pointer);
inline void
- fix_child(node_pointer p_y);
+ fix_child(node_pointer);
inline static void
- make_root(node_pointer p_nd);
+ make_root(node_pointer);
inline void
- make_root_and_link(node_pointer p_nd);
+ make_root_and_link(node_pointer);
inline void
remove_max_node();
to_aux_except_max();
inline void
- add_to_aux(node_pointer p_nd);
+ add_to_aux(node_pointer);
inline void
make_from_aux();
rank_bound();
inline void
- make_child_of(node_pointer p_nd, node_pointer p_new_parent);
+ make_child_of(node_pointer, node_pointer);
inline void
- remove_node(node_pointer p_nd);
+ remove_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 p_nd, bool root,
- const char* file, int line) const;
+ assert_node_consistent(node_const_pointer, bool, const char*, int) const;
void
- assert_aux_null(const char* file, int line) const;
-#endif
-
- private:
- node_pointer m_p_max;
+ assert_aux_null(const char*, int) const;
+#endif
- node_pointer m_a_aux[max_rank];
+ node_pointer m_p_max;
+ node_pointer m_a_aux[max_rank];
};
enum
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \
__FILE__, __LINE__);)
-#define PB_DS_ASSERT_AUX_NULL(X) \
+#define PB_DS_ASSERT_AUX_NULL(X) \
_GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);)
#include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp>
#undef PB_DS_ASSERT_NODE_CONSISTENT
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_BASE_T_P
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// warranty.
/**
- * @file trace_fn_imps.hpp
+ * @file thin_heap_/trace_fn_imps.hpp
* Contains an implementation class for left_child_next_sibling_heap_.
*/
trace() const
{
std::cerr << std::endl;
-
std::cerr << "m_p_max " << m_p_max << std::endl;
-
base_type::trace();
}
// -*- 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
// warranty.
/**
- * @file node_metadata_selector.hpp
+ * @file tree_policy/node_metadata_selector.hpp
* Contains an implementation class for trees.
*/
-#ifndef PB_DS_TREE_NODE_METADATA_SELECTOR_HPP
-#define PB_DS_TREE_NODE_METADATA_SELECTOR_HPP
+#ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
+#define PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
+ /// Tree metadata helper.
+ template<typename Node_Update, bool _BTp>
+ struct tree_metadata_helper;
- template<typename Node_Update, bool Null>
- struct tree_metadata_helper
- {
- typedef typename Node_Update::metadata_type type;
- };
+ template<typename Node_Update>
+ struct tree_metadata_helper<Node_Update, false>
+ {
+ typedef typename Node_Update::metadata_type type;
+ };
template<typename Node_Update>
- struct tree_metadata_helper<
- Node_Update,
- true>
- {
- typedef null_node_metadata type;
- };
+ struct tree_metadata_helper<Node_Update, true>
+ {
+ typedef null_type type;
+ };
+ /// Tree node metadata dispatch.
template<typename Key,
typename Data,
- class Cmp_Fn,
- template<typename Const_Node_Iterator,
- class Const_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct tree_node_metadata_selector
+ typename Cmp_Fn,
+ template<typename Node_CItr,
+ typename Const_Iterator,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct tree_node_metadata_dispatch
{
private:
- typedef
- dumconst_node_iterator<
- Key,
- Data,
- Allocator>
- dumconst_node_it;
+ typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type;
+ typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u;
+ typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u;
enum
{
- null_update =
- is_same<
- Node_Update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator>,
- null_tree_node_update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator> >::value
+ null_update = is_same<__node_u, __nnode_u>::value
};
public:
- typedef
- typename tree_metadata_helper<
- Node_Update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator>,
- null_update>::type
- type;
+ typedef typename tree_metadata_helper<__node_u, null_update>::type type;
};
-
} // namespace detail
} // namespace __gnu_pbds
-#endif // #ifndef PB_DS_TREE_NODE_METADATA_SELECTOR_HPP
+#endif // #ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP
+++ /dev/null
-// -*- 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 null_node_update_imp.hpp
- * Contains an implementation of null_node_update.
- */
-
-PB_DS_CLASS_T_DEC
-template<typename Const_Node_Iterator_,
- typename Node_Iterator_,
- class Cmp_Fn_,
- typename Allocator_>
-inline void
-PB_DS_CLASS_C_DEC::
-swap(null_tree_node_update< Const_Node_Iterator_, Node_Iterator_, Cmp_Fn_, Allocator_>& /*other*/)
-{ }
-
// warranty.
/**
- * @file order_statistics_imp.hpp
+ * @file tree_policy/order_statistics_imp.hpp
* Contains forward declarations for order_statistics_key
*/
find_by_order(size_type order)
{
node_iterator it = node_begin();
-
node_iterator end_it = node_end();
while (it != end_it)
{
node_iterator l_it = it.get_l_child();
-
- const size_type o = (l_it == end_it)?
- 0 :
- l_it.get_metadata();
+ const size_type o = (l_it == end_it)? 0 : l_it.get_metadata();
if (order == o)
- return (*it);
+ return *it;
else if (order < o)
it = l_it;
else
{
order -= o + 1;
-
it = it.get_r_child();
}
}
- return (PB_DS_BASE_C_DEC::end_iterator());
+ return base_type::end_iterator();
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order) const
-{
- return (const_cast<PB_DS_CLASS_C_DEC* >(this)->find_by_order(order));
-}
+{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-order_of_key(const_key_reference r_key) const
+order_of_key(key_const_reference r_key) const
{
- const_node_iterator it = node_begin();
-
- const_node_iterator end_it = node_end();
-
- const cmp_fn& r_cmp_fn =
- const_cast<PB_DS_CLASS_C_DEC* >(this)->get_cmp_fn();
+ node_const_iterator it = node_begin();
+ node_const_iterator end_it = node_end();
+ const cmp_fn& r_cmp_fn = const_cast<PB_DS_CLASS_C_DEC*>(this)->get_cmp_fn();
size_type ord = 0;
-
while (it != end_it)
{
- const_node_iterator l_it = it.get_l_child();
+ node_const_iterator l_it = it.get_l_child();
if (r_cmp_fn(r_key, this->extract_key(*(*it))))
it = l_it;
else if (r_cmp_fn(this->extract_key(*(*it)), r_key))
{
-
- ord += (l_it == end_it)?
- 1 :
- 1 + l_it.get_metadata();
-
+ ord += (l_it == end_it)? 1 : 1 + l_it.get_metadata();
it = it.get_r_child();
}
else
{
- ord += (l_it == end_it)?
- 0 :
- l_it.get_metadata();
-
+ ord += (l_it == end_it)? 0 : l_it.get_metadata();
it = end_it;
}
}
-
- return (ord);
+ return ord;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-operator()(node_iterator node_it, const_node_iterator end_nd_it) const
+operator()(node_iterator node_it, node_const_iterator end_nd_it) const
{
- node_iterator l_child_it = node_it.get_l_child();
- const size_type l_rank =(l_child_it == end_nd_it)? 0 : l_child_it.get_metadata();
+ node_iterator l_it = node_it.get_l_child();
+ const size_type l_rank = (l_it == end_nd_it) ? 0 : l_it.get_metadata();
- node_iterator r_child_it = node_it.get_r_child();
- const size_type r_rank =(r_child_it == end_nd_it)? 0 : r_child_it.get_metadata();
+ node_iterator r_it = node_it.get_r_child();
+ const size_type r_rank = (r_it == end_nd_it) ? 0 : r_it.get_metadata();
- const_cast<metadata_reference>(node_it.get_metadata())=
- 1 + l_rank + r_rank;
+ const_cast<metadata_reference>(node_it.get_metadata())= 1 + l_rank + r_rank;
}
PB_DS_CLASS_T_DEC
// warranty.
/**
- * @file sample_tree_node_update.hpp
+ * @file tree_policy/sample_tree_node_update.hpp
* Contains a samle node update functor.
*/
#ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
#define PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
-// A sample node updator.
-template<typename Const_Node_Iterator,
-
- class Node_Iterator,
-
- class Cmp_Fn,
-
- class Allocator
- >
-class sample_tree_node_update
+namespace __gnu_pbds
{
-
-public:
-
- // Metadata type.
- typedef std::size_t metadata_type;
-
-protected:
-
- // Default constructor.
- sample_tree_node_update();
-
- // Updates the rank of a node through a node_iterator node_it; end_nd_it is the end node iterator.
- inline void
- operator()(node_iterator node_it, const_node_iterator end_nd_it) const;
-
-};
-
+ /// A sample node updator.
+ template<typename Const_Node_Iter, typename Node_Iter, typename Cmp_Fn,
+ typename _Alloc>
+ class sample_tree_node_update
+ {
+ typedef std::size_t metadata_type;
+
+ // Default constructor.
+ sample_tree_node_update();
+
+ // Updates the rank of a node through a node_iterator node_it;
+ // end_nd_it is the end node iterator.
+ inline void
+ operator()(node_iterator node_it, node_const_iterator end_nd_it) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// warranty.
/**
- * @file tree_trace_base.hpp
+ * @file detail/tree_trace_base.hpp
* Contains tree-related policies.
*/
#ifdef PB_DS_TREE_TRACE
-#include <ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp>
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
+#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
namespace __gnu_pbds
{
-
namespace detail
{
-
#ifdef PB_DS_TREE_TRACE
#define PB_DS_CLASS_T_DEC \
- template< \
- class Const_Node_Iterator, \
- class Node_Iterator, \
- class Cmp_Fn, \
- bool Node_Based, \
- class Allocator>
+ template<typename Node_CItr, typename Node_Itr, \
+ typename Cmp_Fn, bool Node_Based, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- tree_trace_base< \
- Const_Node_Iterator, \
- Node_Iterator, \
- Cmp_Fn, \
- Node_Based, \
- Allocator>
-
-#define PB_DS_BASE_C_DEC \
- basic_tree_policy_base< \
- Const_Node_Iterator, \
- Node_Iterator, \
- Allocator>
-
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class Cmp_Fn,
- bool Node_Based,
- class Allocator>
- class tree_trace_base : private PB_DS_BASE_C_DEC
+ tree_trace_base<Node_CItr, Node_Itr, Cmp_Fn, \
+ Node_Based, _Alloc>
+
+#define PB_DS_TRACE_BASE \
+ branch_policy<Node_CItr, Node_Itr, _Alloc>
+
+ /// Tracing base class.
+ template<typename Node_CItr, typename Node_Itr,
+ typename Cmp_Fn, bool Node_Based, typename _Alloc>
+ class tree_trace_base : private PB_DS_TRACE_BASE
{
public:
void
trace() const;
private:
- typedef PB_DS_BASE_C_DEC base_type;
-
- typedef Const_Node_Iterator const_node_iterator;
+ typedef PB_DS_TRACE_BASE base_type;
+ typedef Node_CItr node_const_iterator;
+ typedef typename _Alloc::size_type size_type;
- typedef typename Allocator::size_type size_type;
-
- private:
void
- trace_node(const_node_iterator nd_it, size_type level) const;
+ trace_node(node_const_iterator, size_type) const;
virtual bool
empty() const = 0;
- virtual const_node_iterator
+ virtual node_const_iterator
node_begin() const = 0;
- virtual const_node_iterator
+ virtual node_const_iterator
node_end() const = 0;
static void
- print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,true>);
+ print_node_pointer(Node_CItr, integral_constant<int,true>);
static void
- print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,false>);
+ print_node_pointer(Node_CItr, integral_constant<int,false>);
template<typename Metadata_>
static void
- trace_it_metadata(Const_Node_Iterator nd_it, type_to_type<Metadata_>);
+ trace_it_metadata(Node_CItr, type_to_type<Metadata_>);
static void
- trace_it_metadata(Const_Node_Iterator, type_to_type<null_node_metadata>);
+ trace_it_metadata(Node_CItr, type_to_type<null_type>);
};
PB_DS_CLASS_T_DEC
trace() const
{
if (empty())
- return;
-
+ return;
trace_node(node_begin(), 0);
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- trace_node(const_node_iterator nd_it, size_type level) const
+ trace_node(node_const_iterator nd_it, size_type level) const
{
if (nd_it.get_r_child() != node_end())
- trace_node(nd_it.get_r_child(), level + 1);
+ trace_node(nd_it.get_r_child(), level + 1);
for (size_type i = 0; i < level; ++i)
- std::cerr << ' ';
+ std::cerr << ' ';
print_node_pointer(nd_it, integral_constant<int,Node_Based>());
std::cerr << base_type::extract_key(*(*nd_it));
- typedef
- type_to_type<
- typename const_node_iterator::metadata_type>
- m_type_ind_t;
+ typedef type_to_type<typename node_const_iterator::metadata_type>
+ m_type_ind_t;
trace_it_metadata(nd_it, m_type_ind_t());
std::cerr << std::endl;
if (nd_it.get_l_child() != node_end())
- trace_node(nd_it.get_l_child(), level + 1);
+ trace_node(nd_it.get_l_child(), level + 1);
}
PB_DS_CLASS_T_DEC
template<typename Metadata_>
void
PB_DS_CLASS_C_DEC::
- trace_it_metadata(Const_Node_Iterator nd_it, type_to_type<Metadata_>)
+ trace_it_metadata(Node_CItr nd_it, type_to_type<Metadata_>)
{
- std::cerr << " (" <<
- static_cast<unsigned long>(nd_it.get_metadata()) << ") ";
+ const unsigned long ul = static_cast<unsigned long>(nd_it.get_metadata());
+ std::cerr << " (" << ul << ") ";
}
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- trace_it_metadata(Const_Node_Iterator, type_to_type<null_node_metadata>)
+ trace_it_metadata(Node_CItr, type_to_type<null_type>)
{ }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,true>)
- {
- std::cerr << nd_it.m_p_nd << " ";
- }
+ print_node_pointer(Node_CItr nd_it, integral_constant<int,true>)
+ { std::cerr << nd_it.m_p_nd << " "; }
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
- print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,false>)
- {
- std::cerr <<* nd_it << " ";
- }
+ print_node_pointer(Node_CItr nd_it, integral_constant<int,false>)
+ { std::cerr << *nd_it << " "; }
#undef PB_DS_CLASS_T_DEC
-
#undef PB_DS_CLASS_C_DEC
-
-#undef PB_DS_BASE_C_DEC
-
+#undef PB_DS_TRACE_BASE
#endif // #ifdef PB_DS_TREE_TRACE
} // namespace detail
-
} // namespace __gnu_pbds
#endif // #ifdef PB_DS_TREE_TRACE
#endif // #ifndef PB_DS_TREE_TRACE_BASE_HPP
-
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// warranty.
/**
- * @file node_metadata_selector.hpp
+ * @file trie_policy/node_metadata_selector.hpp
* Contains an implementation class for tries.
*/
-#ifndef PB_DS_TRIE_NODE_METADATA_SELECTOR_HPP
-#define PB_DS_TRIE_NODE_METADATA_SELECTOR_HPP
+#ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
+#define PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
namespace detail
{
+ /// Trie metadata helper.
+ template<typename Node_Update, bool _BTp>
+ struct trie_metadata_helper;
- template<typename Node_Update, bool Null>
- struct trie_metadata_helper
- {
- typedef typename Node_Update::metadata_type type;
- };
+ template<typename Node_Update>
+ struct trie_metadata_helper<Node_Update, false>
+ {
+ typedef typename Node_Update::metadata_type type;
+ };
template<typename Node_Update>
- struct trie_metadata_helper<
- Node_Update,
- true>
- {
- typedef null_node_metadata type;
- };
+ struct trie_metadata_helper<Node_Update, true>
+ {
+ typedef null_type type;
+ };
+ /// Trie node metadata dispatch.
template<typename Key,
typename Data,
- class Cmp_Fn,
- template<typename Const_Node_Iterator,
- class Const_Iterator,
- class Cmp_Fn_,
- class Allocator_>
- class Node_Update,
- class Allocator>
- struct trie_node_metadata_selector
+ typename Cmp_Fn,
+ template<typename Node_CItr,
+ typename Const_Iterator,
+ typename Cmp_Fn_,
+ typename _Alloc_>
+ class Node_Update,
+ typename _Alloc>
+ struct trie_node_metadata_dispatch
{
private:
- typedef
- dumconst_node_iterator<
- Key,
- Data,
- Allocator>
- dumconst_node_it;
+ typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type;
+ typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u;
+ typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u;
enum
{
- null_update =
- is_same<
- Node_Update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator>,
- null_trie_node_update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator> >::value
+ null_update = is_same<__node_u, __nnode_u>::value
};
public:
- typedef
- typename trie_metadata_helper<
- Node_Update<
- dumconst_node_it,
- dumconst_node_it,
- Cmp_Fn,
- Allocator>,
- null_update>::type
- type;
+ typedef typename trie_metadata_helper<__node_u, null_update>::type type;
};
-
} // namespace detail
} // namespace __gnu_pbds
-#endif // #ifndef PB_DS_TRIE_NODE_METADATA_SELECTOR_HPP
+#endif // #ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP
+++ /dev/null
-// -*- 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 null_node_update_imp.hpp
- * Contains an implementation of null_node_update.
- */
-
-PB_DS_CLASS_T_DEC
-template<typename Const_Node_Iterator_,
- typename Node_Iterator_,
- class E_Access_Traits_,
- typename Allocator_>
-inline void
-PB_DS_CLASS_C_DEC::
-swap(null_trie_node_update< Const_Node_Iterator_, Node_Iterator_, E_Access_Traits_, Allocator_>& /*other*/)
-{ }
-
// warranty.
/**
- * @file order_statistics_imp.hpp
+ * @file trie_policy/order_statistics_imp.hpp
* Contains forward declarations for order_statistics_key
*/
find_by_order(size_type order)
{
if (empty())
- return (end());
+ return end();
++order;
-
node_iterator nd_it = node_begin();
while (true)
{
if (order > nd_it.get_metadata())
- return (++base_type::rightmost_it(nd_it));
+ return ++base_type::rightmost_it(nd_it);
const size_type num_children = nd_it.num_children();
-
if (num_children == 0)
- return (*nd_it);
+ return *nd_it;
for (size_type i = 0; i < num_children; ++i)
- {
+ {
node_iterator child_nd_it = nd_it.get_child(i);
-
if (order <= child_nd_it.get_metadata())
- {
+ {
i = num_children;
-
nd_it = child_nd_it;
- }
+ }
else
order -= child_nd_it.get_metadata();
- }
+ }
}
}
inline typename PB_DS_CLASS_C_DEC::const_iterator
PB_DS_CLASS_C_DEC::
find_by_order(size_type order) const
-{
- return (const_cast<PB_DS_CLASS_C_DEC* >(this)->find_by_order(order));
-}
+{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); }
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-order_of_key(const_key_reference r_key) const
+order_of_key(key_const_reference r_key) const
{
- const E_Access_Traits& r_traits =
- const_cast<PB_DS_CLASS_C_DEC* >(this)->get_e_access_traits();
+ const _ATraits& r_traits =
+ const_cast<PB_DS_CLASS_C_DEC* >(this)->get_access_traits();
- return (order_of_prefix(
- r_traits.begin(r_key),
- r_traits.end(r_key)));
+ return order_of_prefix(r_traits.begin(r_key), r_traits.end(r_key));
}
PB_DS_CLASS_T_DEC
inline typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-order_of_prefix(typename e_access_traits::const_iterator b, typename e_access_traits::const_iterator e) const
+order_of_prefix(typename access_traits::const_iterator b,
+ typename access_traits::const_iterator e) const
{
if (empty())
- return (0);
-
- const E_Access_Traits& r_traits =
- const_cast<PB_DS_CLASS_C_DEC* >(this)->get_e_access_traits();
-
- const_node_iterator nd_it = node_begin();
+ return 0;
- const_node_iterator end_nd_it = node_end();
+ const _ATraits& r_traits =
+ const_cast<PB_DS_CLASS_C_DEC*>(this)->get_access_traits();
+ node_const_iterator nd_it = node_begin();
+ node_const_iterator end_nd_it = node_end();
size_type ord = 0;
while (true)
{
const size_type num_children = nd_it.num_children();
-
if (num_children == 0)
- {
- const_key_reference r_key =
- base_type::extract_key(*(*nd_it));
-
- typename e_access_traits::const_iterator key_b =
+ {
+ key_const_reference r_key = base_type::extract_key(*(*nd_it));
+ typename access_traits::const_iterator key_b =
r_traits.begin(r_key);
- typename e_access_traits::const_iterator key_e =
+ typename access_traits::const_iterator key_e =
r_traits.end(r_key);
- return ((base_type::less( key_b, key_e, b, e, r_traits))?
- ord + 1 :
- ord);
- }
-
- const_node_iterator next_nd_it = end_nd_it;
+ return (base_type::less(key_b, key_e, b, e, r_traits)) ?
+ ord + 1 : ord;
+ }
+ node_const_iterator next_nd_it = end_nd_it;
size_type i = num_children - 1;
do
- {
- const_node_iterator child_nd_it = nd_it.get_child(i);
+ {
+ node_const_iterator child_nd_it = nd_it.get_child(i);
if (next_nd_it != end_nd_it)
ord += child_nd_it.get_metadata();
- else if (!base_type::less(
- b, e,
+ else if (!base_type::less(b, e,
child_nd_it.valid_prefix().first,
child_nd_it.valid_prefix().second,
r_traits))
next_nd_it = child_nd_it;
- }
+ }
while (i-- > 0);
if (next_nd_it == end_nd_it)
- return (ord);
+ return ord;
nd_it = next_nd_it;
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-operator()(node_iterator nd_it, const_node_iterator /*end_nd_it*/) const
+operator()(node_iterator nd_it, node_const_iterator /*end_nd_it*/) const
{
const size_type num_children = nd_it.num_children();
-
size_type children_rank = 0;
-
for (size_type i = 0; i < num_children; ++i)
children_rank += nd_it.get_child(i).get_metadata();
- const_cast<size_type& >(nd_it.get_metadata()) =(num_children == 0)? 1 : children_rank;
+ const size_type res = (num_children == 0) ? 1 : children_rank;
+ const_cast<size_type&>(nd_it.get_metadata()) = res;
}
-
-PB_DS_CLASS_T_DEC
-PB_DS_CLASS_C_DEC::
-~trie_order_statistics_node_update()
-{ }
// warranty.
/**
- * @file prefix_search_node_update_imp.hpp
+ * @file trie_policy/prefix_search_node_update_imp.hpp
* Contains an implementation of prefix_search_node_update.
*/
typename PB_DS_CLASS_C_DEC::const_iterator,
typename PB_DS_CLASS_C_DEC::const_iterator>
PB_DS_CLASS_C_DEC::
-prefix_range(const_key_reference r_key) const
+prefix_range(key_const_reference r_key) const
{
- const e_access_traits& r_traits = get_e_access_traits();
-
- return (prefix_range(
- r_traits.begin(r_key),
- r_traits.end(r_key)));
+ const access_traits& r_traits = get_access_traits();
+ return (prefix_range(r_traits.begin(r_key), r_traits.end(r_key)));
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::iterator,
typename PB_DS_CLASS_C_DEC::iterator>
PB_DS_CLASS_C_DEC::
-prefix_range(const_key_reference r_key)
+prefix_range(key_const_reference r_key)
{
- return (prefix_range(
- get_e_access_traits().begin(r_key),
- get_e_access_traits().end(r_key)));
+ return (prefix_range(get_access_traits().begin(r_key),
+ get_access_traits().end(r_key)));
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::const_iterator,
typename PB_DS_CLASS_C_DEC::const_iterator>
PB_DS_CLASS_C_DEC::
-prefix_range(typename e_access_traits::const_iterator b, typename e_access_traits::const_iterator e) const
+prefix_range(typename access_traits::const_iterator b,
+ typename access_traits::const_iterator e) const
{
const std::pair<iterator, iterator> non_const_ret =
const_cast<PB_DS_CLASS_C_DEC* >(this)->prefix_range(b, e);
- return (std::make_pair(
- const_iterator(non_const_ret.first),
+ return (std::make_pair(const_iterator(non_const_ret.first),
const_iterator(non_const_ret.second)));
}
typename PB_DS_CLASS_C_DEC::iterator,
typename PB_DS_CLASS_C_DEC::iterator>
PB_DS_CLASS_C_DEC::
-prefix_range(typename e_access_traits::const_iterator b, typename e_access_traits::const_iterator e)
+prefix_range(typename access_traits::const_iterator b,
+ typename access_traits::const_iterator e)
{
- Node_Iterator nd_it = node_begin();
- Node_Iterator end_nd_it = node_end();
-
- const e_access_traits& r_traits =
- get_e_access_traits();
+ Node_Itr nd_it = node_begin();
+ Node_Itr end_nd_it = node_end();
+ const access_traits& r_traits = get_access_traits();
const size_type given_range_length = std::distance(b, e);
while (true)
return (std::make_pair(end(), end()));
const size_type common_range_length =
- PB_DS_BASE_C_DEC::common_prefix_len(nd_it, b, e, r_traits);
+ base_type::common_prefix_len(nd_it, b, e, r_traits);
if (common_range_length >= given_range_length)
- {
+ {
iterator ret_b = this->leftmost_it(nd_it);
-
iterator ret_e = this->rightmost_it(nd_it);
-
return (std::make_pair(ret_b, ++ret_e));
- }
-
+ }
nd_it = next_child(nd_it, b, e, end_nd_it, r_traits);
}
}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::node_iterator
PB_DS_CLASS_C_DEC::
-next_child(node_iterator nd_it, typename e_access_traits::const_iterator b, typename e_access_traits::const_iterator e, node_iterator end_nd_it, const e_access_traits& r_traits)
+next_child(node_iterator nd_it, typename access_traits::const_iterator b,
+ typename access_traits::const_iterator e, node_iterator end_nd_it,
+ const access_traits& r_traits)
{
const size_type num_children = nd_it.num_children();
-
node_iterator ret = end_nd_it;
-
size_type max_length = 0;
-
for (size_type i = 0; i < num_children; ++i)
{
node_iterator pot = nd_it.get_child(i);
-
const size_type common_range_length =
- PB_DS_BASE_C_DEC::common_prefix_len( pot, b, e, r_traits);
+ base_type::common_prefix_len(pot, b, e, r_traits);
if (common_range_length > max_length)
- {
+ {
ret = pot;
-
max_length = common_range_length;
- }
+ }
}
-
return (ret);
}
PB_DS_CLASS_T_DEC
inline void
PB_DS_CLASS_C_DEC::
-operator()(node_iterator /*nd_it*/, const_node_iterator /*end_nd_it*/) const
+operator()(node_iterator /*nd_it*/, node_const_iterator /*end_nd_it*/) const
{ }
--- /dev/null
+// -*- C++ -*-
+
+// 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
+// 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 trie_policy/sample_trie_access_traits.hpp
+ * Contains a sample probe policy.
+ */
+
+#ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
+#define PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
+
+namespace __gnu_pbds
+{
+ /// A sample trie element access traits.
+ struct sample_trie_access_traits
+ {
+ typedef std::size_t size_type;
+ typedef std::string key_type;
+
+ typedef typename _Alloc::template rebind<key_type> __rebind_k;
+ typedef typename __rebind_k::other::const_reference key_const_reference;
+ typedef std::string::const_iterator const_iterator;
+
+ // Element type.
+ typedef char e_type;
+
+ enum
+ {
+ max_size = 4
+ };
+
+ // Returns a const_iterator to the first element of r_key.
+ inline static const_iterator
+ begin(key_const_reference);
+
+ // Returns a const_iterator to the after-last element of r_key.
+ inline static const_iterator
+ end(key_const_reference);
+
+ // Maps an element to a position.
+ inline static size_type
+ e_pos(e_type);
+ };
+}
+#endif // #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 sample_trie_e_access_traits.hpp
- * Contains a sample probe policy.
- */
-
-#ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
-#define PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
-
-// A sample trie element-access traits.
-class sample_trie_e_access_traits
-{
-
-public:
-
- // Size type.
- typedef std::size_t size_type;
-
- // Key type.
- typedef std::string key_type;
-
- // Const key reference type.
- typedef
- typename Allocator::template rebind<
- key_type>::other::const_reference
- const_key_reference;
-
- // Element const iterator type.
- typedef std::string::const_iterator const_iterator;
-
- // Element type.
- typedef char e_type;
-
- enum
- {
- max_size = 4
- };
-
-public:
-
- // Returns a const_iterator to the first element of r_key.
- inline static const_iterator
- begin(const_key_reference r_key);
-
- // Returns a const_iterator to the after-last element of r_key.
- inline static const_iterator
- end(const_key_reference r_key);
-
- // Maps an element to a position.
- inline static size_type
- e_pos(e_type e);
-
-};
-
-#endif // #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP
// warranty.
/**
- * @file sample_trie_node_update.hpp
+ * @file trie_policy/sample_trie_node_update.hpp
* Contains a samle node update functor.
*/
#ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
#define PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
-// A sample node updator.
-template<typename Const_Node_Iterator,
-
- class Node_Iterator,
-
- class E_Access_Traits,
-
- class Allocator
- >
-class sample_trie_node_update
+namespace __gnu_pbds
{
-
-public:
-
- // Metadata type.
- typedef std::size_t metadata_type;
-
-protected:
-
- // Default constructor.
- sample_trie_node_update();
-
- // Updates the rank of a node through a node_iterator node_it; end_nd_it is the end node iterator.
- inline void
- operator()(node_iterator node_it, const_node_iterator end_nd_it) const;
-
-};
-
+ /// A sample node updator.
+ template<typename Node_CItr, typename Node_Itr,
+ typename _ATraits, typename _Alloc>
+ class sample_trie_node_update
+ {
+ public:
+ typedef std::size_t metadata_type;
+
+ protected:
+ // Default constructor.
+ sample_trie_node_update();
+
+ // Updates the rank of a node through a node_iterator node_it;
+ // end_nd_it is the end node iterator.
+ inline void
+ operator()(node_iterator, node_const_iterator) const;
+ };
+}
#endif // #ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP
+++ /dev/null
-// -*- 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 string_trie_e_access_traits_imp.hpp
- * Contains a policy for extracting character positions from
- * a string for a vector-based PATRICIA tree
- */
-
-PB_DS_CLASS_T_DEC
-detail::integral_constant<int, Reverse> PB_DS_CLASS_C_DEC::s_rev_ind;
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::size_type
-PB_DS_CLASS_C_DEC::
-e_pos(e_type e)
-{
- return (static_cast<size_type>(e - min_e_val));
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-begin(const_key_reference r_key)
-{
- return (begin_imp(r_key, s_rev_ind));
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-end(const_key_reference r_key)
-{
- return (end_imp(r_key, s_rev_ind));
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-begin_imp(const_key_reference r_key, detail::false_type)
-{
- return (r_key.begin());
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-begin_imp(const_key_reference r_key, detail::true_type)
-{
- return (r_key.rbegin());
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-end_imp(const_key_reference r_key, detail::false_type)
-{
- return (r_key.end());
-}
-
-PB_DS_CLASS_T_DEC
-inline typename PB_DS_CLASS_C_DEC::const_iterator
-PB_DS_CLASS_C_DEC::
-end_imp(const_key_reference r_key, detail::true_type)
-{
- return (r_key.rend());
-}
// warranty.
/**
- * @file trie_policy_base.hpp
+ * @file trie_policy/trie_policy_base.hpp
* Contains an implementation of trie_policy_base.
*/
#ifndef PB_DS_TRIE_POLICY_BASE_HPP
#define PB_DS_TRIE_POLICY_BASE_HPP
-#include <ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp>
+#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
namespace __gnu_pbds
{
namespace detail
{
-
-#define PB_DS_CLASS_T_DEC \
- template< \
- class Const_Node_Iterator, \
- class Node_Iterator, \
- class E_Access_Traits, \
- typename Allocator>
-
-#define PB_DS_CLASS_C_DEC \
- trie_policy_base< \
- Const_Node_Iterator, \
- Node_Iterator, \
- E_Access_Traits, \
- Allocator>
-
-#define PB_DS_BASE_C_DEC \
- basic_tree_policy_base< \
- Const_Node_Iterator, \
- Node_Iterator, \
- Allocator>
-
- template<typename Const_Node_Iterator,
- class Node_Iterator,
- class E_Access_Traits,
- class Allocator>
- class trie_policy_base : public PB_DS_BASE_C_DEC
+ /// Base class for trie policies.
+ template<typename Node_CItr, typename Node_Itr,
+ typename _ATraits, typename _Alloc>
+ class trie_policy_base
+ : public branch_policy<Node_CItr, Node_Itr, _Alloc>
{
+ typedef branch_policy<Node_CItr, Node_Itr, _Alloc> base_type;
public:
-
- typedef E_Access_Traits e_access_traits;
-
- typedef Allocator allocator_type;
-
- typedef typename allocator_type::size_type size_type;
-
- typedef null_node_metadata metadata_type;
-
- typedef Const_Node_Iterator const_node_iterator;
-
- typedef Node_Iterator node_iterator;
-
- typedef typename const_node_iterator::value_type const_iterator;
-
- typedef typename node_iterator::value_type iterator;
-
- public:
-
- typedef typename PB_DS_BASE_C_DEC::key_type key_type;
-
- typedef
- typename PB_DS_BASE_C_DEC::const_key_reference
- const_key_reference;
+ typedef _ATraits access_traits;
+ typedef _Alloc allocator_type;
+ typedef typename allocator_type::size_type size_type;
+ typedef null_type metadata_type;
+ typedef Node_CItr node_const_iterator;
+ typedef Node_Itr node_iterator;
+ typedef typename node_const_iterator::value_type const_iterator;
+ typedef typename node_iterator::value_type iterator;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_const_reference key_const_reference;
protected:
-
virtual const_iterator
end() const = 0;
virtual iterator
end() = 0;
- virtual const_node_iterator
+ virtual node_const_iterator
node_begin() const = 0;
virtual node_iterator
node_begin() = 0;
- virtual const_node_iterator
+ virtual node_const_iterator
node_end() const = 0;
virtual node_iterator
node_end() = 0;
- virtual const e_access_traits&
- get_e_access_traits() const = 0;
+ virtual const access_traits&
+ get_access_traits() const = 0;
private:
- typedef
- std::pair<
- typename e_access_traits::const_iterator,
- typename e_access_traits::const_iterator>
- prefix_range_t;
-
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename access_traits::const_iterator e_const_iterator;
+ typedef std::pair<e_const_iterator, e_const_iterator> prefix_range_t;
protected:
static size_type
- common_prefix_len(node_iterator nd_it, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r, const e_access_traits& r_traits);
+ common_prefix_len(node_iterator, e_const_iterator,
+ e_const_iterator, const access_traits&);
static iterator
- leftmost_it(node_iterator nd_it);
+ leftmost_it(node_iterator);
static iterator
- rightmost_it(node_iterator nd_it);
+ rightmost_it(node_iterator);
static bool
- less(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r, const e_access_traits& r_traits);
+ less(e_const_iterator, e_const_iterator, e_const_iterator,
+ e_const_iterator, const access_traits&);
};
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Node_CItr, typename Node_Itr, \
+ typename _ATraits, typename _Alloc>
+
+#define PB_DS_CLASS_C_DEC \
+ trie_policy_base<Node_CItr, Node_Itr, _ATraits, _Alloc>
+
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
- common_prefix_len(node_iterator nd_it, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r, const e_access_traits& r_traits)
+ common_prefix_len(node_iterator nd_it, e_const_iterator b_r,
+ e_const_iterator e_r, const access_traits& r_traits)
{
prefix_range_t pref_range = nd_it.valid_prefix();
- typename e_access_traits::const_iterator b_l = pref_range.first;
- typename e_access_traits::const_iterator e_l = pref_range.second;
+ e_const_iterator b_l = pref_range.first;
+ e_const_iterator e_l = pref_range.second;
- const size_type range_length_l =
- std::distance(b_l, e_l);
-
- const size_type range_length_r =
- std::distance(b_r, e_r);
+ const size_type range_length_l = std::distance(b_l, e_l);
+ const size_type range_length_r = std::distance(b_r, e_r);
if (range_length_r < range_length_l)
{
std::swap(b_l, b_r);
-
std::swap(e_l, e_r);
}
size_type ret = 0;
-
while (b_l != e_l)
{
if (r_traits.e_pos(*b_l) != r_traits.e_pos(*b_r))
- return (ret);
+ return ret;
++ret;
-
++b_l;
-
++b_r;
}
- return (ret);
+ return ret;
}
PB_DS_CLASS_T_DEC
leftmost_it(node_iterator nd_it)
{
if (nd_it.num_children() == 0)
- return (*nd_it);
+ return *nd_it;
- return (leftmost_it(nd_it.get_child(0)));
+ return leftmost_it(nd_it.get_child(0));
}
PB_DS_CLASS_T_DEC
const size_type num_children = nd_it.num_children();
if (num_children == 0)
- return (*nd_it);
+ return *nd_it;
- return (rightmost_it(nd_it.get_child(num_children - 1)));
+ return rightmost_it(nd_it.get_child(num_children - 1));
}
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
- less(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r, const e_access_traits& r_traits)
+ less(e_const_iterator b_l, e_const_iterator e_l,
+ e_const_iterator b_r, e_const_iterator e_r,
+ const access_traits& r_traits)
{
while (b_l != e_l)
{
if (b_r == e_r)
- return (false);
-
- size_type l_pos =
- r_traits.e_pos(*b_l);
- size_type r_pos =
- r_traits.e_pos(*b_r);
+ return false;
+ size_type l_pos = r_traits.e_pos(*b_l);
+ size_type r_pos = r_traits.e_pos(*b_r);
if (l_pos != r_pos)
return (l_pos < r_pos);
++b_l;
++b_r;
}
-
- return (b_r != e_r);
+ return b_r != e_r;
}
#undef PB_DS_CLASS_T_DEC
-
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
-
} // namespace detail
} // namespace __gnu_pbds
#endif // #ifndef PB_DS_TRIE_POLICY_BASE_HPP
-
--- /dev/null
+// -*- 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 trie_policy/trie_string_access_traits_imp.hpp
+ * Contains a policy for extracting character positions from
+ * a string for a vector-based PATRICIA tree
+ */
+
+PB_DS_CLASS_T_DEC
+detail::integral_constant<int, Reverse> PB_DS_CLASS_C_DEC::s_rev_ind;
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::size_type
+PB_DS_CLASS_C_DEC::
+e_pos(e_type e)
+{
+ return (static_cast<size_type>(e - min_e_val));
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+begin(key_const_reference r_key)
+{
+ return (begin_imp(r_key, s_rev_ind));
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+end(key_const_reference r_key)
+{
+ return (end_imp(r_key, s_rev_ind));
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+begin_imp(key_const_reference r_key, detail::false_type)
+{
+ return (r_key.begin());
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+begin_imp(key_const_reference r_key, detail::true_type)
+{
+ return (r_key.rbegin());
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+end_imp(key_const_reference r_key, detail::false_type)
+{
+ return (r_key.end());
+}
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_iterator
+PB_DS_CLASS_C_DEC::
+end_imp(key_const_reference r_key, detail::true_type)
+{
+ return (r_key.rend());
+}
// warranty.
/**
- * @file type_utils.hpp
+ * @file detail/type_utils.hpp
* Contains utilities for handnling types. All of these classes are based on
* Modern C++ by Andrei Alxandrescu.
*/
// -*- 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
// warranty.
/**
- * @file types_traits.hpp
+ * @file detail/types_traits.hpp
* Contains a traits class of types used by containers.
*/
#ifndef PB_DS_TYPES_TRAITS_HPP
#define PB_DS_TYPES_TRAITS_HPP
-#include <ext/pb_ds/detail/basic_types.hpp>
+#include <algorithm>
+#include <utility>
+#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
#include <utility>
{
namespace detail
{
- template<typename Key, typename Mapped, typename Alloc, bool Store_Extra>
- struct vt_base_selector
- {
- typedef value_type_base<Key, Mapped, Alloc, Store_Extra> type;
- };
+ /// Primary template.
+ template<typename Key, typename Mapped>
+ struct no_throw_copies
+ {
+ static const bool __simple = is_simple<Key>::value
+ && is_simple<Mapped>::value;
+ typedef integral_constant<int, __simple> indicator;
+ };
+
+ /// Specialization.
+ template<typename Key>
+ struct no_throw_copies<Key, null_type>
+ {
+ typedef integral_constant<int, is_simple<Key>::value> indicator;
+ };
+
+
+ //@{
+ /**
+ * Data properties computation.
+ */
+
+ /// Stored value.
+ template<typename _Tv>
+ struct stored_value
+ {
+ typedef _Tv value_type;
+ value_type m_value;
+ };
+
+ /// Stored hash.
+ template<typename _Th>
+ struct stored_hash
+ {
+ typedef _Th hash_type;
+ hash_type m_hash;
+ };
+
+ /// Primary template for representation of stored data.
+ /// Two types of data can be stored: value and hash.
+ template<typename _Tv, typename _Th>
+ struct stored_data
+ : public stored_value<_Tv>, public stored_hash<_Th>
+ { };
+
+ /// Specialization for representation of stored data of just value type.
+ template<typename _Tv>
+ struct stored_data<_Tv, null_type>
+ : public stored_value<_Tv>
+ { };
+
+ /// Primary template.
+ template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
+ struct type_base;
+
+ /**
+ * Specialization of type_base for the case where the hash value
+ * is not stored alongside each value.
+ */
+ template<typename Key, typename Mapped, typename _Alloc>
+ struct type_base<Key, Mapped, _Alloc, false>
+ {
+ public:
+ typedef typename _Alloc::size_type size_type;
+
+ private:
+ typedef typename _Alloc::template rebind<Mapped> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef std::pair<const Key, Mapped> __value_type;
+ typedef typename _Alloc::template rebind<__value_type> __rebind_v;
+ typedef typename __rebind_v::other __rebind_va;
+
+ public:
+ typedef typename __rebind_ma::value_type mapped_type;
+ typedef typename __rebind_ma::pointer mapped_pointer;
+ typedef typename __rebind_ma::const_pointer mapped_const_pointer;
+ typedef typename __rebind_ma::reference mapped_reference;
+ typedef typename __rebind_ma::const_reference mapped_const_reference;
+
+ typedef typename __rebind_va::value_type value_type;
+ typedef typename __rebind_va::pointer pointer;
+ typedef typename __rebind_va::const_pointer const_pointer;
+ typedef typename __rebind_va::reference reference;
+ typedef typename __rebind_va::const_reference const_reference;
+
+ typedef stored_data<value_type, null_type> stored_data_type;
+ };
+
+ /**
+ * Specialization of type_base for the case where the hash value
+ * is stored alongside each value.
+ */
+ template<typename Key, typename Mapped, typename _Alloc>
+ struct type_base<Key, Mapped, _Alloc, true>
+ {
+ public:
+ typedef typename _Alloc::size_type size_type;
+
+ private:
+ typedef typename _Alloc::template rebind<Mapped> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef std::pair<const Key, Mapped> __value_type;
+ typedef typename _Alloc::template rebind<__value_type> __rebind_v;
+ typedef typename __rebind_v::other __rebind_va;
+
+ public:
+ typedef typename __rebind_ma::value_type mapped_type;
+ typedef typename __rebind_ma::pointer mapped_pointer;
+ typedef typename __rebind_ma::const_pointer mapped_const_pointer;
+ typedef typename __rebind_ma::reference mapped_reference;
+ typedef typename __rebind_ma::const_reference mapped_const_reference;
+
+ typedef typename __rebind_va::value_type value_type;
+ typedef typename __rebind_va::pointer pointer;
+ typedef typename __rebind_va::const_pointer const_pointer;
+ typedef typename __rebind_va::reference reference;
+ typedef typename __rebind_va::const_reference const_reference;
+
+ typedef stored_data<value_type, size_type> stored_data_type;
+ };
+
+
+ /**
+ * Specialization of type_base for the case where the hash value
+ * is not stored alongside each value.
+ */
+ template<typename Key, typename _Alloc>
+ struct type_base<Key, null_type, _Alloc, false>
+ {
+ public:
+ typedef typename _Alloc::size_type size_type;
+ typedef Key value_type;
+
+ private:
+ typedef typename _Alloc::template rebind<null_type> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef typename _Alloc::template rebind<value_type> __rebind_v;
+ typedef typename __rebind_v::other __rebind_va;
+
+ public:
+ typedef typename __rebind_ma::value_type mapped_type;
+ typedef typename __rebind_ma::pointer mapped_pointer;
+ typedef typename __rebind_ma::const_pointer mapped_const_pointer;
+ typedef typename __rebind_ma::reference mapped_reference;
+ typedef typename __rebind_ma::const_reference mapped_const_reference;
+
+ typedef typename __rebind_va::pointer pointer;
+ typedef typename __rebind_va::const_pointer const_pointer;
+ typedef typename __rebind_va::reference reference;
+ typedef typename __rebind_va::const_reference const_reference;
+
+ typedef stored_data<value_type, null_type> stored_data_type;
+
+ static null_type s_null_type;
+ };
+
+ template<typename Key, typename _Alloc>
+ null_type
+ type_base<Key, null_type, _Alloc, false>::s_null_type;
+
+
+ /**
+ * Specialization of type_base for the case where the hash value
+ * is stored alongside each value.
+ */
+ template<typename Key, typename _Alloc>
+ struct type_base<Key, null_type, _Alloc, true>
+ {
+ public:
+ typedef typename _Alloc::size_type size_type;
+ typedef Key value_type;
+
+ private:
+ typedef typename _Alloc::template rebind<null_type> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef typename _Alloc::template rebind<value_type> __rebind_v;
+ typedef typename __rebind_v::other __rebind_va;
+
+ public:
+ typedef typename __rebind_ma::value_type mapped_type;
+ typedef typename __rebind_ma::pointer mapped_pointer;
+ typedef typename __rebind_ma::const_pointer mapped_const_pointer;
+ typedef typename __rebind_ma::reference mapped_reference;
+ typedef typename __rebind_ma::const_reference mapped_const_reference;
+
+ typedef typename __rebind_va::pointer pointer;
+ typedef typename __rebind_va::const_pointer const_pointer;
+ typedef typename __rebind_va::reference reference;
+ typedef typename __rebind_va::const_reference const_reference;
+
+ typedef stored_data<value_type, size_type> stored_data_type;
+
+ static null_type s_null_type;
+ };
+
+ template<typename Key, typename _Alloc>
+ null_type
+ type_base<Key, null_type, _Alloc, true>::s_null_type;
+
+
+ /// Type base dispatch.
+ template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
+ struct type_dispatch
+ {
+ typedef type_base<Key, Mapped, _Alloc, Store_Hash> type;
+ };
+
+ /// Traits for abstract types.
+ template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
+ struct types_traits
+ : public type_dispatch<Key, Mapped, _Alloc, Store_Hash>::type
+ {
+ private:
+ typedef no_throw_copies<Key, Mapped> __nothrowcopy;
+ typedef typename _Alloc::template rebind<Key>::other __rebind_a;
+
+ public:
+ typedef typename _Alloc::size_type size_type;
+ typedef typename __rebind_a::value_type key_type;
+ typedef typename __rebind_a::pointer key_pointer;
+ typedef typename __rebind_a::const_pointer key_const_pointer;
+ typedef typename __rebind_a::reference key_reference;
+ typedef typename __rebind_a::const_reference key_const_reference;
+ typedef std::pair<size_type, size_type> comp_hash;
+ typedef integral_constant<int, Store_Hash> store_extra;
+ typedef typename __nothrowcopy::indicator no_throw_indicator;
- template<typename Key, typename Mapped, typename Alloc, bool Store_Extra>
- struct types_traits
- : public vt_base_selector<Key, Mapped, Alloc, Store_Extra>::type
- {
- typedef typename Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::value_type key_type;
- typedef typename key_allocator::pointer key_pointer;
- typedef typename key_allocator::const_pointer const_key_pointer;
- typedef typename key_allocator::reference key_reference;
- typedef typename key_allocator::const_reference const_key_reference;
- typedef typename Alloc::size_type size_type;
-
- // Extra value (used when the extra value is stored with each value).
- typedef std::pair<size_type, size_type> comp_hash;
-
- typedef integral_constant<int, Store_Extra> store_extra;
- store_extra m_store_extra_indicator;
-
- typedef typename no_throw_copies<Key, Mapped>::indicator no_throw_copies;
- no_throw_copies m_no_throw_copies_indicator;
+ store_extra m_store_extra_indicator;
+ no_throw_indicator m_no_throw_copies_indicator;
};
+ //@}
} // namespace detail
} // namespace __gnu_pbds
-#endif
+#endif
// warranty.
/**
- * @file const_iterator.hpp
+ * @file unordered_iterator/const_iterator.hpp
* Contains an iterator class used for const ranging over the elements of the
- * table.
+ * table.
*/
// Const range-type iterator.
class const_iterator_ :
- public const_point_iterator_
+ public point_const_iterator_
{
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 value_type_ value_type;
protected:
- typedef const_point_iterator_ base_type;
+ typedef point_const_iterator_ base_type;
protected:
* of a table.
* */
inline
- const_iterator_(const_pointer_ p_value, PB_DS_GEN_POS pos, const PB_DS_CLASS_C_DEC* p_tbl) : const_point_iterator_(p_value),
+ const_iterator_(const_pointer_ p_value, PB_DS_GEN_POS pos, const PB_DS_CLASS_C_DEC* p_tbl) : point_const_iterator_(p_value),
m_p_tbl(p_tbl),
m_pos(pos)
{ }
+++ /dev/null
-// -*- C++ -*-
-
-// 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
-// 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 const_point_iterator.hpp
- * Contains an iterator class returned by the tables' const find and insert
- * methods.
- */
-
-class point_iterator_;
-
-// Const point-type iterator.
-class const_point_iterator_
-{
-
-public:
-
- // Category.
- typedef trivial_iterator_tag iterator_category;
-
- // Difference type.
- typedef trivial_iterator_difference_type difference_type;
-
- // Iterator's value type.
- typedef value_type_ value_type;
-
- // Iterator's pointer type.
- typedef pointer_ pointer;
-
- // Iterator's const pointer type.
- typedef const_pointer_ const_pointer;
-
- // Iterator's reference type.
- typedef reference_ reference;
-
- // Iterator's const reference type.
- typedef const_reference_ const_reference;
-
-public:
-
- inline
- const_point_iterator_(const_pointer p_value) : m_p_value(p_value)
- { }
-
- // Default constructor.
- inline
- const_point_iterator_()
-
- : m_p_value(0)
- { }
-
- // Copy constructor.
- inline
- const_point_iterator_(const const_point_iterator_& other)
-
- : m_p_value(other.m_p_value)
- { }
-
- // Copy constructor.
- inline
- const_point_iterator_(const point_iterator_& other)
-
- : m_p_value(other.m_p_value)
- { }
-
- // Access.
- inline const_pointer
- operator->() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
-
- return (m_p_value);
- }
-
- // Access.
- inline const_reference
- operator*() const
- {
- _GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
-
- return (*m_p_value);
- }
-
- // Compares content to a different iterator object.
- inline bool
- operator==(const point_iterator_& other) const
- {
- return (m_p_value == other.m_p_value);
- }
-
- // Compares content to a different iterator object.
- inline bool
- operator==(const const_point_iterator_& other) const
- {
- return (m_p_value == other.m_p_value);
- }
-
- // Compares content (negatively) to a different iterator object.
- inline bool
- operator!=(const point_iterator_& other) const
- {
- return (m_p_value != other.m_p_value);
- }
-
- // Compares content (negatively) to a different iterator object.
- inline bool
- operator!=(const const_point_iterator_& other) const
- {
- return (m_p_value != other.m_p_value);
- }
-
-protected:
- const_pointer m_p_value;
-
- friend class point_iterator_;
-
- friend class PB_DS_CLASS_C_DEC;
-};
-
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 value_type_ value_type;
--- /dev/null
+// -*- C++ -*-
+
+// 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
+// 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 unordered_iterator/point_const_iterator.hpp
+ * Contains an iterator class returned by the tables' const find and insert
+ * methods.
+ */
+
+class point_iterator_;
+
+// Const point-type iterator.
+class point_const_iterator_
+{
+
+public:
+
+ // Category.
+ typedef trivial_iterator_tag iterator_category;
+
+ // Difference type.
+ typedef trivial_iterator_difference_type difference_type;
+
+ // Iterator's value type.
+ typedef value_type_ value_type;
+
+ // Iterator's pointer type.
+ typedef pointer_ pointer;
+
+ // Iterator's const pointer type.
+ typedef const_pointer_ const_pointer;
+
+ // Iterator's reference type.
+ typedef reference_ reference;
+
+ // Iterator's const reference type.
+ typedef const_reference_ const_reference;
+
+public:
+
+ inline
+ point_const_iterator_(const_pointer p_value) : m_p_value(p_value)
+ { }
+
+ // Default constructor.
+ inline
+ point_const_iterator_()
+
+ : m_p_value(0)
+ { }
+
+ // Copy constructor.
+ inline
+ point_const_iterator_(const point_const_iterator_& other)
+
+ : m_p_value(other.m_p_value)
+ { }
+
+ // Copy constructor.
+ inline
+ point_const_iterator_(const point_iterator_& other)
+
+ : m_p_value(other.m_p_value)
+ { }
+
+ // Access.
+ inline const_pointer
+ operator->() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
+
+ return (m_p_value);
+ }
+
+ // Access.
+ inline const_reference
+ operator*() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(m_p_value != 0);
+
+ return (*m_p_value);
+ }
+
+ // Compares content to a different iterator object.
+ inline bool
+ operator==(const point_iterator_& other) const
+ {
+ return (m_p_value == other.m_p_value);
+ }
+
+ // Compares content to a different iterator object.
+ inline bool
+ operator==(const point_const_iterator_& other) const
+ {
+ return (m_p_value == other.m_p_value);
+ }
+
+ // Compares content (negatively) to a different iterator object.
+ inline bool
+ operator!=(const point_iterator_& other) const
+ {
+ return (m_p_value != other.m_p_value);
+ }
+
+ // Compares content (negatively) to a different iterator object.
+ inline bool
+ operator!=(const point_const_iterator_& other) const
+ {
+ return (m_p_value != other.m_p_value);
+ }
+
+protected:
+ const_pointer m_p_value;
+
+ friend class point_iterator_;
+
+ friend class PB_DS_CLASS_C_DEC;
+};
+
// Compares content to a different iterator object.
inline bool
- operator==(const const_point_iterator_& other) const
+ operator==(const point_const_iterator_& other) const
{
return (m_p_value == other.m_p_value);
}
// Compares content (negatively) to a different iterator object.
inline bool
- operator!=(const const_point_iterator_& other) const
+ operator!=(const point_const_iterator_& other) const
{
return (m_p_value != other.m_p_value);
}
{ }
protected:
- friend class const_point_iterator_;
+ friend class point_const_iterator_;
friend class PB_DS_CLASS_C_DEC;
namespace __gnu_pbds
{
- // A null hash function, indicating that the combining hash function
- // is actually a ranged hash function.
- struct null_hash_fn
- { };
-
- // A null probe function, indicating that the combining probe
- // function is actually a ranged probe function.
- struct null_probe_fn
- { };
-
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC linear_probe_fn<Size_Type>
- // A probe sequence policy using fixed increments.
+ /// A probe sequence policy using fixed increments.
template<typename Size_Type = std::size_t>
class linear_probe_fn
{
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC quadratic_probe_fn<Size_Type>
- // A probe sequence policy using square increments.
+ /// A probe sequence policy using square increments.
template<typename Size_Type = std::size_t>
class quadratic_probe_fn
{
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC direct_mask_range_hashing<Size_Type>
- // A mask range-hashing class (uses a bit-mask).
+ /// A mask range-hashing class (uses a bit-mask).
template<typename Size_Type = std::size_t>
class direct_mask_range_hashing
: public detail::mask_based_range_hashing<Size_Type>
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC direct_mod_range_hashing<Size_Type>
- // A mod range-hashing class (uses the modulo function).
+ /// A mod range-hashing class (uses the modulo function).
template<typename Size_Type = std::size_t>
class direct_mod_range_hashing
: public detail::mod_based_range_hashing<Size_Type>
#define PB_DS_CLASS_C_DEC hash_load_check_resize_trigger<External_Load_Access, Size_Type>
#define PB_DS_SIZE_BASE_C_DEC detail::hash_load_check_resize_trigger_size_base<Size_Type, External_Load_Access>
- // A resize trigger policy based on a load check. It keeps the
- // load factor between some load factors load_min and load_max.
+ /// A resize trigger policy based on a load check. It keeps the
+ /// load factor between some load factors load_min and load_max.
template<bool External_Load_Access = false, typename Size_Type = std::size_t>
class hash_load_check_resize_trigger : private PB_DS_SIZE_BASE_C_DEC
{
#define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type>
#define PB_DS_CLASS_C_DEC cc_hash_max_collision_check_resize_trigger<External_Load_Access, Size_Type>
- // A resize trigger policy based on collision checks. It keeps the
- // simulated load factor lower than some given load factor.
+ /// A resize trigger policy based on collision checks. It keeps the
+ /// simulated load factor lower than some given load factor.
template<bool External_Load_Access = false, typename Size_Type = std::size_t>
class cc_hash_max_collision_check_resize_trigger
{
#define PB_DS_CLASS_T_DEC template<typename Size_Type>
#define PB_DS_CLASS_C_DEC hash_exponential_size_policy<Size_Type>
- // A size policy whose sequence of sizes form an exponential
- // sequence (typically powers of 2.
+ /// A size policy whose sequence of sizes form an exponential
+ /// sequence (typically powers of 2.
template<typename Size_Type = std::size_t>
class hash_exponential_size_policy
{
#define PB_DS_CLASS_T_DEC
#define PB_DS_CLASS_C_DEC hash_prime_size_policy
- // A size policy whose sequence of sizes form a nearly-exponential
- // sequence of primes.
+ /// A size policy whose sequence of sizes form a nearly-exponential
+ /// sequence of primes.
class hash_prime_size_policy
{
public:
#define PB_DS_CLASS_C_DEC hash_standard_resize_policy<Size_Policy, Trigger_Policy, External_Size_Access, Size_Type>
- // A resize policy which delegates operations to size and trigger policies.
+ /// A resize policy which delegates operations to size and trigger policies.
template<typename Size_Policy = hash_exponential_size_policy<>,
typename Trigger_Policy = hash_load_check_resize_trigger<>,
bool External_Size_Access = false,
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2007, 2009, 2010
+// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
#include <bits/c++config.h>
#include <cstdlib>
-#include <ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp>
+#include <ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
namespace __gnu_pbds
{
- // A null type that means that each link in a list-based container
- // does not actually need metadata.
- struct null_lu_metadata
- { };
-
-#define PB_DS_CLASS_T_DEC template<typename Allocator>
-#define PB_DS_CLASS_C_DEC move_to_front_lu_policy<Allocator>
-
- // A list-update policy that unconditionally moves elements to the
- // front of the list.
- template<typename Allocator = std::allocator<char> >
- class move_to_front_lu_policy
- {
- public:
- typedef Allocator allocator_type;
-
- // Metadata on which this functor operates.
- typedef null_lu_metadata metadata_type;
-
- // Reference to metadata on which this functor operates.
- typedef typename allocator_type::template rebind<metadata_type>::other metadata_rebind;
- typedef typename metadata_rebind::reference metadata_reference;
-
- // Creates a metadata object.
- metadata_type
- operator()() const;
-
- // Decides whether a metadata object should be moved to the front
- // of the list.
- inline bool
- operator()(metadata_reference r_metadata) const;
-
- private:
- static null_lu_metadata s_metadata;
- };
-
-#include <ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp>
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
-#define PB_DS_CLASS_T_DEC template<std::size_t Max_Count, class Allocator>
-#define PB_DS_CLASS_C_DEC counter_lu_policy<Max_Count, Allocator>
-
- // A list-update policy that moves elements to the front of the list
- // based on the counter algorithm.
- template<std::size_t Max_Count = 5,
- typename Allocator = std::allocator<char> >
- class counter_lu_policy
- : private detail::counter_lu_policy_base<typename Allocator::size_type>
- {
- public:
- typedef Allocator allocator_type;
-
- enum
- {
- max_count = Max_Count
- };
-
- typedef typename allocator_type::size_type size_type;
-
- // Metadata on which this functor operates.
- typedef detail::counter_lu_metadata<size_type> metadata_type;
-
- // Reference to metadata on which this functor operates.
- typedef typename Allocator::template rebind<metadata_type>::other metadata_rebind;
- typedef typename metadata_rebind::reference metadata_reference;
-
- // Creates a metadata object.
- metadata_type
- operator()() const;
-
- // Decides whether a metadata object should be moved to the front
- // of the list.
- bool
- operator()(metadata_reference r_metadata) const;
-
- private:
- typedef detail::counter_lu_policy_base<typename Allocator::size_type> base_type;
- };
-
-#include <ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp>
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
+ /**
+ * A list-update policy that unconditionally moves elements to the
+ * front of the list. A null type means that each link in a
+ * list-based container does not actually need metadata.
+ */
+ template<typename _Alloc = std::allocator<char> >
+ class lu_move_to_front_policy
+ {
+ public:
+ typedef _Alloc allocator_type;
+
+ // Metadata on which this functor operates.
+ typedef null_type metadata_type;
+
+ private:
+ typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
+
+ public:
+ // Reference to metadata on which this functor operates.
+ typedef typename __rebind_m::other::reference metadata_reference;
+
+ // Creates a metadata object.
+ metadata_type
+ operator()() const
+ { return s_metadata; }
+
+ // Decides whether a metadata object should be moved to the front
+ // of the list.
+ inline bool
+ operator()(metadata_reference r_metadata) const
+ { return true; }
+
+ private:
+ static null_type s_metadata;
+ };
+
+ /**
+ * A list-update policy that moves elements to the front of the
+ * list based on the counter algorithm.
+ */
+ template<std::size_t Max_Count = 5, typename _Alloc = std::allocator<char> >
+ class lu_counter_policy
+ : private detail::lu_counter_policy_base<typename _Alloc::size_type>
+ {
+ public:
+ typedef _Alloc allocator_type;
+ typedef typename allocator_type::size_type size_type;
+
+ enum
+ {
+ max_count = Max_Count
+ };
+
+ // Metadata on which this functor operates.
+ typedef detail::lu_counter_metadata<size_type> metadata_type;
+
+ private:
+ typedef detail::lu_counter_policy_base<size_type> base_type;
+ typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
+
+ public:
+ // Reference to metadata on which this functor operates.
+ typedef typename __rebind_m::other::reference metadata_reference;
+
+ // Creates a metadata object.
+ metadata_type
+ operator()() const
+ { return base_type::operator()(max_count); }
+
+ // Decides whether a metadata object should be moved to the front
+ // of the list.
+ bool
+ operator()(metadata_reference r_data) const
+ { return base_type::operator()(r_data, max_count); }
+ };
} // namespace __gnu_pbds
#endif
namespace __gnu_pbds
{
- // A priority queue.
- template<typename Value_Type,
- typename Cmp_Fn = std::less<Value_Type>,
+ /**
+ * @brief A priority queue composed of one specific heap policy.
+ * @ingroup pbds
+ */
+ template<typename _Tv,
+ typename Cmp_Fn = std::less<_Tv>,
typename Tag = pairing_heap_tag,
- typename Allocator = std::allocator<char> >
- class priority_queue
- : public detail::priority_queue_base_dispatch<Value_Type,
- Cmp_Fn,Tag,Allocator>::type
+ typename _Alloc = std::allocator<char> >
+ class priority_queue
+ : public detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type
{
- private:
- typedef typename
- detail::priority_queue_base_dispatch<Value_Type, Cmp_Fn,
- Tag, Allocator>::type base_type;
-
public:
- typedef Value_Type value_type;
+ typedef _Tv value_type;
typedef Cmp_Fn cmp_fn;
typedef Tag container_category;
- typedef Allocator allocator_type;
+ typedef _Alloc allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
- typedef typename allocator_type::template rebind<value_type>::other value_rebind;
- typedef typename value_rebind::reference reference;
- typedef typename value_rebind::const_reference const_reference;
- typedef typename value_rebind::pointer pointer;
- typedef typename value_rebind::const_pointer const_pointer;
+ private:
+ typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc,
+ Tag>::type
+ base_type;
+ typedef typename _Alloc::template rebind<_Tv> __rebind_v;
+ typedef typename __rebind_v::other __rebind_va;
+
+ public:
+ typedef typename __rebind_va::reference reference;
+ typedef typename __rebind_va::const_reference const_reference;
+ typedef typename __rebind_va::pointer pointer;
+ typedef typename __rebind_va::const_pointer const_pointer;
- 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::point_const_iterator point_const_iterator;
typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
priority_queue() { }
virtual
~priority_queue() { }
- priority_queue&
+ priority_queue&
operator=(const priority_queue& other)
{
if (this != &other)
};
} // namespace __gnu_pbds
-#endif
+#endif
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
/**
* @file tag_and_trait.hpp
* Contains tags and traits, e.g., ones describing underlying
- * data structures.
+ * data structures.
*/
#ifndef PB_DS_TAG_AND_TRAIT_HPP
*/
namespace __gnu_pbds
{
- // A trivial iterator tag. Signifies that the iterators has none of
- // the STL's movement abilities.
+ /** @defgroup pbds Policy-Based Data Structures
+ * @ingroup extensions
+ *
+ * This is a library of policy-based elementary data structures:
+ * associative containers and priority queues. It is designed for
+ * high-performance, flexibility, semantic safety, and conformance
+ * to the corresponding containers in std (except for some points
+ * where it differs by design).
+ *
+ * For details, see:
+ * http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html
+ *
+ * @{
+ */
+
+ /**
+ * @defgroup tags Tags
+ * @{
+ */
+ /// A trivial iterator tag. Signifies that the iterators has none of
+ /// the STL's movement abilities.
struct trivial_iterator_tag
{ };
- // Prohibit moving trivial iterators.
+ /// Prohibit moving trivial iterators.
typedef void trivial_iterator_difference_type;
- // Signifies a basic invalidation guarantee that any iterator,
- // pointer, or reference to a container object's mapped value type
- // is valid as long as the container is not modified.
+ /**
+ * @defgroup invalidation_tags Invalidation Guarantees.
+ * @ingroup tags
+ * @{
+ */
+
+ /**
+ * Signifies a basic invalidation guarantee that any iterator,
+ * pointer, or reference to a container object's mapped value type
+ * is valid as long as the container is not modified.
+ */
struct basic_invalidation_guarantee
{ };
- // Signifies an invalidation guarantee that includes all those of
- // its base, and additionally, that any point-type iterator,
- // pointer, or reference to a container object's mapped value type
- // is valid as long as its corresponding entry has not be erased,
- // regardless of modifications to the container object.
+ /**
+ * Signifies an invalidation guarantee that includes all those of
+ * its base, and additionally, that any point-type iterator,
+ * pointer, or reference to a container object's mapped value type
+ * is valid as long as its corresponding entry has not be erased,
+ * regardless of modifications to the container object.
+ */
struct point_invalidation_guarantee : public basic_invalidation_guarantee
{ };
- // Signifies an invalidation guarantee that includes all those of
- // its base, and additionally, that any range-type iterator
- // (including the returns of begin() and end()) is in the correct
- // relative positions to other range-type iterators as long as its
- // corresponding entry has not be erased, regardless of
- // modifications to the container object.
+ /**
+ * Signifies an invalidation guarantee that includes all those of
+ * its base, and additionally, that any range-type iterator
+ * (including the returns of begin() and end()) is in the correct
+ * relative positions to other range-type iterators as long as its
+ * corresponding entry has not be erased, regardless of
+ * modifications to the container object.
+ */
struct range_invalidation_guarantee : public point_invalidation_guarantee
{ };
+ //@}
- /// A mapped-policy indicating that an associative container is a set.
- // XXX should this be a trait of the form is_set<T> ??
- struct null_mapped_type { };
-
-
+ /**
+ * @defgroup ds_tags Data Structure Tag Hierarchy.
+ * @ingroup tags
+ * @{
+ */
/// Base data structure tag.
struct container_tag
{ };
- /// Basic string container, inclusive of strings, ropes, etc.
- struct string_tag : public container_tag { };
-
/// Basic sequence.
struct sequence_tag : public container_tag { };
+ /// Basic string container, inclusive of strings, ropes, etc.
+ struct string_tag : public sequence_tag { };
+
/// Basic associative-container.
- struct associative_container_tag : public container_tag { };
+ struct associative_tag : public container_tag { };
- /// Basic hash.
- struct basic_hash_tag : public associative_container_tag { };
+ /// Basic hash structure.
+ struct basic_hash_tag : public associative_tag { };
/// Collision-chaining hash.
struct cc_hash_tag : public basic_hash_tag { };
/// General-probing hash.
struct gp_hash_tag : public basic_hash_tag { };
- /// Basic tree.
- struct basic_tree_tag : public associative_container_tag { };
+ /// Basic branch structure.
+ struct basic_branch_tag : public associative_tag { };
/// tree.
- struct tree_tag : public basic_tree_tag { };
+ struct tree_tag : public basic_branch_tag { };
/// Red-black tree.
struct rb_tree_tag : public tree_tag { };
struct ov_tree_tag : public tree_tag { };
/// trie.
- struct trie_tag : public basic_tree_tag { };
+ struct trie_tag : public basic_branch_tag { };
/// PATRICIA trie.
struct pat_trie_tag : public trie_tag { };
/// List-update.
- struct list_update_tag : public associative_container_tag { };
+ struct list_update_tag : public associative_tag { };
/// Basic priority-queue.
struct priority_queue_tag : public container_tag { };
/// Thin heap.
struct thin_heap_tag : public priority_queue_tag { };
-
-
- /// Base traits type for containers.
- template<typename Tag>
- struct container_traits_base;
-
+ //@}
+ //@}
+
+
+ /**
+ * @defgroup traits Traits
+ * @{
+ */
+
+ /**
+ * @brief Represents no type, or absence of type, for template tricks.
+ *
+ * In a mapped-policy, indicates that an associative container is a set.
+ *
+ * In a list-update policy, indicates that each link does not need
+ * metadata.
+ *
+ * In a hash policy, indicates that the combining hash function
+ * is actually a ranged hash function.
+ *
+ * In a probe policy, indicates that the combining probe function
+ * is actually a ranged probe function.
+ */
+ struct null_type { };
+
+
+ /// Primary template, container traits base.
+ template<typename _Tag>
+ struct container_traits_base;
+
+ /// Specialization, cc hash.
template<>
struct container_traits_base<cc_hash_tag>
{
- typedef cc_hash_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef cc_hash_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
+ /// Specialization, gp hash.
template<>
struct container_traits_base<gp_hash_tag>
{
- typedef gp_hash_tag container_category;
- typedef basic_invalidation_guarantee invalidation_guarantee;
+ typedef gp_hash_tag container_category;
+ typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
+ order_preserving = false,
erase_can_throw = false,
split_join_can_throw = false,
reverse_iteration = false
};
};
+ /// Specialization, rb tree.
template<>
struct container_traits_base<rb_tree_tag>
{
- typedef rb_tree_tag container_category;
- typedef range_invalidation_guarantee invalidation_guarantee;
+ typedef rb_tree_tag container_category;
+ typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = true,
- erase_can_throw = false,
+ order_preserving = true,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = true
+ reverse_iteration = true
};
};
+ /// Specialization, splay tree.
template<>
struct container_traits_base<splay_tree_tag>
{
- typedef splay_tree_tag container_category;
- typedef range_invalidation_guarantee invalidation_guarantee;
+ typedef splay_tree_tag container_category;
+ typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = true,
- erase_can_throw = false,
- split_join_can_throw = false,
- reverse_iteration = true
+ order_preserving = true,
+ erase_can_throw = false,
+ split_join_can_throw = false,
+ reverse_iteration = true
};
};
+ /// Specialization, ov tree.
template<>
struct container_traits_base<ov_tree_tag>
{
- typedef ov_tree_tag container_category;
- typedef basic_invalidation_guarantee invalidation_guarantee;
+ typedef ov_tree_tag container_category;
+ typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = true,
- erase_can_throw = true,
- split_join_can_throw = true,
- reverse_iteration = false
+ order_preserving = true,
+ erase_can_throw = true,
+ split_join_can_throw = true,
+ reverse_iteration = false
};
};
+ /// Specialization, pat trie.
template<>
struct container_traits_base<pat_trie_tag>
{
- typedef pat_trie_tag container_category;
- typedef range_invalidation_guarantee invalidation_guarantee;
+ typedef pat_trie_tag container_category;
+ typedef range_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = true,
- erase_can_throw = false,
- split_join_can_throw = true,
- reverse_iteration = true
+ order_preserving = true,
+ erase_can_throw = false,
+ split_join_can_throw = true,
+ reverse_iteration = true
};
};
+ /// Specialization, list update.
template<>
struct container_traits_base<list_update_tag>
{
- typedef list_update_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef list_update_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = false
+ reverse_iteration = false
};
};
-
+ /// Specialization, pairing heap.
template<>
struct container_traits_base<pairing_heap_tag>
{
- typedef pairing_heap_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef pairing_heap_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = false
+ reverse_iteration = false
};
};
+ /// Specialization, thin heap.
template<>
struct container_traits_base<thin_heap_tag>
{
- typedef thin_heap_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef thin_heap_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = false
+ reverse_iteration = false
};
};
+ /// Specialization, binomial heap.
template<>
struct container_traits_base<binomial_heap_tag>
{
- typedef binomial_heap_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef binomial_heap_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = false
+ reverse_iteration = false
};
};
+ /// Specialization, rc binomial heap.
template<>
struct container_traits_base<rc_binomial_heap_tag>
{
- typedef rc_binomial_heap_tag container_category;
- typedef point_invalidation_guarantee invalidation_guarantee;
+ typedef rc_binomial_heap_tag container_category;
+ typedef point_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = false,
- reverse_iteration = false
+ reverse_iteration = false
};
};
+ /// Specialization, binary heap.
template<>
struct container_traits_base<binary_heap_tag>
{
- typedef binary_heap_tag container_category;
- typedef basic_invalidation_guarantee invalidation_guarantee;
+ typedef binary_heap_tag container_category;
+ typedef basic_invalidation_guarantee invalidation_guarantee;
enum
{
- order_preserving = false,
- erase_can_throw = false,
+ order_preserving = false,
+ erase_can_throw = false,
split_join_can_throw = true,
- reverse_iteration = false
+ reverse_iteration = false
};
};
- /// container_traits
+ /// Container traits.
// See Matt Austern for the name, S. Meyers MEFC++ #2, others.
template<typename Cntnr>
- struct container_traits
+ struct container_traits
: public container_traits_base<typename Cntnr::container_category>
{
- typedef Cntnr container_type;
- typedef typename Cntnr::container_category container_category;
- typedef container_traits_base<container_category> base_type;
+ typedef Cntnr container_type;
+ typedef typename Cntnr::container_category container_category;
+ typedef container_traits_base<container_category> base_type;
typedef typename base_type::invalidation_guarantee invalidation_guarantee;
enum
reverse_iteration = base_type::reverse_iteration
};
};
+ //@}
+
+
+ namespace detail
+ {
+ /// Dispatch mechanism, primary template for associative types.
+ template<typename Key, typename Mapped, typename _Alloc, typename Tag,
+ typename Policy_Tl = null_type>
+ struct container_base_dispatch;
+ } // namespace __detail
+ //@}
} // namespace __gnu_pbds
#endif
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
#include <bits/c++config.h>
#include <iterator>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp>
+#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp>
namespace __gnu_pbds
{
- // A null node updator, indicating that no node updates are required.
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- typename Cmp_Fn,
- typename Allocator>
- struct null_tree_node_update
- { };
-
#define PB_DS_CLASS_T_DEC \
- template<typename Const_Node_Iterator, class Node_Iterator, class Cmp_Fn, class Allocator>
+ template<typename Node_CItr, typename Node_Itr, typename Cmp_Fn, \
+ typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- tree_order_statistics_node_update<Const_Node_Iterator, Node_Iterator, Cmp_Fn, Allocator>
+ tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>
-#define PB_DS_BASE_C_DEC \
- detail::basic_tree_policy_base<Const_Node_Iterator, Node_Iterator, Allocator>
+#define PB_DS_BRANCH_POLICY_BASE \
+ detail::branch_policy<Node_CItr, Node_Itr, _Alloc>
- // Functor updating ranks of entrees.
- template<typename Const_Node_Iterator, typename Node_Iterator,
- typename Cmp_Fn, typename Allocator>
- class tree_order_statistics_node_update : private PB_DS_BASE_C_DEC
+ /// Functor updating ranks of entrees.
+ template<typename Node_CItr, typename Node_Itr,
+ typename Cmp_Fn, typename _Alloc>
+ class tree_order_statistics_node_update : private PB_DS_BRANCH_POLICY_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_BRANCH_POLICY_BASE base_type;
public:
- typedef Cmp_Fn cmp_fn;
- typedef Allocator allocator_type;
- typedef typename allocator_type::size_type size_type;
- typedef typename base_type::key_type key_type;
- typedef typename base_type::const_key_reference const_key_reference;
-
- typedef size_type metadata_type;
- typedef Const_Node_Iterator const_node_iterator;
- typedef Node_Iterator node_iterator;
- typedef typename const_node_iterator::value_type const_iterator;
- typedef typename node_iterator::value_type iterator;
+ typedef Cmp_Fn cmp_fn;
+ typedef _Alloc allocator_type;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_const_reference key_const_reference;
+
+ typedef size_type metadata_type;
+ typedef Node_CItr node_const_iterator;
+ typedef Node_Itr node_iterator;
+ typedef typename node_const_iterator::value_type const_iterator;
+ typedef typename node_iterator::value_type iterator;
// Finds an entry by __order. Returns a const_iterator to the
// entry with the __order order, or a const_iterator to the
// container object's end if order is at least the size of the
// container object.
inline const_iterator
- find_by_order(size_type order) const;
+ find_by_order(size_type) const;
// Finds an entry by __order. Returns an iterator to the entry
// with the __order order, or an iterator to the container
// object's end if order is at least the size of the container
// object.
inline iterator
- find_by_order(size_type order);
+ find_by_order(size_type);
// Returns the order of a key within a sequence. For exapmle, if
// r_key is the smallest key, this method will return 0; if r_key
// return 1; if r_key is a key larger than the largest key, this
// method will return the size of r_c.
inline size_type
- order_of_key(const_key_reference r_key) const;
+ order_of_key(key_const_reference) const;
private:
// Const reference to the container's value-type.
- typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::const_reference const_reference;
// Const pointer to the container's value-type.
- typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::const_pointer const_pointer;
+
+ typedef typename _Alloc::template rebind<metadata_type>::other __rebind_m;
- typedef typename allocator_type::template rebind<metadata_type>::other metadata_rebind;
// Const metadata reference.
- typedef typename metadata_rebind::const_reference const_metadata_reference;
+ typedef typename __rebind_m::const_reference metadata_const_reference;
// Metadata reference.
- typedef typename metadata_rebind::reference metadata_reference;
+ typedef typename __rebind_m::reference metadata_reference;
- // Returns the const_node_iterator associated with the tree's root node.
- virtual const_node_iterator
+ // Returns the node_const_iterator associated with the tree's root node.
+ virtual node_const_iterator
node_begin() const = 0;
// Returns the node_iterator associated with the tree's root node.
virtual node_iterator
node_begin() = 0;
- // Returns the const_node_iterator associated with a just-after leaf node.
- virtual const_node_iterator
+ // Returns the node_const_iterator associated with a just-after leaf node.
+ virtual node_const_iterator
node_end() const = 0;
// Returns the node_iterator associated with a just-after leaf node.
// Updates the rank of a node through a node_iterator node_it;
// end_nd_it is the end node iterator.
inline void
- operator()(node_iterator node_it, const_node_iterator end_nd_it) const;
+ operator()(node_iterator, node_const_iterator) const;
virtual
~tree_order_statistics_node_update();
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_BRANCH_POLICY_BASE
} // namespace __gnu_pbds
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
namespace __gnu_pbds
{
- // A null node updator, indicating that no node updates are required.
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- typename E_Access_Traits,
- typename Allocator>
- struct null_trie_node_update
- { };
-
-#define PB_DS_CLASS_T_DEC \
- template<typename String, typename String::value_type Min_E_Val, typename String::value_type Max_E_Val, bool Reverse, typename Allocator>
+#define PB_DS_CLASS_T_DEC \
+ template<typename String, typename String::value_type Min_E_Val, \
+ typename String::value_type Max_E_Val, bool Reverse, \
+ typename _Alloc>
-#define PB_DS_CLASS_C_DEC \
- string_trie_e_access_traits<String, Min_E_Val,Max_E_Val,Reverse,Allocator>
+#define PB_DS_CLASS_C_DEC \
+ trie_string_access_traits<String, Min_E_Val,Max_E_Val,Reverse,_Alloc>
- // Element access traits for string types.
+ /// Element access traits for string types.
template<typename String = std::string,
- typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min,
- typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max,
+ typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min,
+ typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max,
bool Reverse = false,
- typename Allocator = std::allocator<char> >
- struct string_trie_e_access_traits
+ typename _Alloc = std::allocator<char> >
+ struct trie_string_access_traits
{
public:
- typedef typename Allocator::size_type size_type;
- typedef String key_type;
- typedef typename Allocator::template rebind<key_type>::other key_rebind;
- typedef typename key_rebind::const_reference const_key_reference;
+ typedef typename _Alloc::size_type size_type;
+ typedef String key_type;
+ typedef typename _Alloc::template rebind<key_type> __rebind_k;
+ typedef typename __rebind_k::other::const_reference key_const_reference;
enum
{
};
// Element const iterator type.
- typedef typename detail::__conditional_type<Reverse, typename String::const_reverse_iterator, typename String::const_iterator>::__type const_iterator;
+ typedef typename detail::__conditional_type<Reverse, \
+ typename String::const_reverse_iterator, \
+ typename String::const_iterator>::__type const_iterator;
// Element type.
typedef typename std::iterator_traits<const_iterator>::value_type e_type;
PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2);
// Returns a const_iterator to the first element of
- // const_key_reference agumnet.
+ // key_const_reference agumnet.
inline static const_iterator
- begin(const_key_reference);
+ begin(key_const_reference);
// Returns a const_iterator to the after-last element of
- // const_key_reference argument.
+ // key_const_reference argument.
inline static const_iterator
- end(const_key_reference);
+ end(key_const_reference);
// Maps an element to a position.
inline static size_type
e_pos(e_type e);
private:
-
inline static const_iterator
- begin_imp(const_key_reference, detail::false_type);
+ begin_imp(key_const_reference, detail::false_type);
inline static const_iterator
- begin_imp(const_key_reference, detail::true_type);
+ begin_imp(key_const_reference, detail::true_type);
inline static const_iterator
- end_imp(const_key_reference, detail::false_type);
+ end_imp(key_const_reference, detail::false_type);
inline static const_iterator
- end_imp(const_key_reference, detail::true_type);
+ end_imp(key_const_reference, detail::true_type);
static detail::integral_constant<int, Reverse> s_rev_ind;
};
-#include <ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp>
+#include <ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_T_DEC \
- template<typename Const_Node_Iterator,typename Node_Iterator,class E_Access_Traits, typename Allocator>
+ template<typename Node_CItr,typename Node_Itr, \
+ typename _ATraits, typename _Alloc>
#define PB_DS_CLASS_C_DEC \
- trie_prefix_search_node_update<Const_Node_Iterator, Node_Iterator, E_Access_Traits,Allocator>
-
-#define PB_DS_BASE_C_DEC \
- detail::trie_policy_base<Const_Node_Iterator,Node_Iterator,E_Access_Traits, Allocator>
-
- // A node updator that allows tries to be searched for the range of
- // values that match a certain prefix.
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- typename E_Access_Traits,
- typename Allocator>
- class trie_prefix_search_node_update : private PB_DS_BASE_C_DEC
+ trie_prefix_search_node_update<Node_CItr, Node_Itr, \
+ _ATraits,_Alloc>
+
+#define PB_DS_TRIE_POLICY_BASE \
+ detail::trie_policy_base<Node_CItr,Node_Itr,_ATraits, _Alloc>
+
+ /// A node updator that allows tries to be searched for the range of
+ /// values that match a certain prefix.
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename _ATraits,
+ typename _Alloc>
+ class trie_prefix_search_node_update : private PB_DS_TRIE_POLICY_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_TRIE_POLICY_BASE base_type;
public:
- typedef typename base_type::key_type key_type;
- typedef typename base_type::const_key_reference const_key_reference;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_const_reference key_const_reference;
// Element access traits.
- typedef E_Access_Traits e_access_traits;
+ typedef _ATraits access_traits;
// Const element iterator.
- typedef typename e_access_traits::const_iterator const_e_iterator;
+ typedef typename access_traits::const_iterator a_const_iterator;
- // Allocator type.
- typedef Allocator allocator_type;
+ // _Alloc type.
+ typedef _Alloc allocator_type;
// Size type.
- typedef typename allocator_type::size_type size_type;
- typedef detail::null_node_metadata metadata_type;
- typedef Const_Node_Iterator const_node_iterator;
- typedef Node_Iterator node_iterator;
- typedef typename const_node_iterator::value_type const_iterator;
- typedef typename node_iterator::value_type iterator;
+ typedef typename allocator_type::size_type size_type;
+ typedef null_type metadata_type;
+ typedef Node_Itr node_iterator;
+ typedef Node_CItr node_const_iterator;
+ typedef typename node_iterator::value_type iterator;
+ typedef typename node_const_iterator::value_type const_iterator;
// Finds the const iterator range corresponding to all values
// whose prefixes match r_key.
std::pair<const_iterator, const_iterator>
- prefix_range(const_key_reference) const;
+ prefix_range(key_const_reference) const;
// Finds the iterator range corresponding to all values whose
// prefixes match r_key.
std::pair<iterator, iterator>
- prefix_range(const_key_reference);
+ prefix_range(key_const_reference);
// Finds the const iterator range corresponding to all values
// whose prefixes match [b, e).
std::pair<const_iterator, const_iterator>
- prefix_range(const_e_iterator, const_e_iterator) const;
+ prefix_range(a_const_iterator, a_const_iterator) const;
// Finds the iterator range corresponding to all values whose
// prefixes match [b, e).
std::pair<iterator, iterator>
- prefix_range(const_e_iterator, const_e_iterator);
+ prefix_range(a_const_iterator, a_const_iterator);
protected:
// Called to update a node's metadata.
inline void
- operator()(node_iterator node_it, const_node_iterator end_nd_it) const;
+ operator()(node_iterator node_it, node_const_iterator end_nd_it) const;
private:
+ node_iterator
+ next_child(node_iterator, a_const_iterator, a_const_iterator,
+ node_iterator, const access_traits&);
+
// Returns the const iterator associated with the just-after last element.
virtual const_iterator
end() const = 0;
virtual iterator
end() = 0;
- // Returns the const_node_iterator associated with the trie's root node.
- virtual const_node_iterator
+ // Returns the node_const_iterator associated with the trie's root node.
+ virtual node_const_iterator
node_begin() const = 0;
// Returns the node_iterator associated with the trie's root node.
virtual node_iterator
node_begin() = 0;
- // Returns the const_node_iterator associated with a just-after leaf node.
- virtual const_node_iterator
+ // Returns the node_const_iterator associated with a just-after leaf node.
+ virtual node_const_iterator
node_end() const = 0;
// Returns the node_iterator associated with a just-after leaf node.
node_end() = 0;
// Access to the cmp_fn object.
- virtual const e_access_traits&
- get_e_access_traits() const = 0;
-
- node_iterator
- next_child(node_iterator, const_e_iterator, const_e_iterator,
- node_iterator, const e_access_traits&);
+ virtual const access_traits&
+ get_access_traits() const = 0;
};
#include <ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp>
#undef PB_DS_CLASS_C_DEC
#define PB_DS_CLASS_C_DEC \
- trie_order_statistics_node_update<Const_Node_Iterator, Node_Iterator,E_Access_Traits, Allocator>
-
- // Functor updating ranks of entrees.
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- typename E_Access_Traits,
- typename Allocator>
- class trie_order_statistics_node_update : private PB_DS_BASE_C_DEC
+ trie_order_statistics_node_update<Node_CItr, Node_Itr, \
+ _ATraits, _Alloc>
+
+ /// Functor updating ranks of entrees.
+ template<typename Node_CItr,
+ typename Node_Itr,
+ typename _ATraits,
+ typename _Alloc>
+ class trie_order_statistics_node_update : private PB_DS_TRIE_POLICY_BASE
{
private:
- typedef PB_DS_BASE_C_DEC base_type;
+ typedef PB_DS_TRIE_POLICY_BASE base_type;
public:
- typedef E_Access_Traits e_access_traits;
- typedef typename e_access_traits::const_iterator const_e_iterator;
- typedef Allocator allocator_type;
- typedef typename allocator_type::size_type size_type;
- typedef typename base_type::key_type key_type;
- typedef typename base_type::const_key_reference const_key_reference;
-
- typedef size_type metadata_type;
- typedef Const_Node_Iterator const_node_iterator;
- typedef Node_Iterator node_iterator;
- typedef typename const_node_iterator::value_type const_iterator;
- typedef typename node_iterator::value_type iterator;
+ typedef _ATraits access_traits;
+ typedef typename access_traits::const_iterator a_const_iterator;
+ typedef _Alloc allocator_type;
+ typedef typename allocator_type::size_type size_type;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_const_reference key_const_reference;
+
+ typedef size_type metadata_type;
+ typedef Node_CItr node_const_iterator;
+ typedef Node_Itr node_iterator;
+ typedef typename node_const_iterator::value_type const_iterator;
+ typedef typename node_iterator::value_type iterator;
// Finds an entry by __order. Returns a const_iterator to the
// entry with the __order order, or a const_iterator to the
// return 1; if r_key is a key larger than the largest key, this
// method will return the size of r_c.
inline size_type
- order_of_key(const_key_reference) const;
+ order_of_key(key_const_reference) const;
// Returns the order of a prefix within a sequence. For exapmle,
// if [b, e] is the smallest prefix, this method will return 0; if
// will return 1; if r_key is a key larger than the largest key,
// this method will return the size of r_c.
inline size_type
- order_of_prefix(const_e_iterator, const_e_iterator) const;
+ order_of_prefix(a_const_iterator, a_const_iterator) const;
+
+ protected:
+ // Updates the rank of a node through a node_iterator node_it;
+ // end_nd_it is the end node iterator.
+ inline void
+ operator()(node_iterator, node_const_iterator) const;
private:
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::const_pointer const_pointer;
- typedef typename Allocator::template rebind<metadata_type>::other metadata_rebind;
- typedef typename metadata_rebind::const_reference const_metadata_reference;
- typedef typename metadata_rebind::reference metadata_reference;
+ typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
+ typedef typename __rebind_m::other __rebind_ma;
+ typedef typename __rebind_ma::const_reference metadata_const_reference;
+ typedef typename __rebind_ma::reference metadata_reference;
// Returns true if the container is empty.
virtual bool
virtual iterator
end() = 0;
- // Returns the const_node_iterator associated with the trie's root node.
- virtual const_node_iterator
+ // Returns the node_const_iterator associated with the trie's root node.
+ virtual node_const_iterator
node_begin() const = 0;
// Returns the node_iterator associated with the trie's root node.
virtual node_iterator
node_begin() = 0;
- // Returns the const_node_iterator associated with a just-after
+ // Returns the node_const_iterator associated with a just-after
// leaf node.
- virtual const_node_iterator
+ virtual node_const_iterator
node_end() const = 0;
// Returns the node_iterator associated with a just-after leaf node.
node_end() = 0;
// Access to the cmp_fn object.
- virtual e_access_traits&
- get_e_access_traits() = 0;
-
- protected:
- // Updates the rank of a node through a node_iterator node_it;
- // end_nd_it is the end node iterator.
- inline void
- operator()(node_iterator, const_node_iterator) const;
-
- // Destructor.
- virtual
- ~trie_order_statistics_node_update();
+ virtual access_traits&
+ get_access_traits() = 0;
};
#include <ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp>
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
-#undef PB_DS_BASE_C_DEC
+#undef PB_DS_TRIE_POLICY_BASE
} // namespace __gnu_pbds
return self.__mmap_re.sub('\nmmap_\n', cntnr)
def make(self, res, of_name):
- theme.output_format = 'png'
+ theme.output_format = 'svg'
theme.output_file = of_name
theme.scale_factor = 2
-# theme.default_font_size = 5
+ theme.default_font_family = "Gill Sans Std"
+ theme.default_line_width = 0.5
+ theme.default_font_size = 7
theme.use_color = 1
theme.reinitialize()
y_tick_interval = self.__get_y_tics(res)
- xaxis = axis.X(format = '/a90/hL%d',
+# xaxis = axis.X(format = '/a90/hL%d',
+ xaxis = axis.X(format = "/a-50{}%d",
tic_interval = 200,
label = res.x_label)
- yaxis = axis.Y(format = '%.2e',
+# yaxis = axis.Y(format = '%.2e',
+ yaxis = axis.Y(format = "/a-50{}%.2e",
tic_interval = y_tick_interval,
label = res.y_label)
legend_lines = len(res.cntnr_list)
legend_vloc = 50 + (legend_lines * 10)
+ legend_hloc = -0
ar = area.T(x_axis = xaxis, y_axis = yaxis,
- legend = legend.T(loc=(0,-legend_vloc),
+ legend = legend.T(loc=(legend_hloc,-legend_vloc),
frame_line_style=None,
inter_row_sep=2),
size=(240,110))
res_gtr = res_getter(test_infos_f_name)
res = res_gtr.get(res_dir, test_name)
png_mkr = png_maker()
- png_of_name = doc_dir + '/' + test_name + '_' + build_name + '.png'
+# png_of_name = doc_dir + '/' + test_name + '_' + build_name + '.png'
+ png_of_name = doc_dir + '/' + test_name + '_' + build_name + '.svg'
print png_of_name
png_mkr.make(res, png_of_name)
newname=`echo $f | sed 's/__detail_/__detail::/'`
mv $f $newname
done
+for f in *__gnu_pbds_detail_*; do
+ newname=`echo $f | sed 's/detail_/detail::/'`
+ mv $f $newname
+done
for f in *__parallel_*; do
newname=`echo $f | sed 's/__parallel_/__parallel::/'`
mv $f $newname
</test>
<test name = "text_find_timing_test_hash">
<file name = "text_find_timing.xml"></file>
- <cntnr name = "n_hash_map_ncah"></cntnr>
<cntnr name = "cc_hash_mask_exp_nea_lc_1div8_1div1_nsth_map"></cntnr>
<cntnr name = "cc_hash_mod_prime_nea_lc_1div8_1div1_nsth_map"></cntnr>
<cntnr name = "cc_hash_mask_exp_nea_lc_1div8_1div2_sth_map"></cntnr>
acc["a"][160] = 142;
// Verify the number of accounts that "a" holds.
- accounts_t::const_point_iterator it = acc.find("a");
+ accounts_t::point_const_iterator it = acc.find("a");
assert(it != acc.end());
assert(it->second.size() == 2);
// -*- 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
typedef typename Cntnr::const_iterator const_iterator;
for (const_iterator it = r_c.begin(); it != r_c.end(); ++it)
- cout <<* it << endl;
+ cout << *it << endl;
assert(!r_c.empty());
assert(r_c.size() == 10);
{
{
// Perform operations on a collision-chaining hash set.
- cc_hash_table<int, null_mapped_type> c;
+ cc_hash_table<int, null_type> c;
some_op_sequence(c);
}
{
// Perform operations on a general-probing hash set.
- gp_hash_table<int, null_mapped_type> c;
+ gp_hash_table<int, null_type> c;
some_op_sequence(c);
}
{
// Perform operations on a red-black tree set.
- tree<int, null_mapped_type> c;
+ tree<int, null_type> c;
some_op_sequence(c);
}
// Perform operations on a splay tree set.
tree<
int,
- null_mapped_type,
+ null_type,
less<int>,
splay_tree_tag> c;
some_op_sequence(c);
// Perform operations on a splay tree set.
tree<
int,
- null_mapped_type,
+ null_type,
less<int>,
ov_tree_tag> c;
some_op_sequence(c);
{
// Perform operations on a list-update set.
- list_update<int, null_mapped_type> c;
+ list_update<int, null_type> c;
some_op_sequence(c);
}
typedef
cc_hash_table<
string,
- null_mapped_type,
- null_hash_fn,
+ null_type,
+ null_type,
equal_to<string>,
simple_string_ranged_hash_fn>
set_t;
// Functor updating maximal endpoints of entries. Algorithm taken from
// "Introduction to Algorithms" by Cormen, Leiserson, and Rivest.
-template<class Const_Node_Iterator,
- class Node_Iterator,
+template<class Node_CItr,
+ class Node_Itr,
class Cmp_Fn,
- class Allocator>
+ typename _Alloc>
struct intervals_node_update
{
public:
bool
overlaps(const interval& r_interval)
{
- Const_Node_Iterator nd_it = node_begin();
- Const_Node_Iterator end_it = node_end();
+ Node_CItr nd_it = node_begin();
+ Node_CItr end_it = node_end();
while (nd_it != end_it)
{
return true;
// Get the const node iterator of the node's left child.
- Const_Node_Iterator l_nd_it = nd_it.get_l_child();
+ Node_CItr l_nd_it = nd_it.get_l_child();
// Calculate the maximal endpoint of the left child. If the
// node has no left child, then this is the node's maximal
// updated; end_nd_it is a const node iterator to a just-after leaf
// node.
inline void
- operator()(Node_Iterator nd_it, Const_Node_Iterator end_nd_it)
+ operator()(Node_Itr nd_it, Node_CItr end_nd_it)
{
// The left maximal endpoint is 0 if there is no left child.
const unsigned int l_max_endpoint =(nd_it.get_l_child() == end_nd_it)?
max((*nd_it)->second, max<unsigned int>(l_max_endpoint, r_max_endpoint));
}
- virtual Const_Node_Iterator
+ virtual Node_CItr
node_begin() const = 0;
- virtual Const_Node_Iterator
+ virtual Node_CItr
node_end() const = 0;
virtual
// Test a red-black tree.
some_op_sequence(tree<
interval,
- null_mapped_type,
+ null_type,
less<interval>,
rb_tree_tag,
intervals_node_update>());
// Test an ordered-vector tree.
some_op_sequence(tree<
interval,
- null_mapped_type,
+ null_type,
less<interval>,
ov_tree_tag,
intervals_node_update>());
// Test a splay tree.
some_op_sequence(tree<
interval,
- null_mapped_type,
+ null_type,
less<interval>,
splay_tree_tag,
intervals_node_update>());
typedef
tree<
int,
- null_mapped_type,
+ null_type,
less<int>,
rb_tree_tag,
// This policy updates nodes' metadata for order statistics.
typedef string dna_t;
// Following is an element access traits for a DNA string.
-struct dna_string_e_access_traits
+struct dna_string_access_traits
{
public:
typedef size_t size_type;
typedef dna_t key_type;
- typedef const key_type& const_key_reference;
+ typedef const key_type& key_const_reference;
typedef char e_type;
typedef string::const_iterator const_iterator;
// Returns a const_iterator to the firstelement of r_key.
inline static const_iterator
- begin(const_key_reference r_key)
+ begin(key_const_reference r_key)
{ return r_key.begin(); }
// Returns a const_iterator to the after-lastelement of r_key.
inline static const_iterator
- end(const_key_reference r_key)
+ end(key_const_reference r_key)
{ return r_key.end(); }
// Maps an element to a position.
};
// A PATRICIA trie with DNA string element-access traits.
-typedef dna_string_e_access_traits traits_type;
+typedef dna_string_access_traits traits_type;
typedef trie<dna_t, string, traits_type> trie_type;
int main()
// A PATRICIA trie with a prefix-search node-updator type. Note that
// since the node updator is trie_prefix_search_node_update, then the
// container includes its method prefix_range.
-typedef null_mapped_type mapped_type;
-typedef string_trie_e_access_traits<> cmp_fn;
+typedef null_type mapped_type;
+typedef trie_string_access_traits<> cmp_fn;
typedef pat_trie_tag tag_type;
typedef trie<string, mapped_type, cmp_fn, tag_type,
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file hash_data_map_rand.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on hash_data_map_rand
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by priority_queue_types, from
+// regression/common_type.hpp. This is just a compile-time list of 5
+// hash tables, with different policies for the type of table
+// (gp_hash, cc_hash), for the resize policies and probe functions.
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef std::equal_to<basic_type> equal_type;
+
+
+typedef __gnu_pbds::test::direct_mod_range_hashing_t_<allocator_type>
+ cprobe_type1;
+
+typedef __gnu_pbds::test::direct_mask_range_hashing_t_<allocator_type>
+ cprobe_type2;
+
+
+typedef __gnu_pbds::test::quadratic_probe_fn_t_<basic_type, allocator_type>
+ probe_type1;
+
+typedef __gnu_pbds::test::linear_probe_fn_t_<basic_type, allocator_type>
+ probe_type2;
+
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 2, false>
+ trigger_type1;
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 2, true>
+ trigger_type2;
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 1, false>
+ trigger_type3;
+
+typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, false>
+ trigger_type4;
+
+typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, true>
+ trigger_type5;
+
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_prime_size_policy_t_, trigger_type1, false, unsigned long> resize_type1;
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type2, true, unsigned long>
+ resize_type2;
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type5, false, unsigned long>
+ resize_type3;
+
+
+
+// gp_hash 1
+typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type1, probe_type1, resize_type1,
+ false, allocator_type>
+ gp_hash_type1;
+
+// gp_hash 2
+typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, probe_type2, resize_type2,
+ true, allocator_type>
+ gp_hash_type2;
+
+
+// cc_hash 1
+typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, resize_type3,
+ false, allocator_type>
+ cc_hash_type1;
+
+// cc_hash 2
+typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, resize_type2,
+ false, allocator_type>
+ cc_hash_type2;
+
+// cc_hash 3
+typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type1, resize_type1,
+ true, allocator_type>
+ cc_hash_type3;
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef cc_hash_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(gp_hash_type1());
+ test(gp_hash_type2());
+
+ test(cc_hash_type1());
+ test(cc_hash_type2());
+ test(cc_hash_type3());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file hash_data_map_rand.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on hash_data_map_rand
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by priority_queue_types, from
+// regression/common_type.hpp. This is just a compile-time list of 5
+// hash tables, with different policies for the type of table
+// (gp_hash, cc_hash), for the resize policies and probe functions.
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef std::equal_to<basic_type> equal_type;
+
+
+typedef __gnu_pbds::test::direct_mod_range_hashing_t_<allocator_type>
+ cprobe_type1;
+
+typedef __gnu_pbds::test::direct_mask_range_hashing_t_<allocator_type>
+ cprobe_type2;
+
+
+typedef __gnu_pbds::test::quadratic_probe_fn_t_<basic_type, allocator_type>
+ probe_type1;
+
+typedef __gnu_pbds::test::linear_probe_fn_t_<basic_type, allocator_type>
+ probe_type2;
+
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 2, false>
+ trigger_type1;
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 2, true>
+ trigger_type2;
+
+typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
+ 1, 8, 1, 1, false>
+ trigger_type3;
+
+typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, false>
+ trigger_type4;
+
+typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, true>
+ trigger_type5;
+
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_prime_size_policy_t_, trigger_type1, false, unsigned long> resize_type1;
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type2, true, unsigned long>
+ resize_type2;
+
+typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type5, false, unsigned long>
+ resize_type3;
+
+
+
+// gp_hash 1
+typedef gp_hash_table<basic_type, null_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type1, probe_type1, resize_type1,
+ false, allocator_type>
+ gp_hash_type1;
+
+// gp_hash 2
+typedef gp_hash_table<basic_type, null_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, probe_type2, resize_type2,
+ true, allocator_type>
+ gp_hash_type2;
+
+
+// cc_hash 1
+typedef cc_hash_table<basic_type, null_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, resize_type3,
+ false, allocator_type>
+ cc_hash_type1;
+
+// cc_hash 2
+typedef cc_hash_table<basic_type, null_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type2, resize_type2,
+ false, allocator_type>
+ cc_hash_type2;
+
+// cc_hash 3
+typedef cc_hash_table<basic_type, null_type, __gnu_pbds::test::hash,
+ equal_type, cprobe_type1, resize_type1,
+ true, allocator_type>
+ cc_hash_type3;
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef cc_hash_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(gp_hash_type1());
+ test(gp_hash_type2());
+
+ test(cc_hash_type1());
+ test(cc_hash_type2());
+ test(cc_hash_type3());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
// warranty.
/**
- * @file lu_data_map_rand_regression_test.cpp
+ * @file list_update_data_map_rand.cc
* Contains a random-operation test for maps and sets.
*/
--- /dev/null
+// { dg-require-time "" }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file list_update_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+// Debug version of the rand regression tests, based on list_update_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by list_update_types, from
+// regression/common_type.hpp. This is just a compile-time list of
+// list_update types, with different policies for the type of
+// update (lu_move_to_front_policy, lu_counter_policy).
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef std::equal_to<basic_type> equal_type;
+
+typedef __gnu_pbds::test::lu_move_to_front_policy_t_ policy_type1;
+
+typedef __gnu_pbds::test::lu_counter_policy_t_<allocator_type, 5u>
+ policy_type2;
+
+
+typedef list_update<basic_type, basic_type, equal_type, policy_type1,
+ allocator_type>
+ list_type1;
+
+typedef list_update<basic_type, basic_type, equal_type, policy_type2,
+ allocator_type>
+ list_type2;
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef list_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, 50, 10, .2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(list_type1());
+ test(list_type2());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file list_update_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+// Debug version of the rand regression tests, based on list_update_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by list_update_types, from
+// regression/common_type.hpp. This is just a compile-time list of
+// list_update types, with different policies for the type of
+// update (lu_move_to_front_policy, lu_counter_policy).
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef std::equal_to<basic_type> equal_type;
+
+typedef __gnu_pbds::test::lu_move_to_front_policy_t_ policy_type1;
+
+typedef __gnu_pbds::test::lu_counter_policy_t_<allocator_type, 5u>
+ policy_type2;
+
+
+typedef list_update<basic_type, null_type, equal_type, policy_type1,
+ allocator_type>
+ list_type1;
+
+typedef list_update<basic_type, null_type, equal_type, policy_type2,
+ allocator_type>
+ list_type2;
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef list_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, 50, 10, .2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(list_type1());
+ test(list_type2());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file priority_queue_rand_debug.cc
+ * Contains a random-operation test for priority queues.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/priority_queue/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 500
+#endif
+
+#ifndef KEYS
+# define KEYS 1000
+#endif
+
+// Debug version of the rand regression tests, based on priority_queue_rand
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by priority_queue_types, from
+// regression/common_type.hpp. This is just a compile-time list of 5
+// priority_queue types, with different policies for the type of priority_queue
+// (pairing_heap_tag, binomial_heap_tag, rc_binomial_heap_tag,
+// binary_heap_tag, thin_heap_tag).
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+
+// pairing_heap_tag
+typedef priority_queue<basic_type, std::less<basic_type>,
+ pairing_heap_tag, allocator_type>
+ priority_queue_type1;
+
+// binomial_heap_tag
+typedef priority_queue<basic_type, std::less<basic_type>,
+ binomial_heap_tag, allocator_type>
+ priority_queue_type2;
+
+// rc_binomial_heap_tag
+typedef priority_queue<basic_type, std::less<basic_type>,
+ rc_binomial_heap_tag, allocator_type>
+ priority_queue_type3;
+
+// binary_heap_tag
+typedef priority_queue<basic_type, std::less<basic_type>,
+ binary_heap_tag, allocator_type>
+ priority_queue_type4;
+
+// thin_heap_tag
+typedef priority_queue<basic_type, std::less<basic_type>,
+ thin_heap_tag, allocator_type>
+ priority_queue_type5;
+
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef priority_queue_type4 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+
+ }
+
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1304368293;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .1, .2, .001, 1, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(priority_queue_type1());
+ test(priority_queue_type2());
+ test(priority_queue_type3());
+ test(priority_queue_type4());
+ test(priority_queue_type5());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file tree_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on tree_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by tree_types, from
+// regression/common_type.hpp. This is just a compile-time list of 6
+// tree types, with different policies for the type of tree
+// (ov_tree_tag, rb_tree_tag, splay_tree_tag) and for the node
+// update (null_node_update, tree_order_statistics_node_update)
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+
+// ov_tree_tag
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ ov_tree_tag, null_node_update,
+ allocator_type> ov_tree_type1;
+
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ ov_tree_tag, tree_order_statistics_node_update,
+ allocator_type> ov_tree_type2;
+
+// rb_tree_tag
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ rb_tree_tag, null_node_update,
+ allocator_type> rb_tree_type1;
+
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ rb_tree_tag, tree_order_statistics_node_update,
+ allocator_type> rb_tree_type2;
+
+// splay_tree_tag
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ splay_tree_tag, null_node_update,
+ allocator_type> splay_tree_type1;
+
+typedef tree<basic_type, basic_type, std::less<basic_type>,
+ splay_tree_tag, tree_order_statistics_node_update,
+ allocator_type> splay_tree_type2;
+
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef ov_tree_type2 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(ov_tree_type1());
+ test(ov_tree_type2());
+ test(rb_tree_type1());
+ test(rb_tree_type2());
+ test(splay_tree_type1());
+ test(splay_tree_type2());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file tree_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on tree_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by tree_types, from
+// regression/common_type.hpp. This is just a compile-time list of 6
+// tree types, with different policies for the type of tree
+// (ov_tree_tag, rb_tree_tag, splay_tree_tag) and for the node
+// update (null_node_update, tree_order_statistics_node_update)
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+
+// ov_tree_tag
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ ov_tree_tag, null_node_update,
+ allocator_type> ov_tree_type1;
+
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ ov_tree_tag, tree_order_statistics_node_update,
+ allocator_type> ov_tree_type2;
+
+// rb_tree_tag
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ rb_tree_tag, null_node_update,
+ allocator_type> rb_tree_type1;
+
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ rb_tree_tag, tree_order_statistics_node_update,
+ allocator_type> rb_tree_type2;
+
+// splay_tree_tag
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ splay_tree_tag, null_node_update,
+ allocator_type> splay_tree_type1;
+
+typedef tree<basic_type, null_type, std::less<basic_type>,
+ splay_tree_tag, tree_order_statistics_node_update,
+ allocator_type> splay_tree_type2;
+
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef ov_tree_type2 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+ }
+
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(ov_tree_type1());
+ test(ov_tree_type2());
+ test(rb_tree_type1());
+ test(rb_tree_type2());
+ test(splay_tree_type1());
+ test(splay_tree_type2());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file trie_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on trie_no_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by tree_types, from
+// regression/common_type.hpp. This is just a compile-time list of 6
+// tree types, with different policies for the type of tree
+// (pat_trie_tag) and for the node
+// update (null_node_update, trie_order_statistics_node_update,
+// trie_order_staticstics_node_update, trie_prefix_search_node_update)
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef __gnu_pbds::trie_string_access_traits<basic_type, char('a'), 100,
+ false, allocator_type>
+ etraits_type;
+
+// pat_trie_tag
+typedef trie<basic_type, basic_type, etraits_type, pat_trie_tag,
+ null_node_update, allocator_type>
+ trie_type1;
+
+typedef trie<basic_type, basic_type, etraits_type, pat_trie_tag,
+ trie_order_statistics_node_update, allocator_type>
+ trie_type2;
+
+typedef trie<basic_type, basic_type, etraits_type, pat_trie_tag,
+ trie_prefix_search_node_update, allocator_type>
+ trie_type3;
+
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef trie_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+
+ }
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(trie_type1());
+ test(trie_type2());
+ test(trie_type3());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
--- /dev/null
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-D_GLIBCXX_DEBUG -DITERATIONS=5" { target simulator } }
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file trie_data_map_rand_debug.cc
+ * Contains a random-operation test for maps and sets, separated out.
+ */
+
+#define PB_DS_REGRESSION
+//#define PB_DS_REGRESSION_TRACE
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+#include <ext/throw_allocator.h>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+#ifndef ITERATIONS
+# define ITERATIONS 100
+#endif
+
+#ifndef KEYS
+# define KEYS 200
+#endif
+
+// Debug version of the rand regression tests, based on trie_no_data_map.
+
+// 1
+// Simplify things by unrolling the typelist of the different
+// container types into individual statements.
+//
+// Unroll the typelist represented by tree_types, from
+// regression/common_type.hpp. This is just a compile-time list of 6
+// tree types, with different policies for the type of tree
+// (pat_trie_tag) and for the node
+// update (null_node_update, trie_order_statistics_node_update,
+// trie_order_staticstics_node_update, trie_prefix_search_node_update)
+
+using namespace __gnu_pbds::test::detail;
+using namespace __gnu_pbds;
+typedef __gnu_pbds::test::basic_type basic_type;
+typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
+typedef __gnu_pbds::trie_string_access_traits<basic_type, char('a'), 100,
+ false, allocator_type>
+ etraits_type;
+
+// pat_trie_tag
+typedef trie<basic_type, null_type, etraits_type, pat_trie_tag,
+ null_node_update, allocator_type>
+ trie_type1;
+
+typedef trie<basic_type, null_type, etraits_type, pat_trie_tag,
+ trie_order_statistics_node_update, allocator_type>
+ trie_type2;
+
+typedef trie<basic_type, null_type, etraits_type, pat_trie_tag,
+ trie_prefix_search_node_update, allocator_type>
+ trie_type3;
+
+
+// 2
+// Specialize container_rand_regression_test for specific container
+// type and test function.
+
+#ifdef SPECIALIZE
+// For testing one specific container type.
+typedef trie_type1 test_type;
+
+void debug_break_here() { }
+
+namespace __gnu_pbds {
+ namespace test {
+ namespace detail {
+
+ template<>
+ void
+ container_rand_regression_test<test_type>::operator()()
+ {
+
+ }
+ }
+ }
+}
+#endif
+
+int
+main()
+{
+ // Set up the test object.
+ size_t sd = 1303948889;
+ rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
+
+ // 1
+ // Determine the problem container, function that fails.
+ test(trie_type1());
+ test(trie_type2());
+ test(trie_type3());
+
+#ifdef SPECIALIZE
+ // 2
+ // With specified problem container set test_type typedef
+ // appropriately above. Then, specialize operator()(), also
+ // above. Finally, run this below.
+ using namespace std;
+ test_type obj;
+ test(obj);
+#endif
+
+ return 0;
+}
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
erase_test<vec_t::const_iterator> tst(b, vn, vs, vm);
typedef __gnu_test::tracker_allocator<char> alloc_t;
{
- typedef hash_common_types<int, __gnu_pbds::null_mapped_type, int_hash, std::equal_to<int>, alloc_t>::performance_tl tl_t;
+ typedef hash_common_types<int, __gnu_pbds::null_type, int_hash, std::equal_to<int>, alloc_t>::performance_tl tl_t;
tl_t tl;
__gnu_cxx::typelist::apply(tst, tl);
try
{
xml_test_performance_formatter fmt("Size", "Memory (bytes)");
- typedef __gnu_test::tracker_allocator<char> callocator_type;
- typedef __gnu_test::tracker_allocator<char> sallocator_type;
- typedef std::basic_string<char, std::char_traits<char>, callocator_type> string_t;
+ typedef __gnu_test::tracker_allocator<char> allocator_type;
+ typedef std::char_traits<char> traits_type;
+ typedef std::basic_string<char, traits_type, allocator_type> string_t;
+ typedef std::less<string_t> cmp_type;
typedef std::vector<std::pair<string_t, char> > vec_t;
vec_t a_v(vm);
vec_t::const_iterator b = a_v.begin();
test_t tst(b, vn, vs, vm);
{
- typedef pq_common_types<string_t, std::less<string_t>, callocator_type>::performance_tl pq_tl_t;
+ typedef pq_common_types<string_t, cmp_type, allocator_type>::performance_tl pq_tl_t;
pq_tl_t tl;
__gnu_cxx::typelist::apply(tst, tl);
}
{
- typedef native_priority_queue<string_t, true, std::less<string_t>, sallocator_type> native_pq_t;
+ typedef native_priority_queue<string_t, true, cmp_type,
+ allocator_type> native_pq_t;
tst(native_pq_t());
}
{
- typedef native_priority_queue<string_t, false, std::less<string_t>, sallocator_type> native_pq_t;
+ typedef native_priority_queue<string_t, false, cmp_type,
+ allocator_type> native_pq_t;
tst(native_pq_t());
}
}
// -*- 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
{
typedef tree_order_statistics_test< true> test_t;
test_t tst(vn, vs, vm);
- typedef tree_common_types<int, __gnu_pbds::null_mapped_type, std::less<int>, __gnu_pbds::tree_order_statistics_node_update>::performance_tl tl_t;
+ typedef tree_common_types<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::tree_order_statistics_node_update>::performance_tl tl_t;
tl_t tl;
__gnu_cxx::typelist::apply(tst, tl);
}
// -*- 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
typedef tree_split_join_test<true> test_t;
test_t tst(vn, vs, vm);
- typedef tree_common_types<int, __gnu_pbds::null_mapped_type>::performance_tl tl_t;
+ typedef tree_common_types<int, __gnu_pbds::null_type>::performance_tl tl_t;
tl_t tl;
__gnu_cxx::typelist::apply(tst, tl);
}
// -*- 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
typename Data,
class Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
class Eq_Fn = std::equal_to<Key>,
- class Allocator = std::allocator<std::pair<const Key, Data> > >
+ typename _Alloc = std::allocator<std::pair<const Key, Data> > >
struct hash_common_types
{
private:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 8,
1, 2,
false>
typedef
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 8,
1, 2,
true>
typedef
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 8,
1, 1,
false>
typedef
__gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 2,
false>
no_access_half_max_col_check_check_resize_trigger_policy;
typedef
__gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 2,
true>
access_half_max_col_check_check_resize_trigger_policy;
- typedef __gnu_pbds::test::linear_probe_fn_t_<Key, Allocator> lin_p_t;
+ typedef __gnu_pbds::test::linear_probe_fn_t_<Key, _Alloc> lin_p_t;
- typedef __gnu_pbds::test::quadratic_probe_fn_t_<Key, Allocator> quad_p_t;
+ typedef __gnu_pbds::test::quadratic_probe_fn_t_<Key, _Alloc> quad_p_t;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
performance_cc_policy0;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
__gnu_pbds::test::hash_prime_size_policy_t_>::type
performance_cc_policy1;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
no_access_one_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
performance_cc_policy2;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc>,
no_access_one_load_check_resize_trigger_policy,
__gnu_pbds::test::hash_prime_size_policy_t_ >::type
performance_cc_policy3;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::true_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
performance_cc_policy4;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
no_access_half_max_col_check_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
performance_cc_policy5;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
access_half_max_col_check_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
regression_cc_policy0;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::false_type,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
regression_cc_policy1;
typedef
typename __gnu_cxx::typelist::create4<
__gnu_pbds::detail::true_type,
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_prime_size_policy_t_ >::type
+ __gnu_pbds::test::hash_prime_size_policy_t_>::type
regression_cc_policy2;
typedef
typename __gnu_cxx::typelist::create5<
__gnu_pbds::detail::false_type,
lin_p_t,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
performance_gp_policy0;
typedef
typename __gnu_cxx::typelist::create5<
__gnu_pbds::detail::false_type,
quad_p_t,
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc>,
no_access_half_load_check_resize_trigger_policy,
__gnu_pbds::test::hash_prime_size_policy_t_ >::type
performance_gp_policy1;
typename __gnu_cxx::typelist::create5<
__gnu_pbds::detail::false_type,
quad_p_t,
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc>,
access_half_load_check_resize_trigger_policy,
__gnu_pbds::test::hash_prime_size_policy_t_>::type
regression_gp_policy0;
typename __gnu_cxx::typelist::create5<
__gnu_pbds::detail::true_type,
lin_p_t,
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator>,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc>,
access_half_load_check_resize_trigger_policy,
- __gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator> >::type
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >::type
regression_gp_policy1;
typedef
{
private:
typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 0>::type
+ typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
store_hash_indicator;
enum
store_hash = store_hash_indicator::value
};
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 1>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 1>::type
comb_hash_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 2>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 2>::type
trigger_policy;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 3>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 3>::type
size_policy;
public:
Hash_Fn,
Eq_Fn,
comb_hash_fn,
- __gnu_pbds::hash_standard_resize_policy<
- size_policy,
- trigger_policy,
- false>,
+ __gnu_pbds::hash_standard_resize_policy<size_policy, trigger_policy,
+ false>,
store_hash,
- Allocator>
+ _Alloc>
type;
};
{
private:
typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 0>::type
+ typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
store_hash_indicator;
enum
store_hash = store_hash_indicator::value
};
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 1>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 1>::type
comb_hash_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 2>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 2>::type
trigger_policy;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 3>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 3>::type
size_policy;
public:
Hash_Fn,
Eq_Fn,
comb_hash_fn,
- __gnu_pbds::hash_standard_resize_policy<
- size_policy,
- trigger_policy,
- true>,
+ __gnu_pbds::hash_standard_resize_policy<size_policy, trigger_policy,
+ true>,
store_hash,
- Allocator>
+ _Alloc>
type;
};
struct no_access_generic_gp_hash_table_t
{
private:
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 0>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
store_hash_indicator;
enum
store_hash = store_hash_indicator::value
};
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 1>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 1>::type
probe_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 2>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 2>::type
comb_probe_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 3>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 3>::type
trigger_policy;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 4>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 4>::type
size_policy;
public:
Eq_Fn,
comb_probe_fn,
probe_fn,
- __gnu_pbds::hash_standard_resize_policy<
- size_policy,
- trigger_policy,
- false>,
+ __gnu_pbds::hash_standard_resize_policy<size_policy, trigger_policy,
+ false>,
store_hash,
- Allocator>
+ _Alloc>
type;
};
struct access_generic_gp_hash_table_t
{
private:
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 0>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
store_hash_indicator;
enum
store_hash = store_hash_indicator::value
};
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 1>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 1>::type
probe_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 2>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 2>::type
comb_probe_fn;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 3>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 3>::type
trigger_policy;
- typedef
- typename __gnu_cxx::typelist::at_index<
- Policy_Tl, 4>::type
+ typedef typename __gnu_cxx::typelist::at_index<Policy_Tl, 4>::type
size_policy;
public:
Eq_Fn,
comb_probe_fn,
probe_fn,
- __gnu_pbds::hash_standard_resize_policy<
- size_policy,
- trigger_policy,
- true>,
+ __gnu_pbds::hash_standard_resize_policy<size_policy, trigger_policy,
+ true>,
store_hash,
- Allocator>
+ _Alloc>
type;
};
class Comb_Probe_Fn_TL,
class Eq_Fn =
std::equal_to<Key>,
- class Allocator =
- std::allocator<
- std::pair<
- const Key,
- Data> > >
+ typename _Alloc = std::allocator<std::pair<const Key, Data> > >
struct ranged_hash_common_types
{
private:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 8,
1, 2,
false>
typedef
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
1, 8,
1, 1,
false>
typedef
__gnu_pbds::hash_standard_resize_policy<
__gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator>,
+ _Alloc>,
no_access_half_load_check_resize_trigger_policy>
mask_half_resize_policy_t;
typedef
__gnu_pbds::hash_standard_resize_policy<
__gnu_pbds::test::hash_exponential_size_policy_t_<
- Allocator>,
+ _Alloc>,
no_access_one_load_check_resize_trigger_policy>
mask_one_resize_policy_t;
template<typename Comb_Hash_Fn_>
struct half_resize_policy_selector;
- template<typename Allocator_>
- struct half_resize_policy_selector<
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator_> >
+ template<typename _Alloc_>
+ struct half_resize_policy_selector<__gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc_> >
{
typedef mask_half_resize_policy_t type;
};
- template<typename Allocator_>
- struct half_resize_policy_selector<
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator_> >
+ template<typename _Alloc_>
+ struct half_resize_policy_selector<__gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc_> >
{
typedef mod_half_resize_policy_t type;
};
template<typename Comb_Hash_Fn_>
struct one_resize_policy_selector;
- template<typename Allocator_>
- struct one_resize_policy_selector<
- __gnu_pbds::test::direct_mask_range_hashing_t_<
- Allocator_> >
+ template<typename _Alloc_>
+ struct one_resize_policy_selector<__gnu_pbds::test::direct_mask_range_hashing_t_<_Alloc_> >
{
typedef mask_one_resize_policy_t type;
};
- template<typename Allocator_>
- struct one_resize_policy_selector<
- __gnu_pbds::test::direct_mod_range_hashing_t_<
- Allocator_> >
+ template<typename _Alloc_>
+ struct one_resize_policy_selector<__gnu_pbds::test::direct_mod_range_hashing_t_<_Alloc_> >
{
typedef mod_one_resize_policy_t type;
};
__gnu_pbds::cc_hash_table<
Key,
Data,
- __gnu_pbds::null_hash_fn,
+ __gnu_pbds::null_type,
Eq_Fn,
Comb_Hash_Fn,
- typename one_resize_policy_selector<
- typename Comb_Hash_Fn::comb_fn>::type,
- false,
- Allocator>
+ typename one_resize_policy_selector<typename Comb_Hash_Fn::comb_fn>::type,
+ false, _Alloc>
type;
};
__gnu_pbds::gp_hash_table<
Key,
Data,
- __gnu_pbds::null_hash_fn,
+ __gnu_pbds::null_type,
Eq_Fn,
Comb_Probe_Fn,
- __gnu_pbds::null_probe_fn,
- typename half_resize_policy_selector<
- typename Comb_Probe_Fn::comb_fn>::type,
+ __gnu_pbds::null_type,
+ typename half_resize_policy_selector<typename Comb_Probe_Fn::comb_fn>::type,
false,
- Allocator>
+ _Alloc>
type;
};
};
template<typename Key, typename Data, class Eq_Fn = std::equal_to<Key>,
- class Allocator =
- std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class lu_common_types
{
private:
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
- typedef __gnu_pbds::test::move_to_front_lu_policy_t_ mtf_u;
+ typedef __gnu_pbds::test::lu_move_to_front_policy_t_ mtf_u;
- typedef __gnu_pbds::test::counter_lu_policy_t_<Allocator, 5> cnt_5_u;
+ typedef __gnu_pbds::test::lu_counter_policy_t_<_Alloc, 5> cnt_5_u;
typedef typename __gnu_cxx::typelist::create1<mtf_u>::type lu_policy0;
public:
typedef
- __gnu_pbds::list_update<Key, Data, Eq_Fn, update_policy_t, Allocator>
+ __gnu_pbds::list_update<Key, Data, Eq_Fn, update_policy_t, _Alloc>
type;
};
typedef
- typename __gnu_cxx::typelist::transform<
- lu_policies,
+ typename __gnu_cxx::typelist::transform<lu_policies,
generic_list_update_t>::type
lu_types;
typedef
- typename __gnu_cxx::typelist::at_index<
- lu_types,
- 0>::type
+ typename __gnu_cxx::typelist::at_index<lu_types, 0>::type
min_lu_type;
public:
};
template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
- template<typename Const_Node_Iterator,
- class Node_Iterator,
+ template<typename Node_CItr,
+ class Node_Itr,
class Cmp_Fn_,
- class Allocator_>
- class Node_Update = __gnu_pbds::null_tree_node_update,
- class Allocator = std::allocator<std::pair<const Key, Data> > >
+ typename _Alloc_>
+ class Node_Update = __gnu_pbds::null_node_update,
+ typename _Alloc = std::allocator<std::pair<const Key, Data> > >
struct tree_common_types
{
private:
Cmp_Fn,
__gnu_pbds::ov_tree_tag,
Node_Update,
- Allocator>
+ _Alloc>
ov_tree_assoc_container_t;
typedef
Cmp_Fn,
__gnu_pbds::rb_tree_tag,
Node_Update,
- Allocator>
+ _Alloc>
rb_tree_assoc_container_t;
typedef
Cmp_Fn,
__gnu_pbds::splay_tree_tag,
Node_Update,
- Allocator>
+ _Alloc>
splay_tree_assoc_container_t;
public:
template<typename Key,
typename Data,
- class E_Access_Traits =
- typename __gnu_pbds::detail::default_trie_e_access_traits<Key>::type,
+ class _ATraits =
+ typename __gnu_pbds::detail::default_trie_access_traits<Key>::type,
class Tag = __gnu_pbds::pat_trie_tag,
- template<typename Const_Node_Iterator,
- typename Node_Iterator,
- class E_Access_Traits_,
- typename Allocator_>
- class Node_Update = __gnu_pbds::null_trie_node_update,
- class Allocator = std::allocator<char> >
+ template<typename Node_CItr,
+ typename Node_Itr,
+ class _ATraits_,
+ typename _Alloc_>
+ class Node_Update = __gnu_pbds::null_node_update,
+ typename _Alloc = std::allocator<char> >
class trie_common_types
{
private:
- typedef __gnu_pbds::trie<Key, Data, E_Access_Traits, Tag, Node_Update, Allocator> type;
+ typedef __gnu_pbds::trie<Key, Data, _ATraits, Tag, Node_Update, _Alloc> type;
public:
typedef typename __gnu_cxx::typelist::create1<type>::type performance_tl;
// -*- 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
const std::string node_update_str =
make_xml_tag("Node_Update",
"value",(tree_supports_order_statistics<Cntnr>::value ?
- "tree_order_statistics_node_update" : "null_tree_node_update"));
+ "tree_order_statistics_node_update" : "null_node_update"));
return make_xml_tag("type", "value", "tree", category_str + node_update_str);
}
else if (trie_supports_prefix_search<Cntnr>::value)
s = "trie_prefix_search_node_update";
else
- s = "null_trie_node_update";
+ s = "null_node_update";
std::string node_s = make_xml_tag("Node_Update", "value", s);
return make_xml_tag("type", "value", "trie", category_s + node_s);
}
struct lu_policy_string_form;
template<>
- struct lu_policy_string_form<move_to_front_lu_policy_t_>
+ struct lu_policy_string_form<lu_move_to_front_policy_t_>
{
static std::string
name()
desc()
{
return make_xml_tag("Update_Policy", "value",
- "move_to_front_lu_policy");
+ "lu_move_to_front_policy");
}
};
- template<typename Allocator, typename Allocator::size_type Max_Count>
- struct lu_policy_string_form<counter_lu_policy_t_<Allocator, Max_Count> >
+ template<typename _Alloc, typename _Alloc::size_type Max_Count>
+ struct lu_policy_string_form<lu_counter_policy_t_<_Alloc, Max_Count> >
{
static std::string
name()
static std::string
desc()
{
- return (make_xml_tag("Update_Policy", "value", "counter_lu_policy",
+ return (make_xml_tag("Update_Policy", "value", "lu_counter_policy",
"Max_Count", Max_Count));
}
};
template<typename Probe_Fn>
struct probe_fn_string_form;
- template<typename Key, class Allocator>
- struct probe_fn_string_form<linear_probe_fn_t_<Key, Allocator> >
+ template<typename Key, typename _Alloc>
+ struct probe_fn_string_form<linear_probe_fn_t_<Key, _Alloc> >
{
static std::string
name()
{ return make_xml_tag("Probe_Fn", "value", "linear_probe_fn"); }
};
- template<typename Key, class Allocator>
- struct probe_fn_string_form<quadratic_probe_fn_t_<Key, Allocator> >
+ template<typename Key, typename _Alloc>
+ struct probe_fn_string_form<quadratic_probe_fn_t_<Key, _Alloc> >
{
static std::string
name()
};
template<>
- struct probe_fn_string_form<__gnu_pbds::null_probe_fn>
+ struct probe_fn_string_form<__gnu_pbds::null_type>
{
static std::string
name()
static std::string
desc()
- { return make_xml_tag("Probe_Fn", "value", "null_probe_fn"); }
+ { return make_xml_tag("Probe_Fn", "value", "null_type"); }
};
} // namespace detail
template<typename Size_Policy>
struct size_policy_string_form;
- template<typename Allocator>
+ template<typename _Alloc>
struct size_policy_string_form<
- __gnu_pbds::test::hash_exponential_size_policy_t_<Allocator> >
+ __gnu_pbds::test::hash_exponential_size_policy_t_<_Alloc> >
{
static std::string
name()
value = __gnu_pbds::detail::is_same<
typename Tree_Cntnr::node_update,
__gnu_pbds::tree_order_statistics_node_update<
- typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_const_iterator,
typename Tree_Cntnr::node_iterator,
typename Tree_Cntnr::cmp_fn,
typename Tree_Cntnr::allocator_type> >::value
value = __gnu_pbds::detail::is_same<
typename Tree_Cntnr::node_update,
__gnu_pbds::trie_order_statistics_node_update<
- typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_const_iterator,
typename Tree_Cntnr::node_iterator,
- typename Tree_Cntnr::e_access_traits,
+ typename Tree_Cntnr::access_traits,
typename Tree_Cntnr::allocator_type> >::value
};
};
value = __gnu_pbds::detail::is_same<
typename Tree_Cntnr::node_update,
__gnu_pbds::trie_prefix_search_node_update<
- typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_const_iterator,
typename Tree_Cntnr::node_iterator,
- typename Tree_Cntnr::e_access_traits,
+ typename Tree_Cntnr::access_traits,
typename Tree_Cntnr::allocator_type> >::value
};
};
template<typename Trigger_Policy>
struct trigger_policy_string_form;
- template<typename Allocator,
- typename Allocator::size_type Min_Load_Nom,
- typename Allocator::size_type Min_Load_Denom,
- typename Allocator::size_type Max_Load_Nom,
- typename Allocator::size_type Max_Load_Denom,
+ template<typename _Alloc,
+ typename _Alloc::size_type Min_Load_Nom,
+ typename _Alloc::size_type Min_Load_Denom,
+ typename _Alloc::size_type Max_Load_Nom,
+ typename _Alloc::size_type Max_Load_Denom,
bool External_Access>
struct trigger_policy_string_form<
__gnu_pbds::test::hash_load_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
Min_Load_Nom,
Min_Load_Denom,
Max_Load_Nom,
}
};
- template<typename Allocator,
- typename Allocator::size_type Load_Nom,
- typename Allocator::size_type Load_Denom,
+ template<typename _Alloc,
+ typename _Alloc::size_type Load_Nom,
+ typename _Alloc::size_type Load_Denom,
bool External_Access>
struct trigger_policy_string_form<
__gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
- Allocator,
+ _Alloc,
Load_Nom,
Load_Denom,
External_Access> >
namespace test
{
template<typename Key, class Cmp_Fn = std::less<Key>,
- class Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_set : public PB_DS_BASE_C_DEC
{
private:
- typedef std::set<Key, Cmp_Fn, typename Allocator::template rebind<Key>::other> base_type;
+ typedef std::set<Key, Cmp_Fn, typename _Alloc::template rebind<Key>::other> base_type;
public:
typedef native_tree_tag container_category;
{ return (""); }
static std::string
- name(__gnu_pbds::null_mapped_type)
+ name(__gnu_pbds::null_type)
{ return ("set"); }
static std::string
- desc(__gnu_pbds::null_mapped_type)
+ desc(__gnu_pbds::null_type)
{ return (""); }
public:
{
namespace test
{
- template<typename Allocator>
+ template<typename _Alloc>
struct direct_mask_range_hashing_t_
- : public __gnu_pbds::direct_mask_range_hashing<typename Allocator::size_type>
+ : public __gnu_pbds::direct_mask_range_hashing<typename _Alloc::size_type>
{
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef __gnu_pbds::direct_mask_range_hashing<size_type> base_type;
};
- template<typename Allocator>
+ template<typename _Alloc>
struct direct_mod_range_hashing_t_
- : public __gnu_pbds::direct_mod_range_hashing<typename Allocator::size_type>
+ : public __gnu_pbds::direct_mod_range_hashing<typename _Alloc::size_type>
{
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef __gnu_pbds::direct_mod_range_hashing<size_type> base_type;
};
- template<typename Allocator,
- typename Allocator::size_type Min_Load_Nom,
- typename Allocator::size_type Min_Load_Denom,
- typename Allocator::size_type Max_Load_Nom,
- typename Allocator::size_type Max_Load_Denom,
+ template<typename _Alloc,
+ typename _Alloc::size_type Min_Load_Nom,
+ typename _Alloc::size_type Min_Load_Denom,
+ typename _Alloc::size_type Max_Load_Nom,
+ typename _Alloc::size_type Max_Load_Denom,
bool External_Access>
struct hash_load_check_resize_trigger_t_
: public __gnu_pbds::hash_load_check_resize_trigger<External_Access,
- typename Allocator::size_type>
+ typename _Alloc::size_type>
{
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef __gnu_pbds::hash_load_check_resize_trigger<External_Access, size_type> base_type;
inline
};
};
- template<typename Allocator,
- typename Allocator::size_type Load_Nom,
- typename Allocator::size_type Load_Denom,
+ template<typename _Alloc,
+ typename _Alloc::size_type Load_Nom,
+ typename _Alloc::size_type Load_Denom,
bool External_Access>
struct cc_hash_max_collision_check_resize_trigger_t_
: public __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access,
- typename Allocator::size_type>
+ typename _Alloc::size_type>
{
- typedef typename Allocator::size_type size_type;
+ typedef typename _Alloc::size_type size_type;
typedef __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access, size_type> base_type;
inline
struct hash_prime_size_policy_t_ : public __gnu_pbds::hash_prime_size_policy
{ };
- template<typename Allocator>
+ template<typename _Alloc>
struct hash_exponential_size_policy_t_
- : public __gnu_pbds::hash_exponential_size_policy<typename Allocator::size_type>
+ : public __gnu_pbds::hash_exponential_size_policy<typename _Alloc::size_type>
{ };
- template<typename Key, class Allocator>
+ template<typename Key, typename _Alloc>
struct linear_probe_fn_t_
- : public __gnu_pbds::linear_probe_fn<typename Allocator::size_type>
+ : public __gnu_pbds::linear_probe_fn<typename _Alloc::size_type>
{ };
- template<typename Key, class Allocator>
+ template<typename Key, typename _Alloc>
struct quadratic_probe_fn_t_
- : public __gnu_pbds::quadratic_probe_fn<typename Allocator::size_type>
+ : public __gnu_pbds::quadratic_probe_fn<typename _Alloc::size_type>
{ };
- template<typename Allocator, typename Allocator::size_type Max_Count>
- struct counter_lu_policy_t_
- : public __gnu_pbds::counter_lu_policy<Max_Count, Allocator>
+ template<typename _Alloc, typename _Alloc::size_type Max_Count>
+ struct lu_counter_policy_t_
+ : public __gnu_pbds::lu_counter_policy<Max_Count, _Alloc>
{
- typedef __gnu_pbds::counter_lu_policy<Max_Count, Allocator> base_type;
+ typedef __gnu_pbds::lu_counter_policy<Max_Count, _Alloc> base_type;
};
- struct move_to_front_lu_policy_t_
- : public __gnu_pbds::move_to_front_lu_policy<>
+ struct lu_move_to_front_policy_t_
+ : public __gnu_pbds::lu_move_to_front_policy<>
{ };
} // namespace test
} // namespace __gnu_pbds
namespace test
{
template<typename Value_Type, typename Cmp_Fn = std::less<Value_Type>,
- class Allocator = std::allocator<Value_Type> >
+ typename _Alloc = std::allocator<Value_Type> >
struct pq_common_types
{
private:
- typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::pairing_heap_tag, Allocator> pairing_heap_t;
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::pairing_heap_tag, _Alloc> pairing_heap_t;
- typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binomial_heap_tag, Allocator> binomial_heap_t;
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binomial_heap_tag, _Alloc> binomial_heap_t;
- typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::rc_binomial_heap_tag, Allocator> rc_binomial_heap_t;
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::rc_binomial_heap_tag, _Alloc> rc_binomial_heap_t;
- typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binary_heap_tag, Allocator> binary_heap_t;
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binary_heap_tag, _Alloc> binary_heap_t;
- typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::thin_heap_tag, Allocator> thin_heap_t;
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::thin_heap_tag, _Alloc> thin_heap_t;
typedef typename __gnu_cxx::typelist::create5<thin_heap_t, pairing_heap_t, binomial_heap_t, rc_binomial_heap_t, binary_heap_t>::type all_tl;
{
#define PB_DS_BASE_C_DEC \
std::tr1::__unordered_map<Key, Data, Hash_Fn, Eq_Fn, \
- typename Allocator::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
+ typename _Alloc::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
template<typename Key,
typename Data,
typename Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
typename Eq_Fn = std::equal_to<Key>,
typename Less_Fn = std::less<Key>,
- typename Allocator = std::allocator<char>, bool Cache_Hash = false
+ typename _Alloc = std::allocator<char>, bool Cache_Hash = false
>
class native_hash_map : public PB_DS_BASE_C_DEC
{
namespace test
{
#define PB_DS_BASE_C_DEC \
- std::tr1::unordered_multimap<Key, Data, Hash_Fn, Eq_Fn, Allocator>
+ std::tr1::unordered_multimap<Key, Data, Hash_Fn, Eq_Fn, _Alloc>
template<typename Key,
typename Data,
class Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
class Eq_Fn = std::equal_to<Key>,
class Less_Fn = std::less<Key>,
- class Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_hash_multimap : public PB_DS_BASE_C_DEC
{
private:
public:
typedef native_hash_tag container_category;
- typedef Allocator allocator;
+ typedef _Alloc allocator;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
{
#define PB_DS_BASE_C_DEC \
std::tr1::__unordered_set<Key, Hash_Fn, Eq_Fn, \
- typename Allocator::template rebind<Key>::other, Cache_Hash>
+ typename _Alloc::template rebind<Key>::other, Cache_Hash>
template<typename Key,
size_t Init_Size = 8,
typename Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
typename Eq_Fn = std::equal_to<Key>,
typename Less_Fn = std::less<Key>,
- typename Allocator = std::allocator<char>, bool Cache_Hash = false
+ typename _Alloc = std::allocator<char>, bool Cache_Hash = false
>
class native_hash_set : public PB_DS_BASE_C_DEC
{
{
#define PB_DS_BASE_C_DEC \
std::map<Key, Data, Cmp_Fn, \
-typename Allocator::template rebind<std::pair<const Key, Data > >::other >
+typename _Alloc::template rebind<std::pair<const Key, Data > >::other >
template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
- class Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_map : public PB_DS_BASE_C_DEC
{
private:
{
#define PB_DS_BASE_C_DEC \
std::multimap<Key, Data, Less_Fn, \
- typename Allocator::template rebind<std::pair<const Key, Data> >::other>
+ typename _Alloc::template rebind<std::pair<const Key, Data> >::other>
template<typename Key, typename Data, class Less_Fn = std::less<Key>,
- class Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_multimap : public PB_DS_BASE_C_DEC
{
private:
public:
typedef native_tree_tag container_category;
- typedef Allocator allocator;
+ typedef _Alloc allocator;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
std::pair<Key, Data> >::other::const_reference
const_reference;
{
namespace detail
{
- template<typename Value_Type, bool Vector, typename Allocator>
+ template<typename Value_Type, bool Vector, typename _Alloc>
struct base_seq
{
private:
- typedef typename Allocator::template rebind<Value_Type> value_rebind;
+ typedef typename _Alloc::template rebind<Value_Type> value_rebind;
public:
typedef std::vector<Value_Type, typename value_rebind::other> type;
};
- template<typename Value_Type, typename Allocator>
- struct base_seq<Value_Type, false, Allocator>
+ template<typename Value_Type, typename _Alloc>
+ struct base_seq<Value_Type, false, _Alloc>
{
private:
- typedef typename Allocator::template rebind<Value_Type> value_rebind;
+ typedef typename _Alloc::template rebind<Value_Type> value_rebind;
public:
typedef std::deque<Value_Type, typename value_rebind::other> type;
{ };
#define PB_DS_CLASS_C_DEC \
- native_priority_queue<Value_Type, Vector, Cmp_Fn, Allocator>
+ native_priority_queue<Value_Type, Vector, Cmp_Fn, _Alloc>
#define PB_DS_BASE_C_DEC \
- std::priority_queue<Value_Type, typename detail::base_seq<Value_Type, Vector, Allocator>::type, Cmp_Fn>
+ std::priority_queue<Value_Type, typename detail::base_seq<Value_Type, Vector, _Alloc>::type, Cmp_Fn>
template<typename Value_Type,
bool Vector,
typename Cmp_Fn = std::less<Value_Type>,
- typename Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_priority_queue : public PB_DS_BASE_C_DEC
{
private:
typedef PB_DS_BASE_C_DEC base_type;
- typedef typename Allocator::template rebind<Value_Type> value_rebind;
+ typedef typename _Alloc::template rebind<Value_Type> value_rebind;
public:
typedef Value_Type value_type;
namespace test
{
#define PB_DS_BASE_C_DEC \
- std::set<Key, Cmp_Fn, typename Allocator::template rebind<Key>::other>
+ std::set<Key, Cmp_Fn, typename _Alloc::template rebind<Key>::other>
template<typename Key, class Cmp_Fn = std::less<Key>,
- class Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
class native_set : public PB_DS_BASE_C_DEC
{
private:
{ return (static_cast<size_t>(i)); }
};
- template<typename Key, typename Allocator = std::allocator<char> >
+ template<typename Key, typename _Alloc = std::allocator<char> >
struct hash_set_tl_t
{
typedef
typename __gnu_pbds::test::hash_common_types<
Key,
- __gnu_pbds::null_mapped_type,
+ __gnu_pbds::null_type,
int_hash,
std::equal_to<Key>,
- Allocator>::performance_min_tl
+ _Alloc>::performance_min_tl
type;
};
- template<typename Key, typename Allocator = std::allocator<char> >
+ template<typename Key, typename _Alloc = std::allocator<char> >
struct lu_set_tl_t
{
typedef
typename __gnu_pbds::test::lu_common_types<
Key,
- __gnu_pbds::null_mapped_type,
+ __gnu_pbds::null_type,
std::equal_to<
Key>,
- Allocator>::performance_min_tl
+ _Alloc>::performance_min_tl
type;
};
template<typename Key,
class Sec_Tl,
- typename Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
struct hash_mmap_tl_t
{
private:
hash_fn_t,
std::equal_to<
Key>,
- Allocator>::performance_min_tl
+ _Alloc>::performance_min_tl
type;
};
template<typename Key,
class Sec_Tl,
- typename Allocator = std::allocator<char> >
+ typename _Alloc = std::allocator<char> >
struct tree_mmap_tl_t
{
private:
Cntnr_T,
std::less<
Key>,
- __gnu_pbds::null_tree_node_update,
- Allocator>::performance_min_tl
+ __gnu_pbds::null_node_update,
+ _Alloc>::performance_min_tl
type;
};
type;
};
- template<typename Key, typename Mapped, typename Allocator>
+ template<typename Key, typename Mapped, typename _Alloc>
struct hash_hash_mmap_tl_t
{
private:
- typedef typename hash_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+ typedef typename hash_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
public:
- typedef typename hash_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ typedef typename hash_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
};
- template<typename Key, typename Mapped, typename Allocator>
+ template<typename Key, typename Mapped, typename _Alloc>
struct tree_hash_mmap_tl_t
{
private:
- typedef typename hash_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+ typedef typename hash_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
public:
- typedef typename tree_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ typedef typename tree_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
};
- template<typename Key, typename Mapped, typename Allocator>
+ template<typename Key, typename Mapped, typename _Alloc>
struct tree_lu_mmap_tl_t
{
private:
- typedef typename lu_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+ typedef typename lu_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
public:
- typedef typename tree_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ typedef typename tree_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
};
- template<typename Key, typename Mapped, typename Allocator>
+ template<typename Key, typename Mapped, typename _Alloc>
struct hash_lu_mmap_tl_t
{
private:
- typedef typename lu_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+ typedef typename lu_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
public:
- typedef typename hash_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ typedef typename hash_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
};
} // namespace detail
- template<typename Key, typename Mapped, typename Allocator>
+ template<typename Key, typename Mapped, typename _Alloc>
struct mmap_tl_t
{
private:
typedef
- typename detail::hash_hash_mmap_tl_t<Key, Mapped, Allocator>::type
+ typename detail::hash_hash_mmap_tl_t<Key, Mapped, _Alloc>::type
hh_mmap_tl_t;
typedef
- typename detail::hash_lu_mmap_tl_t<Key, Mapped, Allocator>::type
+ typename detail::hash_lu_mmap_tl_t<Key, Mapped, _Alloc>::type
hl_mmap_tl_t;
typedef
- typename detail::tree_hash_mmap_tl_t<Key, Mapped, Allocator>::type
+ typename detail::tree_hash_mmap_tl_t<Key, Mapped, _Alloc>::type
th_mmap_tl_t;
typedef
- typename detail::tree_lu_mmap_tl_t<Key, Mapped, Allocator>::type
+ typename detail::tree_lu_mmap_tl_t<Key, Mapped, _Alloc>::type
tl_mmap_tl_t;
public:
typedef
__gnu_pbds::test::hash_common_types<
int,
- __gnu_pbds::null_mapped_type>::tl
+ __gnu_pbds::null_type>::tl
hash_set_tl_t;
template<typename Cntnr_T>
typedef
__gnu_pbds::test::tree_common_types<
int,
- __gnu_pbds::null_mapped_type>::tl
+ __gnu_pbds::null_type>::tl
tree_set_tl_t;
template<typename Cntnr_T>
operator()(std::size_t resolution)
{
size_t not_found_count = 0;
- typedef typename Cntnr::const_point_iterator iterator_type;
+ typedef typename Cntnr::point_const_iterator iterator_type;
for (std::size_t i = 0; i < resolution; ++i)
{
iterator_type end = m_r_container.end();
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2008, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
}
};
- typedef __gnu_pbds::string_trie_e_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> e_access_traits_t;
+ typedef __gnu_pbds::trie_string_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> access_traits_t;
template<typename Data_Type>
struct tree_types
{
private:
- typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::null_tree_node_update, alloc_type>::regression_tl no_order_statistics_tl_t;
+ typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::null_node_update, alloc_type>::regression_tl no_order_statistics_tl_t;
typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::tree_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
struct trie_types
{
private:
- typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::null_trie_node_update, alloc_type>::regression_tl no_updates_tl_t;
+ typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::null_node_update, alloc_type>::regression_tl no_updates_tl_t;
- typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
+ typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
- typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_prefix_search_node_update, alloc_type>::regression_tl prefix_search_tl_t;
+ typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_prefix_search_node_update, alloc_type>::regression_tl prefix_search_tl_t;
public:
typedef typename __gnu_cxx::typelist::append<no_updates_tl_t, typename __gnu_cxx::typelist::append<prefix_search_tl_t, order_statistics_tl_t>::type>::type tl_t;
};
- namespace detail
- {
-
- };
-
typedef vector_adaptor<basic_type, alloc_type> vector_type;
typedef __gnu_cxx::typelist::create1<vector_type>::type vector_tl_t;
// Associative types.
- typedef tree_types<null_mapped_type>::tl_t tree_set_tl_t;
- typedef tree_types<null_mapped_type>::min_tl_t min_tree_set_tl_t;
+ typedef tree_types<null_type>::tl_t tree_set_tl_t;
+ typedef tree_types<null_type>::min_tl_t min_tree_set_tl_t;
typedef tree_types<basic_type>::tl_t tree_map_tl_t;
typedef tree_types<basic_type>::min_tl_t min_tree_map_tl_t;
- typedef hash_types<null_mapped_type>::tl_t hash_set_tl_t;
- typedef hash_types<null_mapped_type>::min_tl_t min_hash_set_tl_t;
+ typedef hash_types<null_type>::tl_t hash_set_tl_t;
+ typedef hash_types<null_type>::min_tl_t min_hash_set_tl_t;
typedef hash_types<basic_type>::tl_t hash_map_tl_t;
typedef hash_types<basic_type>::min_tl_t min_hash_map_tl_t;
- typedef lu_types<null_mapped_type>::tl_t lu_set_tl_t;
- typedef lu_types<null_mapped_type>::min_tl_t min_lu_set_tl_t;
+ typedef lu_types<null_type>::tl_t lu_set_tl_t;
+ typedef lu_types<null_type>::min_tl_t min_lu_set_tl_t;
typedef lu_types<basic_type>::tl_t lu_map_tl_t;
typedef lu_types<basic_type>::min_tl_t min_lu_map_tl_t;
- typedef trie_types<null_mapped_type>::tl_t trie_set_tl_t;
- typedef trie_types<null_mapped_type>::min_tl_t min_trie_set_tl_t;
+ typedef trie_types<null_type>::tl_t trie_set_tl_t;
+ typedef trie_types<null_type>::min_tl_t min_trie_set_tl_t;
typedef trie_types<basic_type>::tl_t trie_map_tl_t;
typedef trie_types<basic_type>::min_tl_t min_trie_map_tl_t;
} // namespace test
typedef typename cntnr::size_type size_type;
typedef regression_test_traits<Cntnr> test_traits;
typedef typename test_traits::key_type key_type;
- typedef typename test_traits::const_key_reference const_key_reference;
+ typedef typename test_traits::key_const_reference key_const_reference;
typedef typename test_traits::value_type value_type;
typedef typename test_traits::native_type native_type;
typedef twister_rand_gen gen;
try
{
p_c = new Cntnr();
- * p_c =* m_p_c;
+ *p_c = *m_p_c;
std::swap(p_c, m_p_c);
}
catch(__gnu_cxx::forced_error&)
switch(get_next_sub_op(2))
{
case 0:
- p_c = new Cntnr(m_p_c->get_e_access_traits());
+ p_c = new Cntnr(m_p_c->get_access_traits());
m_native_c.clear();
break;
case 1:
p_c = new Cntnr(m_p_c->begin(), m_p_c->end(),
- m_p_c->get_e_access_traits());
+ m_p_c->get_access_traits());
break;
default:
PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
m_alloc.set_probability(0);
const key_type k = native_key;
m_alloc.set_probability(1);
- typename cntnr::const_point_iterator found_it = r_c.find(k);
+ typename cntnr::point_const_iterator found_it = r_c.find(k);
PB_DS_THROW_IF_FAILED(found_it != r_c.end(),
test_traits::native_val_to_string(*it),
&r_c, &r_native_c);
prefix_search = test_traits::prefix_search,
has_mapped = !__gnu_pbds::detail::is_same<
typename Cntnr::mapped_type,
- __gnu_pbds::null_mapped_type>::value
+ __gnu_pbds::null_type>::value
};
order_preserving_cmp_imp(r_c, r_native_c,
break;
case 1:
PB_DS_RUN_MTHD(copy_constructor)
- break;
+ break;
case 2:
PB_DS_RUN_MTHD(it_constructor)
- break;
+ break;
case 3:
PB_DS_RUN_MTHD(assignment_operator)
- break;
+ break;
case 4:
PB_DS_RUN_MTHD(split_join)
- break;
+ break;
case 5:
resize();
break;
m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_probability(m_tp);
- const_key_reference r_k = test_traits::extract_key(v);
- typename cntnr::const_point_iterator found_it = m_p_c->find(r_k);
+ key_const_reference r_k = test_traits::extract_key(v);
+ typename cntnr::point_const_iterator found_it = m_p_c->find(r_k);
const bool existed = (found_it != m_p_c->end());
const std::pair<typename cntnr::point_iterator, bool> ins_ret = m_p_c->insert(v);
enum
{
no_data = __gnu_pbds::detail::is_same<
- typename Cntnr::const_key_reference,
+ typename Cntnr::key_const_reference,
typename Cntnr::const_reference>::value
};
m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_probability(m_tp);
- (*m_p_c)[v] = __gnu_pbds::null_mapped_type();
+ (*m_p_c)[v] = __gnu_pbds::null_type();
m_native_c.insert(test_traits::native_value(v));
}
catch(__gnu_cxx::forced_error&)
{
typedef typename Cntnr::key_type test_key_type;
typedef typename Cntnr::key_reference test_key_reference;
- typedef typename Cntnr::const_key_reference test_const_key_reference;
+ typedef typename Cntnr::key_const_reference test_key_const_reference;
typedef typename Cntnr::key_pointer test_key_pointer;
- typedef typename Cntnr::const_key_pointer test_const_key_pointer;
+ typedef typename Cntnr::key_const_pointer test_key_const_pointer;
}
PB_DS_CLASS_T_DEC
{
typedef typename Cntnr::mapped_type test_mapped_type;
typedef typename Cntnr::mapped_reference test_mapped_reference;
- typedef typename Cntnr::const_mapped_reference test_const_mapped_reference;
+ typedef typename Cntnr::mapped_const_reference test_mapped_const_reference;
typedef typename Cntnr::mapped_pointer test_mapped_pointer;
- typedef typename Cntnr::const_mapped_pointer test_const_mapped_pointer;
+ typedef typename Cntnr::mapped_const_pointer test_mapped_const_pointer;
}
PB_DS_CLASS_T_DEC
iterator_defs()
{
typedef typename Cntnr::point_iterator test_point_iterator;
- typedef typename Cntnr::const_point_iterator const_test_point_iterator;
+ typedef typename Cntnr::point_const_iterator const_test_point_iterator;
typedef typename Cntnr::iterator test_iterator;
typedef typename Cntnr::const_iterator const_test_iterator;
}
node_iterator_defs(__gnu_pbds::detail::true_type)
{
typedef typename Cntnr::node_iterator test_node_iterator;
- typedef typename Cntnr::const_node_iterator test_const_node_iterator;
+ typedef typename Cntnr::node_const_iterator test_node_const_iterator;
}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
policy_defs(__gnu_pbds::pat_trie_tag)
{
- typedef typename Cntnr::e_access_traits e_access_traits;
+ typedef typename Cntnr::access_traits access_traits;
}
PB_DS_CLASS_C_DEC::
policy_access(__gnu_pbds::pat_trie_tag)
{
- typename Cntnr::e_access_traits& r_t = m_p_c->get_e_access_traits();
+ typename Cntnr::access_traits& r_t = m_p_c->get_access_traits();
assert(&r_t);
}
split_join = container_traits::order_preserving
};
- return (split_join_imp(__gnu_pbds::detail::integral_constant<int,split_join>()));
+ typedef __gnu_pbds::detail::integral_constant<int, split_join> __true_type;
+ return split_join_imp(__true_type());
}
PB_DS_CLASS_T_DEC
PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
- typename cntnr::const_point_iterator const_find_it(it);
+ typename cntnr::point_const_iterator const_find_it(it);
PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
{
typename cntnr::const_iterator const_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it(const_it);
+ typename cntnr::point_const_iterator const_find_it(const_it);
PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
}
{
typename cntnr::point_iterator find_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it(find_it);
+ typename cntnr::point_const_iterator const_find_it(find_it);
PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
}
PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = it;
PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
{
typename cntnr::const_iterator const_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = const_it;
PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
{
typename cntnr::point_iterator find_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = find_it;
PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
- typename cntnr::const_point_iterator const_find_it(it);
+ typename cntnr::point_const_iterator const_find_it(it);
PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = it;
PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2010, 2011
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
double ep, double cp, double mp, bool d)
: m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp),
m_mp(mp), m_disp(d)
- { }
+ {
+ if (m_disp)
+ xml_test_rand_regression_formatter(seed, n, m, tp, ip, ep, cp, mp);
+ }
template<typename Cntnr>
void
double ep = 0.2;
double cp = 0.001;
double mp = 0.25;
- bool disp = false; // show progress
+ bool disp = true; // show progress
try
{
detail::verify_params(sd, n, m, tp, ip, ep, cp, mp, disp);
}
- catch (__gnu_pbds::test::illegal_input_error&)
+ catch(__gnu_pbds::test::illegal_input_error&)
{
detail::usage(name);
return -1;
}
- catch (...)
+ catch(...)
{
return -2;
};
- // XXX RAII, constructor takes bool for display
- xml_test_rand_regression_formatter* p_fmt = 0;
- if (disp)
- p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, ep, cp, mp);
-
try
{
detail::rand_reg_test tst(sd, n, m, tp, ip, ep, cp, mp, disp);
catch (...)
{
std::cerr << "Test failed with seed " << sd << std::endl;
- if (disp)
- delete p_fmt;
throw;
}
- if (disp)
- delete p_fmt;
return 0;
}
usage(const std::string& name)
{
using namespace std;
- cerr << "usage: " << name << " <sd> <n> <m> <tp> <ip> <ep> <cp> <mp> ['t' | 'f']" <<
- endl << endl;
+ cerr << "usage: " << name
+ << " <sd> <n> <m> <tp> <ip> <ep> <cp> <mp> ['t' | 'f']"
+ << endl << endl;
cerr << "This test performs basic regression tests on various associative containers."
"For each container, it performs a sequence of operations. At each iteration, it does "
iterator_defs()
{
typedef typename Cntnr::point_iterator test_point_iterator;
- typedef typename Cntnr::const_point_iterator const_test_point_iterator;
+ typedef typename Cntnr::point_const_iterator const_test_point_iterator;
typedef typename Cntnr::iterator test_iterator;
typedef typename Cntnr::const_iterator const_test_iterator;
}
{
typename cntnr::const_iterator const_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it(const_it);
+ typename cntnr::point_const_iterator const_find_it(const_it);
_GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
}
{
typename cntnr::iterator it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it1(it);
+ typename cntnr::point_const_iterator const_find_it1(it);
_GLIBCXX_THROW_IF(const_find_it1 != it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(const_find_it1 == it), "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(find_it1 == it), "", m_p_c, &m_native_c);
typename cntnr::point_iterator find_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it(find_it);
+ typename cntnr::point_const_iterator const_find_it(find_it);
_GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
}
_GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = it;
_GLIBCXX_THROW_IF(const_find_it != it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(const_find_it == it), "", m_p_c, &m_native_c);
{
typename cntnr::const_iterator const_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = const_it;
_GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
{
typename cntnr::point_iterator find_it = m_p_c->end();
- typename cntnr::const_point_iterator const_find_it;
+ typename cntnr::point_const_iterator const_find_it;
const_find_it = find_it;
_GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
_GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
double dp, double ep, double cp, double mp, bool d)
: m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep),
m_cp(cp), m_mp(mp), m_disp(d)
- { }
+ {
+ if (m_disp)
+ xml_test_rand_regression_formatter(seed, n, m, tp, ip, ep, cp, mp);
+ }
template<typename Cntnr>
void
// Sane defaults.
size_t n = iter;
size_t m = keys;
- size_t sd = 0; // 0 = time-determined arbitrary
+ size_t sd = twister_rand_gen::get_time_determined_seed();
double tp = 0.2;
double ip = 0.6;
double dp = 0.1;
double ep = 0.2;
double cp = 0.001;
double mp = 1;
- bool disp = false; // show progress
+ bool disp = true; // show progress
try
{
return -2;
};
- xml_test_rand_regression_formatter* p_fmt = 0;
- if (sd == 0)
- sd = twister_rand_gen::get_time_determined_seed();
- if (disp)
- p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, dp,
- ep, cp, mp);
-
try
{
detail::rand_reg_test tst(sd, n, m, tp, ip, dp, ep, cp, mp, disp);
catch(...)
{
std::cerr << "Test failed with seed " << sd << std::endl;
- if (disp)
- delete p_fmt;
- return -1;
+ throw;
}
- if (disp)
- delete p_fmt;
return 0;
}
namespace detail
{
- template<typename Key, class Allocator>
+ template<typename Key, typename _Alloc>
struct native_key_type;
- template<typename Allocator>
+ template<typename _Alloc>
struct native_key_type<
basic_type,
- Allocator>
+ _Alloc>
{
typedef std::string type;
static type
- native_key(typename Allocator::template rebind<
+ native_key(typename _Alloc::template rebind<
basic_type>::other::const_reference r_key)
{
return (std::string(r_key));
}
};
- template<typename Hd, class Tl, class Allocator>
+ template<typename Hd, class Tl, typename _Alloc>
struct native_key_type<
std::pair<
Hd,
Tl>,
- Allocator>
+ _Alloc>
{
- typedef typename native_key_type< Hd, Allocator>::type hd_type;
+ typedef typename native_key_type< Hd, _Alloc>::type hd_type;
- typedef typename native_key_type< Tl, Allocator>::type tl_type;
+ typedef typename native_key_type< Tl, _Alloc>::type tl_type;
typedef std::pair< hd_type, tl_type> type;
static type
- native_key(typename Allocator::template rebind< std::pair<Hd, Tl> >::other::const_reference r_key)
+ native_key(typename _Alloc::template rebind< std::pair<Hd, Tl> >::other::const_reference r_key)
{
return (std::make_pair(
- native_key_type<Hd, Allocator>::native_key(r_key.first),
- native_key_type<Tl, Allocator>::native_key(r_key.second)));
+ native_key_type<Hd, _Alloc>::native_key(r_key.first),
+ native_key_type<Tl, _Alloc>::native_key(r_key.second)));
}
};
template<typename Native_Key_Type,
class Key_Type,
class Data_Type,
- class Allocator>
+ typename _Alloc>
struct native_type_traits_base;
- template<typename Native_Key_Type, class Key_Type, class Allocator>
+ template<typename Native_Key_Type, class Key_Type, typename _Alloc>
struct native_type_traits_base<
Native_Key_Type,
Key_Type,
basic_type,
- Allocator>
+ _Alloc>
{
public:
typedef std::map< Native_Key_Type, std::string> type;
}
static typename type::value_type
- native_value(typename Allocator::template rebind< std::pair<Key_Type, basic_type> >::other::const_reference r_val)
+ native_value(typename _Alloc::template rebind< std::pair<Key_Type, basic_type> >::other::const_reference r_val)
{
return (std::make_pair(
- native_key_type<Key_Type, Allocator>::native_key(r_val.first),
+ native_key_type<Key_Type, _Alloc>::native_key(r_val.first),
std::string(r_val.second)));
}
};
- template<typename Native_Key_Type, class Key_Type, class Allocator>
+ template<typename Native_Key_Type, class Key_Type, typename _Alloc>
struct native_type_traits_base<
Native_Key_Type,
Key_Type,
- __gnu_pbds::null_mapped_type,
- Allocator>
+ __gnu_pbds::null_type,
+ _Alloc>
{
public:
typedef std::set< Native_Key_Type> type;
}
static typename type::value_type
- native_value(typename Allocator::template rebind<
+ native_value(typename _Alloc::template rebind<
Key_Type>::other::const_reference r_val)
{
- return (native_key_type<Key_Type, Allocator>::native_key(
+ return (native_key_type<Key_Type, _Alloc>::native_key(
r_val));
}
};
#define PB_DS_NATIVE_KEY_TYPE_C_DEC \
native_key_type< \
Key_Type, \
- Allocator>
+ _Alloc>
#define PB_DS_BASE_C_DEC \
native_type_traits_base< \
typename PB_DS_NATIVE_KEY_TYPE_C_DEC::type, \
Key_Type, \
Data_Type, \
- Allocator>
+ _Alloc>
- template<typename Key_Type, class Data_Type, class Allocator>
+ template<typename Key_Type, class Data_Type, typename _Alloc>
struct native_type_traits : public PB_DS_BASE_C_DEC
{
typedef typename PB_DS_BASE_C_DEC::type type;
typedef typename type::key_type key_type;
static typename PB_DS_NATIVE_KEY_TYPE_C_DEC::type
- native_key(typename Allocator::template rebind<
+ native_key(typename _Alloc::template rebind<
Key_Type>::other::const_reference r_key)
{
return (PB_DS_NATIVE_KEY_TYPE_C_DEC::native_key(r_key));
// Only associative containers.
typedef typename Cntnr::key_type key_type;
- typedef typename Cntnr::const_key_reference const_key_reference;
+ typedef typename Cntnr::key_const_reference key_const_reference;
typedef typename native_type::key_type native_key_type;
enum
generate_value(Gen& r_gen, size_t max)
{ return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max); }
- static const_key_reference
+ static key_const_reference
extract_key(const_reference r_val)
{ return type_traits_base::extract_key(r_val); }
static native_key_type
- native_key(const_key_reference r_key)
+ native_key(key_const_reference r_key)
{ return native_type_traits_base::native_key(r_key); }
static native_value_type
{ return to_string(r_val); }
static std::string
- key_to_string(const_key_reference r_key)
+ key_to_string(key_const_reference r_key)
{ return to_string(r_key); }
static std::string
{ return to_string(r_native_val); }
static bool
- prefix_match(const_key_reference r_key, const std::string& r_native_key)
+ prefix_match(key_const_reference r_key, const std::string& r_native_key)
{
const size_t len = std::min(r_key.length(), r_native_key.length());
const std::string substr = r_native_key.substr(0, len);
{
typedef Cntnr cntnr;
typedef typename cntnr::key_type key_type;
- typedef typename cntnr::const_key_reference const_key_reference;
+ typedef typename cntnr::key_const_reference key_const_reference;
typedef typename cntnr::value_type value_type;
typedef typename cntnr::const_reference const_reference;
typedef typename cntnr::mapped_type mapped_type;
- typedef typename cntnr::const_mapped_reference const_mapped_reference;
+ typedef typename cntnr::mapped_const_reference mapped_const_reference;
template<typename Gen>
static key_type
generate_value(Gen& r_gen, size_t max)
{ return generate_value(r_gen, max, value_type()); }
- static const_key_reference
+ static key_const_reference
extract_key(const_reference r_val)
{ return extract_key_imp(r_val); }
template<typename Gen>
static value_type
- generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_mapped_type)
+ generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_type)
{ return basic_type(r_gen, max); }
template<typename Gen>
std::pair<const basic_type, basic_type>)
{ return std::make_pair(basic_type(gen, max), basic_type(gen, max)); }
- static const_key_reference
+ static key_const_reference
extract_key_imp(basic_type_const_reference r_val)
{ return r_val; }
- static const_key_reference
+ static key_const_reference
extract_key_imp(pair_type_const_reference r_val)
{ return r_val.first; }
};
template<typename _Tp, bool _Bt = traits<_Tp>::is_allocator_aware::value>
struct allocator_aware_types
{
- // Allocator-aware requirements (table 82)
+ // _Alloc-aware requirements (table 82)
typedef _Tp test_type;
typedef typename test_type::allocator_type allocator_type;
};