diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-27 15:33:38 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-27 15:33:38 +0000 |
commit | df7eb3d5044a2b6c97fccdd744bd4c177dd23f14 (patch) | |
tree | 0df480a2eef205a44aee318644b3d0b7c574b6a6 /libstdc++-v3/include | |
parent | c468addf32e9dff50e38d43f7371c991d275e285 (diff) | |
download | gcc-df7eb3d5044a2b6c97fccdd744bd4c177dd23f14.tar.gz |
2005-06-27 Benjamin Kosnik <bkoz@redhat.com>
Ami Tavory <pbassoc@gmail.com>
* docs/html/documentation.html: Add link for policy based
associative containers docs.
* docs/html/ext/pb_assoc/Std_hash_set_impl.jpg: New.
* docs/html/ext/pb_assoc/acks.html: New.
* docs/html/ext/pb_assoc/balls_and_bins.jpg: New.
* docs/html/ext/pb_assoc/basic_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/basic_assoc_cntnr_compound_data.html: New.
* docs/html/ext/pb_assoc/basic_assoc_cntnr_no_data.html: New.
* docs/html/ext/pb_assoc/basic_ds_tag.html: New.
* docs/html/ext/pb_assoc/basic_hash_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/basic_hash_ds_tag.html: New.
* docs/html/ext/pb_assoc/basic_invalidation_guarantee.html: New.
* docs/html/ext/pb_assoc/basic_ms_tag.html: New.
* docs/html/ext/pb_assoc/basic_tree_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/
basic_tree_assoc_cntnr_const_node_iterator.html: New.
* docs/html/ext/pb_assoc/
basic_tree_assoc_cntnr_node_iterator.html: New.
* docs/html/ext/pb_assoc/basic_tree_assoc_cntnr_rev.html: New.
* docs/html/ext/pb_assoc/basic_tree_assoc_cntnr_rev_it.html: New.
* docs/html/ext/pb_assoc/basic_tree_ds_tag.html: New.
* docs/html/ext/pb_assoc/cc_hash_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/cc_hash_ds_tag.html: New.
* docs/html/ext/pb_assoc/
cc_hash_max_collision_check_resize_trigger.html: New.
* docs/html/ext/pb_assoc/cc_hash_policy_cd.jpg: New.
* docs/html/ext/pb_assoc/cd.jpg: New.
* docs/html/ext/pb_assoc/component_requirements.html: New.
* docs/html/ext/pb_assoc/compound_data_enabled_ms_tag.html: New.
* docs/html/ext/pb_assoc/compound_data_type.html: New.
* docs/html/ext/pb_assoc/compound_ds_tag.html: New.
* docs/html/ext/pb_assoc/concepts.html: New.
* docs/html/ext/pb_assoc/contact.html: New.
* docs/html/ext/pb_assoc/counter_update_metadata.html: New.
* docs/html/ext/pb_assoc/counter_update_policy.html: New.
* docs/html/ext/pb_assoc/data_enabled_ms_tag.html: New.
* docs/html/ext/pb_assoc/design.html: New.
* docs/html/ext/pb_assoc/different_underlying_dss.jpg: New.
* docs/html/ext/pb_assoc/direct_mask_range_hashing.html: New.
* docs/html/ext/pb_assoc/direct_mod_range_hashing.html: New.
* docs/html/ext/pb_assoc/disclaimer.html: New.
* docs/html/ext/pb_assoc/ds_gen.html: New.
* docs/html/ext/pb_assoc/ds_tag_cd.jpg: New.
* docs/html/ext/pb_assoc/ds_traits.html: New.
* docs/html/ext/pb_assoc/embedded_lists_1.jpg: New.
* docs/html/ext/pb_assoc/embedded_lists_2.jpg: New.
* docs/html/ext/pb_assoc/examples.html: New.
* docs/html/ext/pb_assoc/exception_guarantees_specifics.html: New.
* docs/html/ext/pb_assoc/find_invalidation_guarantee.html: New.
* docs/html/ext/pb_assoc/find_iterators_cd.jpg: New.
* docs/html/ext/pb_assoc/find_iterators_range_ops_1.jpg: New.
* docs/html/ext/pb_assoc/find_iterators_range_ops_2.jpg: New.
* docs/html/ext/pb_assoc/generics.html: New.
* docs/html/ext/pb_assoc/gp_hash_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/gp_hash_ds_tag.html: New.
* docs/html/ext/pb_assoc/gp_hash_policy_cd.jpg: New.
* docs/html/ext/pb_assoc/hash_and_probe_general.html: New.
* docs/html/ext/pb_assoc/hash_based_containers.html: New.
* docs/html/ext/pb_assoc/hash_cd.jpg: New.
* docs/html/ext/pb_assoc/hash_exponential_size_policy.html: New.
* docs/html/ext/pb_assoc/hash_fn.html: New.
* docs/html/ext/pb_assoc/hash_load_check_resize_trigger.html: New.
* docs/html/ext/pb_assoc/hash_policies.html: New.
* docs/html/ext/pb_assoc/hash_policy_cd.jpg: New.
* docs/html/ext/pb_assoc/hash_prime_size_policy.html: New.
* docs/html/ext/pb_assoc/hash_range_hashing_seq_diagram.jpg: New.
* docs/html/ext/pb_assoc/hash_range_hashing_seq_diagram2.jpg: New.
* docs/html/ext/pb_assoc/hash_ranged_hash_range_hashing_fns.jpg: New.
* docs/html/ext/pb_assoc/hash_standard_resize_policy.html: New.
* docs/html/ext/pb_assoc/home.html: New.
* docs/html/ext/pb_assoc/index.html: New.
* docs/html/ext/pb_assoc/insert_resize_sequence_diagram1.jpg: New.
* docs/html/ext/pb_assoc/insert_resize_sequence_diagram2.jpg: New.
* docs/html/ext/pb_assoc/insert_resize_sequence_diagram3.jpg: New.
* docs/html/ext/pb_assoc/insert_type_methods.html: New.
* docs/html/ext/pb_assoc/interface.html: New.
* docs/html/ext/pb_assoc/interval_node_invariants.jpg: New.
* docs/html/ext/pb_assoc/introduction.html: New.
* docs/html/ext/pb_assoc/invalidation_guarantee_cd.jpg: New.
* docs/html/ext/pb_assoc/invalidation_guarantee_erase.jpg: New.
* docs/html/ext/pb_assoc/lib_download.html: New.
* docs/html/ext/pb_assoc/linear_probe_fn.html: New.
* docs/html/ext/pb_assoc/list_updates.html: New.
* docs/html/ext/pb_assoc/lu_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/lu_based_containers.html: New.
* docs/html/ext/pb_assoc/lu_cd.jpg: New.
* docs/html/ext/pb_assoc/lu_ds_tag.html: New.
* docs/html/ext/pb_assoc/lu_ops.jpg: New.
* docs/html/ext/pb_assoc/mmap_value_utils.html: New.
* docs/html/ext/pb_assoc/motivation.html: New.
* docs/html/ext/pb_assoc/move_to_front_update_metadata.html: New.
* docs/html/ext/pb_assoc/move_to_front_update_policy.html: New.
* docs/html/ext/pb_assoc/ms_cd.jpg: New.
* docs/html/ext/pb_assoc/ms_gen.html: New.
* docs/html/ext/pb_assoc/ms_tag_cd.jpg: New.
* docs/html/ext/pb_assoc/ms_traits.html: New.
* docs/html/ext/pb_assoc/node_invariant_invalidations.jpg: New.
* docs/html/ext/pb_assoc/node_invariants.html: New.
* docs/html/ext/pb_assoc/node_invariants.jpg: New.
* docs/html/ext/pb_assoc/non_unique_mapping.html: New.
* docs/html/ext/pb_assoc/non_unique_mapping_containers.jpg: New.
* docs/html/ext/pb_assoc/null_data_type.html: New.
* docs/html/ext/pb_assoc/null_hash_fn.html: New.
* docs/html/ext/pb_assoc/null_probe_fn.html: New.
* docs/html/ext/pb_assoc/order_by_key.html: New.
* docs/html/ext/pb_assoc/order_statistics_key.html: New.
* docs/html/ext/pb_assoc/order_statistics_key_cmp.html: New.
* docs/html/ext/pb_assoc/order_statistics_node_updator.html: New.
* docs/html/ext/pb_assoc/ov_tree_ds_tag.html: New.
* docs/html/ext/pb_assoc/overview.html: New.
* docs/html/ext/pb_assoc/pb_assoc_ex.html: New.
* docs/html/ext/pb_assoc/portability.html: New.
* docs/html/ext/pb_assoc/quadratic_probe_fn.html: New.
* docs/html/ext/pb_assoc/range_invalidation_guarantee.html: New.
* docs/html/ext/pb_assoc/rank_node_invariants.jpg: New.
* docs/html/ext/pb_assoc/rationale_null_node_updator.jpg: New.
* docs/html/ext/pb_assoc/rb_tree_ds_tag.html: New.
* docs/html/ext/pb_assoc/reference_iterator.jpg: New.
* docs/html/ext/pb_assoc/references.html: New.
* docs/html/ext/pb_assoc/regression_tests.html: New.
* docs/html/ext/pb_assoc/resize_general.html: New.
* docs/html/ext/pb_assoc/resize_policies.html: New.
* docs/html/ext/pb_assoc/resize_policy_cd.jpg: New.
* docs/html/ext/pb_assoc/restoring_node_invariants.jpg: New.
* docs/html/ext/pb_assoc/sample_node_updator.hpp: New.
* docs/html/ext/pb_assoc/sample_probe_fn.hpp: New.
* docs/html/ext/pb_assoc/sample_probe_fn.html: New.
* docs/html/ext/pb_assoc/sample_range_hashing.hpp: New.
* docs/html/ext/pb_assoc/sample_range_hashing.html: New.
* docs/html/ext/pb_assoc/sample_ranged_hash_fn.hpp: New.
* docs/html/ext/pb_assoc/sample_ranged_hash_fn.html: New.
* docs/html/ext/pb_assoc/sample_ranged_probe_fn.hpp: New.
* docs/html/ext/pb_assoc/sample_ranged_probe_fn.html: New.
* docs/html/ext/pb_assoc/sample_resize_policy.hpp: New.
* docs/html/ext/pb_assoc/sample_resize_policy.html: New.
* docs/html/ext/pb_assoc/sample_resize_trigger.hpp: New.
* docs/html/ext/pb_assoc/sample_size_policy.hpp: New.
* docs/html/ext/pb_assoc/sample_update_policy.hpp: New.
* docs/html/ext/pb_assoc/size_policies_general.html: New.
* docs/html/ext/pb_assoc/splay_tree_ds_tag.html: New.
* docs/html/ext/pb_assoc/timing_tests.html: New.
* docs/html/ext/pb_assoc/toc.html: New.
* docs/html/ext/pb_assoc/tree_assoc_cntnr.html: New.
* docs/html/ext/pb_assoc/
tree_assoc_cntnr_const_node_iterator.html: New.
* docs/html/ext/pb_assoc/tree_assoc_cntnr_node_iterator.html: New.
* docs/html/ext/pb_assoc/tree_based_containers.html: New.
* docs/html/ext/pb_assoc/tree_cd.jpg: New.
* docs/html/ext/pb_assoc/trigger_policies_general.html: New.
* docs/html/ext/pb_assoc/tutorial.html: New.
* docs/html/ext/pb_assoc/update_seq_diagram.jpg: New.
* include/Makefile.am: Add assoc_srcdir, assoc_builddir, assoc_subdir,
assoc_headers.
* include/Makefile.in: Regenerate.
* include/ext/typelist.h: New.
* include/ext/pb_assoc/assoc_cntnr.hpp: New.
* include/ext/pb_assoc/data_type.hpp: New.
* include/ext/pb_assoc/ds_trait.hpp: New.
* include/ext/pb_assoc/exception.hpp: New.
* include/ext/pb_assoc/hash_policy.hpp: New.
* include/ext/pb_assoc/lu_policy.hpp: New.
* include/ext/pb_assoc/ms_trait.hpp: New.
* include/ext/pb_assoc/tree_policy.hpp: New.
* include/ext/pb_assoc/trivial_iterator_def.hpp: New.
* include/ext/pb_assoc/detail/assoc_cntnr_base.hpp: New.
* include/ext/pb_assoc/detail/cond_dealtor.hpp: New.
* include/ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ds_trait_imp.hpp: New.
* include/ext/pb_assoc/detail/hash_types_traits.hpp: New.
* include/ext/pb_assoc/detail/map_debug_base.hpp: New.
* include/ext/pb_assoc/detail/mapping_level_imp.hpp: New.
* include/ext/pb_assoc/detail/ms_category_imp.hpp: New.
* include/ext/pb_assoc/detail/ms_trait_imp.hpp: New.
* include/ext/pb_assoc/detail/order_statistics_imp.hpp: New.
* include/ext/pb_assoc/detail/standard_policies.hpp: New.
* include/ext/pb_assoc/detail/standard_sizes.hpp: New.
* include/ext/pb_assoc/detail/type_utils.hpp: New.
* include/ext/pb_assoc/detail/typelist.hpp: New.
* include/ext/pb_assoc/detail/types_traits.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
d_find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
d_insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/extract_key.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_assoc_cntnr/
iterators_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/
resize_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
node_iteration_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
policy_access_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
r_erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
r_range_iteration_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
range_iteration_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/
split_join_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
bin_search_tree_.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
cond_dtor_entry_dealtor.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
cond_key_dtor_entry_dealtor.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/find_iterators.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
iterators_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/node_iterators.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
r_erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/rotate_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/bin_search_tree_/
split_join_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_hash_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/cmp_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
cond_key_dtor_entry_dealtor.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
constructor_destructor_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
constructor_destructor_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
debug_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
debug_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/entry_list_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
erase_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
erase_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
find_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
find_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
insert_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
insert_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/iterators_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
policy_access_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/resize_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
resize_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/
resize_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/size_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/cc_ht_map_/standard_policies.hpp: New.
* include/ext/pb_assoc/detail/eq_fn/eq_by_less.hpp: New.
* include/ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp: New.
* include/ext/pb_assoc/detail/gp_hash_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
constructor_destructor_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
constructor_destructor_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
debug_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
debug_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
erase_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
erase_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
find_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
find_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
insert_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
insert_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/iterator_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
policy_access_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/resize_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
resize_no_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/gp_ht_map_/
resize_store_hash_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/
direct_mask_range_hashing_imp.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/
direct_mod_range_hashing_imp.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/linear_probe_fn_imp.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/
mask_based_range_hashing.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/mod_based_range_hashing.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/probe_fn_base.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/quadratic_probe_fn_imp.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/ranged_hash_fn.hpp: New.
* include/ext/pb_assoc/detail/hash_fn/ranged_probe_fn.hpp: New.
* include/ext/pb_assoc/detail/lu_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_assoc_cntnr/
policy_access_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/iterators_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/lu_map_.hpp: New.
* include/ext/pb_assoc/detail/lu_map_/policy_access_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/lu_policy/
counter_lu_metadata_imp.hpp: New.
* include/ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/cond_dtor.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/iterators_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/node_iterators.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp: New.
* include/ext/pb_assoc/detail/ov_tree_map_/split_join_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/node.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp: New.
* include/ext/pb_assoc/detail/rb_tree_map_/split_join_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
cc_hash_max_collision_resize_trigger_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
hash_exponential_size_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
hash_load_check_resize_trigger_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
hash_prime_size_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
hash_standard_resize_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/
ht_prime_size_policy_imp.hpp: New.
* include/ext/pb_assoc/detail/resize_policy/size_base.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/
constructors_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/debug_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/node.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/splay_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp: New.
* include/ext/pb_assoc/detail/splay_tree_/split_join_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/tree_assoc_cntnr/
constructor_destructor_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/tree_policy/
null_node_updator_imp.hpp: New.
* include/ext/pb_assoc/detail/tree_policy/
order_statistics_imp.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_append.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_apply.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_at_index.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_contains.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_filter.hpp: New.
* include/ext/pb_assoc/detail/typelist/typelist_transform.hpp: New.
* include/ext/pb_assoc/detail/typelist/
typelist_typelist_append.hpp: New.
* include/ext/pb_assoc/detail/unordered_iterator/
const_find_iterator.hpp: New.
* include/ext/pb_assoc/detail/unordered_iterator/
const_iterator.hpp: New.
* include/ext/pb_assoc/detail/unordered_iterator/
find_iterator.hpp: New.
* include/ext/pb_assoc/detail/unordered_iterator/iterator.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
constructor_destructor_and_related.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
erase_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
erase_if_pred.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/find_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/info_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
insert_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
invalidation_guarantee_selector.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
it_value_type_traits.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/iterator.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
iterator_fn_imps.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/ref_pair.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
value_type_adapter.hpp: New.
* include/ext/pb_assoc/detail/value_type_adapter/
value_type_traits.hpp: New.
* testsuite/Makefile.am (CLEANFILES): Add .o, .dat, .cc.
* testsuite/Makefile.in: Regenerate.
* testsuite/testsuite_common_types.h: New.
* testsuite/testsuite_visualization.h: New.
* testsuite/ext/pb_assoc/example/basic_map.cc: New.
* testsuite/ext/pb_assoc/example/basic_multimap.cc: New.
* testsuite/ext/pb_assoc/example/basic_set.cc: New.
* testsuite/ext/pb_assoc/example/ds_traits.cc: New.
* testsuite/ext/pb_assoc/example/erase_if.cc: New.
* testsuite/ext/pb_assoc/example/extract_key.cc: New.
* testsuite/ext/pb_assoc/example/hash_find_neg.cc: New.
* testsuite/ext/pb_assoc/example/hash_illegal_resize.cc: New.
* testsuite/ext/pb_assoc/example/hash_initial_size.cc: New.
* testsuite/ext/pb_assoc/example/hash_load_set_change.cc: New.
* testsuite/ext/pb_assoc/example/hash_mod.cc: New.
* testsuite/ext/pb_assoc/example/hash_resize.cc: New.
* testsuite/ext/pb_assoc/example/hash_resize_neg.cc: New.
* testsuite/ext/pb_assoc/example/hash_shift_mask.cc: New.
* testsuite/ext/pb_assoc/example/mapping_level.cc: New.
* testsuite/ext/pb_assoc/example/mapping_level_neg.cc: New.
* testsuite/ext/pb_assoc/example/ms_traits.cc: New.
* testsuite/ext/pb_assoc/example/ranged_hash.cc: New.
* testsuite/ext/pb_assoc/example/store_hash.cc: New.
* testsuite/ext/pb_assoc/example/tree_intervals.cc: New.
* testsuite/ext/pb_assoc/example/tree_join.cc: New.
* testsuite/ext/pb_assoc/example/tree_order_statistics.cc: New.
* testsuite/ext/pb_assoc/example/tree_order_statistics_join.cc: New.
* testsuite/ext/pb_assoc/example/tree_split.cc: New.
* testsuite/performance/20_util/allocator/(insert.cc,
insert_insert.cc, list_sort_search.cc, map_mt_find.cc, map_thread.cc,
producer_consumer.cc): Recast to use typelists and move to...
* testsuite/performance/23_containers/find/map.cc: New.
* testsuite/performance/23_containers/index/map.cc: New.
* testsuite/performance/23_containers/insert/associative.cc: New.
* testsuite/performance/23_containers/insert/sequence.cc: New.
* testsuite/performance/23_containers/insert_erase/associative.cc: New.
* testsuite/performance/23_containers/producer_consumer/
(associative.cc, sequence.cc): New.
* testsuite/performance/23_containers/sort_search/list.cc: New.
* testsuite/performance/23_containers/container_benchmark.cc: Remove.
* testsuite/performance/23_containers/map_create_fill.cc: Move...
* testsuite/performance/23_containers/create/map.cc: ...here.
* testsuite/performance/23_containers/set_create_from_sorted.cc: Move.
* testsuite/performance/23_containers/create_from_sorted/set.cc: here.
* testsuite/performance/23_containers/list_create_fill_sort.cc: Move...
* testsuite/performance/23_containers/create_sort/list.cc: ...here.
* testsuite/performance/23_containers/set_insert_from_sorted.cc: Move.
* testsuite/performance/23_containers/insert_from_sorted/set.cc: here.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101354 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
204 files changed, 31934 insertions, 16 deletions
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 2144611c0c1..38b97433739 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -196,8 +196,241 @@ backward_headers = \ ${backward_srcdir}/strstream \ ${backward_srcdir}/backward_warning.h + +assoc_srcdir = ${glibcxx_srcdir}/include/ext/pb_assoc +assoc_builddir = ./ext/pb_assoc + +assoc_subdirs = \ + ${assoc_builddir}/detail \ + ${assoc_builddir}/detail/tree_assoc_cntnr \ + ${assoc_builddir}/detail/basic_assoc_cntnr \ + ${assoc_builddir}/detail/splay_tree_ \ + ${assoc_builddir}/detail/typelist \ + ${assoc_builddir}/detail/basic_hash_assoc_cntnr \ + ${assoc_builddir}/detail/cc_ht_map_ \ + ${assoc_builddir}/detail/gp_ht_map_ \ + ${assoc_builddir}/detail/tree_policy \ + ${assoc_builddir}/detail/resize_policy \ + ${assoc_builddir}/detail/bin_search_tree_ \ + ${assoc_builddir}/detail/basic_tree_assoc_cntnr \ + ${assoc_builddir}/detail/cc_hash_assoc_cntnr \ + ${assoc_builddir}/detail/value_type_adapter \ + ${assoc_builddir}/detail/lu_policy \ + ${assoc_builddir}/detail/gp_hash_assoc_cntnr \ + ${assoc_builddir}/detail/unordered_iterator \ + ${assoc_builddir}/detail/ov_tree_map_ \ + ${assoc_builddir}/detail/lu_assoc_cntnr \ + ${assoc_builddir}/detail/hash_fn \ + ${assoc_builddir}/detail/eq_fn \ + ${assoc_builddir}/detail/rb_tree_map_ \ + ${assoc_builddir}/detail/lu_map_ + +assoc_headers = \ + ${assoc_srcdir}/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/type_utils.hpp \ + ${assoc_srcdir}/detail/order_statistics_imp.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_find_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/extract_key.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_extract_key.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/splay_tree_.hpp \ + ${assoc_srcdir}/detail/splay_tree_/node.hpp \ + ${assoc_srcdir}/detail/splay_tree_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/splay_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_transform.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_apply.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_filter.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_at_index.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_contains.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_append.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_typelist_append.hpp \ + ${assoc_srcdir}/detail/ds_trait_imp.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cmp_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cond_key_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/entry_list_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cc_ht_map_.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/standard_policies.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/size_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/gp_ht_map_.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/iterator_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/tree_policy/order_statistics_imp.hpp \ + ${assoc_srcdir}/detail/tree_policy/null_node_updator_imp.hpp \ + ${assoc_srcdir}/detail/types_traits.hpp \ + ${assoc_srcdir}/detail/mapping_level_imp.hpp \ + ${assoc_srcdir}/detail/map_debug_base.hpp \ + ${assoc_srcdir}/detail/resize_policy/ht_prime_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_prime_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/size_base.hpp \ + ${assoc_srcdir}/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_exponential_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_standard_resize_policy_imp.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/find_iterators.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/node_iterators.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/rotate_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/r_erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/assoc_cntnr_base.hpp \ + ${assoc_srcdir}/detail/ms_category_imp.hpp \ + ${assoc_srcdir}/detail/hash_types_traits.hpp \ + ${assoc_srcdir}/detail/typelist.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/invalidation_guarantee_selector.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/iterator.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/constructor_destructor_and_related.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/value_type_traits.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/ref_pair.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/it_value_type_traits.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/erase_if_pred.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/value_type_adapter.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/iterator_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_policy/mtf_lu_policy_imp.hpp \ + ${assoc_srcdir}/detail/lu_policy/counter_lu_policy_imp.hpp \ + ${assoc_srcdir}/detail/lu_policy/counter_lu_metadata_imp.hpp \ + ${assoc_srcdir}/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/find_iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/const_iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/const_find_iterator.hpp \ + ${assoc_srcdir}/detail/standard_policies.hpp \ + ${assoc_srcdir}/detail/standard_sizes.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/ov_tree_map_.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/node_iterators.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/hash_fn/linear_probe_fn_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/mod_based_range_hashing.hpp \ + ${assoc_srcdir}/detail/hash_fn/direct_mod_range_hashing_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/probe_fn_base.hpp \ + ${assoc_srcdir}/detail/hash_fn/ranged_probe_fn.hpp \ + ${assoc_srcdir}/detail/hash_fn/quadratic_probe_fn_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/direct_mask_range_hashing_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/ranged_hash_fn.hpp \ + ${assoc_srcdir}/detail/hash_fn/mask_based_range_hashing.hpp \ + ${assoc_srcdir}/detail/eq_fn/eq_by_less.hpp \ + ${assoc_srcdir}/detail/eq_fn/hash_eq_fn.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/node.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/rb_tree_.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/lu_map_.hpp \ + ${assoc_srcdir}/detail/lu_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/ms_trait_imp.hpp \ + ${assoc_srcdir}/detail/cond_dealtor.hpp \ + ${assoc_srcdir}/hash_policy.hpp \ + ${assoc_srcdir}/trivial_iterator_def.hpp \ + ${assoc_srcdir}/ds_trait.hpp \ + ${assoc_srcdir}/exception.hpp \ + ${assoc_srcdir}/tree_policy.hpp \ + ${assoc_srcdir}/lu_policy.hpp \ + ${assoc_srcdir}/ms_trait.hpp \ + ${assoc_srcdir}/assoc_cntnr.hpp \ + ${assoc_srcdir}/data_type.hpp + + ext_srcdir = ${glibcxx_srcdir}/include/ext -ext_builddir = ./ext +ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/array_allocator.h \ @@ -209,6 +442,8 @@ ext_headers = \ ${ext_srcdir}/functional \ ${ext_srcdir}/hash_map \ ${ext_srcdir}/hash_set \ + ${ext_srcdir}/hash_fun.h \ + ${ext_srcdir}/hashtable.h \ ${ext_srcdir}/iterator \ ${ext_srcdir}/malloc_allocator.h \ ${ext_srcdir}/memory \ @@ -221,8 +456,8 @@ ext_headers = \ ${ext_srcdir}/rope \ ${ext_srcdir}/ropeimpl.h \ ${ext_srcdir}/slist \ - ${ext_srcdir}/hash_fun.h \ - ${ext_srcdir}/hashtable.h + ${ext_srcdir}/typelist.h + tr1_srcdir = ${glibcxx_srcdir}/include/tr1 tr1_builddir = ./tr1 @@ -407,7 +642,7 @@ endif # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-tr1 stamp-debug stamp-host + stamp-backward stamp-ext stamp-assoc stamp-tr1 stamp-debug stamp-host # List of all files that are created by explicit building, editing, or # catenation. @@ -427,8 +662,8 @@ stamp-std: ${std_headers} fi ;\ if [ ! -f stamp-std ]; then \ (cd ${std_builddir} && for h in $?; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ fi ;\ $(STAMP) stamp-std @@ -448,8 +683,8 @@ stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra} fi ;\ if [ ! -f stamp-c_base ]; then \ (cd ${c_base_builddir} && for h in ${c_base_headers}; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ if [ ! -z "${c_base_headers_extra}" ]; then \ (cd ${bits_builddir} && $(LN_S) ${c_base_headers_extra} . || true) ;\ @@ -486,6 +721,19 @@ stamp-ext: ${ext_headers} fi ;\ $(STAMP) stamp-ext +# Have to deal with nested include directories, gah! Strip off source +# directory before making the link. +stamp-assoc: ${assoc_headers} + @if [ ! -d "${assoc_builddir}" ]; then \ + mkdir -p ${assoc_subdirs} ;\ + fi ;\ + if [ ! -f stamp-assoc ]; then \ + (cd ${assoc_builddir} && for h in $?; do \ + build_name=`echo $$h | sed -e "s|${assoc_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done) ;\ + fi ;\ + $(STAMP) stamp-assoc stamp-tr1: ${tr1_headers} @if [ ! -d "${tr1_builddir}" ]; then \ @@ -637,6 +885,13 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir} for file in ${ext_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${assoc_builddir} + for dir in ${assoc_subdirs}; do \ + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/$${dir} ; done + for file in ${assoc_headers}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${assoc_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${assoc_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} for file in ${tr1_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 7f27b85491d..cbda94c713f 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -409,8 +409,238 @@ backward_headers = \ ${backward_srcdir}/strstream \ ${backward_srcdir}/backward_warning.h +assoc_srcdir = ${glibcxx_srcdir}/include/ext/pb_assoc +assoc_builddir = ./ext/pb_assoc +assoc_subdirs = \ + ${assoc_builddir}/detail \ + ${assoc_builddir}/detail/tree_assoc_cntnr \ + ${assoc_builddir}/detail/basic_assoc_cntnr \ + ${assoc_builddir}/detail/splay_tree_ \ + ${assoc_builddir}/detail/typelist \ + ${assoc_builddir}/detail/basic_hash_assoc_cntnr \ + ${assoc_builddir}/detail/cc_ht_map_ \ + ${assoc_builddir}/detail/gp_ht_map_ \ + ${assoc_builddir}/detail/tree_policy \ + ${assoc_builddir}/detail/resize_policy \ + ${assoc_builddir}/detail/bin_search_tree_ \ + ${assoc_builddir}/detail/basic_tree_assoc_cntnr \ + ${assoc_builddir}/detail/cc_hash_assoc_cntnr \ + ${assoc_builddir}/detail/value_type_adapter \ + ${assoc_builddir}/detail/lu_policy \ + ${assoc_builddir}/detail/gp_hash_assoc_cntnr \ + ${assoc_builddir}/detail/unordered_iterator \ + ${assoc_builddir}/detail/ov_tree_map_ \ + ${assoc_builddir}/detail/lu_assoc_cntnr \ + ${assoc_builddir}/detail/hash_fn \ + ${assoc_builddir}/detail/eq_fn \ + ${assoc_builddir}/detail/rb_tree_map_ \ + ${assoc_builddir}/detail/lu_map_ + +assoc_headers = \ + ${assoc_srcdir}/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/type_utils.hpp \ + ${assoc_srcdir}/detail/order_statistics_imp.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_find_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/extract_key.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/d_extract_key.hpp \ + ${assoc_srcdir}/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/splay_tree_.hpp \ + ${assoc_srcdir}/detail/splay_tree_/node.hpp \ + ${assoc_srcdir}/detail/splay_tree_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/splay_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/splay_tree_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_transform.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_apply.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_filter.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_at_index.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_contains.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_append.hpp \ + ${assoc_srcdir}/detail/typelist/typelist_typelist_append.hpp \ + ${assoc_srcdir}/detail/ds_trait_imp.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cmp_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cond_key_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/entry_list_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/cc_ht_map_.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/standard_policies.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/size_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/gp_ht_map_.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/iterator_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp \ + ${assoc_srcdir}/detail/tree_policy/order_statistics_imp.hpp \ + ${assoc_srcdir}/detail/tree_policy/null_node_updator_imp.hpp \ + ${assoc_srcdir}/detail/types_traits.hpp \ + ${assoc_srcdir}/detail/mapping_level_imp.hpp \ + ${assoc_srcdir}/detail/map_debug_base.hpp \ + ${assoc_srcdir}/detail/resize_policy/ht_prime_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_prime_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/size_base.hpp \ + ${assoc_srcdir}/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_exponential_size_policy_imp.hpp \ + ${assoc_srcdir}/detail/resize_policy/hash_standard_resize_policy_imp.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/find_iterators.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/node_iterators.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/rotate_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/r_erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp \ + ${assoc_srcdir}/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/assoc_cntnr_base.hpp \ + ${assoc_srcdir}/detail/ms_category_imp.hpp \ + ${assoc_srcdir}/detail/hash_types_traits.hpp \ + ${assoc_srcdir}/detail/typelist.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/invalidation_guarantee_selector.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/iterator.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/constructor_destructor_and_related.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/value_type_traits.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/ref_pair.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/it_value_type_traits.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/erase_if_pred.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/value_type_adapter.hpp \ + ${assoc_srcdir}/detail/value_type_adapter/iterator_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_policy/mtf_lu_policy_imp.hpp \ + ${assoc_srcdir}/detail/lu_policy/counter_lu_policy_imp.hpp \ + ${assoc_srcdir}/detail/lu_policy/counter_lu_metadata_imp.hpp \ + ${assoc_srcdir}/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/find_iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/const_iterator.hpp \ + ${assoc_srcdir}/detail/unordered_iterator/const_find_iterator.hpp \ + ${assoc_srcdir}/detail/standard_policies.hpp \ + ${assoc_srcdir}/detail/standard_sizes.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/ov_tree_map_.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/node_iterators.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/hash_fn/linear_probe_fn_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/mod_based_range_hashing.hpp \ + ${assoc_srcdir}/detail/hash_fn/direct_mod_range_hashing_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/probe_fn_base.hpp \ + ${assoc_srcdir}/detail/hash_fn/ranged_probe_fn.hpp \ + ${assoc_srcdir}/detail/hash_fn/quadratic_probe_fn_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/direct_mask_range_hashing_imp.hpp \ + ${assoc_srcdir}/detail/hash_fn/ranged_hash_fn.hpp \ + ${assoc_srcdir}/detail/hash_fn/mask_based_range_hashing.hpp \ + ${assoc_srcdir}/detail/eq_fn/eq_by_less.hpp \ + ${assoc_srcdir}/detail/eq_fn/hash_eq_fn.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/node.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/split_join_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/rb_tree_.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/lu_map_.hpp \ + ${assoc_srcdir}/detail/lu_map_/erase_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/policy_access_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/insert_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/find_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/constructor_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/info_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/iterators_fn_imps.hpp \ + ${assoc_srcdir}/detail/lu_map_/debug_fn_imps.hpp \ + ${assoc_srcdir}/detail/constructors_destructor_fn_imps.hpp \ + ${assoc_srcdir}/detail/ms_trait_imp.hpp \ + ${assoc_srcdir}/detail/cond_dealtor.hpp \ + ${assoc_srcdir}/hash_policy.hpp \ + ${assoc_srcdir}/trivial_iterator_def.hpp \ + ${assoc_srcdir}/ds_trait.hpp \ + ${assoc_srcdir}/exception.hpp \ + ${assoc_srcdir}/tree_policy.hpp \ + ${assoc_srcdir}/lu_policy.hpp \ + ${assoc_srcdir}/ms_trait.hpp \ + ${assoc_srcdir}/assoc_cntnr.hpp \ + ${assoc_srcdir}/data_type.hpp + ext_srcdir = ${glibcxx_srcdir}/include/ext -ext_builddir = ./ext +ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/array_allocator.h \ @@ -422,6 +652,8 @@ ext_headers = \ ${ext_srcdir}/functional \ ${ext_srcdir}/hash_map \ ${ext_srcdir}/hash_set \ + ${ext_srcdir}/hash_fun.h \ + ${ext_srcdir}/hashtable.h \ ${ext_srcdir}/iterator \ ${ext_srcdir}/malloc_allocator.h \ ${ext_srcdir}/memory \ @@ -434,8 +666,7 @@ ext_headers = \ ${ext_srcdir}/rope \ ${ext_srcdir}/ropeimpl.h \ ${ext_srcdir}/slist \ - ${ext_srcdir}/hash_fun.h \ - ${ext_srcdir}/hashtable.h + ${ext_srcdir}/typelist.h tr1_srcdir = ${glibcxx_srcdir}/include/tr1 tr1_builddir = ./tr1 @@ -615,7 +846,7 @@ PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS) # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-tr1 stamp-debug stamp-host + stamp-backward stamp-ext stamp-assoc stamp-tr1 stamp-debug stamp-host # List of all files that are created by explicit building, editing, or @@ -804,8 +1035,8 @@ stamp-std: ${std_headers} fi ;\ if [ ! -f stamp-std ]; then \ (cd ${std_builddir} && for h in $?; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ fi ;\ $(STAMP) stamp-std @@ -825,8 +1056,8 @@ stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra} fi ;\ if [ ! -f stamp-c_base ]; then \ (cd ${c_base_builddir} && for h in ${c_base_headers}; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ if [ ! -z "${c_base_headers_extra}" ]; then \ (cd ${bits_builddir} && $(LN_S) ${c_base_headers_extra} . || true) ;\ @@ -863,6 +1094,20 @@ stamp-ext: ${ext_headers} fi ;\ $(STAMP) stamp-ext +# Have to deal with nested include directories, gah! Strip off source +# directory before making the link. +stamp-assoc: ${assoc_headers} + @if [ ! -d "${assoc_builddir}" ]; then \ + mkdir -p ${assoc_subdirs} ;\ + fi ;\ + if [ ! -f stamp-assoc ]; then \ + (cd ${assoc_builddir} && for h in $?; do \ + build_name=`echo $$h | sed -e "s|${assoc_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done) ;\ + fi ;\ + $(STAMP) stamp-assoc + stamp-tr1: ${tr1_headers} @if [ ! -d "${tr1_builddir}" ]; then \ mkdir -p ${tr1_builddir} ;\ @@ -1007,6 +1252,13 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir} for file in ${ext_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${assoc_builddir} + for dir in ${assoc_subdirs}; do \ + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/$${dir} ; done + for file in ${assoc_headers}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${assoc_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${assoc_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} for file in ${tr1_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done diff --git a/libstdc++-v3/include/ext/pb_assoc/assoc_cntnr.hpp b/libstdc++-v3/include/ext/pb_assoc/assoc_cntnr.hpp new file mode 100644 index 00000000000..6615536c546 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/assoc_cntnr.hpp @@ -0,0 +1,1590 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 assoc_cntnr.hpp + * Contains associative containers. + */ + +#ifndef ASSOC_CNTNR_HPP +#define ASSOC_CNTNR_HPP + +#include <ext/pb_assoc/ms_trait.hpp> +#include <ext/pb_assoc/ds_trait.hpp> +#include <ext/pb_assoc/detail/type_utils.hpp> +#include <ext/pb_assoc/detail/typelist.hpp> +#include <ext/pb_assoc/detail/standard_policies.hpp> +#include <ext/pb_assoc/detail/mapping_level_imp.hpp> +#include <ext/pb_assoc/detail/assoc_cntnr_base.hpp> +#include <ext/pb_assoc/detail/value_type_adapter/value_type_adapter.hpp> + +namespace pb_assoc +{ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class DS_Tag, \ + class Policy_Tl, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + detail::assoc_cntnr_base< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator>::type + +#define PB_ASSOC_DIRECT_BASE_C_DEC \ + detail::assoc_cntnr_base< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator>::type + + template<typename Key, + typename Data, + class DS_Tag, + class Policy_Tl, + class Allocator> + class basic_assoc_cntnr + : public detail::assoc_cntnr_base<Key, Data, DS_Tag, Policy_Tl, Allocator>::type + { + public: + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef DS_Tag ds_category; + typedef data_enabled_ms_tag ms_category; + typedef Allocator allocator; + + typedef + typename allocator::template rebind< + Key>::other::value_type + key_type; + + typedef + typename allocator::template rebind< + Key>::other::reference + key_reference; + + typedef + typename allocator::template rebind< + Key>::other::const_reference + const_key_reference; + + typedef + typename allocator::template rebind< + Key>::other::pointer + key_pointer; + + typedef + typename allocator::template rebind< + Key>::other::const_pointer + const_key_pointer; + + typedef + typename allocator::template rebind< + Data>::other::value_type + data_type; + + typedef + typename allocator::template rebind< + Data>::other::reference + data_reference; + + typedef + typename allocator::template rebind< + Data>::other::const_reference + const_data_reference; + + typedef + typename allocator::template rebind< + Data>::other::pointer + data_pointer; + + typedef + typename allocator::template rebind< + Data>::other::const_pointer + const_data_pointer; + + typedef + typename allocator::template rebind< + std::pair<const key_type, data_type> >::other::value_type + value_type; + + typedef + typename allocator::template rebind< + std::pair<const key_type, data_type> >::other::reference + reference; + + typedef + typename allocator::template rebind< + std::pair<const key_type, data_type> >::other::const_reference + const_reference; + + typedef + typename allocator::template rebind< + std::pair<const key_type, data_type> >::other::pointer + pointer; + + typedef + typename allocator::template rebind< + std::pair<const key_type, data_type> >::other::const_pointer + const_pointer; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_find_iterator + const_find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + public: + + virtual + ~basic_assoc_cntnr(); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + inline static const_key_reference + extract_key(const_reference r_val); + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + + inline data_reference + operator[](const_key_reference r_key); + + inline find_iterator + find(const_key_reference r_key) + { + return (my_base::find(r_key)); + } + + inline const_find_iterator + find(const_key_reference r_key) const + { + return (my_base::find(r_key)); + } + + inline const_data_reference + operator[](const_key_reference r_key) const; + + inline size_type + erase(const_key_reference r_key); + + template<class Pred> + inline size_type + erase_if(Pred prd); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + + protected: + +#define PB_ASSOC_CLASS_NAME basic_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + typename PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + +#undef PB_ASSOC_CLASS_NAME + + private: + typedef typename PB_ASSOC_BASE_C_DEC my_base; + + private: + basic_assoc_cntnr& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + +#include <ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + class Cntnr, \ + class DS_Tag, \ + class Policy_Tl, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + compound_data_type< \ + Cntnr>, \ + DS_Tag, \ + Policy_Tl, \ + Allocator> + +#define PB_ASSOC_DIRECT_BASE_C_DEC \ + detail::value_type_adapter< \ + Key, \ + compound_data_type< \ + Cntnr>, \ + DS_Tag, \ + Policy_Tl, \ + Allocator, \ + detail::mapping_level_imp< \ + compound_data_type< \ + Cntnr> >::value - 1> + +#define PB_ASSOC_BASE_C_DEC \ + detail::assoc_cntnr_base< \ + Key, \ + compound_data_type< \ + Cntnr>, \ + DS_Tag, \ + Policy_Tl, \ + Allocator>::type + + template<typename Key, + class Cntnr, + class DS_Tag, + class Policy_Tl, + class Allocator> + class basic_assoc_cntnr<Key, compound_data_type< Cntnr>, DS_Tag, Policy_Tl, Allocator> : public PB_ASSOC_DIRECT_BASE_C_DEC + { + public: + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef DS_Tag ds_category; + typedef compound_data_enabled_ms_tag ms_category; + typedef Allocator allocator; + + typedef + typename allocator::template rebind< + Key>::other::value_type + key_type; + + typedef + typename allocator::template rebind< + Key>::other::reference + key_reference; + + typedef + typename allocator::template rebind< + Key>::other::const_reference + const_key_reference; + + typedef + typename allocator::template rebind< + Key>::other::pointer + key_pointer; + + typedef + typename allocator::template rebind< + Key>::other::const_pointer + const_key_pointer; + + typedef + typename allocator::template rebind< + Cntnr>::other::value_type + data_type; + + typedef + typename allocator::template rebind< + Cntnr>::other::reference + data_reference; + + typedef + typename allocator::template rebind< + Cntnr>::other::const_reference + const_data_reference; + + typedef + typename allocator::template rebind< + Cntnr>::other::pointer + data_pointer; + + typedef + typename allocator::template rebind< + Cntnr>::other::const_pointer + const_data_pointer; + + typedef + typename allocator::template rebind< + std::pair<const key_type, Cntnr> >::other::value_type + value_type; + + typedef + typename allocator::template rebind< + std::pair<const key_type, Cntnr> >::other::reference + reference; + + typedef + typename allocator::template rebind< + std::pair<const key_type, Cntnr> >::other::const_reference + const_reference; + + typedef + typename allocator::template rebind< + std::pair<const key_type, Cntnr> >::other::pointer + pointer; + + typedef + typename allocator::template rebind< + std::pair<const key_type, Cntnr> >::other::const_pointer + const_pointer; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_find_iterator + const_find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + template<int Mapping_Level> + struct rebind + { + private: + enum + { + mapping_level = + detail::mapping_level_imp<compound_data_type<Cntnr> >::value + }; + + public: + typedef + detail::value_type_adapter< + Key, + compound_data_type< + Cntnr>, + DS_Tag, + Policy_Tl, + Allocator, + mapping_level - Mapping_Level> + other; + }; + + public: + + virtual + ~basic_assoc_cntnr(); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + inline static const_key_reference + extract_key(const_reference r_val); + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + + inline data_reference + operator[](const_key_reference r_key); + + inline find_iterator + find(const_key_reference r_key) + { + return (my_base::find(r_key)); + } + + inline const_find_iterator + find(const_key_reference r_key) const + { + return (my_base::find(r_key)); + } + + inline const_data_reference + operator[](const_key_reference r_key) const; + + inline size_type + erase(const_key_reference r_key); + + template<class Pred> + inline size_type + erase_if(Pred prd); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + + protected: + +#define PB_ASSOC_CLASS_NAME basic_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + typename PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + +#undef PB_ASSOC_CLASS_NAME + + private: + typedef typename PB_ASSOC_BASE_C_DEC my_base; + + private: + basic_assoc_cntnr& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + +#include <ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class DS_Tag, class Policy_Tl, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + null_data_type, \ + DS_Tag, \ + Policy_Tl, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + detail::assoc_cntnr_base< \ + Key, \ + null_data_type, \ + DS_Tag, \ + Policy_Tl, \ + Allocator>::type + + template<typename Key, class DS_Tag, class Policy_Tl, class Allocator> + class basic_assoc_cntnr<Key, null_data_type, DS_Tag, Policy_Tl, Allocator> : public PB_ASSOC_BASE_C_DEC + { + public: + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef DS_Tag ds_category; + typedef basic_ms_tag ms_category; + typedef Allocator allocator; + + typedef + typename allocator::template rebind< + Key>::other::value_type + key_type; + + typedef + typename allocator::template rebind< + Key>::other::reference + key_reference; + + typedef + typename allocator::template rebind< + Key>::other::const_reference + const_key_reference; + + typedef + typename allocator::template rebind< + Key>::other::pointer + key_pointer; + + typedef + typename allocator::template rebind< + Key>::other::const_pointer + const_key_pointer; + + typedef + typename allocator::template rebind< + key_type>::other::value_type + value_type; + + typedef + typename allocator::template rebind< + key_type>::other::const_reference + reference; + + typedef + typename allocator::template rebind< + key_type>::other::const_reference + const_reference; + + typedef + typename allocator::template rebind< + key_type>::other::const_pointer + pointer; + + typedef + typename allocator::template rebind<key_type>::other::const_pointer + const_pointer; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_find_iterator + const_find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + public: + + virtual + ~basic_assoc_cntnr(); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + inline static const_key_reference + extract_key(const_reference r_val); + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + + inline find_iterator + find(const_key_reference r_key) + { return (my_base::find(r_key)); } + + inline const_find_iterator + find(const_key_reference r_key) const + { return (my_base::find(r_key)); } + + inline size_type + erase(const_key_reference r_key); + + template<class Pred> + inline size_type + erase_if(Pred prd); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + + protected: + +#define PB_ASSOC_CLASS_NAME basic_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_C_DEC PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + typename PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + +#undef PB_ASSOC_CLASS_NAME + + private: + typedef typename PB_ASSOC_BASE_C_DEC my_base; + + private: + basic_assoc_cntnr& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + +#include <ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_assoc_cntnr/extract_key.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_TYPELIST_CHAIN1(X0) pb_assoc::detail::typelist_chain<X0, pb_assoc::detail::null_type> +#define PB_ASSOC_TYPELIST_CHAIN2(X0, X1) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN1(X1) > +#define PB_ASSOC_TYPELIST_CHAIN3(X0, X1, X2) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN2(X1, X2) > +#define PB_ASSOC_TYPELIST_CHAIN4(X0, X1, X2, X3) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN3(X1, X2, X3) > +#define PB_ASSOC_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN4(X1, X2, X3, X4) > +#define PB_ASSOC_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) > +#define PB_ASSOC_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) > +#define PB_ASSOC_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) > +#define PB_ASSOC_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) > +#define PB_ASSOC_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) > +#define PB_ASSOC_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) > +#define PB_ASSOC_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) > +#define PB_ASSOC_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) > +#define PB_ASSOC_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) > +#define PB_ASSOC_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) > + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Hash_Fn, \ + class Eq_Fn, \ + class Resize_Policy, \ + bool Store_Hash, \ + class DS_Tag, \ + class Policy_TL, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_hash_assoc_cntnr< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Resize_Policy, \ + Store_Hash, \ + DS_Tag, \ + Policy_TL, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + Data, \ + DS_Tag, \ + typename pb_assoc::detail::typelist_append< \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN4( Hash_Fn, Eq_Fn, Resize_Policy, pb_assoc::detail::int_to_type<Store_Hash>) >, \ + Policy_TL>::type, \ + Allocator> + + template<typename Key, + typename Data, + class Hash_Fn, + class Eq_Fn, + class Resize_Policy, + bool Store_Hash, + class DS_Tag, + class Policy_TL, + class Allocator> + class basic_hash_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + public: + typedef Hash_Fn hash_fn; + + typedef Eq_Fn eq_fn; + + typedef Resize_Policy resize_policy; + + enum + { + store_hash = Store_Hash + }; + + virtual + ~basic_hash_assoc_cntnr(); + + hash_fn& + get_hash_fn(); + + const hash_fn& + get_hash_fn() const; + + eq_fn& + get_eq_fn(); + + const eq_fn& + get_eq_fn() const; + + Resize_Policy& + get_resize_policy(); + + const resize_policy& + get_resize_policy() const; + + protected: + + typedef typename Allocator::size_type size_type; + + virtual void + do_resize(size_type new_size); + +#define PB_ASSOC_CLASS_NAME basic_hash_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_C_DEC PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + + basic_hash_assoc_cntnr& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + +#include <ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Hash_Fn, \ + class Eq_Fn, \ + class Comb_Hash_Fn, \ + class Resize_Policy, \ + bool Store_Hash, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + cc_hash_assoc_cntnr< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Comb_Hash_Fn, \ + Resize_Policy, \ + Store_Hash, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_hash_assoc_cntnr< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Resize_Policy, \ + Store_Hash, \ + cc_hash_ds_tag, \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN1( \ + Comb_Hash_Fn) >, \ + Allocator> + + template<typename Key, + typename Data, + class Hash_Fn = typename pb_assoc::detail::def_hash_fn<Key>::type, + class Eq_Fn = typename pb_assoc::detail::def_eq_fn<Key>::type, + class Comb_Hash_Fn = pb_assoc::detail::def_comb_hash_fn::type, + class Resize_Policy = + typename pb_assoc::detail::def_resize_policy<Comb_Hash_Fn>::type, + bool Store_Hash = pb_assoc::detail::def_store_hash, + class Allocator = std::allocator<char> > + class cc_hash_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + public: + typedef Comb_Hash_Fn comb_hash_fn; + + cc_hash_assoc_cntnr(); + + cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn); + + cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn); + + cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, + const Comb_Hash_Fn& r_comb_hash_fn); + + cc_hash_assoc_cntnr(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); + + template<class It> + cc_hash_assoc_cntnr(It first_it, It last_it); + + template<class It> + cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn); + + template<class It> + cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, + const Eq_Fn& r_eq_fn); + + template<class It> + cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + template<class It> + cc_hash_assoc_cntnr(It first_it, It last_it, 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); + + cc_hash_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~cc_hash_assoc_cntnr(); + + PB_ASSOC_CLASS_C_DEC& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + comb_hash_fn& + get_comb_hash_fn(); + + const comb_hash_fn& + get_comb_hash_fn() const; + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Hash_Fn, \ + class Eq_Fn, \ + class Comb_Probe_Fn, \ + class Probe_Fn, \ + class Resize_Policy, \ + bool Store_Hash, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + gp_hash_assoc_cntnr< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Comb_Probe_Fn, \ + Probe_Fn, \ + Resize_Policy, \ + Store_Hash, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_hash_assoc_cntnr< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Resize_Policy, \ + Store_Hash, \ + gp_hash_ds_tag, \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN2( Comb_Probe_Fn, Probe_Fn) >, \ + Allocator> + + template<typename Key, + typename Data, + class Hash_Fn = typename pb_assoc::detail::def_hash_fn<Key>::type, + class Eq_Fn = typename pb_assoc::detail::def_eq_fn<Key>::type, + class Comb_Probe_Fn = pb_assoc::detail::def_comb_hash_fn::type, + class Probe_Fn = typename detail::def_probe_fn<Comb_Probe_Fn>::type, + class Resize_Policy = + typename pb_assoc::detail::def_resize_policy<Comb_Probe_Fn>::type, + + bool Store_Hash = pb_assoc::detail::def_store_hash, + class Allocator = std::allocator<char> > + class gp_hash_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + public: + typedef Comb_Probe_Fn comb_probe_fn; + typedef Probe_Fn probe_fn; + + gp_hash_assoc_cntnr(); + + gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn); + + gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn); + + gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, + const Comb_Probe_Fn& r_comb_probe_fn); + + gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, + const Comb_Probe_Fn& r_comb_probe_fn, + const Probe_Fn& r_probe_fn); + + gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, + const Comb_Probe_Fn& r_comb_probe_fn, + const Probe_Fn& r_probe_fn, + const Resize_Policy& r_resize_policy); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn); + + template<class It> + gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy); + + gp_hash_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~gp_hash_assoc_cntnr(); + + PB_ASSOC_CLASS_C_DEC& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + comb_probe_fn& + get_comb_probe_fn(); + + const comb_probe_fn& + get_comb_probe_fn() const; + + probe_fn& + get_probe_fn(); + + const probe_fn& + get_probe_fn() const; + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class DS_Tag, \ + class Node_Updator, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_tree_assoc_cntnr< \ + Key, \ + Data, \ + Cmp_Fn, \ + DS_Tag, \ + Node_Updator, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + Data, \ + DS_Tag, \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN2( Cmp_Fn, Node_Updator) >, \ + Allocator> + + template<typename Key, + typename Data, + class Cmp_Fn, + class DS_Tag, + class Node_Updator, + class Allocator> + class basic_tree_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + public: + typedef typename Allocator::size_type size_type; + + typedef + typename Allocator::template rebind< + Key>::other::const_reference + const_key_reference; + + typedef Cmp_Fn cmp_fn; + + typedef Node_Updator node_updator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_reverse_iterator + const_reverse_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::reverse_iterator + reverse_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_node_iterator + const_node_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::node_iterator node_iterator; + + virtual + ~basic_tree_assoc_cntnr(); + + cmp_fn& + get_cmp_fn(); + + const cmp_fn& + get_cmp_fn() const; + + node_updator& + get_node_updator(); + + const node_updator& + get_node_updator() const; + + inline size_type + erase(const_key_reference r_key); + + inline iterator + erase(iterator it); + + inline reverse_iterator + erase(reverse_iterator it) + { + return (my_base::erase(it)); + } + + inline reverse_iterator + rbegin() + { + return (my_base::rbegin()); + } + + inline const_reverse_iterator + rbegin() const + { + return (my_base::rbegin()); + } + + inline reverse_iterator + rend() + { + return (my_base::rend()); + } + + inline const_reverse_iterator + rend() const + { + return (my_base::rend()); + } + + inline node_iterator + node_begin() + { + return (my_base::node_begin()); + } + + inline const_node_iterator + node_begin() const + { + return (my_base::node_begin()); + } + + inline node_iterator + node_end() + { + return (my_base::node_end()); + } + + inline const_node_iterator + node_end() const + { + return (my_base::node_end()); + } + + void + join(PB_ASSOC_CLASS_C_DEC& r_other); + + inline void + split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + +#define PB_ASSOC_CLASS_NAME basic_tree_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_C_DEC PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class Node_Updator, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + basic_tree_assoc_cntnr< \ + Key, \ + Data, \ + Cmp_Fn, \ + ov_tree_ds_tag, \ + Node_Updator, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + Data, \ + ov_tree_ds_tag, \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN2( Cmp_Fn, Node_Updator) >, \ + Allocator> + + template<typename Key, + typename Data, + typename Cmp_Fn, + typename Node_Updator, + typename Allocator> + class basic_tree_assoc_cntnr<Key, Data, Cmp_Fn, ov_tree_ds_tag, Node_Updator, Allocator> + : public PB_ASSOC_BASE_C_DEC + { + public: + typedef typename Allocator::size_type size_type; + + typedef + typename Allocator::template rebind< + Key>::other::const_reference + const_key_reference; + + typedef Cmp_Fn cmp_fn; + + typedef Node_Updator node_updator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_node_iterator + const_node_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::node_iterator node_iterator; + + virtual + ~basic_tree_assoc_cntnr(); + + cmp_fn& + get_cmp_fn(); + + const cmp_fn& + get_cmp_fn() const; + + node_updator& + get_node_updator(); + + const node_updator& + get_node_updator() const; + + inline size_type + erase(const_key_reference r_key); + + inline iterator + erase(iterator it); + + inline node_iterator + node_begin() + { + return (my_base::node_begin()); + } + + inline const_node_iterator + node_begin() const + { + return (my_base::node_begin()); + } + + inline node_iterator + node_end() + { + return (my_base::node_end()); + } + + inline const_node_iterator + node_end() const + { + return (my_base::node_end()); + } + + void + join(PB_ASSOC_CLASS_C_DEC& r_other); + + inline void + split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + +#define PB_ASSOC_CLASS_NAME basic_tree_assoc_cntnr + +#define PB_ASSOC_DIRECT_BASE_C_DEC PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp> +#include <ext/pb_assoc/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class DS_Tag, \ + class Node_Updator, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + tree_assoc_cntnr< \ + Key, \ + Data, \ + Cmp_Fn, \ + DS_Tag, \ + Node_Updator, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_tree_assoc_cntnr< \ + Key, \ + Data, \ + Cmp_Fn, \ + DS_Tag, \ + Node_Updator, \ + Allocator> + + template<typename Key, typename Data, class Cmp_Fn = std::less<Key>, + typename DS_Tag = rb_tree_ds_tag, + typename Node_Updator = pb_assoc::detail::def_node_updator, + typename Allocator = std::allocator<char> > + class tree_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + typedef Cmp_Fn cmp_fn; + typedef Node_Updator node_updator; + + public: + tree_assoc_cntnr(); + tree_assoc_cntnr(const cmp_fn& r_cmp_fn); + tree_assoc_cntnr(const cmp_fn& r_cmp_fn, const Node_Updator&r); + + template<typename It> + tree_assoc_cntnr(It first_it, It last_it); + + template<typename It> + tree_assoc_cntnr(It first_it, It last_it, const cmp_fn& r_cmp_fn); + + template<typename It> + tree_assoc_cntnr(It, It, const cmp_fn&, const Node_Updator&); + + tree_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~tree_assoc_cntnr(); + + PB_ASSOC_CLASS_C_DEC& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Eq_Fn, \ + class Update_Policy, \ + class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + lu_assoc_cntnr< \ + Key, \ + Data, \ + Eq_Fn, \ + Update_Policy, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + basic_assoc_cntnr< \ + Key, \ + Data, \ + lu_ds_tag, \ + pb_assoc::detail::typelist< \ + PB_ASSOC_TYPELIST_CHAIN2( Eq_Fn, Update_Policy) >, \ + Allocator> + + template<typename Key, + typename Data, + typename Eq_Fn = typename pb_assoc::detail::def_eq_fn<Key>::type, + typename Update_Policy = pb_assoc::detail::def_update_policy::type, + typename Allocator = std::allocator<char> > + class lu_assoc_cntnr : public PB_ASSOC_BASE_C_DEC + { + public: + typedef Eq_Fn eq_fn; + typedef Allocator allocator; + typedef Update_Policy update_policy; + + lu_assoc_cntnr(); + lu_assoc_cntnr(const Eq_Fn& r_eq_fn); + lu_assoc_cntnr(const Eq_Fn& r_eq_fn, const Update_Policy& r_update_policy); + + template<typename It> + lu_assoc_cntnr(It first_it, It last_it); + + template<typename It> + lu_assoc_cntnr(It first_it, It last_it, const Eq_Fn& r_eq_fn); + + template<typename It> + lu_assoc_cntnr(It, It, const Eq_Fn&, const Update_Policy&); + + lu_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~lu_assoc_cntnr(); + + PB_ASSOC_CLASS_C_DEC& + operator=(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + eq_fn& + get_eq_fn(); + + const eq_fn& + get_eq_fn() const; + + update_policy& + get_update_policy(); + + const update_policy& + get_update_policy() const; + + private: + typedef PB_ASSOC_BASE_C_DEC my_base; + }; + +#include <ext/pb_assoc/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#undef PB_ASSOC_TYPELIST_CHAIN1 +#undef PB_ASSOC_TYPELIST_CHAIN2 +#undef PB_ASSOC_TYPELIST_CHAIN3 +#undef PB_ASSOC_TYPELIST_CHAIN4 +#undef PB_ASSOC_TYPELIST_CHAIN5 +#undef PB_ASSOC_TYPELIST_CHAIN6 +#undef PB_ASSOC_TYPELIST_CHAIN7 +#undef PB_ASSOC_TYPELIST_CHAIN8 +#undef PB_ASSOC_TYPELIST_CHAIN9 +#undef PB_ASSOC_TYPELIST_CHAIN10 +#undef PB_ASSOC_TYPELIST_CHAIN11 +#undef PB_ASSOC_TYPELIST_CHAIN12 +#undef PB_ASSOC_TYPELIST_CHAIN13 +#undef PB_ASSOC_TYPELIST_CHAIN14 +#undef PB_ASSOC_TYPELIST_CHAIN15 + +} // namespace pb_assoc + +#endif // #ifndef ASSOC_CNTNR_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/data_type.hpp b/libstdc++-v3/include/ext/pb_assoc/data_type.hpp new file mode 100644 index 00000000000..8584b782928 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/data_type.hpp @@ -0,0 +1,60 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 data_tye.hpp + * Contains a traits class of types used by containers. + */ + +#ifndef DATA_TYPE_HPP +#define DATA_TYPE_HPP + +namespace pb_assoc +{ + struct null_data_type + { }; + + template<typename Cntnr> + struct compound_data_type + { + typedef Cntnr cntnr; + }; +} // namespace pb_assoc + +#endif // #ifndef DATA_TYPE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/assoc_cntnr_base.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/assoc_cntnr_base.hpp new file mode 100644 index 00000000000..bce621bb2d7 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/assoc_cntnr_base.hpp @@ -0,0 +1,346 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 assoc_cntnr_base.hpp + * Contains an associative container dispatching base. + */ + +#ifndef ASSOC_CNTNR_BASE_HPP +#define ASSOC_CNTNR_BASE_HPP + +#include <ext/pb_assoc/detail/typelist.hpp> + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/lu_map_/lu_map_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/lu_map_/lu_map_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp> +#undef PB_ASSOC_DATA_TRUE_INDICATOR + +#define PB_ASSOC_DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp> +#undef PB_ASSOC_DATA_FALSE_INDICATOR + +namespace pb_assoc +{ + + namespace detail + { + + template<typename Key, + typename Data, + class Data_Structure_Taq, + class Policy_Tl, + class Allocator> + struct assoc_cntnr_base; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + lu_ds_tag, + Policy_Tl, + Allocator> + { + typedef + lu_map_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + lu_ds_tag, + Policy_Tl, + Allocator> + { + typedef + lu_map_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + rb_tree_ds_tag, + Policy_Tl, + Allocator> + { + typedef + rb_tree_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + rb_tree_ds_tag, + Policy_Tl, + Allocator> + { + typedef + rb_tree_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + splay_tree_ds_tag, + Policy_Tl, + Allocator> + + { + typedef + splay_tree_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + splay_tree_ds_tag, + Policy_Tl, + Allocator> + { + typedef + splay_tree_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + ov_tree_ds_tag, + Policy_Tl, + Allocator> + { + typedef + ov_tree_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + ov_tree_ds_tag, + Policy_Tl, + Allocator> + { + typedef + ov_tree_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + Allocator, + typename typelist_at_index<Policy_Tl, 1>::type> + type; + }; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + cc_hash_ds_tag, + Policy_Tl, + Allocator> + { + typedef + cc_ht_map_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + typename typelist_at_index<Policy_Tl, 1>::type, + Allocator, + typelist_at_index<Policy_Tl, 3>::type::value, + typename typelist_at_index<Policy_Tl, 4>::type, + typename typelist_at_index<Policy_Tl, 2>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + cc_hash_ds_tag, + Policy_Tl, + Allocator> + { + typedef + cc_ht_map_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + typename typelist_at_index<Policy_Tl, 1>::type, + Allocator, + typelist_at_index<Policy_Tl, 3>::type::value, + typename typelist_at_index<Policy_Tl, 4>::type, + typename typelist_at_index<Policy_Tl, 2>::type> + type; + }; + + template<typename Key, typename Data, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + Data, + gp_hash_ds_tag, + Policy_Tl, + Allocator> + { + typedef + gp_ht_map_data_< + Key, + Data, + typename typelist_at_index<Policy_Tl, 0>::type, + typename typelist_at_index<Policy_Tl, 1>::type, + Allocator, + typelist_at_index<Policy_Tl, 3>::type::value, + typename typelist_at_index<Policy_Tl, 4>::type, + typename typelist_at_index<Policy_Tl, 5>::type, + typename typelist_at_index<Policy_Tl, 2>::type> + type; + }; + + template<typename Key, class Policy_Tl, class Allocator> + struct assoc_cntnr_base< + Key, + null_data_type, + gp_hash_ds_tag, + Policy_Tl, + Allocator> + { + typedef + gp_ht_map_no_data_< + Key, + null_data_type, + typename typelist_at_index<Policy_Tl, 0>::type, + typename typelist_at_index<Policy_Tl, 1>::type, + Allocator, + typelist_at_index<Policy_Tl, 3>::type::value, + typename typelist_at_index<Policy_Tl, 4>::type, + typename typelist_at_index<Policy_Tl, 5>::type, + typename typelist_at_index<Policy_Tl, 2>::type> + type; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef ASSOC_CNTNR_BASE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..abe851ceda4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,164 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of constructors, destructors, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1, typename T2> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1, typename T2, typename T3> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6, t7) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8> +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) : + PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6, t7, t8) +{ } + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +basic_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_DIRECT_BASE_C_DEC((const PB_ASSOC_DIRECT_BASE_C_DEC& )r_other) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~basic_assoc_cntnr() +{ } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..9f85fad2004 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/constructors_destructor_fn_imps.hpp @@ -0,0 +1,48 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains constructors and destructor implementation. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~basic_assoc_cntnr() +{ } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp new file mode 100644 index 00000000000..31794ecf0d8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_extract_key.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 d_extract_key.hpp + * Contains implementations of info related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_key_reference +PB_ASSOC_CLASS_C_DEC:: +extract_key(const_reference r_val) +{ + return (r_val.first); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp new file mode 100644 index 00000000000..1c3c40252b0 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_find_fn_imps.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 d_find_fn_imps.hpp + * Contains implementations of gp_ht_maps's find related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +operator[](const_key_reference r_key) const +{ + return (my_base::const_subscript_imp(r_key)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp new file mode 100644 index 00000000000..e7878ce22b4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/d_insert_fn_imps.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 d_insert_fn_imps.hpp + * Contains implementations of gp_ht_maps's erase related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +operator[](const_key_reference r_key) +{ + return (my_base::subscript_imp(r_key)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp new file mode 100644 index 00000000000..909cbeb1bb9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/erase_fn_imps.hpp @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of gp_ht_maps's erase related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + return (my_base::erase(r_key)); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + return (my_base::clear()); +} + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred pred) +{ + return (my_base::erase_if(pred)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/extract_key.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/extract_key.hpp new file mode 100644 index 00000000000..cd24328aa77 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/extract_key.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 extract_key.hpp + * Contains implementations of info related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_key_reference +PB_ASSOC_CLASS_C_DEC:: +extract_key(const_reference r_val) +{ + return (r_val); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp new file mode 100644 index 00000000000..07a1ec885d3 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/info_fn_imps.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains implementations of info related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (my_base::size()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (my_base::max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (my_base::empty()); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp new file mode 100644 index 00000000000..919402e7a11 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/insert_fn_imps.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains implementations of gp_ht_maps's erase related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_reference r_value) +{ + return (my_base::insert(r_value)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp new file mode 100644 index 00000000000..c2c095480a8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_assoc_cntnr/iterators_fn_imps.hpp @@ -0,0 +1,76 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterators_fn_imps.hpp + * Contains implementations of gp_ht_map_'s iterators related functions, e.g., + * begin(). + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +begin() +{ + return (my_base::begin()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +end() +{ + return (my_base::end()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +begin() const +{ + return (my_base::begin()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +end() const +{ + return (my_base::end()); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..c9d33302c8a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_CLASS_NAME() +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..ba5cb5f9ecf --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/constructors_destructor_fn_imps.hpp @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~basic_hash_assoc_cntnr() +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp new file mode 100644 index 00000000000..fc5cd65c6f8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_hash_assoc_cntnr/resize_fn_imps.hpp @@ -0,0 +1,51 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_fn_imps.hpp + * Contains implementations of resize functions + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +do_resize(size_type new_size) +{ + return (my_base::do_resize(new_size)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..82f55368fe4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~basic_tree_assoc_cntnr() +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..82f55368fe4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/constructors_destructor_fn_imps.hpp @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~basic_tree_assoc_cntnr() +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp new file mode 100644 index 00000000000..a69f6350dbc --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/erase_fn_imps.hpp @@ -0,0 +1,60 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of rb_tree's find related functions, + * common to all tree container types. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + return (my_base::erase(r_key)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +erase(iterator it) +{ + return (my_base::erase(it)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp new file mode 100644 index 00000000000..6f3f42370f3 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/node_iteration_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_iteration_fn_imps.hpp + * Contains a rb_tree set implementation. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp new file mode 100644 index 00000000000..c3e3794e3fb --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/policy_access_fn_imps.hpp @@ -0,0 +1,76 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 policy_access_fn_imps.hpp + * Contains implementation of rb trees + */ + +PB_ASSOC_CLASS_T_DEC +Cmp_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Cmp_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Node_Updator& +PB_ASSOC_CLASS_C_DEC:: +get_node_updator() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Node_Updator& +PB_ASSOC_CLASS_C_DEC:: +get_node_updator() const +{ + return (*this); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp new file mode 100644 index 00000000000..4dbaaec4600 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_erase_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of rb_tree's find related functions, + * common to all tree container types. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp new file mode 100644 index 00000000000..67a2abaa9fe --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/r_range_iteration_fn_imps.hpp @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 range_iteration_fn_imps.hpp + * Contains a rb_tree set implementation. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp new file mode 100644 index 00000000000..67a2abaa9fe --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/range_iteration_fn_imps.hpp @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 range_iteration_fn_imps.hpp + * Contains a rb_tree set implementation. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp new file mode 100644 index 00000000000..18d30ba1dc6 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/basic_tree_assoc_cntnr/split_join_fn_imps.hpp @@ -0,0 +1,60 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_fn_imps.hpp + * Contains implementation of rb trees + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +join(PB_ASSOC_CLASS_C_DEC& r_other) +{ + return (my_base::join(r_other)); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_base::split(r_key, r_other); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp new file mode 100644 index 00000000000..5667f0ac8bf --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp @@ -0,0 +1,525 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 bin_search_tree_.hpp + * Contains an implementation class for bin_search_tree_. + */ +/* + * This implementation uses an idea from the SGI STL (using a "header" node + * which is needed for efficient iteration). + */ + +#include <ext/pb_assoc/exception.hpp> +#include <ext/pb_assoc/detail/eq_fn/eq_by_less.hpp> +#include <ext/pb_assoc/detail/types_traits.hpp> +#include <ext/pb_assoc/detail/map_debug_base.hpp> +#include <ext/pb_assoc/tree_policy.hpp> +#include <ext/pb_assoc/detail/cond_dealtor.hpp> +#include <ext/pb_assoc/detail/type_utils.hpp> +#include <utility> +#include <functional> +#include <assert.h> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Node, \ + class Cmp_Fn, \ + class Allocator, \ + class Node_Updator> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + bin_search_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + bin_search_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Node, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + pb_assoc::detail::types_traits< \ + Key, \ + Data, \ + Allocator> + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE +#define PB_ASSOC_MAP_DEBUG_BASE_C_DEC \ + pb_assoc::detail::map_debug_base< \ + Key, \ + eq_by_less<Key, Cmp_Fn> > +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#define PB_ASSOC_EP2VP(X)& ((X)->m_value) +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Mapped_Data() +#define PB_ASSOC_EP2VP(X)& ((X)->m_value.first) +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + + template<typename Key, + typename Data, + class Node, + class Cmp_Fn, + class Allocator, + class Node_Updator> + class PB_ASSOC_CLASS_NAME : +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + protected PB_ASSOC_MAP_DEBUG_BASE_C_DEC, +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + protected Cmp_Fn, + public PB_ASSOC_TYPES_TRAITS_C_DEC, + public Node_Updator + { + + protected: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + typedef PB_ASSOC_TYPES_TRAITS_C_DEC my_traits_base; + + typedef Node node; + + typedef + pb_assoc::detail::cond_dealtor< + node, + Allocator> + cond_dealtor_t; + + typedef + typename Allocator::template rebind<node>::other + node_allocator; + + typedef typename node_allocator::value_type node_type; + + typedef typename node_allocator::pointer node_pointer; + + typedef value_type mapped_value_type; + + typedef reference mapped_reference; + + typedef const_reference const_mapped_reference; + + typedef pointer mapped_pointer; + + typedef const_pointer const_mapped_pointer; + +#include <ext/pb_assoc/detail/bin_search_tree_/find_iterators.hpp> + + typedef const_it_<true> const_find_iterator; + + typedef it_<true> find_iterator; + + typedef const_find_iterator const_iterator; + + typedef find_iterator iterator; + + typedef const_it_<false> const_reverse_iterator; + + typedef it_<false> reverse_iterator; + +#include <ext/pb_assoc/detail/bin_search_tree_/node_iterators.hpp> + + typedef const_node_it_ const_node_iterator; + + typedef node_it_ node_iterator; + + typedef Cmp_Fn cmp_fn; + + typedef Allocator allocator; + + private: + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + typedef PB_ASSOC_MAP_DEBUG_BASE_C_DEC my_map_debug_base; +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_updator); + + PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + ~PB_ASSOC_CLASS_NAME(); + + void + initialize_min_max(); + + template<class Other_Map_Type> + bool + cmp_with_other(const Other_Map_Type& r_other) const; + + inline bool + empty() const; + + inline size_type + size() const; + + inline size_type + max_size() const; + + Cmp_Fn& + get_cmp_fn(); + + const Cmp_Fn& + get_cmp_fn() const; + + inline std::pair<find_iterator, bool> + insert_leaf(const_reference r_value); + + inline find_iterator + lower_bound(const_key_reference r_key); + + inline const_find_iterator + lower_bound(const_key_reference r_key) const; + + inline find_iterator + upper_bound(const_key_reference r_key); + + inline const_find_iterator + upper_bound(const_key_reference r_key) const; + + inline find_iterator + find(const_key_reference r_key); + + inline const_find_iterator + find(const_key_reference r_key) const; + + inline void + update_min_max_for_erased_node(node_pointer p_nd); + + inline void + actual_erase_node(node_pointer p_nd); + + void + clear(); + + inline void + rotate_left(node_pointer p_x); + + inline void + rotate_right(node_pointer p_y); + + inline void + rotate_parent(node_pointer p_nd); + + inline void + apply_update(node_pointer p_nd, pb_assoc::null_node_updator* ); + + template<class Node_Updator_> + inline void + apply_update(node_pointer p_nd, Node_Updator_* p_updator); + + template<class Node_Updator_> + inline void + update_to_top(node_pointer p_nd, Node_Updator_* p_updator); + + inline void + update_to_top(node_pointer p_nd, pb_assoc::null_node_updator* ); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + find_end(); + + inline const_iterator + find_end() const; + + inline iterator + end(); + + inline const_iterator + end() const; + + inline reverse_iterator + rbegin() + { + return (reverse_iterator(m_p_head->m_p_right)); + } + + inline const_reverse_iterator + rbegin() const; + + inline reverse_iterator + find_rend(); + + inline const_reverse_iterator + find_rend() const; + + inline reverse_iterator + rend(); + + inline const_reverse_iterator + rend() const; + + bool + join_prep(PB_ASSOC_CLASS_C_DEC& r_other); + + void + join_finish(PB_ASSOC_CLASS_C_DEC& r_other); + + bool + split_prep(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + + void + split_finish(PB_ASSOC_CLASS_C_DEC& r_other); + + size_type + recursive_count(node_pointer p_nd) const; + + inline const_node_iterator + node_begin() const; + + inline node_iterator + node_begin(); + + inline const_node_iterator + node_end() const; + + inline node_iterator + node_end(); + + private: + + inline std::pair<node_pointer, bool> + erase(node_pointer p_nd); + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + void + assert_valid(bool check_iterators, bool check_metadata) const; + + std::pair<const_pointer, const_pointer> + assert_node_consistent(const node_pointer p_nd) const + { + if (p_nd == NULL) + return (std::make_pair((const_pointer)NULL,(const_pointer)NULL)); + + assert_node_consistent_with_left(p_nd); + assert_node_consistent_with_right(p_nd); + + const std::pair<const_pointer, const_pointer> + l_range = + assert_node_consistent(p_nd->m_p_left); + + if (l_range.second != NULL) + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(*l_range.second), + PB_ASSOC_V2F(p_nd->m_value))); + + const std::pair<const_pointer, const_pointer> + r_range = + assert_node_consistent(p_nd->m_p_right); + + if (r_range.first != NULL) + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(p_nd->m_value), + PB_ASSOC_V2F(*r_range.first))); + + return (std::make_pair((l_range.first != NULL)? l_range.first :& p_nd->m_value,(r_range.second != NULL)? r_range.second :& p_nd->m_value)); + } + + void + assert_consistent_with_debug_base() const; + + void + assert_node_consistent_with_left(const node_pointer p_nd) const; + + void + assert_node_consistent_with_right(const node_pointer p_nd) const; + + void + assert_consistent_with_debug_base(const node_pointer p_nd) const; + + void + assert_min() const; + + void + assert_min_imp(const node_pointer p_nd) const; + + void + assert_max() const; + + void + assert_max_imp(const node_pointer p_nd) const; + + void + assert_iterators() const; + + void + assert_size() const; + +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + void + initialize(); + + node_pointer + recursive_copy_node(const node_pointer p_nd); + + inline node_pointer + get_new_node_for_leaf_insert(const_reference r_val, pb_assoc::detail::int_to_type<false>); + + inline node_pointer + get_new_node_for_leaf_insert(const_reference r_val, pb_assoc::detail::int_to_type<true>); + + inline iterator + insert_imp_empty(const_reference r_value); + + inline iterator + insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd); + + static void + clear_imp(node_pointer p_nd); + + protected: + node_pointer m_p_head; + + iterator m_end_it; + + reverse_iterator m_rend_it; + + size_type m_size; + + static node_allocator s_node_allocator; + }; + +#include <ext/pb_assoc/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/split_join_fn_imps.hpp> +#include <ext/pb_assoc/detail/bin_search_tree_/rotate_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_MAP_DEBUG_BASE_C_DEC + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_EP2VP +#undef PB_ASSOC_V2S + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp new file mode 100644 index 00000000000..6061dec0b04 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp @@ -0,0 +1,74 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp new file mode 100644 index 00000000000..0d536a03b4a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp @@ -0,0 +1,85 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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(); + + my_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; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..81454e242df --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp @@ -0,0 +1,258 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::node_allocator +PB_ASSOC_CLASS_C_DEC::s_node_allocator; + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() : + m_p_head(s_node_allocator.allocate(1)), + m_end_it(m_p_head), + m_rend_it(m_p_head), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : + Cmp_Fn(r_cmp_fn), + m_p_head(s_node_allocator.allocate(1)), + m_end_it(m_p_head), + m_rend_it(m_p_head), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + Cmp_Fn(r_cmp_fn), + Node_Updator(r_node_updator), + m_p_head(s_node_allocator.allocate(1)), + m_end_it(m_p_head), + m_rend_it(m_p_head), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + my_map_debug_base(r_other), +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + Cmp_Fn(r_other), + Node_Updator(r_other), + m_p_head(s_node_allocator.allocate(1)), + m_end_it(m_p_head), + m_rend_it(m_p_head), + m_size(0) +{ + initialize(); + + m_size = r_other.m_size; + + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + try + { + m_p_head->m_p_parent = + recursive_copy_node(r_other.m_p_head->m_p_parent); + + if (m_p_head->m_p_parent != NULL) + m_p_head->m_p_parent->m_p_parent = m_p_head; + + m_size = r_other.m_size; + + initialize_min_max(); + } + catch(...) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();) + + s_node_allocator.deallocate(m_p_head, 1); + + throw; + } + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(my_map_debug_base::swap(r_other);) + + std::swap(m_p_head, r_other.m_p_head); + + std::swap(m_size, r_other.m_size); + + std::swap(m_end_it, r_other.m_end_it); + + std::swap(m_rend_it, r_other.m_rend_it); + + std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )r_other); + + Node_Updator::swap(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_CLASS_NAME() +{ + clear(); + + s_node_allocator.deallocate(m_p_head, 1); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize() +{ + m_p_head->m_p_parent = NULL; + m_p_head->m_p_left = m_p_head; + m_p_head->m_p_right = m_p_head; + + m_size = 0; +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::node_pointer +PB_ASSOC_CLASS_C_DEC:: +recursive_copy_node(const node_pointer p_nd) +{ + if (p_nd == NULL) + return (NULL); + + node_pointer p_ret = s_node_allocator.allocate(1); + + try + { + new (p_ret) node(*p_nd); + } + catch(...) + { + s_node_allocator.deallocate(p_ret, 1); + + throw; + } + + p_ret->m_p_left = p_ret->m_p_right = NULL; + + try + { + p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left); + + p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right); + } + catch(...) + { + clear_imp(p_ret); + + throw; + } + + if (p_ret->m_p_left != NULL) + p_ret->m_p_left->m_p_parent = p_ret; + + if (p_ret->m_p_right != NULL) + p_ret->m_p_right->m_p_parent = p_ret; + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_ret);) + + return (p_ret); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize_min_max() +{ + if (m_p_head->m_p_parent == NULL) + { + m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; + + return; + } + + { + node_pointer p_min = m_p_head->m_p_parent; + + while (p_min->m_p_left != NULL) + p_min = p_min->m_p_left; + + m_p_head->m_p_left = p_min; + } + + { + node_pointer p_max = m_p_head->m_p_parent; + + while (p_max->m_p_right != NULL) + p_max = p_max->m_p_right; + + m_p_head->m_p_right = p_max; + } +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/debug_fn_imps.hpp new file mode 100644 index 00000000000..9c31cb8efbf --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/debug_fn_imps.hpp @@ -0,0 +1,278 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid(bool check_iterators, bool check_metadata) const +{ + PB_ASSOC_DBG_ASSERT(m_p_head != NULL); + + if (m_p_head->m_p_parent == NULL) + { + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_left == m_p_head); + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_right == m_p_head); + + if (check_metadata) + PB_ASSOC_DBG_ASSERT(m_size == 0); + } + else + { + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head); + + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_left != m_p_head); + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_right != m_p_head); + + if (check_metadata) + PB_ASSOC_DBG_ASSERT(m_size > 0); + } + + if (check_metadata) + assert_size(); + + if (m_p_head->m_p_parent != NULL) + assert_node_consistent(m_p_head->m_p_parent); + + assert_min(); + assert_max(); + + if (check_metadata) + assert_consistent_with_debug_base(); + + if (check_iterators&& check_metadata) + assert_iterators(); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_node_consistent_with_left(const node_pointer p_nd) const +{ + if (p_nd->m_p_left == NULL) + return; + + PB_ASSOC_DBG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd); + + PB_ASSOC_DBG_ASSERT(!Cmp_Fn::operator()( + PB_ASSOC_V2F(p_nd->m_value), + PB_ASSOC_V2F(p_nd->m_p_left->m_value))); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_node_consistent_with_right(const node_pointer p_nd) const +{ + if (p_nd->m_p_right == NULL) + return; + + PB_ASSOC_DBG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd); + + PB_ASSOC_DBG_ASSERT(!Cmp_Fn::operator()( + PB_ASSOC_V2F(p_nd->m_p_right->m_value), + PB_ASSOC_V2F(p_nd->m_value))); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_min() const +{ + assert_min_imp(m_p_head->m_p_parent); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_min_imp(const node_pointer p_nd) const +{ + if (p_nd == NULL) + { + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_left == m_p_head); + + return; + } + + if (p_nd->m_p_left == NULL) + { + PB_ASSOC_DBG_ASSERT(p_nd == m_p_head->m_p_left); + + return; + } + + assert_min_imp(p_nd->m_p_left); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_max() const +{ + assert_max_imp(m_p_head->m_p_parent); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_max_imp(const node_pointer p_nd) const +{ + if (p_nd == NULL) + { + PB_ASSOC_DBG_ASSERT(m_p_head->m_p_right == m_p_head); + + return; + } + + if (p_nd->m_p_right == NULL) + { + PB_ASSOC_DBG_ASSERT(p_nd == m_p_head->m_p_right); + + return; + } + + assert_max_imp(p_nd->m_p_right); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_iterators() const +{ + PB_ASSOC_DBG_ASSERT(m_end_it.m_p_nd == m_p_head); + PB_ASSOC_DBG_ASSERT(m_rend_it.m_p_nd == m_p_head); + + size_type iterated_num = 0; + + const_iterator prev_it = end(); + + for (const_iterator it = begin(); it != end(); ++it) + { + ++iterated_num; + + PB_ASSOC_DBG_ASSERT(lower_bound( + PB_ASSOC_V2F(*it)).m_p_nd == it.m_p_nd); + + const_iterator upper_bound_it = upper_bound( + PB_ASSOC_V2F(*it)); + + --upper_bound_it; + + PB_ASSOC_DBG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd); + + if (prev_it != end()) + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(*prev_it), + PB_ASSOC_V2F(*it))); + + prev_it = it; + } + + PB_ASSOC_DBG_ASSERT(iterated_num == m_size); + + size_type reverse_iterated_num = 0; + + const_reverse_iterator reverse_prev_it = rend(); + + for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); + ++reverse_it) + { + ++reverse_iterated_num; + + PB_ASSOC_DBG_ASSERT(lower_bound( + PB_ASSOC_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); + + const_iterator upper_bound_it = upper_bound( + PB_ASSOC_V2F(*reverse_it)); + + --upper_bound_it; + + PB_ASSOC_DBG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd); + + if (reverse_prev_it != rend()) + PB_ASSOC_DBG_ASSERT(!Cmp_Fn::operator()( + PB_ASSOC_V2F(*reverse_prev_it), + PB_ASSOC_V2F(*reverse_it))); + + reverse_prev_it = reverse_it; + } + + PB_ASSOC_DBG_ASSERT(reverse_iterated_num == m_size); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_consistent_with_debug_base() const +{ + my_map_debug_base::check_size(m_size); + + assert_consistent_with_debug_base(m_p_head->m_p_parent); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_consistent_with_debug_base(const node_pointer p_nd) const +{ + if (p_nd == NULL) + return; + + my_map_debug_base::check_key_exists( + PB_ASSOC_V2F(p_nd->m_value)); + + assert_consistent_with_debug_base(p_nd->m_p_left); + assert_consistent_with_debug_base(p_nd->m_p_right); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_size() const +{ + PB_ASSOC_DBG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size); +} + +#endif // #ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/erase_fn_imps.hpp new file mode 100644 index 00000000000..872530b4102 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/erase_fn_imps.hpp @@ -0,0 +1,124 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +actual_erase_node(node_pointer p_z) +{ + PB_ASSOC_DBG_ASSERT(m_size > 0); + --m_size; + + PB_ASSOC_DBG_ONLY(erase_existing(PB_ASSOC_V2F(p_z->m_value))); + + p_z->~node(); + + s_node_allocator.deallocate(p_z, 1); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +update_min_max_for_erased_node(node_pointer p_z) +{ + if (m_size == 1) + { + m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; + + return; + } + + if (m_p_head->m_p_left == p_z) + { + iterator it(p_z); + + ++it; + + m_p_head->m_p_left = it.m_p_nd; + } + else if (m_p_head->m_p_right == p_z) + { + iterator it(p_z); + + --it; + + m_p_head->m_p_right = it.m_p_nd; + } +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + clear_imp(m_p_head->m_p_parent); + + m_size = 0; + + initialize(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();) + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear_imp(node_pointer p_nd) +{ + if (p_nd == NULL) + 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); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_fn_imps.hpp new file mode 100644 index 00000000000..1d8449c719d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_fn_imps.hpp @@ -0,0 +1,184 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +lower_bound(const_key_reference r_key) const +{ + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (!Cmp_Fn::operator()(PB_ASSOC_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 (iterator(p_pot)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +lower_bound(const_key_reference r_key) +{ + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (!Cmp_Fn::operator()( + PB_ASSOC_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 (iterator(p_pot)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +upper_bound(const_key_reference r_key) const +{ + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (Cmp_Fn::operator()(r_key, + PB_ASSOC_V2F(p_nd->m_value))) + { + p_pot = p_nd, + + p_nd = p_nd->m_p_left; + } + else + p_nd = p_nd->m_p_right; + + return (const_iterator(p_pot)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +upper_bound(const_key_reference r_key) +{ + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (Cmp_Fn::operator()(r_key, + PB_ASSOC_V2F(p_nd->m_value))) + { + p_pot = p_nd, + + p_nd = p_nd->m_p_left; + } + else + p_nd = p_nd->m_p_right; + + return (find_iterator(p_pot)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, false);) + + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (!Cmp_Fn::operator()(PB_ASSOC_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 find_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(p_pot->m_value)))? + m_p_head : p_pot); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) const +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + node_pointer p_pot = m_p_head; + node_pointer p_nd = m_p_head->m_p_parent; + + while (p_nd != NULL) + if (!Cmp_Fn::operator()(PB_ASSOC_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_find_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(p_pot->m_value)))? + m_p_head : p_pot); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_iterators.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_iterators.hpp new file mode 100644 index 00000000000..69821ee4ffc --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/find_iterators.hpp @@ -0,0 +1,391 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_iterators.hpp + * Contains an implementation class for bin_search_tree_. + */ + +#define PB_ASSOC_CONST_IT_C_DEC \ + const_it_< \ + Is_Forward_Iterator> + +#define PB_ASSOC_CONST_ODIR_IT_C_DEC \ + const_it_< \ + !Is_Forward_Iterator> + +#define PB_ASSOC_IT_C_DEC \ + it_< \ + Is_Forward_Iterator> + +#define PB_ASSOC_ODIR_IT_C_DEC \ + it_< \ + !Is_Forward_Iterator> + +template<bool Is_Forward_Iterator> +class const_it_ +{ + +public: + + typedef std::bidirectional_iterator_tag iterator_category; + + typedef typename Allocator::difference_type difference_type; + + typedef mapped_value_type value_type; + + typedef mapped_pointer pointer; + + typedef const_mapped_pointer const_pointer; + + typedef mapped_reference reference; + + typedef const_mapped_reference const_reference; + +public: + + inline + const_it_(const node_pointer p_nd = NULL) : m_p_nd(const_cast<node_pointer>(p_nd)) + { } + + inline + const_it_(const PB_ASSOC_CONST_ODIR_IT_C_DEC& + r_other) + + : m_p_nd(r_other.m_p_nd) + { } + + inline + PB_ASSOC_CONST_IT_C_DEC& + operator=(const PB_ASSOC_CONST_IT_C_DEC& + r_other) + { + m_p_nd = r_other.m_p_nd; + + return (*this); + } + + inline + PB_ASSOC_CONST_IT_C_DEC& + operator=(const PB_ASSOC_CONST_ODIR_IT_C_DEC& + r_other) + { + m_p_nd = r_other.m_p_nd; + + return (*this); + } + + inline const_pointer + operator->() const + { + PB_ASSOC_DBG_ASSERT(m_p_nd != NULL); + + return (&m_p_nd->m_value); + } + + inline const_reference + operator*() const + { + PB_ASSOC_DBG_ASSERT(m_p_nd != NULL); + + return (m_p_nd->m_value); + } + + inline bool + operator==(const PB_ASSOC_CONST_IT_C_DEC + &r_other) const + { + return (m_p_nd == r_other.m_p_nd); + } + + inline bool + operator==(const PB_ASSOC_CONST_ODIR_IT_C_DEC + &r_other) const + { + return (m_p_nd == r_other.m_p_nd); + } + + inline bool + operator!=(const PB_ASSOC_CONST_IT_C_DEC& + r_other) const + { + return (m_p_nd != r_other.m_p_nd); + } + + inline bool + operator!=(const PB_ASSOC_CONST_ODIR_IT_C_DEC& + r_other) const + { + return (m_p_nd != r_other.m_p_nd); + } + + inline PB_ASSOC_CONST_IT_C_DEC& + operator++() + { + PB_ASSOC_DBG_ASSERT(m_p_nd != NULL); + + inc(int_to_type<Is_Forward_Iterator>()); + + return (*this); + } + + inline PB_ASSOC_CONST_IT_C_DEC + operator++(int) + { + PB_ASSOC_CONST_IT_C_DEC + ret_it(m_p_nd); + + operator++(); + + return (ret_it); + } + + inline PB_ASSOC_CONST_IT_C_DEC& + operator--() + { + dec(int_to_type<Is_Forward_Iterator>()); + + return (*this); + } + + inline PB_ASSOC_CONST_IT_C_DEC + operator--(int) + { + PB_ASSOC_CONST_IT_C_DEC + ret_it(m_p_nd); + + operator--(); + + return (ret_it); + } + +protected: + inline void + inc(int_to_type<false>) + { + dec(int_to_type<true>()); + } + + void + inc(int_to_type<true>) + { + if (m_p_nd->m_p_right != NULL) + { + m_p_nd = m_p_nd->m_p_right; + + while (m_p_nd->m_p_left != NULL) + m_p_nd = m_p_nd->m_p_left; + + return; + } + + node_pointer p_y = m_p_nd->m_p_parent; + + while (m_p_nd == p_y->m_p_right) + { + m_p_nd = p_y; + + p_y = p_y->m_p_parent; + } + + if (m_p_nd->m_p_right != p_y) + m_p_nd = p_y; + } + + inline void + dec(int_to_type<false>) + { + inc(int_to_type<true>()); + } + + void + dec(int_to_type<true>) + { + if (m_p_nd->special_dec_check()&& + m_p_nd->m_p_parent->m_p_parent == m_p_nd) + { + m_p_nd = m_p_nd->m_p_right; + + return; + } + + if (m_p_nd->m_p_left != NULL) + { + node_pointer p_y = m_p_nd->m_p_left; + + while (p_y->m_p_right != NULL) + p_y = p_y->m_p_right; + + m_p_nd = p_y; + + return; + } + + node_pointer p_y = m_p_nd->m_p_parent; + + while (m_p_nd == p_y->m_p_left) + { + m_p_nd = p_y; + + p_y = p_y->m_p_parent; + } + + /* + * This seems to correct an apparent bug in the SGI STL + * implementation. */ + if (m_p_nd->m_p_left != p_y) + m_p_nd = p_y; + } + + friend class PB_ASSOC_CLASS_C_DEC; + +public: + node_pointer m_p_nd; +}; + +template<bool Is_Forward_Iterator> +class it_ : + public PB_ASSOC_CONST_IT_C_DEC + +{ + +public: + + inline + it_(const node_pointer p_nd = NULL) : PB_ASSOC_CONST_IT_C_DEC((node_pointer)p_nd) + { } + + inline + it_(const PB_ASSOC_ODIR_IT_C_DEC& + r_other) + + : PB_ASSOC_CONST_IT_C_DEC( + r_other.m_p_nd) + { } + + inline + PB_ASSOC_IT_C_DEC& + operator=(const PB_ASSOC_IT_C_DEC& + r_other) + { + my_base_it::m_p_nd = r_other.m_p_nd; + + return (*this); + } + + inline + PB_ASSOC_IT_C_DEC& + operator=(const PB_ASSOC_ODIR_IT_C_DEC& + r_other) + { + my_base_it::m_p_nd = r_other.m_p_nd; + + return (*this); + } + + inline pointer + operator->() + { + PB_ASSOC_DBG_ASSERT(my_base_it::m_p_nd != NULL); + + return (&my_base_it::m_p_nd->m_value); + } + + inline reference + operator*() + { + PB_ASSOC_DBG_ASSERT(my_base_it::m_p_nd != NULL); + + return (my_base_it::m_p_nd->m_value); + } + + inline PB_ASSOC_IT_C_DEC& + operator++() + { + PB_ASSOC_CONST_IT_C_DEC:: + operator++(); + + return (*this); + } + + inline PB_ASSOC_IT_C_DEC + operator++(int) + { + PB_ASSOC_IT_C_DEC + ret_it(my_base_it::m_p_nd); + + operator++(); + + return (ret_it); + } + + inline PB_ASSOC_IT_C_DEC& + operator--() + { + PB_ASSOC_CONST_IT_C_DEC:: + operator--(); + + return (*this); + } + + inline PB_ASSOC_IT_C_DEC + operator--(int) + { + PB_ASSOC_IT_C_DEC + ret_it(my_base_it::m_p_nd); + + operator--(); + + return (ret_it); + } + +protected: + typedef PB_ASSOC_CONST_IT_C_DEC my_base_it; + + friend class PB_ASSOC_CLASS_C_DEC; +}; + +#undef PB_ASSOC_CONST_IT_C_DEC + +#undef PB_ASSOC_CONST_ODIR_IT_C_DEC + +#undef PB_ASSOC_IT_C_DEC + +#undef PB_ASSOC_ODIR_IT_C_DEC + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/info_fn_imps.hpp new file mode 100644 index 00000000000..d6d4f547b78 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/info_fn_imps.hpp @@ -0,0 +1,87 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +template<class Other_Map_Type> +bool +PB_ASSOC_CLASS_C_DEC:: +cmp_with_other(const Other_Map_Type& r_other) const +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + if (m_size != r_other.size()) + return (false); + + for (typename Other_Map_Type::const_iterator it = r_other.begin(); + it != r_other.end(); ++it) + if (find((const_key_reference)PB_ASSOC_V2F(*it)) == end()) + return (false); + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (s_node_allocator.max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (m_size); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/insert_fn_imps.hpp new file mode 100644 index 00000000000..725f5007eff --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/insert_fn_imps.hpp @@ -0,0 +1,215 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert_leaf(const_mapped_reference r_mapped_value) +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + if (m_size == 0) + return (std::make_pair( + insert_imp_empty(r_mapped_value), + true)); + + node_pointer p_nd = m_p_head->m_p_parent; + node_pointer p_pot = m_p_head; + + while (p_nd != NULL) + if (!Cmp_Fn::operator()( + PB_ASSOC_V2F(p_nd->m_value), + PB_ASSOC_V2F(r_mapped_value))) + { + p_pot = p_nd; + + p_nd = p_nd->m_p_left; + } + else + p_nd = p_nd->m_p_right; + + if (p_pot == m_p_head) + return (std::make_pair( + insert_leaf_new(r_mapped_value, m_p_head->m_p_right, false), + true)); + + if (!Cmp_Fn::operator()( + PB_ASSOC_V2F(r_mapped_value), + PB_ASSOC_V2F(p_pot->m_value))) + { + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists( + PB_ASSOC_V2F(r_mapped_value))); + + return (std::make_pair(p_pot, false)); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + PB_ASSOC_V2F(r_mapped_value))); + + p_nd = p_pot->m_p_left; + if (p_nd == NULL) + return (std::make_pair( + insert_leaf_new(r_mapped_value, p_pot, true), + true)); + + while (p_nd->m_p_right != NULL) + p_nd = p_nd->m_p_right; + + return (std::make_pair( + insert_leaf_new(r_mapped_value, p_nd, false), + true)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +insert_leaf_new(const_mapped_reference r_mapped_value, node_pointer p_nd, bool left_nd) +{ + node_pointer p_new_nd = + get_new_node_for_leaf_insert(r_mapped_value, my_traits_base::s_no_throw_copies_indicator); + + if (left_nd) + { + PB_ASSOC_DBG_ASSERT(p_nd->m_p_left == NULL); + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(r_mapped_value), + PB_ASSOC_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 + { + PB_ASSOC_DBG_ASSERT(p_nd->m_p_right == NULL); + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(p_nd->m_value), + PB_ASSOC_V2F(r_mapped_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 = NULL; + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_nd)); + + update_to_top(p_new_nd, (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new( + PB_ASSOC_V2F(r_mapped_value))); + + return (iterator(p_new_nd)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +insert_imp_empty(const_mapped_reference r_mapped_value) +{ + node_pointer p_new_node = + get_new_node_for_leaf_insert(r_mapped_value, my_traits_base::s_no_throw_copies_indicator); + + m_p_head->m_p_left = m_p_head->m_p_right = + 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 = NULL; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new( + PB_ASSOC_V2F(r_mapped_value))); + + update_to_top(m_p_head->m_p_parent, (Node_Updator* )this); + + return (iterator(p_new_node)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_pointer +PB_ASSOC_CLASS_C_DEC:: +get_new_node_for_leaf_insert(const_mapped_reference r_val, pb_assoc::detail::int_to_type<false>) +{ + 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 = NULL; + + ++m_size; + + return (p_new_nd); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_pointer +PB_ASSOC_CLASS_C_DEC:: +get_new_node_for_leaf_insert(const_mapped_reference r_val, pb_assoc::detail::int_to_type<true>) +{ + node_pointer p_new_nd = s_node_allocator.allocate(1); + + new (const_cast<void* >( + static_cast<const void* >(&p_new_nd->m_value))) + typename Node::value_type(r_val); + + p_new_nd->m_p_left = p_new_nd->m_p_right = NULL; + + ++m_size; + + return (p_new_nd); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/iterators_fn_imps.hpp new file mode 100644 index 00000000000..275fc748e71 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/iterators_fn_imps.hpp @@ -0,0 +1,164 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterators_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() const +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +begin() +{ + return (iterator(m_p_head->m_p_left)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +begin() const +{ + return (const_iterator(m_p_head->m_p_left)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +end() +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +end() const +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +find_rend() +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +find_rend() const +{ + return (m_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +rbegin() const +{ + return (const_reverse_iterator(m_p_head->m_p_right)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +rend() +{ + return (m_rend_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +rend() const +{ + return (m_rend_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_node_iterator +PB_ASSOC_CLASS_C_DEC:: +node_begin() const +{ + return (const_node_iterator(m_p_head->m_p_parent)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_iterator +PB_ASSOC_CLASS_C_DEC:: +node_begin() +{ + return (node_iterator(m_p_head->m_p_parent)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_node_iterator +PB_ASSOC_CLASS_C_DEC:: +node_end() const +{ + return (const_node_iterator(NULL)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_iterator +PB_ASSOC_CLASS_C_DEC:: +node_end() +{ + return (node_iterator(NULL)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/node_iterators.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/node_iterators.hpp new file mode 100644 index 00000000000..d7425b355d8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/node_iterators.hpp @@ -0,0 +1,144 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 bin_search_tree_. + */ + +class const_node_it_ +{ + +public: + + typedef trivial_iterator_tag iterator_category; + + typedef trivial_iterator_difference_type difference_type; + + typedef const_iterator value_type; + + typedef const_iterator* pointer; + + typedef const_iterator* const_pointer; + + typedef const_iterator& reference; + + typedef const iterator& const_reference; + +public: + + inline + const_node_it_(const node_pointer p_nd = NULL) + + : m_p_nd(const_cast<node_pointer>(p_nd)) + { } + + inline const_iterator + operator*() const + { + return (const_iterator(m_p_nd)); + } + + inline const_node_it_ + l_child() const + { + return (const_node_it_(m_p_nd->m_p_left)); + } + + inline const_node_it_ + r_child() const + { + return (const_node_it_(m_p_nd->m_p_right)); + } + + inline bool + operator==(const const_node_it_& r_other) const + { + return (m_p_nd == r_other.m_p_nd); + } + + inline bool + operator!=(const const_node_it_& r_other) const + { + return (m_p_nd != r_other.m_p_nd); + } + +private: + + friend class PB_ASSOC_CLASS_C_DEC; + +public: + node_pointer m_p_nd; +}; + +class node_it_ : + public const_node_it_ + +{ + +public: + + inline + node_it_(const node_pointer p_nd = NULL) + + : const_node_it_(const_cast<node_pointer>(p_nd)) + { } + + inline iterator + operator*() const + { + return (iterator(const_node_it_::m_p_nd)); + } + + inline node_it_ + l_child() + { + return (node_it_(const_node_it_::m_p_nd->m_p_left)); + } + + inline node_it_ + r_child() + { + return (node_it_(const_node_it_::m_p_nd->m_p_right)); + } + +private: + friend class PB_ASSOC_CLASS_C_DEC; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/r_erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/r_erase_fn_imps.hpp new file mode 100644 index 00000000000..c80d04428ef --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/r_erase_fn_imps.hpp @@ -0,0 +1,124 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 r_erase_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +actual_erase_node(node_pointer p_z) +{ + PB_ASSOC_DBG_ASSERT(m_size > 0); + --m_size; + + PB_ASSOC_DBG_ONLY(erase_existing(PB_ASSOC_V2F(p_z->m_value))); + + p_z->~node(); + + s_node_allocator.deallocate(p_z, 1); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +update_min_max_for_erased_node(node_pointer p_z) +{ + if (m_size == 1) + { + m_p_head->m_p_left = m_p_head->m_p_right = m_p_head; + + return; + } + + if (m_p_head->m_p_left == p_z) + { + iterator it(p_z); + + ++it; + + m_p_head->m_p_left = it.m_p_nd; + } + else if (m_p_head->m_p_right == p_z) + { + iterator it(p_z); + + --it; + + m_p_head->m_p_right = it.m_p_nd; + } +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + + clear_imp(m_p_head->m_p_parent); + + m_size = 0; + + initialize(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();) + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear_imp(node_pointer p_nd) +{ + if (p_nd == NULL) + 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); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/rotate_fn_imps.hpp new file mode 100644 index 00000000000..bbca8ea1fed --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/rotate_fn_imps.hpp @@ -0,0 +1,163 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 rotate_fn_imps.hpp + * Contains imps for rotating nodes. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +rotate_left(node_pointer p_x) +{ + node_pointer p_y = p_x->m_p_right; + + p_x->m_p_right = p_y->m_p_left; + + if (p_y->m_p_left != NULL) + p_y->m_p_left->m_p_parent = p_x; + + p_y->m_p_parent = p_x->m_p_parent; + + if (p_x == m_p_head->m_p_parent) + m_p_head->m_p_parent = p_y; + else if (p_x == p_x->m_p_parent->m_p_left) + p_x->m_p_parent->m_p_left = p_y; + else + p_x->m_p_parent->m_p_right = p_y; + + p_y->m_p_left = p_x; + p_x->m_p_parent = p_y; + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_x);) + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_y);) + + apply_update(p_x, (Node_Updator* )this); + apply_update(p_x->m_p_parent, (Node_Updator* )this); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +rotate_right(node_pointer p_x) +{ + node_pointer p_y = p_x->m_p_left; + + p_x->m_p_left = p_y->m_p_right; + + if (p_y->m_p_right != NULL) + p_y->m_p_right->m_p_parent = p_x; + + p_y->m_p_parent = p_x->m_p_parent; + + if (p_x == m_p_head->m_p_parent) + m_p_head->m_p_parent = p_y; + else if (p_x == p_x->m_p_parent->m_p_right) + p_x->m_p_parent->m_p_right = p_y; + else + p_x->m_p_parent->m_p_left = p_y; + + p_y->m_p_right = p_x; + p_x->m_p_parent = p_y; + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_x);) + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_y);) + + apply_update(p_x, (Node_Updator* )this); + apply_update(p_x->m_p_parent, (Node_Updator* )this); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +rotate_parent(node_pointer p_nd) +{ + node_pointer p_parent = p_nd->m_p_parent; + + if (p_nd == p_parent->m_p_left) + rotate_right(p_parent); + else + rotate_left(p_parent); + + PB_ASSOC_DBG_ASSERT(p_parent->m_p_parent = p_nd); + PB_ASSOC_DBG_ASSERT(p_nd->m_p_left == p_parent || + p_nd->m_p_right == p_parent); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +apply_update(node_pointer /*p_nd*/, pb_assoc::null_node_updator* /*p_updator*/) +{ } + +PB_ASSOC_CLASS_T_DEC +template<class Node_Updator_> +inline void +PB_ASSOC_CLASS_C_DEC:: +apply_update(node_pointer p_nd, Node_Updator_* p_updator) +{ + p_updator->operator()( + &PB_ASSOC_V2F(p_nd->m_value),(p_nd->m_p_left == NULL)? + NULL : + &PB_ASSOC_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == NULL)? + NULL : + &PB_ASSOC_V2F(p_nd->m_p_right->m_value)); +} + +PB_ASSOC_CLASS_T_DEC +template<class Node_Updator_> +inline void +PB_ASSOC_CLASS_C_DEC:: +update_to_top(node_pointer p_nd, Node_Updator_* p_updator) +{ + while (p_nd != m_p_head) + { + apply_update(p_nd, p_updator); + + p_nd = p_nd->m_p_parent; + } +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +update_to_top(node_pointer /*p_nd*/, pb_assoc::null_node_updator* /*p_updator*/) +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/split_join_fn_imps.hpp new file mode 100644 index 00000000000..116e793d009 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/bin_search_tree_/split_join_fn_imps.hpp @@ -0,0 +1,192 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_fn_imps.hpp + * Contains an implementation class for bin_search_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +join_prep(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + if (r_other.m_size == 0) + return (false); + + if (m_size == 0) + { + swap(r_other); + + return (false); + } + + const bool greater = Cmp_Fn::operator()( + PB_ASSOC_V2F(m_p_head->m_p_right->m_value), + PB_ASSOC_V2F(r_other.m_p_head->m_p_left->m_value)); + + const bool lesser = Cmp_Fn::operator()( + PB_ASSOC_V2F(r_other.m_p_head->m_p_right->m_value), + PB_ASSOC_V2F(m_p_head->m_p_left->m_value)); + + if (!greater&& !lesser) + throw cannot_join(); + + if (lesser) + swap(r_other); + + m_size += r_other.m_size; + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + for (const_iterator other_it = r_other.begin(); other_it != r_other.end(); + ++other_it) + { + my_map_debug_base::insert_new(PB_ASSOC_V2F(*other_it)); + r_other.my_map_debug_base::erase_existing(PB_ASSOC_V2F(*other_it)); + } +#endif // PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +join_finish(PB_ASSOC_CLASS_C_DEC& r_other) +{ + initialize_min_max(); + + r_other.initialize(); +} + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +split_prep(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + r_other.clear(); + + if (m_size == 0) + { + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + return (false); + } + + if (Cmp_Fn::operator()(r_key, PB_ASSOC_V2F(m_p_head->m_p_left->m_value))) + { + swap(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + return (false); + } + + if (!Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(m_p_head->m_p_right->m_value))) + { + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + return (false); + } + + if (m_size == 1) + { + swap(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + + return (false); + } + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + for (const_iterator it = begin(); it != end(); ++it) + if (Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*it))) + { + my_map_debug_base::erase_existing(PB_ASSOC_V2F(*it)); + r_other.my_map_debug_base::insert_new(PB_ASSOC_V2F(*it)); + } +#endif // PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +split_finish(PB_ASSOC_CLASS_C_DEC& r_other) +{ + r_other.m_size = r_other.recursive_count(r_other.m_p_head->m_p_parent); + + r_other.initialize_min_max(); + + m_size -= r_other.m_size; + + initialize_min_max(); + + PB_ASSOC_DBG_ONLY(assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(r_other.assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +recursive_count(node_pointer p_nd) const +{ + if (p_nd == NULL) + return (0); + + return (1 + + recursive_count(p_nd->m_p_left) + + recursive_count(p_nd->m_p_right)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..490ddb85fa5 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,153 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn) : + my_base(r_hash_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + my_base(r_hash_fn, r_eq_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + my_base(r_hash_fn, r_eq_fn, r_comb_hash_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(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) : + my_base(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_resize_policy) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC& +PB_ASSOC_CLASS_C_DEC:: +operator=(const PB_ASSOC_CLASS_C_DEC& r_other) +{ + if (this !=& r_other) + { + PB_ASSOC_CLASS_C_DEC tmp(r_other); + + swap(tmp); + } + + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(It first_it, It last_it) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn) : + my_base(r_hash_fn) +{ + copy_from_range(first_it, last_it); +} + +// Tmp Ami make all methods in assoc_cntnr.hpp inline + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + my_base(r_hash_fn, r_eq_fn) +{ + copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + my_base(r_hash_fn, r_eq_fn, r_comb_hash_fn) +{ + copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(It first_it, It last_it, 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) : + my_base(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_resize_policy) +{ + copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_BASE_C_DEC((const PB_ASSOC_BASE_C_DEC& )r_other) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~cc_hash_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_base::swap(r_other); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp new file mode 100644 index 00000000000..3425ebf8ee8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cc_ht_map_.hpp @@ -0,0 +1,602 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 cc_ht_map_.hpp + * Contains an implementation class for cc_ht_map_. + */ + +#include <utility> +#include <iterator> +#include <ext/pb_assoc/detail/cond_dealtor.hpp> +#include <ext/pb_assoc/trivial_iterator_def.hpp> +#include <ext/pb_assoc/detail/hash_fn/ranged_hash_fn.hpp> +#include <ext/pb_assoc/detail/hash_types_traits.hpp> +#include <ext/pb_assoc/detail/types_traits.hpp> +#include <ext/pb_assoc/exception.hpp> +#include <ext/pb_assoc/detail/map_debug_base.hpp> +#include <ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Hash_Fn, \ + class Eq_Fn, \ + class Allocator, \ + bool Store_Hash, \ + class Comb_Hash_Fn, \ + class Resize_Policy> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + cc_ht_map_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + cc_ht_map_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Allocator, \ + Store_Hash, \ + Comb_Hash_Fn, \ + Resize_Policy > + +#define PB_ASSOC_HASH_EQ_FN_C_DEC \ + pb_assoc::detail::hash_eq_fn< \ + Key, \ + Eq_Fn, \ + Allocator, \ + Store_Hash> + +#define PB_ASSOC_RANGED_HASH_FN_C_DEC \ + pb_assoc::detail::ranged_hash_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + Comb_Hash_Fn, \ + Store_Hash> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + types_traits< \ + Key, \ + Data, \ + Allocator> + +#define PB_ASSOC_HASH_TYPES_TRAITS_C_DEC \ + hash_types_traits< \ + typename Allocator::size_type, \ + Store_Hash> + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE +#define PB_ASSOC_MAP_DEBUG_BASE_C_DEC \ + pb_assoc::detail::map_debug_base< \ + Key, \ + Eq_Fn> +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Mapped_Data() +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_STATIC_ASSERT(UNIQUE, E) \ + typedef \ + pb_assoc::detail::static_assert_dummy_class< \ + sizeof(pb_assoc::detail::static_assert<(bool)(E)>)> \ + UNIQUE##static_assert_type + + template<typename Key, + typename Data, + class Hash_Fn, + class Eq_Fn, + class Allocator, + bool Store_Hash, + class Comb_Hash_Fn, + class Resize_Policy > + class PB_ASSOC_CLASS_NAME: +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + protected PB_ASSOC_MAP_DEBUG_BASE_C_DEC, +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + public PB_ASSOC_HASH_EQ_FN_C_DEC, + public Resize_Policy, + public PB_ASSOC_RANGED_HASH_FN_C_DEC, + public PB_ASSOC_TYPES_TRAITS_C_DEC, + public PB_ASSOC_HASH_TYPES_TRAITS_C_DEC + { + + public: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + protected: + + typedef typename PB_ASSOC_HASH_TYPES_TRAITS_C_DEC::comp_hash comp_hash; + + struct no_store_hash_entry + { + value_type m_value; + + typename Allocator::template rebind< + no_store_hash_entry>::other::pointer m_p_next; + }; + + struct store_hash_entry + { + value_type m_value; + + size_type m_hash; + + typename Allocator::template rebind< + store_hash_entry>::other::pointer m_p_next; + }; + + typedef + typename cond_type< + Store_Hash, + store_hash_entry, + no_store_hash_entry>::type + entry; + + typedef + typename Allocator::template rebind<entry>::other + entry_allocator; + + typedef typename entry_allocator::pointer entry_pointer; + + typedef typename entry_allocator::const_pointer const_entry_pointer; + + typedef typename entry_allocator::reference entry_reference; + + typedef + typename entry_allocator::const_reference + const_entry_reference; + + typedef + typename Allocator::template rebind<entry_pointer>::other + entry_pointer_allocator; + + typedef typename entry_pointer_allocator::pointer entry_pointer_array; + + typedef value_type mapped_value_type; + + typedef pointer mapped_pointer; + + typedef const_pointer const_mapped_pointer; + + typedef reference mapped_reference; + + typedef const_reference const_mapped_reference; + +#define PB_ASSOC_GEN_POS std::pair<entry_pointer, size_type> + +#include <ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/iterator.hpp> + +#undef PB_ASSOC_GEN_POS + + typedef find_iterator_ find_iterator; + + typedef const_find_iterator_ const_find_iterator; + + typedef iterator_ iterator; + + typedef const_iterator_ const_iterator; + + typedef Hash_Fn hash_fn; + + typedef Eq_Fn eq_fn; + + typedef Allocator allocator; + + typedef Resize_Policy resize_policy; + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + PB_ASSOC_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_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~PB_ASSOC_CLASS_NAME(); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + Hash_Fn& + get_hash_fn(); + + const Hash_Fn& + get_hash_fn() const; + + Eq_Fn& + get_eq_fn(); + + const Eq_Fn& + get_eq_fn() const; + + Comb_Hash_Fn& + get_comb_hash_fn(); + + const Comb_Hash_Fn& + get_comb_hash_fn() const; + + Resize_Policy& + get_resize_policy(); + + const Resize_Policy& + get_resize_policy() const; + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + + inline data_reference + subscript_imp(const_key_reference r_key); + + inline find_iterator + find(const_key_reference r_key); + + inline const_find_iterator + find(const_key_reference r_key) const; + + inline find_iterator + find_end(); + + inline const_find_iterator + find_end() const; + + template<class T> + inline size_type + erase(T r_t, bool erase_entry_if_last, pb_assoc::detail::int_to_type<false>); + + template<class T> + inline size_type + erase(T r_t, bool erase_entry_if_last, pb_assoc::detail::int_to_type<true>); + + template<class Pred> + inline size_type + erase_if(Pred& r_pred); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + virtual void + assert_valid() const; + +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + virtual void + do_resize(size_type new_size); + + private: + + typedef PB_ASSOC_TYPES_TRAITS_C_DEC my_traits_base; + + typedef PB_ASSOC_HASH_TYPES_TRAITS_C_DEC my_hash_traits_base; + + typedef PB_ASSOC_RANGED_HASH_FN_C_DEC my_ranged_hash_fn_base; + + typedef PB_ASSOC_HASH_EQ_FN_C_DEC my_hash_eq_fn_base; + + typedef Resize_Policy my_resize_base; + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + typedef PB_ASSOC_MAP_DEBUG_BASE_C_DEC my_map_debug_base; +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + + private: + + inline bool + do_resize_if_needed(); + + inline void + do_resize_if_needed_no_throw(); + + void + resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size); + + inline entry_pointer + resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, int_to_type<false>); + + inline entry_pointer + resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, int_to_type<true>); + + template<class For_Each_Fn> + void + do_for_each(For_Each_Fn fn); + + void + deallocate_links_in_list(entry_pointer p_e); + + inline entry_pointer + get_entry(const_reference r_val, int_to_type<false>); + + inline entry_pointer + get_entry(const_reference r_val, int_to_type<true>); + + inline void + rels_entry(entry_pointer p_e); + + void + constructor_insert_new_imp(const_reference r_val, size_type pos, int_to_type<false>); + + void + constructor_insert_new_imp(const_reference r_val, size_type pos, int_to_type<true>); + + void + deallocate_all(); + + inline data_reference + subscript_imp(const_key_reference r_key, int_to_type<false>); + + inline data_reference + subscript_imp(const_key_reference r_key, int_to_type<true>); + + inline std::pair<find_iterator, bool> + insert_imp(const_reference r_val, int_to_type<false>); + + inline std::pair<find_iterator, bool> + insert_imp(const_reference r_val, int_to_type<true>); + + inline pointer + insert_new_imp(const_reference r_val, size_type pos); + + inline pointer + insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair); + + inline const_data_reference + const_subscript_imp(const_key_reference r_key, int_to_type<false>) const; + + inline const_data_reference + const_subscript_imp(const_key_reference r_key, int_to_type<true>) const; + + inline pointer + find_key_pointer(const_key_reference r_key, int_to_type<false>); + + inline pointer + find_key_pointer(const_key_reference r_key, int_to_type<true>); + + template<class T> + inline size_type + erase_in_pos_imp(T r_t, bool erase_entry_if_last, size_type pos); + + template<class T> + inline size_type + erase_in_pos_imp(T r_t, bool erase_entry_if_last, const comp_hash& r_pos_hash_pair); + + inline void + erase_entry_pointer(entry_pointer& r_p_e); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + void + inc_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const; +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + void + inc_it_state(const_pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const; + + void + get_start_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const; + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + void + assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const; + + void + assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_indicator) const; + + void + assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_indicator) const; + +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + private: + static entry_allocator s_entry_allocator; + + static entry_pointer_allocator s_entry_pointer_allocator; + + typedef + pb_assoc::detail::cond_dealtor< + entry, + Allocator> + cond_dealtor_t; + + entry_pointer_array m_a_p_entries; + + size_type m_num_e_p; + + size_type m_num_used_e; + + friend class iterator_; + + friend class const_iterator_; + + static iterator s_end_it; + + static const_iterator s_const_end_it; + + static find_iterator s_find_end_it; + + static const_find_iterator s_const_find_end_it; + + enum + { + store_hash_ok = + !Store_Hash || + !pb_assoc::detail::is_same_type< + Hash_Fn, + pb_assoc::null_hash_fn>::value + }; + + PB_ASSOC_STATIC_ASSERT(sth, store_hash_ok); + }; + +#include <ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/entry_list_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/resize_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/size_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/policy_access_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/insert_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_HASH_EQ_FN_C_DEC + +#undef PB_ASSOC_RANGED_HASH_FN_C_DEC + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_HASH_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_MAP_DEBUG_BASE_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_V2S + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#undef PB_ASSOC_STATIC_ASSERT + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cmp_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cmp_fn_imps.hpp new file mode 100644 index 00000000000..7eac5808df8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cmp_fn_imps.hpp @@ -0,0 +1,92 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 cmp_fn_imps.hpp + * Contains implementations of cc_ht_map_'s entire container comparison related + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +template<class Other_HT_Map_Type> +bool +PB_ASSOC_CLASS_C_DEC:: +operator==(const Other_HT_Map_Type& r_other) const +{ + return (cmp_with_other(r_other)); +} + +PB_ASSOC_CLASS_T_DEC +template<class Other_Map_Type> +bool +PB_ASSOC_CLASS_C_DEC:: +cmp_with_other(const Other_Map_Type& r_other) const +{ + if (size() != r_other.size()) + return (false); + + for (typename Other_Map_Type::const_iterator it = r_other.begin(); + it != r_other.end(); ++it) + { + const_key_reference r_key =(const_key_reference)PB_ASSOC_V2F(*it); + + const_mapped_pointer p_mapped_value = + const_cast<PB_ASSOC_CLASS_C_DEC& >(*this). + find_key_pointer(r_key, my_traits_base::m_store_hash_indicator); + + if (p_mapped_value == NULL) + return (false); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + if (p_mapped_value->second != it->second) + return (false); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + } + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +template<class Other_HT_Map_Type> +bool +PB_ASSOC_CLASS_C_DEC:: +operator!=(const Other_HT_Map_Type& r_other) const +{ + return (!operator==(r_other)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cond_key_dtor_entry_dealtor.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cond_key_dtor_entry_dealtor.hpp new file mode 100644 index 00000000000..864b80541bc --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/cond_key_dtor_entry_dealtor.hpp @@ -0,0 +1,138 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 conditional key destructor, used for exception handling. + */ + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_CLASS_T_DEC \ + template<class HT_Map> + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CKDED_CLASS_NAME< \ + HT_Map> + + /** + * A conditional key destructor, used for exception handling. + **/ + template<class HT_Map> + class PB_ASSOC_CKDED_CLASS_NAME + { + public: + typedef typename HT_Map::entry entry; + + typedef typename HT_Map::entry_allocator entry_allocator; + + typedef typename HT_Map::key_type key_type; + + public: + inline + PB_ASSOC_CKDED_CLASS_NAME(entry_allocator* p_a, entry* p_e); + + inline + ~PB_ASSOC_CKDED_CLASS_NAME(); + + inline void + set_key_destruct(); + + inline void + set_no_action_destructor(); + + protected: + entry_allocator* const m_p_a; + entry* const m_p_e; + + bool m_key_destruct; + bool m_no_action_destructor; + }; + + PB_ASSOC_CLASS_T_DEC + inline + PB_ASSOC_CLASS_C_DEC:: + PB_ASSOC_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_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + set_key_destruct() + { + m_key_destruct = true; + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + set_no_action_destructor() + { + m_no_action_destructor = true; + } + + PB_ASSOC_CLASS_T_DEC + inline + PB_ASSOC_CLASS_C_DEC:: + ~PB_ASSOC_CKDED_CLASS_NAME() + { + if (m_no_action_destructor) + return; + + if (m_key_destruct) + m_p_e->m_value.first.~key_type(); + + m_p_a->deallocate(m_p_e, 1); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..90fa272b6c4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_fn_imps.hpp @@ -0,0 +1,227 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of cc_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::entry_allocator +PB_ASSOC_CLASS_C_DEC::s_entry_allocator; + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::entry_pointer_allocator +PB_ASSOC_CLASS_C_DEC::s_entry_pointer_allocator; + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + while (first_it != last_it) + insert(*(first_it++)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() : + my_ranged_hash_fn_base(Resize_Policy::get_init_size()), + m_a_p_entries(s_entry_pointer_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e_p(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn) : + my_ranged_hash_fn_base(Resize_Policy::get_init_size(), + r_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e_p(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + PB_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn), + my_ranged_hash_fn_base(Resize_Policy::get_init_size(), + r_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e_p(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + PB_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn), + my_ranged_hash_fn_base(Resize_Policy::get_init_size(), + r_hash_fn, r_comb_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e_p(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_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_ASSOC_HASH_EQ_FN_C_DEC(r_eq_fn), + Resize_Policy(r_resize_policy), + my_ranged_hash_fn_base(Resize_Policy::get_init_size(), + r_hash_fn, r_comb_hash_fn), + m_a_p_entries(s_entry_pointer_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e_p(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_HASH_EQ_FN_C_DEC(r_other), + my_resize_base(r_other), + my_ranged_hash_fn_base(r_other), + m_a_p_entries(s_entry_pointer_allocator.allocate( + r_other.m_num_e_p)), + m_num_e_p(r_other.m_num_e_p), + m_num_used_e(r_other.m_num_used_e) +{ + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + std::fill(m_a_p_entries, m_a_p_entries + m_num_e_p, (entry_pointer)NULL); + + try + { + for (size_type i = 0; i < m_num_e_p; ++i) + { + entry_pointer p_e = r_other.m_a_p_entries[i]; + + while (p_e != NULL) + { + constructor_insert_new_imp( + const_mapped_reference(p_e->m_value), i, + my_hash_traits_base::s_store_hash_indicator); + + p_e = p_e->m_p_next; + } + } + } + catch(...) + { + deallocate_all(); + + throw; + } + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_CLASS_NAME() +{ + deallocate_all(); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + + std::swap(m_a_p_entries, r_other.m_a_p_entries); + + std::swap(m_num_e_p, r_other.m_num_e_p); + + std::swap(m_num_used_e, r_other.m_num_used_e); + + my_ranged_hash_fn_base::swap(r_other); + + my_hash_eq_fn_base::swap(r_other); + + my_resize_base::swap(r_other); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::swap(r_other)); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +deallocate_all() +{ + clear(); + + s_entry_pointer_allocator.deallocate(m_a_p_entries, m_num_e_p); +} + +#include <ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp> diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..79641a6bc18 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp @@ -0,0 +1,61 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, int_to_type<false>) +{ + // Following lines might throw an exception. + entry_pointer p_e = get_entry(r_val, my_traits_base::s_no_throw_copies_indicator); + + // At this point no exceptions can be thrown. + + p_e->m_p_next = m_a_p_entries[pos]; + + m_a_p_entries[pos] = p_e; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(r_key);) + } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..551ae8663e2 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/constructor_destructor_store_hash_fn_imps.hpp @@ -0,0 +1,63 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +constructor_insert_new_imp(const_reference r_val, size_type pos, int_to_type<true>) +{ + // Following lines might throw an exception. + entry_pointer p_e = get_entry(r_val, my_traits_base::s_no_throw_copies_indicator); + + // At this point no exceptions can be thrown. + + p_e->m_p_next = m_a_p_entries[pos]; + + p_e->m_hash = my_ranged_hash_fn_base::operator()((const_key_reference)(PB_ASSOC_V2F(p_e->m_value))).second; + + m_a_p_entries[pos] = p_e; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(r_key);) + } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_fn_imps.hpp new file mode 100644 index 00000000000..639f74d4bd4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_fn_imps.hpp @@ -0,0 +1,83 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains implementations of cc_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + my_map_debug_base::check_size(m_num_used_e); + + assert_entry_pointer_array_valid(m_a_p_entries); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const +{ + size_type iterated_num_used_e = 0; + + for (size_type pos = 0; pos < m_num_e_p; ++pos) + { + entry_pointer p_e = a_p_entries[pos]; + + while (p_e != NULL) + { + ++iterated_num_used_e; + + assert_entry_pointer_valid(p_e, my_traits_base::m_store_hash_indicator); + + p_e = p_e->m_p_next; + } + } + + PB_ASSOC_DBG_ASSERT(iterated_num_used_e == m_num_used_e); +} + +#include <ext/pb_assoc/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp> +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..1af3be69d48 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_no_store_hash_fn_imps.hpp @@ -0,0 +1,54 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_entry_pointer_valid(const entry_pointer p_e, store_hash_false_indicator) const +{ + my_map_debug_base::check_key_exists(p_e->m_value.first); +} +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..ae9800301f2 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/debug_store_hash_fn_imps.hpp @@ -0,0 +1,59 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_entry_pointer_valid(const entry_pointer p_e, store_hash_true_indicator) const +{ + my_map_debug_base::check_key_exists(p_e->m_value.first); + + comp_hash pos_hash_pair = + my_ranged_hash_fn_base::operator()(p_e->m_value.first); + + PB_ASSOC_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second); +} +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/entry_list_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/entry_list_fn_imps.hpp new file mode 100644 index 00000000000..9ea01b549af --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/entry_list_fn_imps.hpp @@ -0,0 +1,111 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 entry_list_fn_imps.hpp + * Contains implementations of cc_ht_map_'s entry-list related functions. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +deallocate_links_in_list(entry_pointer p_e) +{ + while (p_e != NULL) + { + entry_pointer p_dealloc_e = p_e; + + p_e = p_e->m_p_next; + + s_entry_allocator.deallocate(p_dealloc_e, 1); + } +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::entry_pointer +PB_ASSOC_CLASS_C_DEC:: +get_entry(const_mapped_reference r_val, int_to_type<true>) +{ + // Following line might throw an exception. + + entry_pointer p_e = s_entry_allocator.allocate(1); + + // Following lines* cannot* throw an exception. + + new (&p_e->m_value) mapped_value_type(r_val); + + return (p_e); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::entry_pointer +PB_ASSOC_CLASS_C_DEC:: +get_entry(const_mapped_reference r_val, int_to_type<false>) +{ + // Following line might throw an exception. + + entry_pointer p_e = s_entry_allocator.allocate(1); + + cond_dealtor_t cond(p_e); + + // Following lines might throw an exception. + + new (&p_e->m_value) mapped_value_type(r_val); + + cond.set_no_action(); + + return (p_e); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +rels_entry(entry_pointer p_e) +{ + /* The following lines cannot throw exceptions + * (unless if key-data dtors do). */ + + PB_ASSOC_V2F(p_e->m_value).~Key(); +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + p_e->m_value.second.~data_type(); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + s_entry_allocator.deallocate(p_e, 1); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_fn_imps.hpp new file mode 100644 index 00000000000..525a41a4fa9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_fn_imps.hpp @@ -0,0 +1,114 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of cc_ht_map_'s erase related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +erase_entry_pointer(entry_pointer& r_p_e) +{ + PB_ASSOC_DBG_ONLY(my_map_debug_base::erase_existing(r_p_e->m_value.first)); + + entry_pointer p_e = r_p_e; + + r_p_e = r_p_e->m_p_next; + + rels_entry(p_e); + + PB_ASSOC_DBG_ASSERT(m_num_used_e > 0); + my_resize_base::notify_erased(--m_num_used_e); +} + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred& r_pred) +{ + size_type num_num_ersd = 0; + + for (size_type pos = 0; pos < m_num_e_p; ++pos) + { + size_t num_ersd = 0; + + if (m_a_p_entries[pos] != NULL&& + r_pred(m_a_p_entries[pos]->m_value)) + { + ++num_ersd; + + erase_entry_pointer(m_a_p_entries[pos]); + } + + entry_pointer p_e = m_a_p_entries[pos]; + + while (p_e != NULL&& p_e->m_p_next != NULL) + if (r_pred(p_e->m_p_next->m_value)) + { + ++num_num_ersd; + + erase_entry_pointer(p_e->m_p_next); + } + } + + do_resize_if_needed_no_throw(); + + return (num_num_ersd); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + for (size_type pos = 0; pos < m_num_e_p; ++pos) + while (m_a_p_entries[pos] != NULL) + erase_entry_pointer(m_a_p_entries[pos]); + + do_resize_if_needed_no_throw(); + + my_resize_base::notify_cleared(); +} + +#include <ext/pb_assoc/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp> + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..1b3e3c5e330 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_no_store_hash_fn_imps.hpp @@ -0,0 +1,159 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 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_ASSOC_CLASS_T_DEC +template<class T> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(T r_t, bool erase_entry_if_last, pb_assoc::detail::int_to_type<false>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (erase_in_pos_imp<T>(r_t, + erase_entry_if_last, + my_ranged_hash_fn_base::operator()( + my_traits_base::ext_eraser::extract_key(r_t)))); +} + +PB_ASSOC_CLASS_T_DEC +template<class T> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_in_pos_imp(T r_t, bool erase_entry_if_last, size_type pos) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_e = m_a_p_entries[pos]; + + my_resize_base::notify_erase_search_start(); + + if (p_e == NULL) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + ext_eraser::extract_key(r_t));) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (0); + } + + if (my_hash_eq_fn_base::operator()( + p_e->m_value.first, + my_traits_base::ext_eraser::extract_key(r_t))) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_exists(my_traits_base::ext_eraser::extract_key(r_t));) + + std::pair<size_type, bool> ers_pair = + my_traits_base::ext_eraser::erase( + PB_ASSOC_EP2VP(m_a_p_entries[pos]), + r_t, erase_entry_if_last); + + if (ers_pair.second) + { + erase_entry_pointer(m_a_p_entries[pos]); + + do_resize_if_needed_no_throw(); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (ers_pair.first); + } + + while (true) + { + entry_pointer p_next_e = p_e->m_p_next; + + if (p_next_e == NULL) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist( + my_traits_base::ext_eraser::extract_key(r_t));) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (0); + } + + if (my_hash_eq_fn_base::operator()( + p_next_e->m_value.first, + my_traits_base::ext_eraser::extract_key(r_t))) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_exists( + my_traits_base::ext_eraser::extract_key(r_t));) + + std::pair<size_type, bool> ers_pair = + my_traits_base::ext_eraser::erase( + PB_ASSOC_EP2VP(p_e->m_p_next), + r_t, erase_entry_if_last); + + if (ers_pair.second) + { + erase_entry_pointer(p_e->m_p_next); + + do_resize_if_needed_no_throw(); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (ers_pair.first); + } + + my_resize_base::notify_erase_search_collision(); + + p_e = p_next_e; + } +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..2762eba3606 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/erase_store_hash_fn_imps.hpp @@ -0,0 +1,159 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s erase related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +template<class T> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(T r_t, bool erase_entry_if_last, pb_assoc::detail::int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (erase_in_pos_imp<T>(r_t, erase_entry_if_last, + my_ranged_hash_fn_base::operator()( + my_traits_base::ext_eraser::extract_key(r_t)))); +} + +PB_ASSOC_CLASS_T_DEC +template<class T> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_in_pos_imp(T r_t, bool erase_entry_if_last, const comp_hash& r_pos_hash_pair) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_e = m_a_p_entries[r_pos_hash_pair.first]; + + my_resize_base::notify_erase_search_start(); + + if (p_e == NULL) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist( + my_traits_base::ext_eraser::extract_key(r_t));) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (0); + } + + if (my_hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, + my_traits_base::ext_eraser::extract_key(r_t), r_pos_hash_pair.second)) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists( + my_traits_base::ext_eraser::extract_key(r_t));) + + std::pair<size_type, bool> ers_pair = + my_traits_base::ext_eraser::erase( + PB_ASSOC_EP2VP(m_a_p_entries[r_pos_hash_pair.first]), + r_t, erase_entry_if_last); + + if (ers_pair.second) + { + erase_entry_pointer(m_a_p_entries[r_pos_hash_pair.first]); + + do_resize_if_needed_no_throw(); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (ers_pair.first); + } + + while (true) + { + entry_pointer p_next_e = p_e->m_p_next; + + if (p_next_e == NULL) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist( + my_traits_base::ext_eraser::extract_key(r_t));) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (0); + } + + if (my_hash_eq_fn_base::operator()( + p_next_e->m_value.first, p_next_e->m_hash, + my_traits_base::ext_eraser::extract_key(r_t), + r_pos_hash_pair.second)) + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_exists( + my_traits_base::ext_eraser::extract_key(r_t));) + + std::pair<size_type, bool> ers_pair = + my_traits_base::ext_eraser::erase( + PB_ASSOC_EP2VP(p_e->m_p_next), + r_t, erase_entry_if_last); + + if (ers_pair.second) + { + erase_entry_pointer(p_e->m_p_next); + + do_resize_if_needed_no_throw(); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (ers_pair.first); + } + + my_resize_base::notify_erase_search_collision(); + + p_e = p_next_e; + } +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_fn_imps.hpp new file mode 100644 index 00000000000..c72aa512226 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_fn_imps.hpp @@ -0,0 +1,83 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains implementations of cc_ht_map_'s find related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (find_key_pointer(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).find_key_pointer(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() +{ + return (NULL); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() const +{ + return (NULL); +} + +#include <ext/pb_assoc/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/find_store_hash_fn_imps.hpp> + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..ff876ff3c51 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_no_store_hash_fn_imps.hpp @@ -0,0 +1,86 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s find related functions, when the hash + * value is not stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key, int_to_type<false>) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this). + find_key_pointer(r_key, my_hash_traits_base::s_store_hash_indicator)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +find_key_pointer(const_key_reference r_key, int_to_type<false>) +{ + entry_pointer p_e = + m_a_p_entries[my_ranged_hash_fn_base::operator()(r_key)]; + + my_resize_base::notify_find_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()(PB_ASSOC_V2F(p_e->m_value), r_key)) + { + my_resize_base::notify_find_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_find_search_end(); + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + if (p_e == NULL) + my_map_debug_base::check_key_does_not_exist(r_key); + else + my_map_debug_base::check_key_exists(r_key); +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + return (&p_e->m_value); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..3db3dd31263 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/find_store_hash_fn_imps.hpp @@ -0,0 +1,88 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s find related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key, int_to_type<true>) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).find_key_pointer(r_key, my_traits_base::m_store_hash_indicator)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +find_key_pointer(const_key_reference r_key, int_to_type<true>) +{ + comp_hash pos_hash_pair = my_ranged_hash_fn_base::operator()(r_key); + + entry_pointer p_e = m_a_p_entries[pos_hash_pair.first]; + + my_resize_base::notify_find_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()(PB_ASSOC_V2F(p_e->m_value), + p_e->m_hash, + r_key, + pos_hash_pair.second)) + { + my_resize_base::notify_find_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_find_search_end(); + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + if (p_e == NULL) + my_map_debug_base::check_key_does_not_exist(r_key); + else + my_map_debug_base::check_key_exists(r_key); +#endif // #ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + return (const_cast<pointer>(&p_e->m_value)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/info_fn_imps.hpp new file mode 100644 index 00000000000..f464e789fc6 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/info_fn_imps.hpp @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains implementations of cc_ht_map_'s entire container info related + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (m_num_used_e); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (m_entry_allocator.max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_fn_imps.hpp new file mode 100644 index 00000000000..2d0a88e3931 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_fn_imps.hpp @@ -0,0 +1,63 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains implementations of cc_ht_map_'s insert related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_reference r_val) +{ + return (insert_imp(r_val, my_hash_traits_base::s_store_hash_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key) +{ + return (subscript_imp(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +#include <ext/pb_assoc/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp> + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..1d628fd55ba --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_no_store_hash_fn_imps.hpp @@ -0,0 +1,148 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s insert related functions, when the hash + * value is not stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key, int_to_type<false>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + const size_type pos = my_ranged_hash_fn_base::operator()(r_key); + + entry_pointer p_e = m_a_p_entries[pos]; + + my_resize_base::notify_insert_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()(p_e->m_value.first, r_key)) + { + my_resize_base::notify_insert_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_insert_search_end(); + + if (p_e != NULL) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (p_e->m_value.second); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key);) + + return (insert_new_imp(std::make_pair(r_key, data_type()), pos)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert_imp(const_reference r_val, int_to_type<false>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + const_key_reference r_key = PB_ASSOC_V2F(r_val); + + const size_type pos = my_ranged_hash_fn_base::operator()(r_key); + + entry_pointer p_e = m_a_p_entries[pos]; + + my_resize_base::notify_insert_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + r_key)) + { + my_resize_base::notify_insert_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_insert_search_end(); + + if (p_e != NULL) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (std::make_pair(&p_e->m_value, false)); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key);) + + return ( + std::make_pair( + insert_new_imp(r_val, pos), + true)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +insert_new_imp(const_reference r_val, size_type pos) +{ + if (do_resize_if_needed()) + pos = my_ranged_hash_fn_base::operator()(PB_ASSOC_V2F(r_val)); + + // Following lines might throw an exception. + entry_pointer p_e = get_entry(r_val, my_traits_base::s_no_throw_copies_indicator); + + // At this point no exceptions can be thrown. + + p_e->m_p_next = m_a_p_entries[pos]; + + m_a_p_entries[pos] = p_e; + + my_resize_base::notify_inserted(++m_num_used_e); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(r_key);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (&p_e->m_value); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..5c546e11d2a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/insert_store_hash_fn_imps.hpp @@ -0,0 +1,157 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s insert related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key, int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + comp_hash pos_hash_pair = my_ranged_hash_fn_base::operator()(r_key); + + entry_pointer p_e = m_a_p_entries[pos_hash_pair.first]; + + my_resize_base::notify_insert_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second)) + { + my_resize_base::notify_insert_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_insert_search_end(); + + if (p_e != NULL) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (p_e->m_value.second); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key);) + + return (insert_new_imp( + value_type(r_key, Data()), pos_hash_pair)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert_imp(const_reference r_val, int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + const_key_reference r_key = PB_ASSOC_V2F(r_val); + + comp_hash pos_hash_pair = my_ranged_hash_fn_base::operator()(r_key); + + entry_pointer p_e = m_a_p_entries[pos_hash_pair.first]; + + my_resize_base::notify_insert_search_start(); + + while (p_e != NULL&& + !my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + p_e->m_hash, + r_key, pos_hash_pair.second)) + { + my_resize_base::notify_insert_search_collision(); + + p_e = p_e->m_p_next; + } + + my_resize_base::notify_insert_search_end(); + + if (p_e != NULL) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return ( + std::make_pair( + static_cast<pointer>(&p_e->m_value), + false)); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key);) + + return ( + std::make_pair( + insert_new_imp(r_val, pos_hash_pair), + true)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) +{ + // Following lines might throw an exception. + + if (do_resize_if_needed()) + r_pos_hash_pair = my_ranged_hash_fn_base::operator()( + PB_ASSOC_V2F(r_val)); + + entry_pointer p_e = get_entry(r_val, my_traits_base::s_no_throw_copies_indicator); + + // At this point no exceptions can be thrown. + + p_e->m_hash = r_pos_hash_pair.second; + + p_e->m_p_next = m_a_p_entries[r_pos_hash_pair.first]; + + m_a_p_entries[r_pos_hash_pair.first] = p_e; + + my_resize_base::notify_inserted(++m_num_used_e); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(r_key);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (static_cast<pointer>(&p_e->m_value)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/iterators_fn_imps.hpp new file mode 100644 index 00000000000..1bdde7562a4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/iterators_fn_imps.hpp @@ -0,0 +1,153 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterators_fn_imps.hpp + * Contains implementations of cc_ht_map_'s iterators related functions, e.g., + * begin(). + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC::s_end_it; + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC::s_const_end_it; + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +begin() +{ + pointer p_value; + std::pair<entry_pointer, size_type> pos; + + get_start_it_state(p_value, pos); + + return (iterator(p_value, pos, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +end() +{ + return (s_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +begin() const +{ + pointer p_value; + + std::pair<entry_pointer, size_type> pos; + + get_start_it_state(p_value, pos); + + return (const_iterator(p_value, pos, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +end() const +{ + return (s_const_end_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +inc_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const +{ + inc_it_state((const_pointer& )r_p_value, r_pos); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +inc_it_state(const_pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const +{ + PB_ASSOC_DBG_ASSERT(r_p_value != NULL); + + r_pos.first = r_pos.first->m_p_next; + + if (r_pos.first != NULL) + { + r_p_value =& r_pos.first->m_value; + + return; + } + + for (++r_pos.second; r_pos.second < m_num_e_p; ++r_pos.second) + if (m_a_p_entries[r_pos.second] != NULL) + { + r_pos.first = m_a_p_entries[r_pos.second]; + + r_p_value =& r_pos.first->m_value; + + return; + } + + r_p_value = NULL; +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +get_start_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const +{ + for (r_pos.second = 0; r_pos.second < m_num_e_p; ++r_pos.second) + if (m_a_p_entries[r_pos.second] != NULL) + { + r_pos.first = m_a_p_entries[r_pos.second]; + + r_p_value = (pointer)(r_pos.first); + + return; + } + + r_p_value = NULL; +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/policy_access_fn_imps.hpp new file mode 100644 index 00000000000..2448d6068de --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/policy_access_fn_imps.hpp @@ -0,0 +1,108 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 policy_access_fn_imps.hpp + * Contains implementations of cc_ht_map_'s policy access + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_hash_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_hash_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Comb_Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_comb_hash_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Comb_Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_comb_hash_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Resize_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_resize_policy() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Resize_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_resize_policy() const +{ + return (*this); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_fn_imps.hpp new file mode 100644 index 00000000000..a9b979ea934 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_fn_imps.hpp @@ -0,0 +1,146 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_fn_imps.hpp + * Contains implementations of cc_ht_map_'s resize related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +do_resize_if_needed() +{ + if (!my_resize_base::is_resize_needed()) + return (false); + + do + do_resize(my_resize_base::get_new_size(m_num_e_p, m_num_used_e)); + while (my_resize_base::is_resize_needed()); + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +do_resize_if_needed_no_throw() +{ + if (!my_resize_base::is_resize_needed()) + return; + + try + { + do + do_resize(my_resize_base::get_new_size(m_num_e_p, m_num_used_e)); + while (my_resize_base::is_resize_needed()); + } + catch(...) + { } + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +do_resize(size_type new_size) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + const size_type old_size = m_num_e_p; + + entry_pointer_array a_p_entries_resized; + + // Following line might throw an exception. + + my_ranged_hash_fn_base::notify_resized(new_size); + + try + { + // Following line might throw an exception. + + a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size); + + m_num_e_p = new_size; + } + catch(...) + { + my_ranged_hash_fn_base::notify_resized(old_size); + + throw; + } + + // At this point no exceptions can be thrown. + + resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size); + + Resize_Policy::notify_resized(new_size); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size) +{ + std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e_p,(entry_pointer)NULL); + + for (size_type pos = 0; pos < old_size; ++pos) + { + entry_pointer p_e = m_a_p_entries[pos]; + + while (p_e != NULL) + p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, my_hash_traits_base::s_store_hash_indicator); + } + + m_num_e_p = new_size; + + PB_ASSOC_DBG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);) + + s_entry_pointer_allocator.deallocate(m_a_p_entries, old_size); + + m_a_p_entries = a_p_entries_resized; + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +#include <ext/pb_assoc/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp> diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..331391d6c7e --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp @@ -0,0 +1,61 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_no_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s resize related functions, when the + * hash value is not stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::entry_pointer +PB_ASSOC_CLASS_C_DEC:: +resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, int_to_type<false>) +{ + const size_type hash_pos = + my_ranged_hash_fn_base::operator()(PB_ASSOC_V2F(p_e->m_value)); + + entry_pointer const p_next_e = p_e->m_p_next; + + p_e->m_p_next = a_p_entries_resized[hash_pos]; + + a_p_entries_resized[hash_pos] = p_e; + + return (p_next_e); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..7f02f6df11b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp @@ -0,0 +1,63 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_store_hash_fn_imps.hpp + * Contains implementations of cc_ht_map_'s resize related functions, when the + * hash value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::entry_pointer +PB_ASSOC_CLASS_C_DEC:: +resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, int_to_type<true>) +{ + const comp_hash pos_hash_pair = + my_ranged_hash_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + p_e->m_hash); + + entry_pointer const p_next_e = p_e->m_p_next; + + p_e->m_p_next = a_p_entries_resized[pos_hash_pair.first]; + + a_p_entries_resized[pos_hash_pair.first] = p_e; + + return (p_next_e); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/size_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/size_fn_imps.hpp new file mode 100644 index 00000000000..940a165a9a4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/size_fn_imps.hpp @@ -0,0 +1,69 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 size_fn_imps.hpp + * Contains implementations of cc_ht_map_'s entire container size related + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (m_num_used_e); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (s_entry_allocator.max_size()); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/standard_policies.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/standard_policies.hpp new file mode 100644 index 00000000000..f25135d3792 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cc_ht_map_/standard_policies.hpp @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 standard_policies.hpp + * Contains standard policies for cc_ht_map types. + */ + +#ifndef CC_HT_MAP_STANDARD_POLICIES_HPP +#define CC_HT_MAP_STANDARD_POLICIES_HPP + +#include <ext/pb_assoc/detail/standard_policies.hpp> + +#endif // #ifndef CC_HT_MAP_STANDARD_POLICIES_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/cond_dealtor.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/cond_dealtor.hpp new file mode 100644 index 00000000000..238e0c65ded --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/cond_dealtor.hpp @@ -0,0 +1,129 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_dealtor.hpp + * Contains a conditional deallocator. + */ + +#ifndef COND_DEALTOR_HPP +#define COND_DEALTOR_HPP + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_COND_DEALTOR_CLASS_T_DEC \ + template<class Entry, class Allocator> + +#define PB_ASSOC_COND_DEALTOR_CLASS_C_DEC \ + cond_dealtor< \ + Entry, \ + Allocator> + + template<class 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_ASSOC_COND_DEALTOR_CLASS_T_DEC + typename PB_ASSOC_COND_DEALTOR_CLASS_C_DEC::entry_allocator + PB_ASSOC_COND_DEALTOR_CLASS_C_DEC::s_alloc; + + PB_ASSOC_COND_DEALTOR_CLASS_T_DEC + inline + PB_ASSOC_COND_DEALTOR_CLASS_C_DEC:: + cond_dealtor(entry_pointer p_e) : + m_p_e(p_e), + m_no_action_destructor(false) + { } + + PB_ASSOC_COND_DEALTOR_CLASS_T_DEC + inline void + PB_ASSOC_COND_DEALTOR_CLASS_C_DEC:: + set_no_action() + { + m_no_action_destructor = true; + } + + PB_ASSOC_COND_DEALTOR_CLASS_T_DEC + inline + PB_ASSOC_COND_DEALTOR_CLASS_C_DEC:: + ~cond_dealtor() + { + if (m_no_action_destructor) + return; + + s_alloc.deallocate(m_p_e, 1); + } + +#undef PB_ASSOC_COND_DEALTOR_CLASS_T_DEC +#undef PB_ASSOC_COND_DEALTOR_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef COND_DEALTOR_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..6ac0391351f --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp @@ -0,0 +1,126 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains constructors_destructor_fn_imps applicable to different containers. + */ + +inline +PB_ASSOC_CLASS_NAME() +{ } + +inline +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : PB_ASSOC_DIRECT_BASE_C_DEC((const PB_ASSOC_DIRECT_BASE_CAST_C_DEC& )r_other) +{ } + +template<typename T0> +inline +PB_ASSOC_CLASS_NAME(T0 t0) : PB_ASSOC_DIRECT_BASE_C_DEC(t0) +{ } + +template<typename T0, typename T1> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1) +{ } + +template<typename T0, typename T1, typename T2> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2) +{ } + +template<typename T0, typename T1, typename T2, typename T3> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3) +{ } + +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4) +{ } + +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5) +{ } + +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6) +{ } + +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6, t7) +{ } + +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8> +inline +PB_ASSOC_CLASS_NAME(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) : PB_ASSOC_DIRECT_BASE_C_DEC(t0, t1, t2, t3, t4, t5, t6, t7, t8) +{ } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ds_trait_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ds_trait_imp.hpp new file mode 100644 index 00000000000..102fda60f2a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ds_trait_imp.hpp @@ -0,0 +1,336 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ds_trait_imp.hpp + * Contains data-structure traits implementation. + */ + +#ifndef DS_TRAIT_IMP_HPP +#define DS_TRAIT_IMP_HPP + +namespace detail +{ + + template<class Cntnr, class DS_Category> + struct erase_can_throw_imp + { + enum + { + value = + pb_assoc::detail::is_same_type< + DS_Category, + ov_tree_ds_tag>::value + }; + }; + + template<class Cntnr> + struct erase_can_throw_imp< + Cntnr, + compound_ds_tag> + { + enum + { + value = Cntnr::erase_can_throw + }; + }; + + template<class Cntnr, class DS_Category> + struct erase_iterators_imp + { + enum + { + value = + pb_assoc::detail::is_same_type< + DS_Category, + rb_tree_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + splay_tree_ds_tag>::value + }; + }; + + template<class Cntnr> + struct erase_iterators_imp< + Cntnr, + compound_ds_tag> + { + enum + { + value = Cntnr::erase_iterators + }; + }; + + template<class Cntnr, class DS_Category> + struct order_preserving_imp + { + enum + { + value = + pb_assoc::detail::is_same_type< + DS_Category, + rb_tree_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + splay_tree_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + ov_tree_ds_tag>::value + }; + }; + + template<class Cntnr> + struct order_preserving_imp< + Cntnr, + compound_ds_tag> + { + enum + { + value = Cntnr::order_preserving + }; + }; + + template<class Cntnr, class DS_Category> + struct invalidation_guarantee_imp + { + private: + enum + { + node_based = + pb_assoc::detail::is_same_type< + DS_Category, + cc_hash_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + rb_tree_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + splay_tree_ds_tag>::value || + pb_assoc::detail::is_same_type< + DS_Category, + lu_ds_tag>::value + }; + + enum + { + vector_organized = + pb_assoc::detail::is_same_type< + DS_Category, + cc_hash_ds_tag>::value + }; + + public: + typedef + typename cond_type< + node_based, + typename cond_type< + vector_organized, + find_invalidation_guarantee, + range_invalidation_guarantee>::type, + basic_invalidation_guarantee>::type + type; + }; + + template<class Cntnr> + struct invalidation_guarantee_imp< + Cntnr, + compound_ds_tag> + { + typedef typename Cntnr::invalidation_guarantee type; + }; + + template<class Cntnr, class DS_Category> + struct reverse_iteration_imp + { + enum + { + value = + is_same_type< + DS_Category, + rb_tree_ds_tag>::value || + is_same_type< + DS_Category, + splay_tree_ds_tag>::value + }; + }; + + template<class Cntnr> + struct reverse_iteration_imp< + Cntnr, + compound_ds_tag> + { + enum + { + value = Cntnr::reverse_iteration + }; + }; + + template<class Cntnr, class DS_Category> + struct split_join_imp + { + enum + { + value = + is_same_type< + DS_Category, + rb_tree_ds_tag>::value || + is_same_type< + DS_Category, + splay_tree_ds_tag>::value || + is_same_type< + DS_Category, + ov_tree_ds_tag>::value + }; + }; + + template<class Cntnr> + struct split_join_imp< + Cntnr, + compound_ds_tag> + { + enum + { + value = false + }; + }; + + template<class Cntnr> + struct basic_data_structure_traits + { + + private: + typedef Cntnr cntnr; + + typedef typename Cntnr::ds_category ds_category; + + public: + enum + { + erase_can_throw = + pb_assoc::detail::erase_can_throw_imp< + cntnr, + ds_category>::value + }; + + enum + { + order_preserving = + pb_assoc::detail::order_preserving_imp< + cntnr, + ds_category>::value + }; + + enum + { + erase_iterators = + pb_assoc::detail::erase_iterators_imp< + Cntnr, + ds_category>::value + }; + + typedef + typename pb_assoc::detail::invalidation_guarantee_imp< + cntnr, + ds_category>::type + invalidation_guarantee; + + enum + { + reverse_iteration = + pb_assoc::detail::reverse_iteration_imp< + cntnr, + ds_category>::value + }; + + enum + { + split_join = + pb_assoc::detail::split_join_imp< + cntnr, + ds_category>::value + }; + }; + + template<class Cntnr, class DS_Category> + struct data_structure_traits : public basic_data_structure_traits< + Cntnr> + { }; + + template<class Cntnr> + struct data_structure_traits< + Cntnr, + rb_tree_ds_tag> : public basic_data_structure_traits< + Cntnr> + { + public: + enum + { + split_join_can_throw = false + }; + }; + + template<class Cntnr> + struct data_structure_traits< + Cntnr, + splay_tree_ds_tag> : public basic_data_structure_traits< + Cntnr> + { + public: + enum + { + split_join_can_throw = false + }; + }; + + template<class Cntnr> + struct data_structure_traits< + Cntnr, + ov_tree_ds_tag> : public basic_data_structure_traits< + Cntnr> + { + public: + enum + { + split_join_can_throw = true + }; + }; + +} // namespace detail + +#endif // #ifndef DS_TRAIT_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/eq_by_less.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/eq_by_less.hpp new file mode 100644 index 00000000000..b2f5a0b327a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/eq_by_less.hpp @@ -0,0 +1,78 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 eq_by_less.hpp + * Contains an equivalence function. + */ + +#ifndef EQ_BY_LESS_HPP +#define EQ_BY_LESS_HPP + +#include <utility> +#include <functional> +#include <vector> +#include <assert.h> +#include <ext/pb_assoc/detail/types_traits.hpp> + +namespace pb_assoc +{ + + namespace detail + { + +#include <functional> + + template<typename Key, class Cmp_Fn> + struct eq_by_less : public std::binary_function<const Key& , const Key& , bool>, + protected Cmp_Fn + { + bool + operator()(const Key& r_lhs, const Key& r_rhs) const + { + return (!(Cmp_Fn::operator()(r_lhs, r_rhs)&& + !(Cmp_Fn::operator()(r_rhs, r_lhs)))); + } + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef EQ_BY_LESS_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp new file mode 100644 index 00000000000..9572bb54a01 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp @@ -0,0 +1,211 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_eq_fn.hpp + * Contains 2 eqivalence functions, one employing a hash value, + * and one ignoring it. + */ + +#ifndef HASH_EQ_FN_HPP +#define HASH_EQ_FN_HPP + +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_HASH_EQ_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HASH_EQ_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HASH_EQ_FN_DEBUG + + template<typename Key, class Eq_Fn, class Allocator, bool Store_Hash> + struct hash_eq_fn; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Eq_Fn, class Allocator> + +#define PB_ASSOC_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 + { + typedef Eq_Fn my_eq_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + hash_eq_fn(); + + hash_eq_fn(const Eq_Fn& r_eq_fn); + + inline bool + operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const; + + inline void + swap(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + hash_eq_fn() + { } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + swap(const PB_ASSOC_CLASS_C_DEC& r_other) + { + std::swap((Eq_Fn& )(*this), (Eq_Fn& )r_other); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + hash_eq_fn(const Eq_Fn& r_eq_fn) : + Eq_Fn(r_eq_fn) + { } + + PB_ASSOC_CLASS_T_DEC + inline bool + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const + { + return (my_eq_fn_base::operator()(r_lhs_key, r_rhs_key)); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Eq_Fn, class Allocator> + +#define PB_ASSOC_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 my_eq_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + hash_eq_fn(); + + hash_eq_fn(const Eq_Fn& r_eq_fn); + + inline bool + operator()(const_key_reference r_lhs_key, size_type lhs_hash, const_key_reference r_rhs_key, size_type rhs_hash) const; + + inline void + swap(const PB_ASSOC_CLASS_C_DEC& r_other); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + hash_eq_fn() + { } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + hash_eq_fn(const Eq_Fn& r_eq_fn) : + Eq_Fn(r_eq_fn) + { } + + PB_ASSOC_CLASS_T_DEC + inline bool + PB_ASSOC_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 + { + PB_ASSOC_DBG_ASSERT(!my_eq_fn_base::operator()(r_lhs_key, r_rhs_key) || + lhs_hash == rhs_hash); + + return (lhs_hash == rhs_hash&& + my_eq_fn_base::operator()(r_lhs_key, r_rhs_key)); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + swap(const PB_ASSOC_CLASS_C_DEC& r_other) + { + std::swap((Eq_Fn& )(*this), (Eq_Fn& )(r_other)); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef HASH_EQ_FN_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..610c4695991 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_hash_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,166 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of gp_ht_maps's constructors, destructors, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_probe_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_probe_fn, r_resize_policy) +{ } + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_probe_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(It first_it, It last_it, const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy) : + PB_ASSOC_BASE_C_DEC(r_hash_fn, r_eq_fn, r_comb_hash_fn, r_probe_fn, r_resize_policy) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +gp_hash_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_BASE_C_DEC((const PB_ASSOC_BASE_C_DEC& )(r_other)) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC& +PB_ASSOC_CLASS_C_DEC:: +operator=(const PB_ASSOC_CLASS_C_DEC& r_other) +{ + if (this !=& r_other) + { + PB_ASSOC_CLASS_C_DEC tmp(r_other); + + swap(tmp); + } + + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~gp_hash_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_base::swap(r_other); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..d1f6b38133b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp @@ -0,0 +1,255 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of gp_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::entry_allocator +PB_ASSOC_CLASS_C_DEC::s_entry_allocator; + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + while (first_it != last_it) + insert(*(first_it++)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() : + my_ranged_probe_fn_base(Resize_Policy::get_init_size()), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn) : + my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : + my_hash_eq_fn_base(r_eq_fn), + my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) : + my_hash_eq_fn_base(r_eq_fn), + my_ranged_probe_fn_base(Resize_Policy::get_init_size(), + r_hash_fn, r_comb_hash_fn), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn) : + my_hash_eq_fn_base(r_eq_fn), + my_ranged_probe_fn_base(Resize_Policy::get_init_size(), + r_hash_fn, r_comb_hash_fn, r_probe_fn), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy) : + my_hash_eq_fn_base(r_eq_fn), + my_resize_base(r_resize_policy), + my_ranged_probe_fn_base(Resize_Policy::get_init_size(), + r_hash_fn, r_comb_hash_fn, r_probe_fn), + m_a_entries(s_entry_allocator.allocate( + Resize_Policy::get_init_size())), + m_num_e(Resize_Policy::get_init_size()), + m_num_used_e(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_r_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + my_hash_eq_fn_base(r_other), + my_resize_base(r_other), + my_ranged_probe_fn_base(r_other), + m_a_entries(s_entry_allocator.allocate( + r_other.m_num_e)), + m_num_e(r_other.m_num_e), + m_num_used_e(r_other.m_num_used_e) +{ + initialize(); + + try + { + for (size_type i = 0; i < m_num_e; ++i) + { + entry_pointer p_e =& r_other.m_a_entries[i]; + if (p_e->m_stat == VALID_ENTRY_STATUS) + constructor_insert_new_imp((const_mapped_reference)p_e->m_value, + i, + my_hash_traits_base::s_store_hash_indicator); + } + } + catch(...) + { + deallocate_all(); + + throw; + } + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_CLASS_NAME() +{ + deallocate_all(); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + + std::swap(m_a_entries, r_other.m_a_entries); + + std::swap(m_num_e, r_other.m_num_e); + + std::swap(m_num_used_e, r_other.m_num_used_e); + + my_ranged_probe_fn_base::swap(r_other); + + my_hash_eq_fn_base::swap(r_other); + + my_resize_base::swap(r_other); + + PB_ASSOC_DBG_ONLY(my_cntnr_debug_base::swap(r_other)); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +deallocate_all() +{ + clear(); + + erase_all_valid_entries(m_a_entries, m_num_e); + + s_entry_allocator.deallocate(m_a_entries, m_num_e); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +erase_all_valid_entries(entry_array a_entries_resized, size_type size) +{ + for (size_type pos = 0; pos < size; ++pos) + { + entry_pointer p_e =& a_entries_resized[pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + p_e->m_value.~value_type(); + } +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize() +{ + for (size_type i = 0; i < m_num_e; ++i) + m_a_entries[i].m_stat = (entry_status)EMPTY_ENTRY_STATUS; +} + +#include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp> diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..94211247961 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp @@ -0,0 +1,61 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_no_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, int_to_type<false>) +{ + PB_ASSOC_DBG_ASSERT(m_a_entries[pos].m_stat != VALID_ENTRY_STATUS); + + entry* const p_e = m_a_entries + pos; + + new (&p_e->m_value) mapped_value_type(r_val); + + p_e->m_stat = VALID_ENTRY_STATUS; + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + insert_new(p_e->m_value.first);) + } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..c26b1dbc7f8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp @@ -0,0 +1,64 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, int_to_type<true>) +{ + PB_ASSOC_DBG_ASSERT(m_a_entries[pos].m_stat != VALID_ENTRY_STATUS); + + entry* const p_e = m_a_entries + pos; + + new (&p_e->m_value) mapped_value_type(r_val); + + p_e->m_hash = my_ranged_probe_fn_base::operator()( + PB_ASSOC_V2F(r_val)).second; + + p_e->m_stat = VALID_ENTRY_STATUS; + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + insert_new(p_e->m_value.first);) + } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_fn_imps.hpp new file mode 100644 index 00000000000..e02864bb172 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_fn_imps.hpp @@ -0,0 +1,60 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains implementations of gp_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + my_map_debug_base::check_size(m_num_used_e); + + assert_entry_array_valid(m_a_entries, my_traits_base::m_store_hash_indicator); +} + +#include <ext/pb_assoc/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp> + +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..bef121d9a94 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_no_store_hash_fn_imps.hpp @@ -0,0 +1,81 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_no_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_entry_array_valid(const entry_array a_entries, store_hash_false_indicator) const +{ + size_type iterated_num_used_e = 0; + + for (size_type pos = 0; pos < m_num_e; ++pos) + { + const_entry_pointer p_e =& a_entries[pos]; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + case ERASED_ENTRY_STATUS: + break; + case VALID_ENTRY_STATUS: + { + const_key_reference r_key = p_e->m_value.first; + + my_map_debug_base::check_key_exists(r_key); + + ++iterated_num_used_e; + + break; + } + default: + PB_ASSOC_DBG_ASSERT(0); + }; + } + + PB_ASSOC_DBG_ASSERT(iterated_num_used_e == m_num_used_e); +} + +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..7c75c23aaa3 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/debug_store_hash_fn_imps.hpp @@ -0,0 +1,86 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_entry_array_valid(const entry_array a_entries, store_hash_true_indicator) const +{ + size_type iterated_num_used_e = 0; + + for (size_type pos = 0; pos < m_num_e; ++pos) + { + const_entry_pointer p_e =& a_entries[pos]; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + case ERASED_ENTRY_STATUS: + break; + case VALID_ENTRY_STATUS: + { + const_key_reference r_key = p_e->m_value.first; + + my_map_debug_base::check_key_exists(r_key); + + const comp_hash pos_hash_pair = + my_ranged_probe_fn_base::operator()(r_key); + + PB_ASSOC_DBG_ASSERT(p_e->m_hash == pos_hash_pair.second); + + ++iterated_num_used_e; + + break; + } + default: + PB_ASSOC_DBG_ASSERT(0); + }; + } + + PB_ASSOC_DBG_ASSERT(iterated_num_used_e == m_num_used_e); +} + +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_fn_imps.hpp new file mode 100644 index 00000000000..1f0e921e0bd --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_fn_imps.hpp @@ -0,0 +1,110 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of gp_ht_map_'s erase related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +erase_entry(entry_pointer p_e) +{ + PB_ASSOC_DBG_ASSERT(p_e->m_stat = VALID_ENTRY_STATUS); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::erase_existing(p_e->m_value.first);) + + p_e->m_value.~value_type(); + + p_e->m_stat = ERASED_ENTRY_STATUS; + + PB_ASSOC_DBG_ASSERT(m_num_used_e > 0); + my_resize_base::notify_erased(--m_num_used_e); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + for (size_type pos = 0; pos < m_num_e; ++pos) + { + entry_pointer p_e =& m_a_entries[pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + erase_entry(p_e); + } + + do_resize_if_needed_no_throw(); + + my_resize_base::notify_cleared(); +} + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred pred) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + size_type num_ersd = 0; + + for (size_type pos = 0; pos < m_num_e; ++pos) + { + entry_pointer p_e =& m_a_entries[pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS&& pred(p_e->m_value)) + { + ++num_ersd; + + erase_entry(p_e); + } + } + + do_resize_if_needed_no_throw(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (num_ersd); +} + +#include <ext/pb_assoc/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp> diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..5c5e383284f --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_no_store_hash_fn_imps.hpp @@ -0,0 +1,104 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 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_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key, int_to_type<false>) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + size_type hash = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + my_resize_base::notify_erase_search_start(); + + for (i = 0; i < m_num_e; ++i) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, hash, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + r_key)); + + return (0); + } + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value))) + { + my_resize_base::notify_erase_search_end(); + + erase_entry(p_e); + + do_resize_if_needed_no_throw(); + + return (1); + } + break; + case ERASED_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_erase_search_collision(); + } + + my_resize_base::notify_erase_search_end(); + + return (0); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..b1cd64257bb --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/erase_store_hash_fn_imps.hpp @@ -0,0 +1,109 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s erase related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key, int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (erase_in_pos_imp(r_key, 0)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_in_pos_imp(const_key_reference r_key, const comp_hash& /*r_pos_hash_pair*/) +{ + const comp_hash pos_hash_pair = + my_ranged_probe_fn_base::operator()(r_key); + + for (size_type i = 0; i < m_num_e; ++i) + { + const size_type pos = my_ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_erase_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + r_key)); + + return (0); + } + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash, r_key, pos_hash_pair.second)) + { + my_resize_base::notify_erase_search_end(); + + erase_entry(p_e); + + do_resize_if_needed_no_throw(); + + return (1); + } + break; + case ERASED_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_erase_search_collision(); + } + + my_resize_base::notify_erase_search_end(); + + return (0); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_fn_imps.hpp new file mode 100644 index 00000000000..b86de2a2781 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_fn_imps.hpp @@ -0,0 +1,94 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains implementations of gp_ht_map_'s find related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return ((find_key_pointer(r_key, my_hash_traits_base::s_store_hash_indicator))); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this). + find_key_pointer(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() +{ + return (NULL); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() const +{ + return (NULL); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key) const +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (const_subscript_imp(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +#include <ext/pb_assoc/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/find_store_hash_fn_imps.hpp> + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..6f63de9f455 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_no_store_hash_fn_imps.hpp @@ -0,0 +1,116 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 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_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key, int_to_type<false>) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this). + find_key_pointer(r_key, my_traits_base::m_store_hash_indicator)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC::find_key_pointer(const_key_reference r_key, int_to_type<false>) +{ + const size_type hash = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + my_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) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, hash, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_find_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist(r_key);) + + return (NULL); + } + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + r_key)) + { + my_resize_base::notify_find_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return ((pointer)&p_e->m_value); + } + break; + case ERASED_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_find_search_collision(); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist(r_key);) + + my_resize_base::notify_find_search_end(); + + return (NULL); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..a4728db88e5 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/find_store_hash_fn_imps.hpp @@ -0,0 +1,118 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s insert related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key, int_to_type<true>) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).find_key_pointer(r_key, my_traits_base::m_store_hash_indicator)->second); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +find_key_pointer(const_key_reference r_key, int_to_type<true>) +{ + comp_hash pos_hash_pair = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + my_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) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_find_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist(r_key);) + + return (NULL); + } + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + p_e->m_hash, + r_key, + pos_hash_pair.second)) + { + my_resize_base::notify_find_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return ((pointer)&p_e->m_value); + } + break; + case ERASED_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_find_search_collision(); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + check_key_does_not_exist(r_key);) + + my_resize_base::notify_find_search_end(); + + return (NULL); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp new file mode 100644 index 00000000000..9344844b216 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/gp_ht_map_.hpp @@ -0,0 +1,602 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 gp_ht_map_.hpp + * Contains an implementation class for gp_ht_map_. + */ + +#include <ext/pb_assoc/detail/cond_dealtor.hpp> +#include <ext/pb_assoc/trivial_iterator_def.hpp> +#include <ext/pb_assoc/detail/hash_fn/ranged_probe_fn.hpp> +#include <ext/pb_assoc/detail/hash_types_traits.hpp> +#include <ext/pb_assoc/detail/types_traits.hpp> +#include <ext/pb_assoc/exception.hpp> +#include <ext/pb_assoc/detail/map_debug_base.hpp> +#include <ext/pb_assoc/detail/eq_fn/hash_eq_fn.hpp> +#ifdef PB_ASSOC_BASIC_REGRESSION +#include <pb_assoc/testsuite/regression/basic_test/throw_prob_adjustor.hpp> +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Hash_Fn, \ + class Eq_Fn, \ + class Allocator, \ + bool Store_Hash, \ + class Comb_Probe_Fn, \ + class Probe_Fn, \ + class Resize_Policy> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + gp_ht_map_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + gp_ht_map_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Hash_Fn, \ + Eq_Fn, \ + Allocator, \ + Store_Hash, \ + Comb_Probe_Fn, \ + Probe_Fn, \ + Resize_Policy> + +#define PB_ASSOC_HASH_EQ_FN_C_DEC \ + pb_assoc::detail::hash_eq_fn< \ + Key, \ + Eq_Fn, \ + Allocator, \ + Store_Hash> + +#define PB_ASSOC_RANGED_PROBE_FN_C_DEC \ + pb_assoc::detail::ranged_probe_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + Comb_Probe_Fn, \ + Probe_Fn, \ + Store_Hash> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + types_traits< \ + Key, \ + Data, \ + Allocator> + +#define PB_ASSOC_HASH_TYPES_TRAITS_C_DEC \ + hash_types_traits< \ + typename Allocator::size_type, \ + Store_Hash> + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE +#define PB_ASSOC_MAP_DEBUG_BASE_C_DEC \ + pb_assoc::detail::map_debug_base< \ + Key, \ + Eq_Fn> +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Mapped_Data() +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_STATIC_ASSERT(UNIQUE, E) \ + typedef \ + pb_assoc::detail::static_assert_dummy_class< \ + sizeof(pb_assoc::detail::static_assert<(bool)(E)>)> \ + UNIQUE##static_assert_type + + template<typename Key, + typename Data, + class Hash_Fn, + class Eq_Fn, + class Allocator, + bool Store_Hash, + class Comb_Probe_Fn, + class Probe_Fn, + class Resize_Policy> + class PB_ASSOC_CLASS_NAME : +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + protected PB_ASSOC_MAP_DEBUG_BASE_C_DEC, +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + public PB_ASSOC_HASH_EQ_FN_C_DEC, + public Resize_Policy, + public PB_ASSOC_RANGED_PROBE_FN_C_DEC, + public PB_ASSOC_TYPES_TRAITS_C_DEC, + public PB_ASSOC_HASH_TYPES_TRAITS_C_DEC + { + + public: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + protected: + + typedef typename PB_ASSOC_HASH_TYPES_TRAITS_C_DEC::comp_hash comp_hash; + + enum ENTRY_STATUS + { + EMPTY_ENTRY_STATUS, + VALID_ENTRY_STATUS, + ERASED_ENTRY_STATUS + }; + + typedef char entry_status; + + struct store_hash_entry + { + value_type m_value; + + entry_status m_stat; + + size_type m_hash; + }; + + struct no_store_hash_entry + { + value_type m_value; + + entry_status m_stat; + }; + + typedef + typename cond_type< + Store_Hash, + store_hash_entry, + no_store_hash_entry>::type + entry; + + typedef + typename Allocator::template rebind<entry>::other + entry_allocator; + + typedef typename entry_allocator::pointer entry_pointer; + + typedef typename entry_allocator::const_pointer const_entry_pointer; + + typedef typename entry_allocator::reference entry_reference; + + typedef + typename entry_allocator::const_reference + const_entry_reference; + + typedef typename entry_allocator::pointer entry_array; + + typedef value_type mapped_value_type; + + typedef pointer mapped_pointer; + + typedef const_pointer const_mapped_pointer; + + typedef reference mapped_reference; + + typedef const_reference const_mapped_reference; + +#define PB_ASSOC_GEN_POS size_type + +#include <ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/iterator.hpp> + +#undef PB_ASSOC_GEN_POS + + typedef find_iterator_ find_iterator; + + typedef const_find_iterator_ const_find_iterator; + + typedef iterator_ iterator; + + typedef const_iterator_ const_iterator; + + typedef Hash_Fn hash_fn; + + typedef Eq_Fn eq_fn; + + typedef Allocator allocator; + + typedef Probe_Fn probe_fn; + + typedef Comb_Probe_Fn comb_hash_fn; + + typedef Resize_Policy resize_policy; + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn); + + PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + virtual + ~PB_ASSOC_CLASS_NAME(); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + Hash_Fn& + get_hash_fn(); + + const Hash_Fn& + get_hash_fn() const; + + Eq_Fn& + get_eq_fn(); + + const Eq_Fn& + get_eq_fn() const; + + Probe_Fn& + get_probe_fn(); + + const Probe_Fn& + get_probe_fn() const; + + Comb_Probe_Fn& + get_comb_probe_fn(); + + const Comb_Probe_Fn& + get_comb_probe_fn() const; + + Resize_Policy& + get_resize_policy(); + + const Resize_Policy& + get_resize_policy() const; + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + + inline data_reference + subscript_imp(const_key_reference r_key); + + inline find_iterator + find(const_key_reference r_key); + + inline const_find_iterator + find(const_key_reference r_key) const; + + inline find_iterator + find_end(); + + inline const_find_iterator + find_end() const; + + inline size_type + erase(const_key_reference r_key, int_to_type<false>); + + inline size_type + erase(const_key_reference r_key, int_to_type<true>); + + template<class Pred> + inline size_type + erase_if(Pred prd); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + virtual void + assert_valid() const; + +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + + virtual void + do_resize(size_type new_size); + + private: + + typedef PB_ASSOC_TYPES_TRAITS_C_DEC my_traits_base; + + typedef PB_ASSOC_HASH_TYPES_TRAITS_C_DEC my_hash_traits_base; + + typedef PB_ASSOC_RANGED_PROBE_FN_C_DEC my_ranged_probe_fn_base; + +#ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + typedef PB_ASSOC_MAP_DEBUG_BASE_C_DEC my_map_debug_base; +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + + typedef PB_ASSOC_HASH_EQ_FN_C_DEC my_hash_eq_fn_base; + + typedef Resize_Policy my_resize_base; + + friend class iterator_; + + friend class const_iterator_; + + private: + + void + deallocate_all(); + + void + initialize(); + + inline void + constructor_insert_new_imp(const_reference r_val, size_type pos, int_to_type<true>); + + inline void + constructor_insert_new_imp(const_reference r_val, size_type pos, int_to_type<false>); + + void + erase_all_valid_entries(entry_array a_entries_resized, size_type size); + + inline bool + do_resize_if_needed(); + + inline void + do_resize_if_needed_no_throw(); + + void + resize_imp(entry_array a_entries_resized, size_type old_size); + + inline void + resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, int_to_type<false>); + + inline void + resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, int_to_type<true>); + + inline size_type + find_ins_pos(const_key_reference r_key, int_to_type<false>); + + inline comp_hash + find_ins_pos(const_key_reference r_key, int_to_type<true>); + + inline std::pair<find_iterator, bool> + insert_imp(const_reference r_val, int_to_type<false>); + + inline std::pair<find_iterator, bool> + insert_imp(const_reference r_val, int_to_type<true>); + + inline pointer + insert_new_imp(const_reference r_val, size_type pos); + + inline pointer + insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair); + + inline data_reference + subscript_imp(const_key_reference r_key, int_to_type<false>); + + inline data_reference + subscript_imp(const_key_reference r_key, int_to_type<true>); + + inline const_data_reference + const_subscript_imp(const_key_reference r_key) const; + + inline pointer + find_key_pointer(const_key_reference r_key, int_to_type<false>); + + inline pointer + find_key_pointer(const_key_reference r_key, int_to_type<true>); + + inline const_data_reference + const_subscript_imp(const_key_reference r_key, int_to_type<false>) const; + + inline const_data_reference + const_subscript_imp(const_key_reference r_key, int_to_type<true>) const; + + inline size_type + erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair); + + inline void + erase_entry(entry_pointer p_e); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + void + inc_it_state(pointer& r_p_value, size_type& r_pos) const; +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + void + inc_it_state(const_pointer& r_p_value, size_type& r_pos) const; + + void + get_start_it_state(const_pointer& r_p_value, size_type& r_pos) const; + + void + get_start_it_state(pointer& r_p_value, size_type& r_pos); + +#ifdef PB_ASSOC_CC_HT_MAP_DEBUG + + void + assert_entry_array_valid(const entry_array a_entries, int_to_type<false>) const; + + void + assert_entry_array_valid(const entry_array a_entries, int_to_type<true>) const; + +#endif // #ifdef PB_ASSOC_GP_HT_MAP_DEBUG_ + + private: + static entry_allocator s_entry_allocator; + + entry_pointer m_a_entries; + + size_type m_num_e; + + size_type m_num_used_e; + + static iterator s_end_it; + + static const_iterator s_const_end_it; + + enum + { + store_hash_ok = + !Store_Hash || + !pb_assoc::detail::is_same_type< + Hash_Fn, + pb_assoc::null_hash_fn>::value + }; + + PB_ASSOC_STATIC_ASSERT(sth, store_hash_ok); + }; + +#include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/resize_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/policy_access_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/iterator_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/insert_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_HASH_EQ_FN_C_DEC + +#undef PB_ASSOC_RANGED_PROBE_FN_C_DEC + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_HASH_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_MAP_DEBUG_BASE_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_V2S + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#undef PB_ASSOC_STATIC_ASSERT + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/info_fn_imps.hpp new file mode 100644 index 00000000000..9969d95eaaa --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/info_fn_imps.hpp @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains implementations of gp_ht_map_'s entire container info related + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (m_num_used_e); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (s_entry_allocator.max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_fn_imps.hpp new file mode 100644 index 00000000000..3e45b170519 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_fn_imps.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains implementations of gp_ht_map_'s insert related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_mapped_reference r_val) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (insert_imp(r_val, my_hash_traits_base::s_store_hash_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (subscript_imp(r_key, my_hash_traits_base::s_store_hash_indicator)); +} + +#include <ext/pb_assoc/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp> + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..b83d3cb2d16 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_no_store_hash_fn_imps.hpp @@ -0,0 +1,184 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 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_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +find_ins_pos(const_key_reference r_key, int_to_type<false>) +{ + size_type hash = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + /* The insertion position is initted to a non-legal value to indicate + * that it has not been initted yet. + */ + size_type ins_pos = m_num_e; + + my_resize_base::notify_insert_search_start(); + + for (i = 0; i < m_num_e; ++i) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, hash, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_insert_search_end(); + + PB_ASSOC_DBG_ONLY( + my_map_debug_base::check_key_does_not_exist(r_key);) + + return ((ins_pos == m_num_e)? pos : ins_pos); + } + break; + case ERASED_ENTRY_STATUS: + if (ins_pos == m_num_e) + ins_pos = pos; + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), r_key)) + { + my_resize_base::notify_insert_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (pos); + } + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_insert_search_collision(); + } + + my_resize_base::notify_insert_search_end(); + + if (ins_pos == m_num_e) + throw cannot_insert(); + + return (ins_pos); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key, int_to_type<false>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + const size_type pos = + find_ins_pos(r_key, my_hash_traits_base::s_store_hash_indicator); + + entry_pointer p_e =& m_a_entries[pos]; + + if (p_e->m_stat != VALID_ENTRY_STATUS) + return (insert_new_imp( + value_type(r_key, Data()), pos)->second); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (p_e->m_value.second); +} + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert_imp(const_reference r_val, int_to_type<false>) +{ + const_key_reference r_key = PB_ASSOC_V2F(r_val); + + const size_type pos = + find_ins_pos(r_key, my_hash_traits_base::s_store_hash_indicator); + + if (m_a_entries[pos].m_stat == VALID_ENTRY_STATUS) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (std::make_pair(&m_a_entries[pos].m_value, false)); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key)); + + return (std::make_pair( + insert_new_imp(r_val, pos), + true)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +insert_new_imp(const_reference r_val, size_type pos) +{ + PB_ASSOC_DBG_ASSERT(m_a_entries[pos].m_stat != VALID_ENTRY_STATUS); + + if (do_resize_if_needed()) + pos = find_ins_pos(PB_ASSOC_V2F(r_val), + my_hash_traits_base::s_store_hash_indicator); + + PB_ASSOC_DBG_ASSERT(m_a_entries[pos].m_stat != VALID_ENTRY_STATUS); + + entry* const p_e = m_a_entries + pos; + + new (&p_e->m_value) value_type(r_val); + + p_e->m_stat = VALID_ENTRY_STATUS; + + my_resize_base::notify_inserted(++m_num_used_e); + + PB_ASSOC_DBG_ONLY(my_map_debug_base:: + insert_new(p_e->m_value.first);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (static_cast<pointer>(&p_e->m_value)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..5584e4fed7b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/insert_store_hash_fn_imps.hpp @@ -0,0 +1,195 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s find related functions, when the hash + * value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::comp_hash +PB_ASSOC_CLASS_C_DEC:: +find_ins_pos(const_key_reference r_key, int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + comp_hash pos_hash_pair = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + /* The insertion position is initted to a non-legal value to indicate + * that it has not been initted yet. + */ + size_type ins_pos = m_num_e; + + my_resize_base::notify_insert_search_start(); + + for (i = 0; i < m_num_e; ++i) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); + + entry* const p_e = m_a_entries + pos; + + switch(p_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + { + my_resize_base::notify_insert_search_end(); + + PB_ASSOC_DBG_ONLY( + my_map_debug_base::check_key_does_not_exist(r_key);) + + return ((ins_pos == m_num_e)? + std::make_pair(pos, pos_hash_pair.second) : + std::make_pair(ins_pos, pos_hash_pair.second)); + } + break; + case ERASED_ENTRY_STATUS: + if (ins_pos == m_num_e) + ins_pos = pos; + break; + case VALID_ENTRY_STATUS: + if (my_hash_eq_fn_base::operator()( + PB_ASSOC_V2F(p_e->m_value), + p_e->m_hash, + r_key, + pos_hash_pair.second)) + { + my_resize_base::notify_insert_search_end(); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key);) + + return (std::make_pair(pos, pos_hash_pair.second)); + } + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + + my_resize_base::notify_insert_search_collision(); + } + + my_resize_base::notify_insert_search_end(); + + if (ins_pos == m_num_e) + throw cannot_insert(); + + return (std::make_pair(ins_pos, pos_hash_pair.second)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key, int_to_type<true>) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + comp_hash pos_hash_pair = + find_ins_pos(r_key, my_hash_traits_base::s_store_hash_indicator); + + if (m_a_entries[pos_hash_pair.first].m_stat != VALID_ENTRY_STATUS) + return (insert_new_imp( + value_type(r_key, Data()), pos_hash_pair)->second); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + return ((m_a_entries + pos_hash_pair.first)->m_value.second); +} + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert_imp(const_reference r_val, int_to_type<true>) +{ + const_key_reference r_key = PB_ASSOC_V2F(r_val); + + comp_hash pos_hash_pair = + find_ins_pos(r_key, my_hash_traits_base::s_store_hash_indicator); + + entry_pointer p_e =& m_a_entries[pos_hash_pair.first]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + return (std::make_pair(&p_e->m_value, false)); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key)); + + return (std::make_pair( + insert_new_imp(r_val, pos_hash_pair), + true)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::pointer +PB_ASSOC_CLASS_C_DEC:: +insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair) +{ + PB_ASSOC_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != + VALID_ENTRY_STATUS); + + if (do_resize_if_needed()) + r_pos_hash_pair = find_ins_pos( + PB_ASSOC_V2F(r_val), + my_hash_traits_base::s_store_hash_indicator); + + PB_ASSOC_DBG_ASSERT(m_a_entries[r_pos_hash_pair.first].m_stat != + VALID_ENTRY_STATUS); + + entry* const p_e = m_a_entries + r_pos_hash_pair.first; + + new (&p_e->m_value) value_type(r_val); + + p_e->m_hash = r_pos_hash_pair.second; + + p_e->m_stat = VALID_ENTRY_STATUS; + + my_resize_base::notify_inserted(++m_num_used_e); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(p_e->m_value.first);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (static_cast<pointer>(&p_e->m_value)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/iterator_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/iterator_fn_imps.hpp new file mode 100644 index 00000000000..8977b823ea3 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/iterator_fn_imps.hpp @@ -0,0 +1,181 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterator_fn_imps.hpp + * Contains implementations of gp_ht_map_'s iterators related functions, e.g., + * begin(). + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC::s_end_it; + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC::s_const_end_it; + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +begin() +{ + pointer p_value; + size_type pos; + + get_start_it_state(p_value, pos); + + return (iterator(p_value, pos, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +end() +{ + return (s_end_it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +begin() const +{ + const_pointer p_value; + size_type pos; + + get_start_it_state(p_value, pos); + + return (const_iterator(p_value, pos, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +end() const +{ + return (s_const_end_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +inc_it_state(pointer& r_p_value, size_type& r_pos) const +{ + PB_ASSOC_DBG_ASSERT(r_p_value != NULL); + + for (++r_pos; r_pos < m_num_e; ++r_pos) + { + const_entry_pointer p_e =& m_a_entries[r_pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + { + r_p_value = static_cast<const_pointer>(&p_e->m_value); + + return; + } + } + + r_p_value = NULL; +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +inc_it_state(const_pointer& r_p_value, size_type& r_pos) const +{ + PB_ASSOC_DBG_ASSERT(r_p_value != NULL); + + for (++r_pos; r_pos < m_num_e; ++r_pos) + { + const_entry_pointer p_e =& m_a_entries[r_pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + { + r_p_value = static_cast<const_pointer>(&p_e->m_value); + + return; + } + } + + r_p_value = NULL; +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +get_start_it_state(const_pointer& r_p_value, size_type& r_pos) const +{ + for (r_pos = 0; r_pos < m_num_e; ++r_pos) + { + const_entry_pointer p_e =& m_a_entries[r_pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + { + r_p_value =& p_e->m_value; + + return; + } + } + + r_p_value = NULL; +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +get_start_it_state(pointer& r_p_value, size_type& r_pos) +{ + for (r_pos = 0; r_pos < m_num_e; ++r_pos) + { + entry_pointer p_e =& m_a_entries[r_pos]; + + if (p_e->m_stat == VALID_ENTRY_STATUS) + { + r_p_value = const_cast<pointer>(&p_e->m_value); + + return; + } + } + + r_p_value = NULL; +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/policy_access_fn_imps.hpp new file mode 100644 index 00000000000..2ba6b237b18 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/policy_access_fn_imps.hpp @@ -0,0 +1,124 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 policy_access_fn_imps.hpp + * Contains implementations of gp_ht_map_'s policy agpess + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_hash_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Hash_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_hash_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Probe_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_probe_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Probe_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_probe_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Comb_Probe_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_comb_probe_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Comb_Probe_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_comb_probe_fn() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Resize_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_resize_policy() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Resize_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_resize_policy() const +{ + return (*this); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_fn_imps.hpp new file mode 100644 index 00000000000..d7c73ac91da --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_fn_imps.hpp @@ -0,0 +1,158 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_fn_imps.hpp + * Contains implementations of gp_ht_map_'s resize related functions. + */ + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +do_resize_if_needed() +{ + if (!my_resize_base::is_resize_needed()) + return (false); + + do + do_resize(my_resize_base::get_new_size(m_num_e, m_num_used_e)); + while (my_resize_base::is_resize_needed()); + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +do_resize_if_needed_no_throw() +{ + if (!my_resize_base::is_resize_needed()) + return; + + try + { + do + do_resize(my_resize_base::get_new_size(m_num_e, m_num_used_e)); + while (my_resize_base::is_resize_needed()); + } + catch(...) + { } + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +do_resize(size_type new_size) +{ +#ifdef PB_ASSOC_BASIC_REGRESSION + throw_prob_adjustor adjust(m_num_e); +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION + + PB_ASSOC_DBG_ONLY(assert_valid();) + + const size_type old_size = m_num_e; + + entry_array a_entries_resized = NULL; + + my_ranged_probe_fn_base::notify_resized(new_size); + + // Following line might throw an exception. + + try + { + a_entries_resized = s_entry_allocator.allocate(new_size); + } + catch(...) + { + my_ranged_probe_fn_base::notify_resized(old_size); + + throw; + } + + m_num_e = new_size; + + for (size_type i = 0; i < m_num_e; ++i) + a_entries_resized[i].m_stat = (entry_status)EMPTY_ENTRY_STATUS; + + try + { + resize_imp(a_entries_resized, old_size); + } + catch(...) + { + erase_all_valid_entries(a_entries_resized, new_size); + + m_num_e = old_size; + + s_entry_allocator.deallocate(a_entries_resized, new_size); + + my_ranged_probe_fn_base::notify_resized(old_size); + + throw; + } + + // At this point no exceptions can be thrown. + + PB_ASSOC_DBG_ONLY(assert_entry_array_valid(a_entries_resized, my_hash_traits_base::s_store_hash_indicator);) + + Resize_Policy::notify_resized(new_size); + + erase_all_valid_entries(m_a_entries, old_size); + + s_entry_allocator.deallocate(m_a_entries, old_size); + + m_a_entries = a_entries_resized; + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +resize_imp(entry_array a_entries_resized, size_type old_size) +{ + for (size_type pos = 0; pos < old_size; ++pos) + if (m_a_entries[pos].m_stat == VALID_ENTRY_STATUS) + resize_imp_reassign(m_a_entries + pos, a_entries_resized, my_hash_traits_base::s_store_hash_indicator); +} + +#include <ext/pb_assoc/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp> +#include <ext/pb_assoc/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp> diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..07f8f2abaee --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp @@ -0,0 +1,84 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_no_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s resize related functions, when the + * hash value is not stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, int_to_type<false>) +{ + const_key_reference r_key = PB_ASSOC_V2F(p_e->m_value); + + size_type hash = my_ranged_probe_fn_base::operator()(r_key); + + size_type i; + + for (i = 0; i < m_num_e; ++i) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, hash, i); + + entry* const p_new_e = a_entries_resized + pos; + + switch(p_new_e->m_stat) + { + case EMPTY_ENTRY_STATUS: + new (&p_new_e->m_value) value_type(p_e->m_value); + + p_new_e->m_stat = VALID_ENTRY_STATUS; + + return; + case ERASED_ENTRY_STATUS: + PB_ASSOC_DBG_ASSERT(0); + break; + case VALID_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + } + + throw cannot_insert(); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp new file mode 100644 index 00000000000..a61ac7a12ce --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp @@ -0,0 +1,93 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 resize_store_hash_fn_imps.hpp + * Contains implementations of gp_ht_map_'s resize related functions, when the + * hash value is stored. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, int_to_type<true>) +{ + const_key_reference r_key = PB_ASSOC_V2F(p_e->m_value); + + size_type hash = + my_ranged_probe_fn_base::operator()(r_key, p_e->m_hash); + + size_type i; + + for (i = 0; i < m_num_e; ++i) + { + const size_type pos = + my_ranged_probe_fn_base::operator()(r_key, hash, i); + + entry* const p_new_e = a_entries_resized + pos; + + switch(p_new_e->m_stat) + { + case EMPTY_ENTRY_STATUS: +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + new (&p_new_e->m_value) mapped_value_type(p_e->m_value); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR + new (&p_new_e->m_value) Key(p_e->m_value); +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATO + + p_new_e->m_hash = hash; + + p_new_e->m_stat = VALID_ENTRY_STATUS; + + return; + case ERASED_ENTRY_STATUS: + PB_ASSOC_DBG_ASSERT(0); + break; + case VALID_ENTRY_STATUS: + break; + default: + PB_ASSOC_DBG_ASSERT(0); + }; + } + + throw cannot_insert(); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mask_range_hashing_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mask_range_hashing_imp.hpp new file mode 100644 index 00000000000..da44db8f4f4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mask_range_hashing_imp.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 direct_mask_range_hashing_imp.hpp + * Contains an implementation of direct_mask_range_hashing. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_mask_based_base::swap(r_other); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_resized(size_type size) +{ + my_mask_based_base::notify_resized(size); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(size_type hash) const +{ + return (my_mask_based_base::range_hash(hash)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mod_range_hashing_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mod_range_hashing_imp.hpp new file mode 100644 index 00000000000..d38f4bb5391 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/direct_mod_range_hashing_imp.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 direct_mod_range_hashing_imp.hpp + * Contains an implementation of direct_mod_range_hashing. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_mod_based_base::swap(r_other); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_resized(size_type size) +{ + my_mod_based_base::notify_resized(size); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(size_type hash) const +{ + return (my_mod_based_base::range_hash(hash)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/linear_probe_fn_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/linear_probe_fn_imp.hpp new file mode 100644 index 00000000000..8e23a821643 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/linear_probe_fn_imp.hpp @@ -0,0 +1,58 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 linear_probe_fn_imp.hpp + * Contains an implementation of linear_probe_fn + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ } + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(Const_Key_Ref /*r_key*/, size_type i) const +{ + return (i); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mask_based_range_hashing.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mask_based_range_hashing.hpp new file mode 100644 index 00000000000..1a731ed298d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mask_based_range_hashing.hpp @@ -0,0 +1,139 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 mask_based_range_hashing.hpp + * Contains a range hashing policy base. + */ + +#ifndef MASK_BASED_RANGE_HASHING_HPP +#define MASK_BASED_RANGE_HASHING_HPP + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + mask_based_range_hashing< \ + Size_Type> + + template<typename Size_Type> + class mask_based_range_hashing + { + protected: + typedef Size_Type size_type; + + protected: + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline size_type + range_hash(size_type hash) const; + + private: + size_type m_mask; + + const static size_type s_num_bits_in_size_type; + + const static size_type s_highest_bit_1; + }; + + PB_ASSOC_CLASS_T_DEC + const typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC::s_num_bits_in_size_type = + sizeof(typename PB_ASSOC_CLASS_C_DEC::size_type) << 3; + + PB_ASSOC_CLASS_T_DEC + const typename PB_ASSOC_CLASS_C_DEC::size_type PB_ASSOC_CLASS_C_DEC::s_highest_bit_1 = + 1 << (s_num_bits_in_size_type - 1); + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + std::swap(m_mask, r_other.m_mask); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + size_type i = 0; + + while (size ^ s_highest_bit_1) + { + size <<= 1; + + ++i; + } + + m_mask = 1; + + i += 2; + + while (i++ < s_num_bits_in_size_type) + m_mask = (m_mask << 1) ^ 1; + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + range_hash(size_type hash) const + { + return (hash& m_mask); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef MASK_BASED_RANGE_HASHING_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mod_based_range_hashing.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mod_based_range_hashing.hpp new file mode 100644 index 00000000000..6f9e8777b25 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/mod_based_range_hashing.hpp @@ -0,0 +1,112 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 mod_based_range_hashing.hpp + * Contains a range hashing policy base. + */ + +#ifndef MOD_BASED_RANGE_HASHING_HPP +#define MOD_BASED_RANGE_HASHING_HPP + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + mod_based_range_hashing< \ + Size_Type> + + template<typename Size_Type> + class mod_based_range_hashing + { + protected: + typedef Size_Type size_type; + + protected: + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline size_type + range_hash(size_type hash) const; + + private: + size_type m_size; + }; + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + std::swap(m_size, r_other.m_size); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + m_size = size; + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + range_hash(size_type hash) const + { + return (hash % m_size); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef MOD_BASED_RANGE_HASHING_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/probe_fn_base.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/probe_fn_base.hpp new file mode 100644 index 00000000000..4d5d5e9a35f --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/probe_fn_base.hpp @@ -0,0 +1,96 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 probe_fn_base.hpp + * Contains a probe policy base. + */ + +#ifndef PROBE_FN_BASE_HPP +#define PROBE_FN_BASE_HPP + +#include <functional> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PROBE_FN_BASE_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PROBE_FN_BASE_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PROBE_FN_BASE_DEBUG + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + probe_fn_base< \ + Allocator> + + template<class Allocator> + class probe_fn_base + { + protected: + ~probe_fn_base(); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ~probe_fn_base() + { } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef PROBE_FN_BASE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/quadratic_probe_fn_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/quadratic_probe_fn_imp.hpp new file mode 100644 index 00000000000..bc630755d4c --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/quadratic_probe_fn_imp.hpp @@ -0,0 +1,57 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 quadratic_probe_fn_imp.hpp + * Contains an implementation of quadratic_probe_fn. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ } + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(Const_Key_Ref /*r_key*/, size_type i) const +{ + return (i* i); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_hash_fn.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_hash_fn.hpp new file mode 100644 index 00000000000..efa5a5819c7 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_hash_fn.hpp @@ -0,0 +1,459 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ranged_hash_fn.hpp + * Contains a unified ranged hash functor, allowing the hash tables to deal with + * a single class for ranged hashing. + */ + +#ifndef RANGED_HASH_FN_HPP +#define RANGED_HASH_FN_HPP + +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG + + template<typename Key, + class Hash_Fn, + class Allocator, + class Comb_Hash_Fn, + bool Store_Hash> + class ranged_hash_fn; + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + class Hash_Fn, \ + class Allocator, \ + class Comb_Hash_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_hash_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + 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, + class Hash_Fn, + class Allocator, + class Comb_Hash_Fn> + class ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, false> : public Hash_Fn, + public Comb_Hash_Fn + { + protected: + typedef typename Allocator::size_type size_type; + + typedef Hash_Fn my_hash_fn_base; + + typedef Comb_Hash_Fn my_comb_hash_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + ranged_hash_fn(size_type size); + + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn); + + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline size_type + operator()(const_key_reference r_key) const; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : + Hash_Fn(r_hash_fn) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + Hash_Fn(r_hash_fn), + Comb_Hash_Fn(r_comb_hash_fn) + { + my_comb_hash_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_hash_fn_base::swap(r_other); + + std::swap((Hash_Fn& )(*this), (Hash_Fn& )r_other); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + my_comb_hash_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key) const + { + return (my_comb_hash_fn_base::operator()( + my_hash_fn_base::operator()(r_key))); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + class Hash_Fn, \ + class Allocator, \ + class Comb_Hash_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_hash_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + 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, + class Hash_Fn, + class Allocator, + class Comb_Hash_Fn> + class ranged_hash_fn<Key, Hash_Fn, Allocator, Comb_Hash_Fn, true> : + public Hash_Fn, + public Comb_Hash_Fn + { + protected: + typedef typename Allocator::size_type size_type; + + typedef std::pair<size_type, size_type> comp_hash; + + typedef Hash_Fn my_hash_fn_base; + + typedef Comb_Hash_Fn my_comb_hash_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + ranged_hash_fn(size_type size); + + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn); + + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline comp_hash + operator()(const_key_reference r_key) const; + + inline comp_hash + operator()(const_key_reference r_key, size_type hash) const; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : + Hash_Fn(r_hash_fn) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + Hash_Fn(r_hash_fn), + Comb_Hash_Fn(r_comb_hash_fn) + { + my_comb_hash_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_hash_fn_base::swap(r_other); + + std::swap((Hash_Fn& )(*this), (Hash_Fn& )r_other); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + my_comb_hash_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::comp_hash + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key) const + { + const size_type hash = my_hash_fn_base::operator()(r_key); + + return (std::make_pair(my_comb_hash_fn_base::operator()(hash), hash)); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::comp_hash + PB_ASSOC_CLASS_C_DEC:: + operator() +#ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG + (const_key_reference r_key, size_type hash) const +#else // #ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG + (const_key_reference /*r_key*/, size_type hash) const +#endif // #ifdef PB_ASSOC_RANGED_HASH_FN_DEBUG + { + PB_ASSOC_DBG_ASSERT(hash == my_hash_fn_base::operator()(r_key)); + + return (std::make_pair(my_comb_hash_fn_base::operator()(hash), hash)); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Allocator, class Comb_Hash_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_hash_fn< \ + Key, \ + null_hash_fn, \ + Allocator, \ + 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 values not be stored. + + **/ + template<typename Key, class Allocator, class Comb_Hash_Fn> + class ranged_hash_fn<Key, null_hash_fn, Allocator, + Comb_Hash_Fn, false> : + public null_hash_fn, + public Comb_Hash_Fn + { + protected: + + typedef typename Allocator::size_type size_type; + + typedef Comb_Hash_Fn my_comb_hash_fn_base; + + protected: + ranged_hash_fn(size_type size); + + ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn); + + ranged_hash_fn(size_type size, const null_hash_fn&r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) : + Comb_Hash_Fn(r_comb_hash_fn) + { } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + Comb_Hash_Fn(r_comb_hash_fn) + { } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_hash_fn_base::swap(r_other); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Allocator, class Comb_Hash_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_hash_fn< \ + Key, \ + null_hash_fn, \ + Allocator, \ + 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 values be stored. + + **/ + template<typename Key, class Allocator, class Comb_Hash_Fn> + class ranged_hash_fn<Key, null_hash_fn, Allocator, + Comb_Hash_Fn, true> : + public null_hash_fn, + public Comb_Hash_Fn + { + protected: + typedef typename Allocator::size_type size_type; + + typedef Comb_Hash_Fn my_comb_hash_fn_base; + + protected: + ranged_hash_fn(size_type size); + + ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn); + + ranged_hash_fn(size_type size, const null_hash_fn&r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size) + { + Comb_Hash_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) : + Comb_Hash_Fn(r_comb_hash_fn) + { } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_hash_fn(size_type size, const null_hash_fn&r_null_hash_fn, const Comb_Hash_Fn& r_comb_hash_fn) : + Comb_Hash_Fn(r_comb_hash_fn) + { } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_hash_fn_base::swap(r_other); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef RANGED_HASH_FN_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_probe_fn.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_probe_fn.hpp new file mode 100644 index 00000000000..60d6acabf16 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_fn/ranged_probe_fn.hpp @@ -0,0 +1,473 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ranged_probe_fn.hpp + * Contains a unified ranged probe functor, allowing the probe tables to deal with + * a single class for ranged probeing. + */ + +#ifndef RANGED_PROBE_FN_HPP +#define RANGED_PROBE_FN_HPP + +#include <ext/pb_assoc/hash_policy.hpp> +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG + + template<typename Key, + class Hash_Fn, + class Allocator, + class Comb_Probe_Fn, + class Probe_Fn, + bool Store_Hash> + class ranged_probe_fn; + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + class Hash_Fn, \ + class Allocator, \ + class Comb_Probe_Fn, \ + class Probe_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_probe_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + 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, + class Hash_Fn, + class Allocator, + class Comb_Probe_Fn, + class Probe_Fn> + class ranged_probe_fn< + Key, + Hash_Fn, + Allocator, + 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 Comb_Probe_Fn my_comb_probe_fn_base; + + typedef Hash_Fn my_hash_fn_base; + + typedef Probe_Fn my_probe_fn_base; + + typedef typename Allocator::template rebind< Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + ranged_probe_fn(size_type size); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline size_type + operator()(const_key_reference r_key) const; + + inline size_type + operator()(const_key_reference r_key, size_type hash, size_type i) const; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size) + { + Comb_Probe_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) : + Hash_Fn(r_hash_fn) + { + Comb_Probe_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn) : + Hash_Fn(r_hash_fn), + Comb_Probe_Fn(r_comb_probe_fn) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn) : + Hash_Fn(r_hash_fn), + Comb_Probe_Fn(r_comb_probe_fn), + Probe_Fn(r_probe_fn) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_probe_fn_base::swap(r_other); + + std::swap((Hash_Fn& )(*this), (Hash_Fn& )r_other); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key) const + { + return (my_comb_probe_fn_base::operator()( + my_hash_fn_base::operator()(r_key))); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key, size_type hash, size_type i) const + { + return (my_comb_probe_fn_base::operator()( + hash + my_probe_fn_base::operator()(r_key, i))); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + class Hash_Fn, \ + class Allocator, \ + class Comb_Probe_Fn, \ + class Probe_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_probe_fn< \ + Key, \ + Hash_Fn, \ + Allocator, \ + Comb_Probe_Fn, \ + Probe_Fn, \ + true> + + /** + * Specialization 2- The client supplies a probe function and a ranged + * probe function, and requests that hash values be stored. + **/ + template<typename Key, + class Hash_Fn, + class Allocator, + class Comb_Probe_Fn, + class Probe_Fn> + class ranged_probe_fn< + Key, + Hash_Fn, + Allocator, + 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 std::pair<size_type, size_type> comp_hash; + + typedef Comb_Probe_Fn my_comb_probe_fn_base; + + typedef Hash_Fn my_hash_fn_base; + + typedef Probe_Fn my_probe_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + ranged_probe_fn(size_type size); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn); + + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + void + notify_resized(size_type size); + + inline comp_hash + operator()(const_key_reference r_key) const; + + inline size_type + operator()(const_key_reference r_key, size_type hash, size_type i) const; + + inline size_type + operator()(const_key_reference r_key, size_type hash) const; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size) + { + Comb_Probe_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) : + Hash_Fn(r_hash_fn) + { + Comb_Probe_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn) : + Hash_Fn(r_hash_fn), + Comb_Probe_Fn(r_comb_probe_fn) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const Probe_Fn& r_probe_fn) : + Hash_Fn(r_hash_fn), + Comb_Probe_Fn(r_comb_probe_fn), + Probe_Fn(r_probe_fn) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_probe_fn_base::swap(r_other); + + std::swap((Hash_Fn& )(*this), (Hash_Fn& )r_other); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + notify_resized(size_type size) + { + my_comb_probe_fn_base::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::comp_hash + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key) const + { + const size_type hash = my_hash_fn_base::operator()(r_key); + + return (std::make_pair(my_comb_probe_fn_base::operator()(hash), hash)); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + operator()(const_key_reference r_key, size_type hash, size_type i) const + { + return (my_comb_probe_fn_base::operator()( + hash + my_probe_fn_base::operator()(r_key, i))); + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + operator() +#ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG + (const_key_reference r_key, size_type hash) const +#else // #ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG + (const_key_reference /*r_key*/, size_type hash) const +#endif // #ifdef PB_ASSOC_RANGED_PROBE_FN_DEBUG + { + PB_ASSOC_DBG_ASSERT(hash == my_hash_fn_base::operator()(r_key)); + + return (hash); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Allocator, class Comb_Probe_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + ranged_probe_fn< \ + Key, \ + null_hash_fn, \ + Allocator, \ + Comb_Probe_Fn, \ + null_probe_fn, \ + false> + + /** + * Specialization 3 and 4- The client does not supply a hash function or + * probe function, and requests that hash values not be stored. + **/ + template<typename Key, class Allocator, class 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 + { + protected: + typedef typename Allocator::size_type size_type; + + typedef Comb_Probe_Fn my_comb_probe_fn_base; + + typedef typename Allocator::template rebind<Key>::other key_allocator; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + ranged_probe_fn(size_type size); + + ranged_probe_fn(size_type size, const Comb_Probe_Fn& r_comb_probe_fn); + + ranged_probe_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const null_probe_fn& r_null_probe_fn); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size) + { + Comb_Probe_Fn::notify_resized(size); + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const Comb_Probe_Fn& r_comb_probe_fn) : + Comb_Probe_Fn(r_comb_probe_fn) + { } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ranged_probe_fn(size_type size, const null_hash_fn& r_null_hash_fn, const Comb_Probe_Fn& r_comb_probe_fn, const null_probe_fn& r_null_probe_fn) : + Comb_Probe_Fn(r_comb_probe_fn) + { } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + my_comb_probe_fn_base::swap(r_other); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef RANGED_PROBE_FN_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/hash_types_traits.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/hash_types_traits.hpp new file mode 100644 index 00000000000..0caf6226431 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/hash_types_traits.hpp @@ -0,0 +1,94 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 types_traits.hpp + * Contains a traits class of types used by containers. + */ + +#ifndef HASH_TYPES_TRAITS +#define HASH_TYPES_TRAITS + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type, bool Store_Hash> + +#define PB_ASSOC_CLASS_C_DEC \ + hash_types_traits< \ + Size_Type, \ + Store_Hash> + + template<typename Size_Type, bool Store_Hash> + struct hash_types_traits + { + public: + typedef + typename cond_type< + Store_Hash, + std::pair<Size_Type, Size_Type>, + Size_Type>::type + comp_hash; + + typedef int_to_type<false> store_hash_false_indicator; + + typedef int_to_type<true> store_hash_true_indicator; + + static pb_assoc::detail::int_to_type<Store_Hash> + s_store_hash_indicator; + }; + + PB_ASSOC_CLASS_T_DEC + pb_assoc::detail::int_to_type<Store_Hash> + PB_ASSOC_CLASS_C_DEC::s_store_hash_indicator; + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef HASH_TYPES_TRAITS diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..03eae597470 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,121 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of lu's constructors, destructor, + * and related functions. + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(const Eq_Fn& r_eq_fn) : + my_base(r_eq_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(const Eq_Fn& r_eq_fn, const Update_Policy& r_update_policy) : + my_base(r_eq_fn, r_update_policy) +{ } + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(It first_it, It last_it) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(It first_it, It last_it, const Eq_Fn& r_eq_fn) : + my_base(r_eq_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(It first_it, It last_it, const Eq_Fn& r_eq_fn, const Update_Policy& r_update_policy) : + my_base(r_eq_fn, r_update_policy) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +lu_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other) : + my_base((const my_base& )(r_other)) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~lu_assoc_cntnr() +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC& +PB_ASSOC_CLASS_C_DEC:: +operator=(const PB_ASSOC_CLASS_C_DEC& r_other) +{ + if (this !=& r_other) + { + PB_ASSOC_CLASS_C_DEC tmp(r_other); + + swap(tmp); + } + + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_base::swap(r_other); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp new file mode 100644 index 00000000000..0c2035e35e8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_assoc_cntnr/policy_access_fn_imps.hpp @@ -0,0 +1,77 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 policy_access_fn_imps.hpp + * Contains implementations of lu_map_'s policy access + * functions. + */ + +PB_ASSOC_CLASS_T_DEC +Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() +{ + return (my_base::get_eq_fn()); +} + +PB_ASSOC_CLASS_T_DEC +const Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() const +{ + return (my_base::get_eq_fn()); +} + +PB_ASSOC_CLASS_T_DEC +Update_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_update_policy() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Update_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_update_policy() const +{ + return (*this); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..ed75adaa3ec --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/constructor_destructor_fn_imps.hpp @@ -0,0 +1,178 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementations of PB_ASSOC_CLASS_NAME. + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::entry_allocator +PB_ASSOC_CLASS_C_DEC::s_entry_allocator; + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + while (first_it != last_it) + insert(*(first_it++)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() : + m_p_l(s_entry_allocator.allocate(1)), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Eq_Fn& r_eq_fn) : + Eq_Fn(r_eq_fn), + m_p_l(s_entry_allocator.allocate(1)), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Eq_Fn& r_eq_fn, const Update_Policy& r_update_policy) : + Eq_Fn(r_eq_fn), + Update_Policy(r_update_policy), + m_p_l(s_entry_allocator.allocate(1)), + m_size(0) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + Eq_Fn(r_other), + Update_Policy(r_other), + m_p_l(s_entry_allocator.allocate(1)), + m_size(0) +{ + initialize(); + + try + { + copy_from_range(r_other.begin(), r_other.end()); + } + catch(...) + { + deallocate_all(true); + + throw; + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + std::swap(m_p_l, r_other.m_p_l); + + std::swap(m_size, r_other.m_size); + + std::swap((Eq_Fn& )(*this), (Eq_Fn& )r_other); + + Update_Policy::swap(r_other); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::swap(r_other);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +deallocate_all(bool deallocate_root) +{ + entry_pointer p_l = m_p_l->m_p_next; + + while (p_l != NULL) + { + entry_pointer p_next_l = p_l->m_p_next; + + p_l->~entry(); + + s_entry_allocator.deallocate(p_l, 1); + + p_l = p_next_l; + } + + if (deallocate_root) + s_entry_allocator.deallocate(m_p_l, 1); + else + m_p_l->m_p_next = NULL; +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_CLASS_NAME() +{ + deallocate_all(true); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize() +{ + m_p_l->m_p_next = NULL; +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/debug_fn_imps.hpp new file mode 100644 index 00000000000..23b893de8c1 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/debug_fn_imps.hpp @@ -0,0 +1,66 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains implementations of cc_ht_map_'s debug-mode functions. + */ + +#ifdef PB_ASSOC_LU_MAP_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + size_type calc_size = 0; + + for (const_iterator it = begin(); it != end(); ++it) + { + my_map_debug_base::check_key_exists(PB_ASSOC_V2F(*it)); + + ++calc_size; + } + + PB_ASSOC_DBG_ASSERT(calc_size == m_size); + + my_map_debug_base::check_size(m_size); +} + +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/erase_fn_imps.hpp new file mode 100644 index 00000000000..f4fc90b75f0 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/erase_fn_imps.hpp @@ -0,0 +1,129 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + entry_pointer p_l = find_imp(r_key); + + if (p_l->m_p_next == NULL) + return (0); + + erase_imp(p_l); + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (1); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();) + + deallocate_all(false); + + m_size = 0; + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred& r_pred) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + size_type num_ersd = 0; + + entry_pointer p_l = m_p_l; + + while (p_l->m_p_next != NULL) + { + if (r_pred(p_l->m_p_next->m_value)) + { + erase_imp(p_l); + + ++num_ersd; + } + else + p_l = p_l->m_p_next; + } + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (num_ersd); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +erase_imp(entry_pointer p_l) +{ + PB_ASSOC_DBG_ASSERT(p_l->m_p_next != NULL); + + entry_pointer p_next_l = p_l->m_p_next->m_p_next; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::erase_existing( + PB_ASSOC_V2F(p_l->m_p_next->m_value));) + + p_l->m_p_next->m_value.~mapped_value_type(); + + s_entry_allocator.deallocate(p_l->m_p_next, 1); + + p_l->m_p_next = p_next_l; + + PB_ASSOC_DBG_ASSERT(m_size > 0); + --m_size; +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/find_fn_imps.hpp new file mode 100644 index 00000000000..af6901340b5 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/find_fn_imps.hpp @@ -0,0 +1,136 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() +{ + return (NULL); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find_end() const +{ + return (NULL); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +move_next_to_front(entry_pointer p_l) const +{ + entry_pointer p_move_l = p_l->m_p_next; + + PB_ASSOC_DBG_ASSERT(p_move_l != NULL); + + p_l->m_p_next = p_move_l->m_p_next; + + p_move_l->m_p_next = m_p_l->m_p_next; + + m_p_l->m_p_next = p_move_l; +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_data_reference +PB_ASSOC_CLASS_C_DEC:: +const_subscript_imp(const_key_reference r_key) const +{ + entry_pointer p_l = find_imp(r_key); + + PB_ASSOC_DBG_ASSERT(p_l->m_p_next != NULL) + + if (Update_Policy::operator()(p_l->m_update_metadata)) + { + move_next_to_front(p_l); + + return (m_p_l->m_p_next->m_value.second); + } + else + return (p_l->m_p_next->m_value.second); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC::find(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_l = find_imp(r_key); + + if (p_l->m_p_next != NULL) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (&p_l->m_p_next->m_value); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (find_end()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC::find(const_key_reference r_key) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_l = find_imp(r_key); + + if (p_l->m_p_next != NULL) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (&m_p_l->m_p_next->m_value); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (find_end()); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/info_fn_imps.hpp new file mode 100644 index 00000000000..761e2cbb258 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/info_fn_imps.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (m_size); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (s_entry_allocator.max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (m_size == 0); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/insert_fn_imps.hpp new file mode 100644 index 00000000000..7ead8cb16f4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/insert_fn_imps.hpp @@ -0,0 +1,148 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair< + typename PB_ASSOC_CLASS_C_DEC::find_iterator, + bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_reference r_val) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_l = find_imp(PB_ASSOC_V2F(r_val)); + + bool found = true; + + if (p_l->m_p_next == NULL) + { + found = false; + + insert_new_after(p_l, r_val); + } + + PB_ASSOC_DBG_ASSERT(Eq_Fn::operator()( + PB_ASSOC_V2F(p_l->m_p_next->m_value), + PB_ASSOC_V2F(r_val))); + + PB_ASSOC_DBG_ONLY(assert_valid();) + + if (Update_Policy::operator()(p_l->m_update_metadata)) + { + move_next_to_front(p_l); + + return (std::make_pair( + find_iterator(&m_p_l->m_p_next->m_value), + !found)); + } + else + return (std::make_pair( + find_iterator(&p_l->m_p_next->m_value), + !found)); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +insert_new_after(entry_pointer p_l, const_reference r_val) +{ + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + PB_ASSOC_V2F(r_val));) + + entry_pointer p_new_l = s_entry_allocator.allocate(1); + + cond_dealtor_t cond(p_new_l); + + new (const_cast<void* >( + static_cast<const void* >(&p_new_l->m_value))) + value_type(r_val); + + cond.set_no_action(); + + PB_ASSOC_DBG_ASSERT(p_l->m_p_next == NULL); + p_l->m_p_next = p_new_l; + + p_new_l->m_p_next = NULL; + + ++m_size; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new(PB_ASSOC_V2F(r_val));) + } + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + entry_pointer p_l = find_imp(r_key); + + bool found = true; + + if (p_l->m_p_next == NULL) + { + found = false; + + insert_new_after(p_l, value_type(r_key, data_type())); + } + + PB_ASSOC_DBG_ASSERT(Eq_Fn::operator()( + PB_ASSOC_V2F(p_l->m_p_next->m_value), + PB_ASSOC_V2F(r_val))); + + PB_ASSOC_DBG_ONLY(assert_valid();) + + if (Update_Policy::operator()(p_l->m_update_metadata)) + { + move_next_to_front(p_l); + + return (m_p_l->m_p_next->m_value.second); + } + else + return (p_l->m_p_next->m_value.second); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/iterators_fn_imps.hpp new file mode 100644 index 00000000000..a3be722020a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/iterators_fn_imps.hpp @@ -0,0 +1,106 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterators_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +begin() +{ + if (m_size == 0) + { + PB_ASSOC_DBG_ASSERT(m_p_l->m_p_next == NULL); + + return (end()); + } + + PB_ASSOC_DBG_ASSERT(m_p_l->m_p_next != NULL); + + return (iterator(&m_p_l->m_p_next->m_value, m_p_l->m_p_next, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +begin() const +{ + if (m_size == 0) + { + PB_ASSOC_DBG_ASSERT(m_p_l->m_p_next == NULL); + + return (end()); + } + + PB_ASSOC_DBG_ASSERT(m_p_l->m_p_next != NULL); + + return (iterator(&m_p_l->m_p_next->m_value, m_p_l->m_p_next, + const_cast<PB_ASSOC_CLASS_C_DEC* >(this))); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +end() +{ + return (iterator(NULL, NULL, this)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +end() const +{ + return (const_iterator(NULL, NULL, + const_cast<PB_ASSOC_CLASS_C_DEC* const>(this))); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +inc_it_state(const_mapped_pointer& r_p_value, entry_pointer& r_pos) const +{ + r_pos = r_pos->m_p_next; + + r_p_value = (r_pos == NULL)? NULL :& r_pos->m_value; +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/lu_map_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/lu_map_.hpp new file mode 100644 index 00000000000..21316e72a27 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/lu_map_.hpp @@ -0,0 +1,464 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_map_.hpp + * Contains a list update map. + */ + +#include <utility> +#include <iterator> +#include <ext/pb_assoc/detail/cond_dealtor.hpp> +#include <ext/pb_assoc/trivial_iterator_def.hpp> +#include <ext/pb_assoc/detail/types_traits.hpp> +#include <ext/pb_assoc/exception.hpp> +#include <ext/pb_assoc/detail/map_debug_base.hpp> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_LU_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_LU_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Eq_Fn, \ + class Allocator, \ + class Update_Policy> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + lu_map_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + lu_map_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Eq_Fn, \ + Allocator, \ + Update_Policy> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + pb_assoc::detail::types_traits< \ + Key, \ + Data, \ + Allocator> + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE +#define PB_ASSOC_MAP_DEBUG_BASE_C_DEC \ + pb_assoc::detail::map_debug_base< \ + Key, \ + Eq_Fn> +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#define PB_ASSOC_EP2VP(X)& ((X)->m_value) +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Data() +#define PB_ASSOC_EP2VP(X)& ((X)->m_value.first) +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#ifdef PB_ASSOC_LU_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_LU_MAP_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ + + /* Skip to the lu, my darling. */ + + template<typename Key, + typename Data, + class Eq_Fn, + class Allocator, + class Update_Policy> + class PB_ASSOC_CLASS_NAME : +#ifdef PB_ASSOC_LU_MAP_DEBUG_ + protected PB_ASSOC_MAP_DEBUG_BASE_C_DEC, +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ + public Eq_Fn, + public Update_Policy, + public PB_ASSOC_TYPES_TRAITS_C_DEC + { + + protected: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + typedef Update_Policy update_policy; + + typedef typename Update_Policy::metadata_type update_metadata; + + struct entry + { + typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type m_value; + + update_metadata m_update_metadata; + + typename Allocator::template rebind<entry>::other::pointer m_p_next; + }; + + typedef + typename Allocator::template rebind<entry>::other + entry_allocator; + + typedef typename entry_allocator::pointer entry_pointer; + + typedef typename entry_allocator::const_pointer const_entry_pointer; + + typedef typename entry_allocator::reference entry_reference; + + typedef + typename entry_allocator::const_reference + const_entry_reference; + + typedef + typename Allocator::template rebind<entry_pointer>::other + entry_pointer_allocator; + + typedef typename entry_pointer_allocator::pointer entry_pointer_array; + +#define PB_ASSOC_GEN_POS entry_pointer + + typedef value_type mapped_value_type; + + typedef pointer mapped_pointer; + + typedef const_pointer const_mapped_pointer; + + typedef reference mapped_reference; + + typedef const_reference const_mapped_reference; + +#include <ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp> +#include <ext/pb_assoc/detail/unordered_iterator/iterator.hpp> + +#undef PB_ASSOC_GEN_POS + + typedef find_iterator_ find_iterator; + + typedef const_find_iterator_ const_find_iterator; + + typedef iterator_ iterator; + + typedef const_iterator_ const_iterator; + + typedef Eq_Fn eq_fn; + + typedef Allocator allocator; + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const Eq_Fn& r_eq_fn); + + PB_ASSOC_CLASS_NAME(const Eq_Fn& r_eq_fn, const Update_Policy& r_update_policy); + + PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~PB_ASSOC_CLASS_NAME(); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + inline size_type + size() const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + Eq_Fn& + get_eq_fn(); + + const Eq_Fn& + get_eq_fn() const; + + inline std::pair<find_iterator, bool> + insert(const_reference r_val); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline data_reference + subscript_imp(const_key_reference r_key); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + inline find_iterator + find(const_key_reference r_key); + + inline const_find_iterator + find(const_key_reference r_key) const; + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline const_data_reference + const_subscript_imp(const_key_reference r_key) const; +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + inline size_type + erase(const_key_reference r_key); + + template<class Pred> + inline size_type + erase_if(Pred& r_pred); + + void + clear(); + + inline iterator + begin(); + + inline const_iterator + begin() const; + + inline iterator + end(); + + inline const_iterator + end() const; + +#ifdef PB_ASSOC_LU_MAP_DEBUG_ + + virtual void + assert_valid() const; + +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ + + private: + + typedef PB_ASSOC_TYPES_TRAITS_C_DEC my_traits_base; + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + typedef PB_ASSOC_MAP_DEBUG_BASE_C_DEC my_map_debug_base; +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + + typedef + pb_assoc::detail::cond_dealtor< + entry, + Allocator> + cond_dealtor_t; + + private: + + void + deallocate_all(bool deallocate_root); + + inline void + move_next_to_front(entry_pointer p_l) const; + + void + initialize(); + + inline void + insert_new_after(entry_pointer p_l, const_reference r_val); + + inline entry_pointer + find_imp(const_key_reference r_key) const + { + entry_pointer p_l = m_p_l; + + while (p_l->m_p_next != NULL) + if (Eq_Fn::operator()( + r_key, + PB_ASSOC_V2F(p_l->m_p_next->m_value))) + { + if (Update_Policy::operator()(p_l->m_update_metadata)) + { + move_next_to_front(p_l); + + return (m_p_l); + } + else + return (p_l); + } + else + p_l = p_l->m_p_next; + + return (p_l); + } + + inline void + erase_imp(entry_pointer p_l); + + inline find_iterator + find_end(); + + inline const_find_iterator + find_end() const; + + void + inc_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const; + + void + inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const; + + void + get_start_it_state(pointer& r_p_value, std::pair<entry_pointer, size_type>& r_pos) const; + +#ifdef PB_ASSOC_LU_MAP_DEBUG_ + + void + assert_entry_pointer_array_valid(const entry_pointer_array a_p_lntries) const; + + void + assert_entry_pointer_valid(const entry_pointer p_l, store_hash_true_indicator) const; + + void + assert_entry_pointer_valid(const entry_pointer p_l, store_hash_false_indicator) const; + +#endif // #ifdef PB_ASSOC_LU_MAP_DEBUG_ + + private: + + static entry_allocator s_entry_allocator; + + mutable entry_pointer m_p_l; + + size_type m_size; + + friend class iterator_; + + friend class const_iterator_; + + static iterator s_end_it; + + static const_iterator s_const_end_it; + + static find_iterator s_find_end_it; + + static const_find_iterator s_const_find_end_it; + + }; + +#include <ext/pb_assoc/detail/lu_map_/constructor_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/policy_access_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/lu_map_/insert_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_MAP_DEBUG_BASE_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_EP2VP +#undef PB_ASSOC_V2S + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/policy_access_fn_imps.hpp new file mode 100644 index 00000000000..c29194ba7e9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_map_/policy_access_fn_imps.hpp @@ -0,0 +1,60 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 policy_access_fn_imps.hpp + * Contains implementations of lu_map_. + */ + +PB_ASSOC_CLASS_T_DEC +Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Eq_Fn& +PB_ASSOC_CLASS_C_DEC:: +get_eq_fn() const +{ + return (*this); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp new file mode 100644 index 00000000000..0a1348d9d87 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp @@ -0,0 +1,66 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_imp.hpp + * Contains implementation of a lu counter policy's metadata. + */ + +PB_ASSOC_CLASS_T_DEC +counter_lu_metadata< + Size_Type> +PB_ASSOC_CLASS_C_DEC:: +operator()(size_type m_max_count) const +{ + return (counter_lu_metadata<Size_Type>(rand() % m_max_count)); +} + +PB_ASSOC_CLASS_T_DEC +template<typename Metadata_Reference> +inline bool +PB_ASSOC_CLASS_C_DEC:: +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); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp new file mode 100644 index 00000000000..392c16444cd --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp @@ -0,0 +1,74 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +counter_lu_policy(size_type max_count /*= 5*/) : + m_max_count(max_count) +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + std::swap(m_max_count, r_other.m_max_count); +} + +PB_ASSOC_CLASS_T_DEC +counter_lu_metadata< + Size_Type> +PB_ASSOC_CLASS_C_DEC:: +operator()() const +{ + return (my_base::operator()(m_max_count)); +} + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +operator()(metadata_reference r_data) const +{ + return (my_base::operator()(r_data, m_max_count)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp new file mode 100644 index 00000000000..8204ce7ff27 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp @@ -0,0 +1,65 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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.hpp + * Contains a move-to-front policy implementation. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& /*r_other*/) +{ } + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::metadata_type +PB_ASSOC_CLASS_C_DEC:: +operator()() const +{ + return (move_to_front_lu_metadata()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +operator()(metadata_reference /*r_data*/) const +{ + return (true); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/map_debug_base.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/map_debug_base.hpp new file mode 100644 index 00000000000..2f98a163d1a --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/map_debug_base.hpp @@ -0,0 +1,248 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 map_debug_base.hpp + * Contains a debug-mode base for all maps. + */ + +#ifndef MAP_DEBUG_BASE_HPP +#define MAP_DEBUG_BASE_HPP + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#include <assert.h> +#include <utility> +#include <set> +#include <pb_assoc/testsuite/regression/res_mng/dbg_ex_allocator_base.hpp> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_MAP_DEBUG_BASE_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_MAP_DEBUG_BASE_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_MAP_DEBUG_BASE_DEBUG + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, class Eq_Fn> + +#define PB_ASSOC_CLASS_C_DEC \ + map_debug_base< \ + Key, \ + Eq_Fn> + + template<typename Key, class Eq_Fn> + class map_debug_base + { + private: + typedef typename std::allocator<Key> key_allocator; + + typedef typename key_allocator::size_type size_type; + + typedef typename key_allocator::const_reference const_key_reference; + + protected: + map_debug_base(); + + map_debug_base(const PB_ASSOC_CLASS_C_DEC& r_other); + + ~map_debug_base(); + + inline void + insert_new(const_key_reference r_key); + + inline void + insert_existing(const_key_reference r_key); + + inline void + erase_existing(const_key_reference r_key); + + void + clear(); + + inline void + check_key_exists(const_key_reference r_key) const; + + inline void + check_key_does_not_exist(const_key_reference r_key) const; + + inline void + check_size(size_type size) const; + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + private: + typedef std::set<Key> key_set; + + private: + key_set m_key_set; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + map_debug_base() + { + + } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + map_debug_base(const PB_ASSOC_CLASS_C_DEC& r_other) : + m_key_set(r_other.m_key_set) + { } + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + ~map_debug_base() + { } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + insert_new(const_key_reference r_key) + { + const double orig_throw_prob = + pb_assoc::detail::test::dbg_ex_allocator_base().get_throw_prob(); + + pb_assoc::detail::test::dbg_ex_allocator_base(). + set_throw_prob(0); + + if (m_key_set.find(r_key) != m_key_set.end()) + abort(); + + try + { + m_key_set.insert(r_key); + } + catch(...) + { + pb_assoc::detail::test::dbg_ex_allocator_base(). + set_throw_prob(orig_throw_prob); + + throw; + } + + pb_assoc::detail::test::dbg_ex_allocator_base(). + set_throw_prob(orig_throw_prob); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + erase_existing(const_key_reference r_key) + { + if (m_key_set.find(r_key) == m_key_set.end()) + abort(); + + m_key_set.erase(r_key); + + if (m_key_set.find(r_key) != m_key_set.end()) + abort(); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + clear() + { + m_key_set.clear(); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + check_key_exists(const_key_reference r_key) const + { + if (m_key_set.find(r_key) == m_key_set.end()) + abort(); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + check_key_does_not_exist(const_key_reference r_key) const + { + if (m_key_set.find(r_key) != m_key_set.end()) + abort(); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + check_size(size_type size) const + { + const size_type key_set_size = m_key_set.size(); + + if (size != key_set_size) + abort(); + } + + PB_ASSOC_CLASS_T_DEC + void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + m_key_set.swap(r_other.m_key_set); + } + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#endif // #ifndef MAP_DEBUG_BASE_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/mapping_level_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/mapping_level_imp.hpp new file mode 100644 index 00000000000..47d7d0b4c50 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/mapping_level_imp.hpp @@ -0,0 +1,90 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 mapping_level_imp.hpp + * Contains mapping level implementation. + */ + +#ifndef MAPPING_LEVEL_IMP_HPP +#define MAPPING_LEVEL_IMP_HPP + +namespace pb_assoc +{ + + namespace detail + { + + template<class Given_Data> + struct mapping_level_imp + { + enum + { + value = 1 + }; + }; + + template<> + struct mapping_level_imp< + null_data_type> + { + enum + { + value = 1 + }; + }; + + template<class Cntnr> + struct mapping_level_imp< + compound_data_type< + Cntnr> > + { + enum + { + value = 1 + + mapping_level_imp< + typename Cntnr::given_data_type>::value + }; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef MAPPING_LEVEL_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ms_category_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ms_category_imp.hpp new file mode 100644 index 00000000000..2d8b61c283f --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ms_category_imp.hpp @@ -0,0 +1,81 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ms_category_imp.hpp + * Contains mapping-semantics category implementation. + */ + +#ifndef MS_CATEGORY_IMP_HPP +#define MS_CATEGORY_IMP_HPP + +namespace pb_assoc +{ + + namespace detail + { + + template<typename Key, class Data> + struct ms_category_imp + { + typedef data_enabled_ms_tag type; + }; + + template<typename Key> + struct ms_category_imp< + Key, + null_data_type> + { + typedef basic_ms_tag type; + }; + + template<typename Key, class Cntnr> + struct ms_category_imp< + Key, + compound_data_type< + Cntnr> > + { + typedef compound_data_enabled_ms_tag type; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef MS_CATEGORY_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ms_trait_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ms_trait_imp.hpp new file mode 100644 index 00000000000..0822463e9a3 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ms_trait_imp.hpp @@ -0,0 +1,136 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ms_category_imp.hpp + * Contains mapping-semantics category implementation. + */ + +#ifndef MS_TRAIT_IMP_HPP +#define MS_TRAIT_IMP_HPP + +namespace detail +{ + + template<class Cntnr, class Mapping_Semantics_Category> + struct mapping_semantics_traits; + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + mapping_semantics_traits< \ + Cntnr, \ + basic_ms_tag> + + template<class Cntnr> + struct mapping_semantics_traits< + Cntnr, + basic_ms_tag> + { + + public: + enum + { + has_data = false, + has_compound_data = false, + mapping_level = 1 + }; + }; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + mapping_semantics_traits< \ + Cntnr, \ + data_enabled_ms_tag> + + template<class Cntnr> + struct mapping_semantics_traits< + Cntnr, + data_enabled_ms_tag> + { + public: + enum + { + has_data = true, + has_compound_data = false, + mapping_level = 1 + }; + }; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + mapping_semantics_traits< \ + Cntnr, \ + compound_data_enabled_ms_tag> + + template<class Cntnr> + struct mapping_semantics_traits< + Cntnr, + compound_data_enabled_ms_tag> + { + public: + enum + { + has_data = true, + has_compound_data = true, + mapping_level = mapping_level_imp< + typename Cntnr::given_data_type>::value + }; + }; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +} // namespace detail + +#endif // #ifndef MS_TRAIT_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/order_statistics_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/order_statistics_imp.hpp new file mode 100644 index 00000000000..d4031583c9c --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/order_statistics_imp.hpp @@ -0,0 +1,436 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 order_statistics_imp.hpp + * Contains forward declarations for order_statistics_key + */ + +#ifndef ORDER_STATISTICS_IMP_HPP +#define ORDER_STATISTICS_IMP_HPP + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Key, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key< \ + Key, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key(const_key_reference r_key) : + m_key(r_key), + m_rank(1) +{ } + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +operator typename PB_ASSOC_CLASS_C_DEC::key_reference() +{ + return (m_key); +} + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +operator typename PB_ASSOC_CLASS_C_DEC::key_type() const +{ + return (m_key); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cmp_Fn, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key_cmp< \ + Cmp_Fn, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key_cmp() +{ } + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key_cmp(const Cmp_Fn& r_cmp_fn) : + Cmp_Fn(r_cmp_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const +{ + return Cmp_Fn::operator()((key_type)r_lhs_key, (key_type)r_rhs_key); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::cmp_fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +inline const typename PB_ASSOC_CLASS_C_DEC::cmp_fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() const +{ + return (*this); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Key, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_node_updator< \ + Key, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +operator()(const_key_pointer p_key, const_key_pointer p_l_child_key, const_key_pointer p_r_child_key) +{ + /* + * The left rank is 0 if there is no left child, + * or the rank of the left child, otherwise. + */ + const size_type l_rank =(p_l_child_key == NULL)? 0 : p_l_child_key->m_rank; + + /* + * The right rank is 0 if there is no right child, + * or the rank of the right child, otherwise. + */ + const size_type r_rank =(p_r_child_key == NULL)? 0 : p_r_child_key->m_rank; + + /* + * The rand of the entry is the sumb of the ranks of its + * children + 1 (for itself). + */ + p_key->m_rank = 1 + l_rank + r_rank; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& /*r_other*/) +{ } + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + find_by_order< \ + Cntnr> + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +operator()(Cntnr& r_c, size_type order) const +{ + return find(r_c, order); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c, size_type order) const +{ + return find(r_c, order); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const Cntnr& r_c, size_type order) +{ + if (order > r_c.size()) + return (r_c.end()); + + /* + * Start at the top of the tree. + */ + typename Cntnr::const_node_iterator it = r_c.node_begin(); + + /* + * Loop up to a leaf. + */ + while (it != r_c.node_end()) + { + typename Cntnr::const_node_iterator l_it = it.l_child(); + + /* + * The order of the element, o, is the rank of the left + * child (for the entry itself). + */ + const size_type o = (l_it == r_c.node_end())? + 0 :(*l_it)->m_rank; + + /* + * If the current order, o, is the order requested, + * the key has been found. + */ + if (order == o) + return (*it); + /* + * If the current order, o, is larger than the order requested, + * we should move to the left subtree. + */ + else if (order < o) + it = l_it; + /* + * Otherwise adujst the requested order and move to the right subtree. + */ + else + { + order -= o + 1; + + it = it.r_child(); + } + } + + return (r_c.end()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +find(Cntnr& r_c, size_type order) +{ + if (order > r_c.size()) + return (r_c.end()); + + /* + * Start at the top of the tree. + */ + typename Cntnr::node_iterator it = r_c.node_begin(); + + /* + * Loop up to a leaf. + */ + while (it != r_c.node_end()) + { + typename Cntnr::node_iterator l_it = it.l_child(); + + /* + * The order of the element, o, is the rank of the left + * child (for the entry itself). + */ + const size_type o = (l_it == r_c.node_end())? + 0 : + r_c.extract_key(*(*l_it)).m_rank; + + /* + * If the current order, o, is the order requested, + * the key has been found. + */ + if (order == o) + return (*it); + /* + * If the current order, o, is larger than the order requested, + * we should move to the left subtree. + */ + else if (order < o) + it = l_it; + /* + * Otherwise adujst the requested order and move to the right subtree. + */ + else + { + order -= o + 1; + + it = it.r_child(); + } + } + + return (r_c.end()); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + order_by_key< \ + Cntnr> + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c, const underlying_key_type& r_key) const +{ + /* + * The logic here is similar to that in order_by_key. + */ + + typename Cntnr::const_node_iterator it = r_c.node_begin(); + + size_type ord = 0; + + while (it != r_c.node_end()) + { + typename Cntnr::const_node_iterator l_it = it.l_child(); + + if (r_c.get_cmp_fn().get_cmp_fn()( + r_key, + r_c.extract_key(*(*it)).m_key)) + it = l_it; + else if (r_c.get_cmp_fn().get_cmp_fn()( + r_c.extract_key(*(*it)).m_key, + r_key)) + { + + ord += (l_it == r_c.node_end())? + 1 : + 1 + r_c.extract_key(*(*l_it)).m_rank; + + it = it.r_child(); + } + else + { + ord += (l_it == r_c.node_end())? + 0 : + r_c.extract_key(*(*l_it)).m_rank; + + it = r_c.node_end(); + } + } + + return (ord); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key_verifier< \ + Cntnr, \ + Allocator> + +template<class Cntnr, class Allocator = std::allocator<char> > +class order_statistics_key_verifier +{ +public: + typedef Cntnr map; + + typedef Allocator allocator; + + typedef typename allocator::size_type size_type; + + typedef + typename allocator::template rebind<map>::other::const_reference + const_map_reference; + +public: + bool + operator()(const Cntnr& r_c) const; + +private: + typedef typename Cntnr::const_node_iterator const_node_iterator; + + typedef typename Cntnr::const_iterator cntnr_const_it; + + typedef std::pair<bool, size_type> stat; + +private: + static stat + verify_imp(const_node_iterator it, const_node_iterator end_it) + { + if (it == end_it) + return (std::make_pair(true, 0)); + + const stat l_ret = + verify_imp(it.l_child(), end_it); + + const stat r_ret = + verify_imp(it.r_child(), end_it); + + if (!l_ret.first || !r_ret.first) + return (std::make_pair(false, 0)); + + if ((*it)->m_rank != 1 + l_ret.second + r_ret.second) + return (std::make_pair(false, 0)); + + return (std::make_pair(true, (*it)->m_rank)); + } +}; + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c) const +{ + const stat top_stat = + verify_imp(r_c.node_begin(), r_c.node_end()); + + return (top_stat.first); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#endif // #ifndef ORDER_STATISTICS_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/cond_dtor.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/cond_dtor.hpp new file mode 100644 index 00000000000..0bda538c4ac --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/cond_dtor.hpp @@ -0,0 +1,88 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 + */ + +class cond_dtor +{ +public: + cond_dtor(pointer 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( + const_cast<typename value_allocator::pointer>(m_a_vec), + m_max_size); + } + + inline void + set_no_action() + { + m_no_action = true; + } + +protected: + pointer m_a_vec; + + iterator& m_r_last_it; + + const size_type m_max_size; + + bool m_no_action; +}; diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..a79f923a178 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp @@ -0,0 +1,278 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::value_allocator +PB_ASSOC_CLASS_C_DEC::s_alloc; + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_OV_TREE_CLASS_NAME() : + m_a_values(NULL), + m_end_it(NULL), + m_size(0) +{ + update(node_begin(), (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : + my_cmp_fn_base(r_cmp_fn), + m_a_values(NULL), + m_end_it(NULL), + m_size(0) +{ + update(node_begin(), (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + my_cmp_fn_base(r_cmp_fn), + Node_Updator(r_node_updator), + m_a_values(NULL), + m_end_it(NULL), + m_size(0) +{ + update(node_begin(), (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_OV_TREE_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + my_cmp_fn_base(r_other), + m_a_values(NULL), + m_end_it(NULL), + m_size(0) +{ + copy_from_ordered_range(r_other.begin(), r_other.end()); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +template<class It> +inline void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + enum + { + is_set_type = is_same_type<Data, null_data_type>::value + }; + + typedef + typename cond_type< + is_set_type, + std::set< + Key, + Cmp_Fn, + typename Allocator::template rebind< + Key>::other>, + std::map< + Key, + Data, + Cmp_Fn, + typename Allocator::template rebind< + std::pair<const Key, Data> >::other> >::type + map_type; + + map_type m(first_it, last_it); + + copy_from_ordered_range(m.begin(), m.end()); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_ordered_range(It first_it, It last_it) +{ + clear(); + + const size_type size = std::distance(first_it, last_it); + + pointer a_values = s_alloc.allocate(size); + + iterator target_it = a_values; + It source_it = first_it; + It source_end_it = last_it; + + cond_dtor cd(a_values, target_it, size); + + while (source_it != source_end_it) + { + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it++); + + ++target_it; + } + + cd.set_no_action(); + + m_a_values = a_values; + + m_size = size; + + m_end_it = m_a_values + m_size; + + update(node_begin(), (Node_Updator* )this); + +#ifdef PB_ASSOC_OV_TREE_DEBUG_ + const_iterator dbg_it = m_a_values; + + while (dbg_it != m_end_it) + { + my_map_debug_base::insert_new(PB_ASSOC_V2F(*dbg_it)); + + dbg_it++; + } + + PB_ASSOC_CLASS_C_DEC::assert_valid(); +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it) +{ + clear(); + + const size_type size = + std::distance(first_it, last_it) + + std::distance(other_first_it, other_last_it); + + pointer a_values = s_alloc.allocate(size); + + iterator target_it = a_values; + It source_it = first_it; + It source_end_it = last_it; + + cond_dtor cd(a_values, target_it, size); + + while (source_it != source_end_it) + { + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it++); + + ++target_it; + } + + source_it = other_first_it; + source_end_it = other_last_it; + + while (source_it != source_end_it) + { + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it++); + + ++target_it; + } + + cd.set_no_action(); + + m_a_values = a_values; + + m_size = size; + + m_end_it = m_a_values + m_size; + + update(node_begin(), (Node_Updator* )this); + +#ifdef PB_ASSOC_OV_TREE_DEBUG_ + const_iterator dbg_it = m_a_values; + + while (dbg_it != m_end_it) + { + my_map_debug_base::insert_new(PB_ASSOC_V2F(*dbg_it)); + + dbg_it++; + } + + PB_ASSOC_CLASS_C_DEC::assert_valid(); +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + std::swap(m_a_values, r_other.m_a_values); + + std::swap(m_size, r_other.m_size); + + std::swap(m_end_it, r_other.m_end_it); + + std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )r_other); + + Node_Updator::swap(r_other); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::swap(r_other);) + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~PB_ASSOC_OV_TREE_CLASS_NAME() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + cond_dtor cd(m_a_values, m_end_it, m_size); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/debug_fn_imps.hpp new file mode 100644 index 00000000000..2b7174edc48 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/debug_fn_imps.hpp @@ -0,0 +1,101 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + +#ifdef PB_ASSOC_OV_TREE_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + if (m_a_mapped_values == NULL || m_end_it == NULL || m_size == 0) + PB_ASSOC_DBG_ASSERT(m_a_mapped_values == NULL&& m_end_it == NULL&& + m_size == 0); + + assert_iterators(); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_iterators() const +{ + my_map_debug_base::check_size(m_size); + + size_type iterated_num = 0; + + const_iterator prev_it = end(); + + PB_ASSOC_DBG_ASSERT( m_end_it == m_a_mapped_values + m_size); + + for (const_iterator it = begin(); it != end(); ++it) + { + ++iterated_num; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists( + PB_ASSOC_V2F(*it))); + + PB_ASSOC_DBG_ASSERT(lower_bound( + PB_ASSOC_V2F(*it)) == it); + + const_iterator upper_bound_it = upper_bound( + PB_ASSOC_V2F(*it)); + + --upper_bound_it; + + PB_ASSOC_DBG_ASSERT(upper_bound_it == it); + + if (prev_it != end()) + PB_ASSOC_DBG_ASSERT(Cmp_Fn::operator()( + PB_ASSOC_V2F(*prev_it), + PB_ASSOC_V2F(*it))); + + prev_it = it; + } + + PB_ASSOC_DBG_ASSERT(iterated_num == m_size); +} + +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/erase_fn_imps.hpp new file mode 100644 index 00000000000..29154cb821e --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/erase_fn_imps.hpp @@ -0,0 +1,234 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + iterator it = find(r_key); + + if (it == find_end()) + return (0); + + erase(it); + + return (1); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +clear() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + if (m_size == 0) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + return; + } + else + { + cond_dtor cd(m_a_values, m_end_it, m_size); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();) + + m_a_values = NULL; + + m_size = 0; + + m_end_it = m_a_values; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred pred) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + +#ifdef PB_ASSOC_BASIC_REGRESSION + throw_prob_adjustor adjust(m_size); +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION + + size_type new_size = 0; + + size_type num_val_ersd = 0; + + iterator source_it = m_a_values; + + for (source_it = begin(); source_it != m_end_it; ++source_it) + { + if (pred(*source_it)) + ++num_val_ersd; + else + ++new_size; + } + + if (new_size == 0) + { + clear(); + + return (num_val_ersd); + } + + pointer a_new_values = s_alloc.allocate(new_size); + + iterator target_it = a_new_values; + + cond_dtor cd(a_new_values, target_it, new_size); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::clear()); + + for (source_it = begin(); source_it != m_end_it; ++source_it) + { + if (!pred(*source_it)) + { + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it); + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new( + PB_ASSOC_V2F(*source_it))); + + ++target_it; + } + } + + cd.set_no_action(); + + { + cond_dtor cd1(m_a_values, m_end_it, m_size); + } + + m_a_values = a_new_values; + + m_size = new_size; + + m_end_it = target_it; + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (num_val_ersd); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +It +PB_ASSOC_CLASS_C_DEC:: +erase(It it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + if (it == end()) + return end(); + + PB_ASSOC_DBG_ONLY( + PB_ASSOC_CLASS_C_DEC::check_key_exists(PB_ASSOC_V2F(*it));) + +#ifdef PB_ASSOC_BASIC_REGRESSION + throw_prob_adjustor adjust(m_size); +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION + + PB_ASSOC_DBG_ASSERT(m_size > 0); + + pointer a_values = s_alloc.allocate(m_size - 1); + + iterator source_it = begin(); + iterator source_end_it = end(); + iterator target_it = a_values; + iterator ret_it = end(); + + cond_dtor cd(a_values, target_it, m_size - 1); + + PB_ASSOC_DBG_ONLY(size_type cnt = 0;) + + while (source_it != source_end_it) + { + if (source_it != it) + { + PB_ASSOC_DBG_ONLY(++cnt;) + PB_ASSOC_DBG_ASSERT(cnt != m_size); + + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it); + + ++target_it; + } + else + ret_it = target_it; + + ++source_it; + } + + cd.set_no_action(); + + PB_ASSOC_DBG_ONLY( + PB_ASSOC_CLASS_C_DEC::erase_existing(PB_ASSOC_V2F(*it));) + { + cond_dtor 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_Updator* )this); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (It(ret_it)); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/find_fn_imps.hpp new file mode 100644 index 00000000000..8b3d6833bf9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/find_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/info_fn_imps.hpp new file mode 100644 index 00000000000..0d271e042dd --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/info_fn_imps.hpp @@ -0,0 +1,95 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +cmp_with_other(const PB_ASSOC_CLASS_C_DEC& r_other) const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + if (size() != r_other.size()) + return (false); + + const_iterator other_it = r_other.begin(); + const_iterator it = begin(); + + while (it != end()) + { + if (*it !=* other_it) + return (false); + + ++it; + + ++other_it; + } + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (m_size); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (s_alloc.max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/insert_fn_imps.hpp new file mode 100644 index 00000000000..e889a182e69 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/insert_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/iterators_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/iterators_fn_imps.hpp new file mode 100644 index 00000000000..0f39b62ac13 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/iterators_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterators_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/node_iterators.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/node_iterators.hpp new file mode 100644 index 00000000000..5633d8bac20 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/node_iterators.hpp @@ -0,0 +1,178 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ov_tree_. + */ + +class const_node_iterator +{ + +public: + + typedef trivial_iterator_tag iterator_category; + + typedef trivial_iterator_difference_type difference_type; + + typedef const_iterator value_type; + + typedef const_iterator* pointer; + + typedef const_iterator* const_pointer; + + typedef const_iterator& reference; + + typedef const iterator& const_reference; + +public: + inline + const_node_iterator(value_pointer p_nd = NULL, value_pointer p_begin_nd = NULL, value_pointer p_end_nd = NULL) : m_p_value(p_nd), + m_p_begin_value(p_begin_nd), + m_p_end_value(p_end_nd) + { } + + inline const_iterator + operator*() const + { + return (m_p_value); + } + + inline const_node_iterator + l_child() const + { + if (m_p_begin_value == m_p_value) + return (const_node_iterator(m_p_begin_value, m_p_begin_value, m_p_begin_value)); + + return (const_node_iterator( + mid_pointer(m_p_begin_value, m_p_value), + m_p_begin_value, + m_p_value)); + } + + inline const_node_iterator + r_child() const + { + if (m_p_value == m_p_end_value) + return (const_node_iterator(m_p_end_value, m_p_end_value, m_p_end_value)); + + return (const_node_iterator( + mid_pointer(m_p_value + 1, m_p_end_value), + m_p_value + 1, + m_p_end_value)); + } + + inline bool + operator==(const const_node_iterator& r_other) const + { + const bool is_end = m_p_begin_value == m_p_end_value; + const bool is_other_end = r_other.m_p_begin_value == r_other.m_p_end_value; + + if (is_end) + return (is_other_end); + + if (is_other_end) + return (is_end); + + if (r_other.m_p_begin_value == r_other.m_p_end_value) + return (m_p_begin_value == m_p_end_value); + + return (m_p_value == r_other.m_p_value); + } + + inline bool + operator!=(const const_node_iterator& r_other) const + { + return (!operator==(r_other)); + } + +private: + friend class PB_ASSOC_CLASS_C_DEC; + +public: + value_pointer m_p_value; + value_pointer m_p_begin_value; + value_pointer m_p_end_value; +}; + +class node_iterator : + public const_node_iterator + +{ + +public: + inline + node_iterator(value_pointer p_nd = NULL, value_pointer p_begin_nd = NULL, value_pointer p_end_nd = NULL) : const_node_iterator(p_nd, p_begin_nd, p_end_nd) + { } + + inline iterator + operator*() const + { + return (iterator(const_node_iterator::m_p_value)); + } + + inline node_iterator + l_child() const + { + if (const_node_iterator::m_p_begin_value == const_node_iterator::m_p_value) + return (node_iterator(const_node_iterator::m_p_begin_value, const_node_iterator::m_p_begin_value, const_node_iterator::m_p_begin_value)); + + return (node_iterator( + mid_pointer(const_node_iterator::m_p_begin_value, const_node_iterator::m_p_value), + const_node_iterator::m_p_begin_value, + const_node_iterator::m_p_value)); + } + + inline node_iterator + r_child() const + { + if (const_node_iterator::m_p_value == const_node_iterator::m_p_end_value) + return (node_iterator(const_node_iterator::m_p_end_value, const_node_iterator::m_p_end_value, const_node_iterator::m_p_end_value)); + + return (node_iterator( + mid_pointer(const_node_iterator::m_p_value + 1, const_node_iterator::m_p_end_value), + const_node_iterator::m_p_value + 1, + const_node_iterator::m_p_end_value)); + } + +private: + + friend class PB_ASSOC_CLASS_C_DEC; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp new file mode 100644 index 00000000000..bea0bc2e14c --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/ov_tree_map_.hpp @@ -0,0 +1,628 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ov_tree_map_.hpp + * Contains an implementation class for ov_tree_. + */ + +#include <map> +#include <set> +#include <ext/pb_assoc/trivial_iterator_def.hpp> +#include <ext/pb_assoc/tree_policy.hpp> +#include <ext/pb_assoc/detail/eq_fn/eq_by_less.hpp> +#include <ext/pb_assoc/detail/types_traits.hpp> +#include <ext/pb_assoc/detail/map_debug_base.hpp> +#include <ext/pb_assoc/detail/type_utils.hpp> +#include <ext/pb_assoc/exception.hpp> +#include <utility> +#include <functional> +#include <algorithm> +#include <vector> +#include <cassert> +#ifdef PB_ASSOC_BASIC_REGRESSION +#include <pb_assoc/testsuite/regression/basic_test/throw_prob_adjustor.hpp> +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_OV_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X); +#define PB_ASSOC_DBG_VERIFY(X) PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_OV_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) ((void)0) +#define PB_ASSOC_DBG_VERIFY(X) X +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class Allocator, \ + class Node_Updator> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_OV_TREE_CLASS_NAME \ + ov_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_OV_TREE_CLASS_NAME \ + ov_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_OV_TREE_CLASS_NAME< \ + Key, \ + Data, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + types_traits< \ + Key, \ + Data, \ + Allocator> + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE +#define PB_ASSOC_MAP_DEBUG_BASE_C_DEC \ + pb_assoc::detail::map_debug_base< \ + Key, \ + eq_by_less<Key, Cmp_Fn> > +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#define PB_ASSOC_EP2VP(X)& ((X)->m_value) +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Mapped_Data() +#define PB_ASSOC_EP2VP(X)& ((X)->m_value.first) +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + + template<typename Key, + typename Data, + class Cmp_Fn, + class Allocator, + class Node_Updator> + class PB_ASSOC_OV_TREE_CLASS_NAME : +#ifdef PB_ASSOC_OV_TREE_DEBUG_ + protected PB_ASSOC_MAP_DEBUG_BASE_C_DEC, +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ + public Cmp_Fn, + public PB_ASSOC_TYPES_TRAITS_C_DEC, + public Node_Updator + { + + protected: + + typedef typename Allocator::size_type size_type; + + typedef typename Allocator::difference_type difference_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + typedef const_pointer const_find_iterator; + + typedef pointer find_iterator; + + typedef const_find_iterator const_iterator; + + typedef find_iterator iterator; + + typedef pointer value_pointer; + +#include <ext/pb_assoc/detail/ov_tree_map_/node_iterators.hpp> + +#include <ext/pb_assoc/detail/ov_tree_map_/cond_dtor.hpp> + + typedef Cmp_Fn cmp_fn; + + typedef Allocator allocator; + + typedef PB_ASSOC_TYPES_TRAITS_C_DEC my_traits_base; + + typedef cmp_fn my_cmp_fn_base; + +#ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + typedef PB_ASSOC_MAP_DEBUG_BASE_C_DEC my_map_debug_base; +#endif // #ifdef PB_ASSOC_USE_MAP_DEBUG_BASE + + protected: + + PB_ASSOC_OV_TREE_CLASS_NAME(); + + PB_ASSOC_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn); + + PB_ASSOC_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator); + + PB_ASSOC_OV_TREE_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + ~PB_ASSOC_OV_TREE_CLASS_NAME(); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + template<class Node_Updator_> + void + update(node_iterator it, Node_Updator_* p_updator) + { + if (it == node_end()) + return; + + update(it.l_child(), p_updator); + update(it.r_child(), p_updator); + + p_updator->operator()(it.m_p_value,(it.l_child() == node_end())? NULL : it.l_child().m_p_value,(it.r_child() == node_end())? NULL : it.r_child().m_p_value); + } + + inline void + update(node_iterator /*it*/, pb_assoc::null_node_updator* ) + { } + + bool + cmp_with_other(const PB_ASSOC_CLASS_C_DEC& r_other) const; + + inline size_type + max_size() const; + + inline bool + empty() const; + + inline size_type + size() const; + + Cmp_Fn& + get_cmp_fn(); + + const Cmp_Fn& + get_cmp_fn() const; + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline data_reference + subscript_imp(const_key_reference r_key) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + find_iterator it = lower_bound(r_key); + + if (it != find_end()&& !Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*it))) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (it->second); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (insert_new_val(it, + std::make_pair(r_key, data_type()))->second); + } + + inline const_data_reference + subscript_imp(const_key_reference r_key) const + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + find_iterator it = lower_bound(r_key); + + PB_ASSOC_DBG_ASSERT(it != find_end()); + + return (it->second); + } +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + inline std::pair<find_iterator, bool> + insert(const_reference r_value) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + const_key_reference r_key = PB_ASSOC_V2F(r_value); + + find_iterator it = lower_bound(r_key); + + if (it != find_end()&& !Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*it))) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + return (std::make_pair(it, false)); + } + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (std::make_pair(insert_new_val(it, r_value), true)); + } + + inline static pointer + mid_pointer(pointer p_begin, pointer p_end) + { + PB_ASSOC_DBG_ASSERT(p_end >= p_begin); + + return (p_begin + (p_end - p_begin) / 2); + } + + inline find_iterator + lower_bound(const_key_reference r_key) + { + pointer it = m_a_values; + + difference_type dist = m_size; + + while (dist > 0) + { + const difference_type mid_dist = dist >> 1; + + pointer mid_it = it + mid_dist; + + if (my_cmp_fn_base::operator()( + PB_ASSOC_V2F(*(it + mid_dist)), + r_key)) + { + it = ++mid_it; + + dist -= mid_dist + 1; + } + else + dist = mid_dist; + } + + return (it); + } + + inline const_find_iterator + lower_bound(const_key_reference r_key) const + { + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).lower_bound(r_key)); + } + + inline find_iterator + upper_bound(const_key_reference r_key) + { + iterator pot_it = lower_bound(r_key); + + if (pot_it != find_end()&& !Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*pot_it))) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + return (++pot_it); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key)); + + return (pot_it); + } + + inline const_find_iterator + upper_bound(const_key_reference r_key) const + { + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).upper_bound(r_key)); + } + + inline find_iterator + find(const_key_reference r_key) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + + iterator pot_it = lower_bound(r_key); + + if (pot_it != find_end()&& !Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*pot_it))) + { + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_exists(r_key)); + + return (pot_it); + } + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist(r_key)); + + return (find_end()); + } + + inline const_find_iterator + find(const_key_reference r_key) const + { + return (const_cast<PB_ASSOC_CLASS_C_DEC& >(*this).find(r_key)); + } + + inline size_type + erase(const_key_reference r_key); + + template<class Pred> + inline size_type + erase_if(Pred pred); + + template<class It> + inline It + erase(It it); + + void + clear(); + + void + join(PB_ASSOC_CLASS_C_DEC& r_other); + + void + split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + + inline iterator + begin() + { + return (m_a_values); + } + + inline const_iterator + begin() const + { + return (m_a_values); + } + + inline iterator + find_end() + { + return (end()); + } + + inline const_iterator + find_end() const + { + return (end()); + } + + inline iterator + end() + { + return (m_end_it); + } + + inline const_iterator + end() const + { + return (m_end_it); + } + + inline const_node_iterator + node_begin() const + { + return (const_node_iterator(mid_pointer(begin(), end()), begin(), end())); + } + + inline node_iterator + node_begin() + { + return (node_iterator(mid_pointer(begin(), end()), begin(), end())); + } + + inline const_node_iterator + node_end() const + { + return (const_node_iterator(end(), end(), end())); + } + + inline node_iterator + node_end() + { + return (node_iterator(end(), end(), end())); + } + + private: + + inline pointer + insert_new_val(iterator it, const_reference r_value) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + +#ifdef PB_ASSOC_BASIC_REGRESSION + throw_prob_adjustor adjust(m_size); +#endif // #ifdef PB_ASSOC_BASIC_REGRESSION + + PB_ASSOC_DBG_ONLY(my_map_debug_base::check_key_does_not_exist( + PB_ASSOC_V2F(r_value))); + + pointer a_values = s_alloc.allocate(m_size + 1); + + iterator source_it = begin(); + iterator source_end_it = end(); + iterator target_it = a_values; + iterator ret_it; + + cond_dtor cd(a_values, target_it, m_size + 1); + + while (source_it != 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))) + value_type(r_value); + + ++target_it; + + while (source_it != source_end_it) + { + new (const_cast<void* >( + static_cast<const void* >(target_it))) + value_type(*source_it++); + + ++target_it; + } + + cd.set_no_action(); + + if (m_size != 0) + { + cond_dtor cd1(m_a_values, m_end_it, m_size); + } + + ++m_size; + + m_a_values = a_values; + + m_end_it = m_a_values + m_size; + + PB_ASSOC_DBG_ONLY(my_map_debug_base::insert_new( + PB_ASSOC_V2F(r_value))); + + update(node_begin(), (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (ret_it); + } + +#ifdef PB_ASSOC_OV_TREE_DEBUG_ + + virtual void + assert_valid() const; + + void + assert_iterators() const; + +#endif // #ifdef PB_ASSOC_OV_TREE_DEBUG_ + + template<class It> + void + copy_from_ordered_range(It first_it, It last_it); + + template<class It> + void + copy_from_ordered_range(It first_it, It last_it, It other_first_it, It other_last_it); + + private: + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type_allocator + value_allocator; + + pointer m_a_values; + + static value_allocator s_alloc; + + pointer m_end_it; + + size_type m_size; + }; + +#include <ext/pb_assoc/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/iterators_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/ov_tree_map_/split_join_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_OV_TREE_CLASS_NAME + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_MAP_DEBUG_BASE_C_DEC + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_EP2VP +#undef PB_ASSOC_V2S + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/split_join_fn_imps.hpp new file mode 100644 index 00000000000..0cc8a604e3d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/ov_tree_map_/split_join_fn_imps.hpp @@ -0,0 +1,189 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_fn_imps.hpp + * Contains an implementation class for ov_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + if (m_size == 0) + { + r_other.clear(); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + return; + } + + if (Cmp_Fn::operator()(r_key, PB_ASSOC_V2F(*begin()))) + { + swap(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + return; + } + + if (!Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*(end() - 1)))) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + return; + } + + if (m_size == 1) + { + swap(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + return; + } + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + for (const_iterator it = begin(); it != end(); ++it) + if (Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(*it))) + { + my_map_debug_base::erase_existing(PB_ASSOC_V2F(*it)); + r_other.my_map_debug_base::insert_new(PB_ASSOC_V2F(*it)); + } +#endif // PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + iterator it = upper_bound(r_key); + + PB_ASSOC_CLASS_C_DEC new_other(r_other, r_other); + + new_other.copy_from_ordered_range(it, end()); + + PB_ASSOC_CLASS_C_DEC new_this(*this, * this); + + new_this.copy_from_ordered_range(begin(), it); + + // No exceptions from this point. + + r_other.update(r_other.node_begin(), (Node_Updator* )(&r_other)); + + update(node_begin(), (Node_Updator* )this); + + r_other.swap(new_other); + + swap(new_this); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +join(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + if (r_other.m_size == 0) + return; + + if (m_size == 0) + { + swap(r_other); + + return; + } + + const bool greater = Cmp_Fn::operator()( + PB_ASSOC_V2F(*(end() - 1)), + PB_ASSOC_V2F(*r_other.begin())); + + const bool lesser = Cmp_Fn::operator()( + PB_ASSOC_V2F(*(r_other.end() - 1)), + PB_ASSOC_V2F(*begin())); + + if (!greater&& !lesser) + throw cannot_join(); + +#ifdef PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + for (const_iterator other_it = r_other.begin(); other_it != r_other.end(); + ++other_it) + { + my_map_debug_base::insert_new(PB_ASSOC_V2F(*other_it)); + r_other.my_map_debug_base::erase_existing(PB_ASSOC_V2F(*other_it)); + } +#endif // PB_ASSOC_BIN_SEARCH_TREE_DEBUG_ + + PB_ASSOC_CLASS_C_DEC new_this(*this, * this); + + if (greater) + new_this.copy_from_ordered_range( + begin(), + end(), + r_other.begin(), + r_other.end()); + else + new_this.copy_from_ordered_range( + r_other.begin(), + r_other.end(), + begin(), + end()); + + // No exceptions from this point. + + swap(new_this); + + r_other.clear(); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + } diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..1f9fb7f40f1 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp @@ -0,0 +1,116 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + while (first_it != last_it) + insert(*(first_it++)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : + PB_ASSOC_BASE_C_DEC(r_cmp_fn) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + PB_ASSOC_BASE_C_DEC(r_cmp_fn, r_node_updator) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_BASE_C_DEC(r_other) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + + PB_ASSOC_BASE_C_DEC::swap(r_other); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize() +{ + PB_ASSOC_BASE_C_DEC::m_p_head->m_red = true; +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/debug_fn_imps.hpp new file mode 100644 index 00000000000..efedce9851e --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/debug_fn_imps.hpp @@ -0,0 +1,87 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +#ifdef PB_ASSOC_RB_TREE_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +assert_node_consistent(const node_pointer p_nd) const +{ + if (p_nd == NULL) + return (1); + + const size_type l_height = assert_node_consistent(p_nd->m_p_left); + const size_type r_height = assert_node_consistent(p_nd->m_p_right); + + if (p_nd->m_red) + { + PB_ASSOC_DBG_ASSERT(is_effectively_black(p_nd->m_p_left)); + + PB_ASSOC_DBG_ASSERT(is_effectively_black(p_nd->m_p_right)); + } + + PB_ASSOC_DBG_ASSERT(l_height == r_height); + + return ((p_nd->m_red? 0 : 1) + l_height); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + PB_ASSOC_DBG_ASSERT(PB_ASSOC_BASE_C_DEC::m_p_head->m_red); + + if (PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent != NULL) + { + PB_ASSOC_DBG_ASSERT(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent->m_red + == false); + + assert_node_consistent(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent); + } +} + +#endif // #ifdef PB_ASSOC_RB_TREE_DEBUG_ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/erase_fn_imps.hpp new file mode 100644 index 00000000000..3d5461fc639 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/erase_fn_imps.hpp @@ -0,0 +1,403 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + iterator it = find(r_key); + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (0); + + erase(it); + + return (1); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(const_iterator it) +{ + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (it); + + const_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + return (ret_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +erase(iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (it); + + iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + return (ret_it); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(const_reverse_iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + if (it == PB_ASSOC_BASE_C_DEC::find_rend()) + return (it); + + const_reverse_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + return (ret_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(reverse_iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + if (it == PB_ASSOC_BASE_C_DEC::find_rend()) + return (it); + + reverse_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + return (ret_it); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred pred) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + size_type num_ersd = 0; + + iterator it = PB_ASSOC_BASE_C_DEC::begin(); + + while (it != PB_ASSOC_BASE_C_DEC::end()) + if (pred(*it)) + { + ++num_ersd; + + it = erase(it); + } + else + ++it; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (num_ersd); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +erase_node(node_pointer p_nd) +{ + remove_node(p_nd); + + PB_ASSOC_BASE_C_DEC::actual_erase_node(p_nd); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +remove_node(node_pointer p_z) +{ + update_min_max_for_erased_node(p_z); + + node_pointer p_y = p_z; + + node_pointer p_x = NULL; + + node_pointer p_new_x_parent = NULL; + + if (p_y->m_p_left == NULL) + p_x = p_y->m_p_right; + else if (p_y->m_p_right == NULL) + p_x = p_y->m_p_left; + else + { + p_y = p_y->m_p_right; + + while (p_y->m_p_left != NULL) + p_y = p_y->m_p_left; + + p_x = p_y->m_p_right; + } + + if (p_y == p_z) + { + p_new_x_parent = p_y->m_p_parent; + + if (p_x != NULL) + p_x->m_p_parent = p_y->m_p_parent; + + if (PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent == p_z) + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_x; + else if (p_z->m_p_parent->m_p_left == p_z) + { + p_y->m_p_left = p_z->m_p_parent; + + p_z->m_p_parent->m_p_left = p_x; + } + else + { + p_y->m_p_left = NULL; + + p_z->m_p_parent->m_p_right = p_x; + } + } + else + { + p_z->m_p_left->m_p_parent = p_y; + + p_y->m_p_left = p_z->m_p_left; + + if (p_y != p_z->m_p_right) + { + p_new_x_parent = p_y->m_p_parent; + + if (p_x != NULL) + p_x->m_p_parent = p_y->m_p_parent; + + p_y->m_p_parent->m_p_left = p_x; + + p_y->m_p_right = p_z->m_p_right; + + p_z->m_p_right->m_p_parent = p_y; + } + else + p_new_x_parent = p_y; + + if (PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent == p_z) + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_y; + else if (p_z->m_p_parent->m_p_left == p_z) + p_z->m_p_parent->m_p_left = p_y; + else + p_z->m_p_parent->m_p_right = p_y; + + p_y->m_p_parent = p_z->m_p_parent; + + std::swap(p_y->m_red, p_z->m_red); + + p_y = p_z; + } + + update_to_top(p_new_x_parent, (Node_Updator* )this); + + if (p_y->m_red) + return; + + remove_fixup(p_x, p_new_x_parent); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +remove_fixup(node_pointer p_x, node_pointer p_new_x_parent) +{ + PB_ASSOC_DBG_ASSERT(p_x == NULL || p_x->m_p_parent == p_new_x_parent); + + while (p_x != PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent&& + is_effectively_black(p_x)) + if (p_x == p_new_x_parent->m_p_left) + { + node_pointer p_w = p_new_x_parent->m_p_right; + + if (p_w->m_red) + { + p_w->m_red = false; + + p_new_x_parent->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_left(p_new_x_parent); + + p_w = p_new_x_parent->m_p_right; + } + + if (is_effectively_black(p_w->m_p_left)&& + is_effectively_black(p_w->m_p_right)) + { + p_w->m_red = true; + + p_x = p_new_x_parent; + + p_new_x_parent = p_new_x_parent->m_p_parent; + } + else + { + if (is_effectively_black(p_w->m_p_right)) + { + if (p_w->m_p_left != NULL) + p_w->m_p_left->m_red = false; + + p_w->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_right(p_w); + + p_w = p_new_x_parent->m_p_right; + } + + p_w->m_red = p_new_x_parent->m_red; + + p_new_x_parent->m_red = false; + + if (p_w->m_p_right != NULL) + p_w->m_p_right->m_red = false; + + PB_ASSOC_BASE_C_DEC::rotate_left(p_new_x_parent); + + update_to_top(p_new_x_parent, (Node_Updator* )this); + + break; + } + } + else + { + node_pointer p_w = p_new_x_parent->m_p_left; + + if (p_w->m_red == true) + { + p_w->m_red = false; + + p_new_x_parent->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_right(p_new_x_parent); + + p_w = p_new_x_parent->m_p_left; + } + + if (is_effectively_black(p_w->m_p_right)&& + is_effectively_black(p_w->m_p_left)) + { + p_w->m_red = true; + + p_x = p_new_x_parent; + + p_new_x_parent = p_new_x_parent->m_p_parent; + } + else + { + if (is_effectively_black(p_w->m_p_left)) + { + if (p_w->m_p_right != NULL) + p_w->m_p_right->m_red = false; + + p_w->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_left(p_w); + + p_w = p_new_x_parent->m_p_left; + } + + p_w->m_red = p_new_x_parent->m_red; + + p_new_x_parent->m_red = false; + + if (p_w->m_p_left != NULL) + p_w->m_p_left->m_red = false; + + PB_ASSOC_BASE_C_DEC::rotate_right(p_new_x_parent); + + update_to_top(p_new_x_parent, (Node_Updator* )this); + + break; + } + } + + if (p_x != NULL) + p_x->m_red = false; +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/find_fn_imps.hpp new file mode 100644 index 00000000000..c0984298f68 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/find_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/info_fn_imps.hpp new file mode 100644 index 00000000000..84a452df956 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/info_fn_imps.hpp @@ -0,0 +1,52 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_effectively_black(const node_pointer p_nd) +{ + return (p_nd == NULL || !p_nd->m_red); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/insert_fn_imps.hpp new file mode 100644 index 00000000000..413707817bc --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/insert_fn_imps.hpp @@ -0,0 +1,176 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_reference r_value) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + std::pair<find_iterator, bool> ins_pair = + PB_ASSOC_BASE_C_DEC::insert_leaf(r_value); + + if (ins_pair.second == true) + { + ins_pair.first.m_p_nd->m_red = true; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(false, true);) + + insert_fixup(ins_pair.first.m_p_nd); + } + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + return (ins_pair); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + std::pair<find_iterator, bool> ins_pair = + PB_ASSOC_BASE_C_DEC::insert_leaf( + value_type(r_key, data_type())); + + if (ins_pair.second == true) + { + ins_pair.first.m_p_nd->m_red = true; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid()); + + insert_fixup(ins_pair.first.m_p_nd); + } + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + return (ins_pair.first.m_p_nd->m_value.second); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +insert_fixup(node_pointer p_nd) +{ + PB_ASSOC_DBG_ASSERT(p_nd->m_red == true); + + while (p_nd != PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent&& + p_nd->m_p_parent->m_red) + { + if (p_nd->m_p_parent == p_nd->m_p_parent->m_p_parent->m_p_left) + { + node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_right; + + if (p_y != NULL&& p_y->m_red) + { + p_nd->m_p_parent->m_red = false; + + p_y->m_red = false; + + p_nd->m_p_parent->m_p_parent->m_red = true; + + p_nd = p_nd->m_p_parent->m_p_parent; + } + else + { + if (p_nd == p_nd->m_p_parent->m_p_right) + { + p_nd = p_nd->m_p_parent; + + PB_ASSOC_BASE_C_DEC::rotate_left(p_nd); + } + + p_nd->m_p_parent->m_red = false; + + p_nd->m_p_parent->m_p_parent->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_right( + p_nd->m_p_parent->m_p_parent); + } + } + else + { + node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_left; + + if (p_y != NULL&& p_y->m_red) + { + p_nd->m_p_parent->m_red = false; + + p_y->m_red = false; + + p_nd->m_p_parent->m_p_parent->m_red = true; + + p_nd = p_nd->m_p_parent->m_p_parent; + } + else + { + if (p_nd == p_nd->m_p_parent->m_p_left) + { + p_nd = p_nd->m_p_parent; + + PB_ASSOC_BASE_C_DEC::rotate_right(p_nd); + } + + p_nd->m_p_parent->m_red = false; + + p_nd->m_p_parent->m_p_parent->m_red = true; + + PB_ASSOC_BASE_C_DEC::rotate_left( + p_nd->m_p_parent->m_p_parent); + } + } + } + + PB_ASSOC_BASE_C_DEC::update_to_top(p_nd, (Node_Updator* )this); + + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent->m_red = false; +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/node.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/node.hpp new file mode 100644 index 00000000000..9a5773bc8e7 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/node.hpp @@ -0,0 +1,89 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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.hpp + * Contains an implementation for rb_tree_. + */ + +#ifndef RB_TREE_NODE_HPP +#define RB_TREE_NODE_HPP + +namespace pb_assoc +{ + + namespace detail + { + + template<class Value_Type, class Allocator> + struct rb_tree_node_ + { + public: + typedef + typename Allocator::template rebind< + rb_tree_node_< + Value_Type, + Allocator> >::other::pointer + node_pointer; + + public: + inline bool + special_dec_check() const + { + return (m_red); + } + + public: + node_pointer m_p_left; + node_pointer m_p_right; + + node_pointer m_p_parent; + + typedef Value_Type value_type; + + value_type m_value; + + bool m_red; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef RB_TREE_NODE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp new file mode 100644 index 00000000000..f890323dada --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/rb_tree_.hpp @@ -0,0 +1,360 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 rb_tree_.hpp + * Contains an implementation for rb_tree_. + */ + +/* + * This implementation uses an idea from the SGI STL (using a "header" node + * which is needed for efficient iteration). + */ + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#ifndef BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#define BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp> +#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#ifndef BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#define BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp> +#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#include <ext/pb_assoc/tree_policy.hpp> +#include <ext/pb_assoc/detail/standard_policies.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/node.hpp> +#include <utility> +#include <vector> +#include <assert.h> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_RB_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_RB_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_RB_TREE_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class Allocator, \ + class Node_Updator> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + rb_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + rb_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_BASE_CLASS_NAME \ + bin_search_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_BASE_CLASS_NAME \ + bin_search_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + types_traits< \ + Key, \ + Data, \ + Allocator> + +#define PB_ASSOC_NODE_C_DEC \ + rb_tree_node_< \ + typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + PB_ASSOC_BASE_CLASS_NAME< \ + Key, \ + Data, \ + PB_ASSOC_NODE_C_DEC, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_V2F(X) (X).first +#define PB_ASSOC_V2S(X) (X).second +#define PB_ASSOC_EP2VP(X)& ((X)->m_value) +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_V2F(X) (X) +#define PB_ASSOC_V2S(X) Mapped_Data() +#define PB_ASSOC_EP2VP(X)& ((X)->m_value.first) +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + + template<typename Key, + typename Data, + class Cmp_Fn, + class Allocator, + class Node_Updator> + struct PB_ASSOC_CLASS_NAME : public PB_ASSOC_BASE_C_DEC + { + + public: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_iterator + const_find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::reverse_iterator + reverse_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_reverse_iterator + const_reverse_iterator; + + private: + + typedef typename PB_ASSOC_BASE_C_DEC::node_pointer node_pointer; + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator); + + PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + inline std::pair<find_iterator, bool> + insert(const_reference r_value); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline data_reference + subscript_imp(const_key_reference r_key); +#endif // #ifdef PB_ASSOC_DATA_TRUE + + inline static bool + is_effectively_black(const node_pointer p_nd); + + inline size_type + erase(const_key_reference r_key); + + inline const_iterator + erase(const_iterator it); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline iterator + erase(iterator it); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + inline const_reverse_iterator + erase(const_reverse_iterator it); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline reverse_iterator + erase(reverse_iterator it); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + template<class Pred> + inline size_type + erase_if(Pred pred); + + void + join(PB_ASSOC_CLASS_C_DEC& r_other); + + void + split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + +#ifdef PB_ASSOC_RB_TREE_DEBUG_ + + virtual void + assert_valid() const; + + size_type + assert_node_consistent(const node_pointer p_nd) const; + +#endif // #ifdef PB_ASSOC_RB_TREE_DEBUG_ + + private: + + void + initialize(); + + void + insert_fixup(node_pointer p_nd); + + void + erase_node(node_pointer p_nd); + + void + remove_node(node_pointer p_nd); + + void + remove_fixup(node_pointer p_x, node_pointer p_new_x_parent); + + void + split_imp(node_pointer p_nd, PB_ASSOC_CLASS_C_DEC& r_other); + + inline node_pointer + split_min(); + + std::pair<node_pointer, node_pointer> + split_min_imp(); + + void + join_imp(node_pointer p_x, node_pointer p_r); + + std::pair<node_pointer, node_pointer> + find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r); + + std::pair<node_pointer, node_pointer> + find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r); + + inline size_type + black_height(node_pointer p_nd); + + void + split_at_node(node_pointer p_nd, PB_ASSOC_CLASS_C_DEC& r_other); + + }; + +#include <ext/pb_assoc/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/split_join_fn_imps.hpp> +#include <ext/pb_assoc/detail/rb_tree_map_/info_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_BASE_CLASS_NAME + +#undef PB_ASSOC_NODE_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#undef PB_ASSOC_V2F +#undef PB_ASSOC_EP2VP +#undef PB_ASSOC_V2S + + } // namespace detail + +} // namespace pb_assoc + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/split_join_fn_imps.hpp new file mode 100644 index 00000000000..211a5249642 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/rb_tree_map_/split_join_fn_imps.hpp @@ -0,0 +1,381 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_fn_imps.hpp + * Contains an implementation for rb_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +join(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + if (PB_ASSOC_BASE_C_DEC::join_prep(r_other) == false) + { + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + return; + } + + const node_pointer p_x = r_other.split_min(); + + join_imp(p_x, r_other.m_p_head->m_p_parent); + + PB_ASSOC_BASE_C_DEC::join_finish(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +join_imp(node_pointer p_x, node_pointer p_r) +{ + PB_ASSOC_DBG_ASSERT(p_x != NULL); + + if (p_r != NULL) + p_r->m_red = false; + + const size_type h = + black_height(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent); + const size_type other_h = black_height(p_r); + + node_pointer p_x_l; + node_pointer p_x_r; + + std::pair<node_pointer, node_pointer> join_pos; + + const bool right_join = h >= other_h; + + if (right_join) + { + join_pos = find_join_pos_right(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent, h, other_h); + + p_x_l = join_pos.first; + p_x_r = p_r; + } + else + { + p_x_l = PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent; + + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_r; + if (p_r != NULL) + p_r->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + join_pos = find_join_pos_left(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent, h, other_h); + + p_x_r = join_pos.first; + } + + node_pointer p_parent = join_pos.second; + + if (p_parent == PB_ASSOC_BASE_C_DEC::m_p_head) + { + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_x; + + p_x->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + } + else + { + p_x->m_p_parent = p_parent; + + if (right_join) + p_x->m_p_parent->m_p_right = p_x; + else + p_x->m_p_parent->m_p_left = p_x; + } + + p_x->m_p_left = p_x_l; + if (p_x_l != NULL) + p_x_l->m_p_parent = p_x; + + p_x->m_p_right = p_x_r; + if (p_x_r != NULL) + p_x_r->m_p_parent = p_x; + + p_x->m_red = true; + + PB_ASSOC_BASE_C_DEC::initialize_min_max(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + PB_ASSOC_BASE_C_DEC::update_to_top(p_x, (Node_Updator* )this); + + insert_fixup(p_x); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + } + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_pointer +PB_ASSOC_CLASS_C_DEC:: +split_min() +{ + PB_ASSOC_DBG_ASSERT(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_left != + PB_ASSOC_BASE_C_DEC::m_p_head); + + node_pointer p_min = PB_ASSOC_BASE_C_DEC::m_p_head->m_p_left; + + remove_node(p_min); + + return (p_min); +} + +PB_ASSOC_CLASS_T_DEC +std::pair< + typename PB_ASSOC_CLASS_C_DEC::node_pointer, + typename PB_ASSOC_CLASS_C_DEC::node_pointer> +PB_ASSOC_CLASS_C_DEC:: +find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r) +{ + PB_ASSOC_DBG_ASSERT(h_l >= h_r); + + if (PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent == NULL) + return (std::make_pair((node_pointer)NULL, + PB_ASSOC_BASE_C_DEC::m_p_head)); + + node_pointer p_l_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + while (h_l > h_r) + { + if (p_l->m_red == false) + { + PB_ASSOC_DBG_ASSERT(h_l > 0); + + --h_l; + } + + p_l_parent = p_l; + + p_l = p_l->m_p_right; + } + + if (!is_effectively_black(p_l)) + { + p_l_parent = p_l; + + p_l = p_l->m_p_right; + } + + PB_ASSOC_DBG_ASSERT(is_effectively_black(p_l)); + PB_ASSOC_DBG_ASSERT(black_height(p_l) == h_r); + PB_ASSOC_DBG_ASSERT(p_l == NULL || p_l->m_p_parent == p_l_parent); + + return (std::make_pair(p_l, p_l_parent)); +} + +PB_ASSOC_CLASS_T_DEC +std::pair< + typename PB_ASSOC_CLASS_C_DEC::node_pointer, + typename PB_ASSOC_CLASS_C_DEC::node_pointer> +PB_ASSOC_CLASS_C_DEC:: +find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r) +{ + PB_ASSOC_DBG_ASSERT(h_r > h_l); + + if (PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent == NULL) + return (std::make_pair((node_pointer)NULL, + PB_ASSOC_BASE_C_DEC::m_p_head)); + + node_pointer p_r_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + while (h_r > h_l) + { + if (p_r->m_red == false) + { + PB_ASSOC_DBG_ASSERT(h_r > 0); + + --h_r; + } + + p_r_parent = p_r; + + p_r = p_r->m_p_left; + } + + if (!is_effectively_black(p_r)) + { + p_r_parent = p_r; + + p_r = p_r->m_p_left; + } + + PB_ASSOC_DBG_ASSERT(is_effectively_black(p_r)); + PB_ASSOC_DBG_ASSERT(black_height(p_r) == h_l); + PB_ASSOC_DBG_ASSERT(p_r == NULL || p_r->m_p_parent == p_r_parent); + + return (std::make_pair(p_r, p_r_parent)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +black_height(node_pointer p_nd) +{ + size_type h = 1; + + while (p_nd != NULL) + { + if (p_nd->m_red == false) + ++h; + + p_nd = p_nd->m_p_left; + } + + return (h); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + if (PB_ASSOC_BASE_C_DEC::split_prep(r_key, r_other) == false) + { + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + + return; + } + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + node_pointer p_nd = upper_bound(r_key).m_p_nd; + + do + { + node_pointer p_next_nd = p_nd->m_p_parent; + + if (Cmp_Fn::operator()( + r_key, + PB_ASSOC_V2F(p_nd->m_value))) + split_at_node(p_nd, r_other); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + p_nd = p_next_nd; + } + while (p_nd != PB_ASSOC_BASE_C_DEC::m_p_head); + + PB_ASSOC_BASE_C_DEC::split_finish(r_other); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, true);) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +split_at_node(node_pointer p_nd, PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ASSERT(p_nd != NULL); + + node_pointer p_l = p_nd->m_p_left; + node_pointer p_r = p_nd->m_p_right; + + node_pointer p_parent = p_nd->m_p_parent; + + if (p_parent == PB_ASSOC_BASE_C_DEC::m_p_head) + { + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_l; + + if (p_l != NULL) + { + p_l->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + p_l->m_red = false; + } + } + else + { + if (p_parent->m_p_left == p_nd) + p_parent->m_p_left = p_l; + else + p_parent->m_p_right = p_l; + + if (p_l != NULL) + p_l->m_p_parent = p_parent; + + update_to_top(p_parent, (Node_Updator* )this); + + if (!p_nd->m_red) + remove_fixup(p_l, p_parent); + } + + PB_ASSOC_BASE_C_DEC::initialize_min_max(); + + PB_ASSOC_DBG_ONLY(assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + PB_ASSOC_DBG_ONLY(r_other.assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_BASE_C_DEC::assert_valid(true, false);) + + r_other.join_imp(p_nd, p_r); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp new file mode 100644 index 00000000000..9504d02c291 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp @@ -0,0 +1,227 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 cc_hash_max_collision_check_resize_trigger_imp.hpp + * Contains an implementation of cc_hash_max_collision_check_resize_trigger. + */ + +PB_ASSOC_CLASS_T_DEC +pb_assoc::detail::int_to_type<External_Load_Access> +PB_ASSOC_CLASS_C_DEC::s_external_load_access_ind; + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +cc_hash_max_collision_check_resize_trigger(float load) : + m_load(load), + m_size(0), + m_num_col(0), + m_max_col(0), + m_resize_needed(false) +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_start() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_collision() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_end() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_start() +{ + m_num_col = 0; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_collision() +{ + ++m_num_col; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_end() +{ + PB_ASSOC_DBG_ASSERT(NOTHING_HT_RESIZE_ACTION == 0); + + m_resize_needed = + m_resize_needed || (m_num_col >= m_max_col); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_start() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_collision() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_end() +{ } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_inserted(size_type num_e) +{ + PB_ASSOC_DBG_ASSERT(num_e <= m_size); + + if (num_e == m_size) + m_resize_needed = true; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erased(size_type num_e) +{ + PB_ASSOC_DBG_ASSERT(num_e <= m_size); + + m_resize_needed = false; +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_cleared() +{ + m_resize_needed = false; +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_resize_needed() const +{ + return (m_resize_needed); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_grow_needed(size_type /*size*/, size_type /*num_used_e*/) const +{ + PB_ASSOC_DBG_ASSERT(m_resize_needed); + + return (true); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_shrink_needed(size_type size, size_type num_used_e) const +{ + PB_ASSOC_DBG_ASSERT(m_resize_needed); + + return (false); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_resized(size_type new_size) +{ + m_size = new_size; + + // max_col <-- \sqrt{2 load \ln( 2 m \ln( m ) ) } + + const double ln_arg = 2* m_size* ::log( (double)m_size); + + m_max_col = (size_type)::ceil( ::sqrt(2* m_load* ::log(ln_arg) ) ); + + m_num_col = 0; + + m_resize_needed = false; +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_externally_resized(size_type new_size) +{ + notify_resized(new_size); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + std::swap(m_load, r_other.m_load); + + std::swap(m_size, r_other.m_size); + + std::swap(m_num_col, r_other.m_num_col); + + std::swap(m_max_col, r_other.m_max_col); + + std::swap(m_resize_needed, r_other.m_resize_needed); +} + +PB_ASSOC_CLASS_T_DEC +inline float +PB_ASSOC_CLASS_C_DEC:: +get_load_imp(pb_assoc::detail::int_to_type<true>) const +{ + return (m_load); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_exponential_size_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_exponential_size_policy_imp.hpp new file mode 100644 index 00000000000..62e30e1d874 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_exponential_size_policy_imp.hpp @@ -0,0 +1,123 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_exponential_size_policy_imp.hpp + * Contains an implementation of hash_exponential_size_policy. + */ + +#ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +hash_exponential_size_policy(size_type start_size, size_type grow_factor) : + m_start_size(start_size), + m_grow_factor(grow_factor) +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + std::swap(m_start_size, r_other.m_start_size); + + std::swap(m_grow_factor, r_other.m_grow_factor); +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_init_size(size_type suggested_size) const +{ + size_type ret = m_start_size; + + while (ret < suggested_size) + ret *= m_grow_factor; + + return (ret); +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_nearest_larger_size(size_type cur_size) const +{ + PB_ASSOC_DBG_ONLY(assert_is_one_of_my_sizes(size);) + + const size_type pot_ret = cur_size* m_grow_factor; + + return ((pot_ret > cur_size)? pot_ret : cur_size); +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_nearest_smaller_size(size_type cur_size) const +{ + PB_ASSOC_DBG_ONLY(assert_is_one_of_my_sizes(size);) + + const size_type pot_ret = cur_size / m_grow_factor; + + return ((pot_ret > 0)? pot_ret : m_start_size); +} + +#ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_is_one_of_my_sizes(size_type size) +{ + PB_ASSOC_DBG_ASSERT(size >= m_start_size); + + while (size >m_start_size) + size /= m_grow_factor; + + PB_ASSOC_DBG_ASSERT(size == m_start_size); +} +#endif // #ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp new file mode 100644 index 00000000000..24a2a9a3411 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp @@ -0,0 +1,352 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_load_check_resize_trigger_imp.hpp.hpp + * Contains an implementation of hash_load_check_resize_trigger.. + */ + +PB_ASSOC_CLASS_T_DEC +pb_assoc::detail::int_to_type<External_Load_Access> +PB_ASSOC_CLASS_C_DEC::s_external_load_access_ind; + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +hash_load_check_resize_trigger(float load_min, float load_max) : + m_load_min(load_min), + m_load_max(load_max), + m_next_shrink_size(0), + m_next_grow_size(0), + m_resize_needed(false) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_start() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_collision() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_end() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_start() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_collision() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_end() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_start() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_collision() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_end() +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_inserted(size_type num_entries) +{ + PB_ASSOC_DBG_ASSERT(num_entries <= m_next_grow_size); + + my_size_base::set_size(num_entries); + + m_resize_needed = (num_entries == m_next_grow_size); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erased(size_type num_entries) +{ + PB_ASSOC_DBG_ASSERT(num_entries >= m_next_shrink_size); + + my_size_base::set_size(num_entries); + + m_resize_needed = (num_entries == m_next_shrink_size); + + PB_ASSOC_DBG_ONLY(assert_valid();) + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_resize_needed() const +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + + return (m_resize_needed); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_grow_needed(size_type /*size*/, size_type num_entries) const +{ + PB_ASSOC_DBG_ASSERT(m_resize_needed); + + return (num_entries >= m_next_grow_size); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_shrink_needed(size_type /*size*/, size_type num_entries) const +{ + PB_ASSOC_DBG_ASSERT(m_resize_needed); + + return (num_entries <= m_next_shrink_size); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~hash_load_check_resize_trigger() +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_resized(size_type new_size) +{ + m_resize_needed = false; + + m_next_grow_size = + size_type(m_load_max* new_size - 1); + + m_next_shrink_size = + size_type(m_load_min* new_size ); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_externally_resized(size_type new_size) +{ + m_resize_needed = false; + + size_type new_grow_size = + size_type(m_load_max* new_size - 1); + + size_type new_shrink_size = + size_type(m_load_min* new_size ); + + if (new_grow_size >= m_next_grow_size) + { + PB_ASSOC_DBG_ASSERT(new_shrink_size > m_next_shrink_size); + + m_next_grow_size = new_grow_size; + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return; + } + + PB_ASSOC_DBG_ASSERT(new_shrink_size <= m_next_shrink_size); + + m_next_shrink_size = new_shrink_size; + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_cleared() +{ + my_size_base::set_size(0); + + m_resize_needed = (0 < m_next_shrink_size); + + PB_ASSOC_DBG_ONLY(assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + + my_size_base::swap(r_other); + + std::swap(m_load_min, r_other.m_load_min); + std::swap(m_load_max, r_other.m_load_max); + + std::swap(m_resize_needed, r_other.m_resize_needed); + + std::swap(m_next_grow_size, r_other.m_next_grow_size); + std::swap(m_next_shrink_size, r_other.m_next_shrink_size); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +inline std::pair<float, float> +PB_ASSOC_CLASS_C_DEC:: +get_loads() const +{ + return (get_loads_imp(s_external_load_access_ind)); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +set_loads(std::pair<float, float> load_pair) +{ + set_loads_imp(load_pair, s_external_load_access_ind); +} + +PB_ASSOC_CLASS_T_DEC +inline std::pair<float, float> +PB_ASSOC_CLASS_C_DEC:: +get_loads_imp(pb_assoc::detail::int_to_type<true>) const +{ + return (std::make_pair(m_load_min, m_load_max)); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +set_loads_imp(std::pair<float, float> load_pair, pb_assoc::detail::int_to_type<true>) +{ + const float old_load_min = m_load_min; + const float old_load_max = m_load_max; + const size_type old_next_shrink_size = m_next_shrink_size; + const size_type old_next_grow_size = m_next_grow_size; + const bool old_resize_needed = m_resize_needed; + + try + { + m_load_min = load_pair.first; + m_load_max = load_pair.second; + + do_resize(static_cast<size_type>( + my_size_base::get_size() / ((m_load_min + m_load_max) / 2))); + } + catch(...) + { + m_load_min = old_load_min; + m_load_max = old_load_max; + m_next_shrink_size = old_next_shrink_size; + m_next_grow_size = old_next_grow_size; + m_resize_needed = old_resize_needed; + + throw; + } +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +do_resize(size_type /*new_size*/) +{ + abort(); +} + +#ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + PB_ASSOC_DBG_ASSERT(m_load_max > m_load_min); + + PB_ASSOC_DBG_ASSERT(m_next_grow_size >= m_next_shrink_size); +} +#endif // #ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_prime_size_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_prime_size_policy_imp.hpp new file mode 100644 index 00000000000..153b0efb939 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_prime_size_policy_imp.hpp @@ -0,0 +1,150 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_prime_size_policy_imp.hpp + * Contains an implementation of hash_prime_size_policy. + */ + +namespace detail +{ + + enum + { + num_distinct_sizes = 28 + }; + + static const size_t s_a_sizes[num_distinct_sizes] = + { + /* Dealing cards... */ + /* 0 */ 53ul, + /* 1 */ 97ul, + /* 2 */ 193ul, + /* 3 */ 389ul, + /* 4 */ 769ul, + /* 5 */ 1543ul, + /* 6 */ 3079ul, + /* 7 */ 6151ul, + /* 8 */ 12289ul, + /* 9 */ 24593ul, + /* 10 */ 49157ul, + /* 11 */ 98317ul, + /* 12 */ 196613ul, + /* 13 */ 393241ul, + /* 14 */ 786433ul, + /* 15 */ 1572869ul, + /* 16 */ 3145739ul, + /* 17 */ 6291469ul, + /* 18 */ 12582917ul, + /* 19 */ 25165843ul, + /* 20 */ 50331653ul, + /* 21 */ 100663319ul, + /* 22 */ 201326611ul, + /* 23 */ 402653189ul, + /* 24 */ 805306457ul, + /* 25 */ 1610612741, + /* 26 */ 3221225473ul, + /* 27 */ 4294967291ul + /* Pot's good, let's play */ + }; + +} // namespace detail + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& /*r_other*/) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_init_size(size_type suggested_size) const +{ + return (get_nearest_larger_size_imp(suggested_size)); +} + +PB_ASSOC_CLASS_T_DEC +inline PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_nearest_larger_size(size_type cur_size) const +{ + PB_ASSOC_DBG_ONLY(assert_is_one_of_my_sizes(cur_size);) + + return (get_nearest_larger_size_imp(cur_size)); +} + +PB_ASSOC_CLASS_T_DEC +inline PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_nearest_smaller_size(size_type cur_size) const +{ + PB_ASSOC_DBG_ONLY(assert_is_one_of_my_sizes(cur_size);) + + return (*std::lower_bound(detail::s_a_sizes, detail::s_a_sizes + detail::num_distinct_sizes, cur_size - 1)); +} + +PB_ASSOC_CLASS_T_DEC +inline PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_nearest_larger_size_imp(size_type size) const +{ + const size_t* const p_upper = + std::upper_bound(detail::s_a_sizes, detail::s_a_sizes + detail::num_distinct_sizes, size); + + return ((p_upper == detail::s_a_sizes + detail::num_distinct_sizes)? + size : + *p_upper); +} + +#ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_is_one_of_my_sizes(size_type size) +{ + const size_t* const p_end = + detail::s_a_sizes + detail::num_distinct_sizes; + + const size_t* const p_found = + std::find(detail::s_a_sizes, p_end, size) + + PB_ASSOC_DBG_ASSERT(p_found != p_end); +} +#endif // #ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_standard_resize_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_standard_resize_policy_imp.hpp new file mode 100644 index 00000000000..1e266d2dd82 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/hash_standard_resize_policy_imp.hpp @@ -0,0 +1,342 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_standard_resize_policy_imp.hpp + * Contains an implementation of hash_standard_resize_policy. + */ + +#ifdef PB_ASSOC_HT_STANDARD_RESIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HT_STANDARD_RESIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HT_STANDARD_RESIZE_POLICY_DEBUG + +PB_ASSOC_CLASS_T_DEC +pb_assoc::detail::int_to_type<External_Size_Access> +PB_ASSOC_CLASS_C_DEC::s_external_size_access_indicator; + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +hash_standard_resize_policy(size_type suggested_size /*= 8*/) : + m_size(Size_Policy::get_init_size(suggested_size)) +{ + my_trigger_policy_base::notify_externally_resized( + Size_Policy::get_init_size(suggested_size)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +hash_standard_resize_policy(const Size_Policy& r_size_policy, size_type suggested_size /*= 8*/) : + Size_Policy(r_size_policy), + m_size(Size_Policy::get_init_size(suggested_size)) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +hash_standard_resize_policy(const Size_Policy& r_size_policy, const Trigger_Policy& r_trigger_policy, size_type suggested_size /*= 8*/) : + Size_Policy(r_size_policy), + Trigger_Policy(r_trigger_policy), + m_size(Size_Policy::get_init_size(suggested_size)) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~hash_standard_resize_policy() +{ } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + my_trigger_policy_base::swap(r_other); + + my_size_policy_base::swap(r_other); + + std::swap(m_size, r_other.m_size); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_start() +{ + my_trigger_policy_base::notify_find_search_start(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_collision() +{ + my_trigger_policy_base::notify_find_search_collision(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_find_search_end() +{ + my_trigger_policy_base::notify_find_search_end(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_start() +{ + my_trigger_policy_base::notify_insert_search_start(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_collision() +{ + my_trigger_policy_base::notify_insert_search_collision(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_insert_search_end() +{ + my_trigger_policy_base::notify_insert_search_end(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_start() +{ + my_trigger_policy_base::notify_erase_search_start(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_collision() +{ + my_trigger_policy_base::notify_erase_search_collision(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erase_search_end() +{ + my_trigger_policy_base::notify_erase_search_end(); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_inserted(size_type num_e) +{ + my_trigger_policy_base::notify_inserted(num_e); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +notify_erased(size_type num_e) +{ + my_trigger_policy_base::notify_inserted(num_e); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_cleared() +{ + my_trigger_policy_base::notify_cleared(); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +is_resize_needed() const +{ + return (my_trigger_policy_base::is_resize_needed()); +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_new_size(size_type size, size_type num_used_e) const +{ + PB_ASSOC_DBG_ASSERT(m_size == size); + + if (my_trigger_policy_base:: + is_grow_needed(size, num_used_e)) + return (my_size_policy_base::get_nearest_larger_size(m_size)); + + PB_ASSOC_DBG_ASSERT(my_trigger_policy_base:: + is_shrink_needed(size, num_used_e)); + + return (my_size_policy_base::get_nearest_smaller_size(m_size)); +} + +PB_ASSOC_CLASS_T_DEC +typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_init_size() const +{ + PB_ASSOC_DBG_ASSERT(m_size == + my_trigger_policy_base::get_init_size()); + + return (m_size); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +notify_resized(size_type new_size) +{ + my_trigger_policy_base::notify_resized(new_size); + + m_size = new_size; +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_actual_size() const +{ + return (get_actual_size(s_external_size_access_indicator)); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +get_actual_size(external_resize_true_indicator) const +{ + return (m_size); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +resize(size_type new_size) +{ + resize(new_size, s_external_size_access_indicator); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +resize(size_type new_size, external_resize_true_indicator) +{ + size_type actual_new_size = my_size_policy_base::get_init_size(1); + while (actual_new_size < new_size) + { + const size_type pot = + my_size_policy_base::get_nearest_larger_size(actual_new_size); + + if (pot == actual_new_size&& pot < new_size) + throw cannot_resize(); + + actual_new_size = pot; + } + + const size_type old_size = m_size; + + try + { + do_resize(actual_new_size); + } + catch(cannot_insert& ) + { + m_size = old_size; + + throw cannot_resize(); + } + catch(...) + { + m_size = old_size; + + throw; + } +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +do_resize(size_type /*new_size*/) +{ + // Tmp Ami + abort(); +} + +PB_ASSOC_CLASS_T_DEC +Trigger_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_trigger_policy() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Trigger_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_trigger_policy() const +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +Size_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_size_policy() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +const Size_Policy& +PB_ASSOC_CLASS_C_DEC:: +get_size_policy() const +{ + return (*this); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/ht_prime_size_policy_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/ht_prime_size_policy_imp.hpp new file mode 100644 index 00000000000..7f250dad0aa --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/ht_prime_size_policy_imp.hpp @@ -0,0 +1,97 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ht_prime_size_policy_imp.hpp + * Contains implementation details for ht_prime_size_policy. + */ + +#ifndef HT_PRIME_SIZE_POLICY_IMP_HPP +#define HT_PRIME_SIZE_POLICY_IMP_HPP + +namespace pb_assoc +{ + + namespace detail + { + + enum + { + num_distinct_sizes = 28 + }; + + static const size_t s_a_sizes[num_distinct_sizes] = + { + /* Dealing cards... */ + /* 0 */ 53ul, + /* 1 */ 97ul, + /* 2 */ 193ul, + /* 3 */ 389ul, + /* 4 */ 769ul, + /* 5 */ 1543ul, + /* 6 */ 3079ul, + /* 7 */ 6151ul, + /* 8 */ 12289ul, + /* 9 */ 24593ul, + /* 10 */ 49157ul, + /* 11 */ 98317ul, + /* 12 */ 196613ul, + /* 13 */ 393241ul, + /* 14 */ 786433ul, + /* 15 */ 1572869ul, + /* 16 */ 3145739ul, + /* 17 */ 6291469ul, + /* 18 */ 12582917ul, + /* 19 */ 25165843ul, + /* 20 */ 50331653ul, + /* 21 */ 100663319ul, + /* 22 */ 201326611ul, + /* 23 */ 402653189ul, + /* 24 */ 805306457ul, + /* 25 */ 1610612741, + /* 26 */ 3221225473ul, + /* 27 */ 4294967291ul + /* Pot's good, let's play */ + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef HT_PRIME_SIZE_POLICY_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/size_base.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/size_base.hpp new file mode 100644 index 00000000000..270352b99ec --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/resize_policy/size_base.hpp @@ -0,0 +1,170 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 size_base.hpp + * Contains an base holding size for some resize policies. + */ + +#ifndef SIZE_BASE_HPP +#define SIZE_BASE_HPP + +namespace pb_assoc +{ + + namespace detail + { + + template<typename Size_Type, bool Hold_Size> + class size_base; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + size_base< \ + Size_Type, \ + true> + + template<typename Size_Type> + class size_base< + Size_Type, + true> + { + protected: + typedef Size_Type size_type; + + protected: + inline + size_base(); + + inline void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline void + set_size(size_type size); + + inline size_type + get_size() const; + + private: + size_type m_size; + }; + + PB_ASSOC_CLASS_T_DEC + PB_ASSOC_CLASS_C_DEC:: + size_base() : + m_size(0) + { } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + set_size(size_type size) + { + m_size = size; + } + + PB_ASSOC_CLASS_T_DEC + inline typename PB_ASSOC_CLASS_C_DEC::size_type + PB_ASSOC_CLASS_C_DEC:: + get_size() const + { + return (m_size); + } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& r_other) + { + std::swap(m_size, r_other.m_size); + } + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + size_base< \ + Size_Type, \ + false> + + template<typename Size_Type> + class size_base< + Size_Type, + false> + { + protected: + typedef Size_Type size_type; + + protected: + inline void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline void + set_size(size_type size); + }; + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + swap(PB_ASSOC_CLASS_C_DEC& /*r_other*/) + { } + + PB_ASSOC_CLASS_T_DEC + inline void + PB_ASSOC_CLASS_C_DEC:: + set_size(size_type /*size*/) + { + // Do nothing + } + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef SIZE_BASE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/constructors_destructor_fn_imps.hpp new file mode 100644 index 00000000000..77cbdd9d241 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/constructors_destructor_fn_imps.hpp @@ -0,0 +1,112 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructors_destructor_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +template<class It> +void +PB_ASSOC_CLASS_C_DEC:: +copy_from_range(It first_it, It last_it) +{ + while (first_it != last_it) + insert(*(first_it++)); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME() +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : + PB_ASSOC_BASE_C_DEC(r_cmp_fn) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + PB_ASSOC_BASE_C_DEC(r_cmp_fn, r_node_updator) +{ + initialize(); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) : + PB_ASSOC_BASE_C_DEC(r_other) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + + PB_ASSOC_BASE_C_DEC::swap(r_other); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +initialize() +{ + PB_ASSOC_BASE_C_DEC::m_p_head->m_special = true; +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/debug_fn_imps.hpp new file mode 100644 index 00000000000..51c8fa5eb8d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/debug_fn_imps.hpp @@ -0,0 +1,73 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 debug_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +#ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_valid() const +{ + PB_ASSOC_BASE_C_DEC::assert_valid(true, true); + + assert_special_imp(m_p_head->m_p_parent); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +assert_special_imp(const node_pointer p_nd) const +{ + if (p_nd == NULL) + return; + + PB_ASSOC_DBG_ASSERT(!p_nd->m_special); + + assert_special_imp(p_nd->m_p_left); + + assert_special_imp(p_nd->m_p_right); +} + +#endif // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/erase_fn_imps.hpp new file mode 100644 index 00000000000..1a0c00c77df --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/erase_fn_imps.hpp @@ -0,0 +1,245 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase(const_key_reference r_key) +{ + iterator it = find(r_key); + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (0); + + erase(it); + + return (1); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(const_iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (it); + + const_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + return (ret_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +erase(iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + if (it == PB_ASSOC_BASE_C_DEC::find_end()) + return (it); + + iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_iterators();) + + return (ret_it); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(const_reverse_iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + if (it == PB_ASSOC_BASE_C_DEC::find_rend()) + return (it); + + const_reverse_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + return (ret_it); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::reverse_iterator +PB_ASSOC_CLASS_C_DEC:: +erase(reverse_iterator it) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + if (it == PB_ASSOC_BASE_C_DEC::find_rend()) + return (it); + + reverse_iterator ret_it = it; + + ++ret_it; + + erase_node(it.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + + return (ret_it); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +PB_ASSOC_CLASS_T_DEC +template<class Pred> +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +erase_if(Pred pred) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + size_type num_ersd = 0; + + iterator it = PB_ASSOC_BASE_C_DEC::begin(); + + while (it != PB_ASSOC_BASE_C_DEC::end()) + if (pred(*it)) + { + ++num_ersd; + + it = erase(it); + } + else + ++it; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (num_ersd); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +erase_node(node_pointer p_nd) +{ + PB_ASSOC_DBG_ASSERT(p_nd != NULL); + + splay(p_nd); + + PB_ASSOC_DBG_ONLY(assert_valid();) + PB_ASSOC_DBG_ASSERT(p_nd == PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent); + + node_pointer p_l = p_nd->m_p_left; + node_pointer p_r = p_nd->m_p_right; + + PB_ASSOC_BASE_C_DEC::update_min_max_for_erased_node(p_nd); + + PB_ASSOC_BASE_C_DEC::actual_erase_node(p_nd); + + if (p_r == NULL) + { + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_l; + + if (p_l != NULL) + p_l->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + PB_ASSOC_DBG_ONLY(assert_valid();) + + return; + } + + node_pointer p_target_r = leftmost(p_r); + + PB_ASSOC_DBG_ASSERT(p_target_r != NULL); + + p_r->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_r; + + splay(p_target_r); + + PB_ASSOC_DBG_ONLY(p_target_r->m_p_left = NULL); + + PB_ASSOC_DBG_ASSERT(p_target_r->m_p_parent == + PB_ASSOC_BASE_C_DEC::m_p_head); + + PB_ASSOC_DBG_ASSERT(PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent == + p_target_r); + + p_target_r->m_p_left = p_l; + + if (p_l != NULL) + p_l->m_p_parent = p_target_r; + + PB_ASSOC_DBG_ONLY(assert_valid();) + + apply_update(p_target_r, (Node_Updator* )this); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::node_pointer +PB_ASSOC_CLASS_C_DEC:: +leftmost(node_pointer p_nd) +{ + PB_ASSOC_DBG_ASSERT(p_nd != NULL); + + while (p_nd->m_p_left != NULL) + p_nd = p_nd->m_p_left; + + return (p_nd); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/find_fn_imps.hpp new file mode 100644 index 00000000000..ff67f5983ef --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/find_fn_imps.hpp @@ -0,0 +1,122 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +lower_bound(const_key_reference r_key) +{ + find_iterator it = PB_ASSOC_BASE_C_DEC::find(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + splay(it.m_p_nd); + + return (it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +lower_bound(const_key_reference r_key) const +{ + find_iterator it = PB_ASSOC_BASE_C_DEC::lower_bound(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + splay(it.m_p_nd); + + return (it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +upper_bound(const_key_reference r_key) +{ + find_iterator it = PB_ASSOC_BASE_C_DEC::upper_bound(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + splay(it.m_p_nd); + + return (it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +upper_bound(const_key_reference r_key) const +{ + find_iterator it = PB_ASSOC_BASE_C_DEC::upper_bound(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + splay(it.m_p_nd); + + return (it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) +{ + find_iterator it = PB_ASSOC_BASE_C_DEC::find(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + splay(it.m_p_nd); + + return (it); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const_key_reference r_key) const +{ + const_find_iterator it = PB_ASSOC_BASE_C_DEC::find(r_key); + + if (it != PB_ASSOC_BASE_C_DEC::end()) + const_cast<PB_ASSOC_CLASS_C_DEC* >(this)->splay(it.m_p_nd); + + return (it); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/info_fn_imps.hpp new file mode 100644 index 00000000000..186812153da --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/info_fn_imps.hpp @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains an implementation. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/insert_fn_imps.hpp new file mode 100644 index 00000000000..77882f3e6c9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/insert_fn_imps.hpp @@ -0,0 +1,89 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline std::pair<typename PB_ASSOC_CLASS_C_DEC::find_iterator, bool> +PB_ASSOC_CLASS_C_DEC:: +insert(const_reference r_value) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + std::pair<find_iterator, bool> ins_pair = + PB_ASSOC_BASE_C_DEC::insert_leaf(r_value); + + ins_pair.first.m_p_nd->m_special = false; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true)); + + splay(ins_pair.first.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid(true, true)); + + return (ins_pair); +} + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::data_reference +PB_ASSOC_CLASS_C_DEC:: +subscript_imp(const_key_reference r_key) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + std::pair<find_iterator, bool> ins_pair = + PB_ASSOC_BASE_C_DEC::insert_leaf( + value_type(r_key, Data())); + + ins_pair.first.m_p_nd->m_special = false; + + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_valid()); + + splay(ins_pair.first.m_p_nd); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return (ins_pair.first.m_p_nd->m_value.second); +} +#endif // #ifdef PB_ASSOC_DATA_TRUE + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/node.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/node.hpp new file mode 100644 index 00000000000..5012d587f5d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/node.hpp @@ -0,0 +1,89 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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.hpp + * Contains an implementation struct for splay_tree_'s node. + */ + +#ifndef SPLAY_TREE_NODE_HPP +#define SPLAY_TREE_NODE_HPP + +namespace pb_assoc +{ + + namespace detail + { + + template<class Value_Type, class Allocator> + struct splay_tree_node_ + { + public: + typedef + typename Allocator::template rebind< + splay_tree_node_< + Value_Type, + Allocator> >::other::pointer + node_pointer; + + public: + inline bool + special_dec_check() const + { + return (m_special); + } + + public: + typedef Value_Type value_type; + + value_type m_value; + + bool m_special; + + node_pointer m_p_left; + node_pointer m_p_right; + + node_pointer m_p_parent; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef SPLAY_TREE_NODE_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_fn_imps.hpp new file mode 100644 index 00000000000..ffccf7b6569 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_fn_imps.hpp @@ -0,0 +1,289 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 splay_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +splay(node_pointer p_nd) +{ + while (p_nd->m_p_parent != PB_ASSOC_BASE_C_DEC::m_p_head) + { + PB_ASSOC_DBG_ONLY(PB_ASSOC_BASE_C_DEC::assert_node_consistent(p_nd);) + + if (p_nd->m_p_parent->m_p_parent == + PB_ASSOC_BASE_C_DEC::m_p_head) + { + PB_ASSOC_BASE_C_DEC::rotate_parent(p_nd); + + PB_ASSOC_DBG_ASSERT(p_nd == + PB_ASSOC_BASE_C_DEC::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; + +#ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + const size_type total = + PB_ASSOC_BASE_C_DEC::recursive_count(p_grandparent); + + PB_ASSOC_DBG_ASSERT(total >= 3); +#endif // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + + 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&& + 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&& + p_grandparent->m_p_left == p_parent) + splay_zig_zig_left(p_nd, p_parent, p_grandparent); + else + splay_zig_zig_right(p_nd, p_parent, p_grandparent); + + PB_ASSOC_DBG_ASSERT(total == + PB_ASSOC_BASE_C_DEC::recursive_count(p_nd)); + } + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_nd);) + } +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) +{ + PB_ASSOC_DBG_ASSERT(p_parent == p_nd->m_p_parent); + PB_ASSOC_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_grandparent);) + + PB_ASSOC_DBG_ASSERT(p_parent->m_p_left == p_nd&& + p_grandparent->m_p_right == p_parent); + + splay_zz_start(p_nd, p_parent, p_grandparent); + + node_pointer p_b = p_nd->m_p_right; + node_pointer p_c = p_nd->m_p_left; + + p_nd->m_p_right = p_parent; + p_parent->m_p_parent = p_nd; + + p_nd->m_p_left = p_grandparent; + p_grandparent->m_p_parent = p_nd; + + p_parent->m_p_left = p_b; + if (p_b != NULL) + p_b->m_p_parent = p_parent; + + p_grandparent->m_p_right = p_c; + if (p_c != NULL) + p_c->m_p_parent = p_grandparent; + + splay_zz_end(p_nd, p_parent, p_grandparent); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) +{ + PB_ASSOC_DBG_ASSERT(p_parent == p_nd->m_p_parent); + PB_ASSOC_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_grandparent);) + + PB_ASSOC_DBG_ASSERT(p_parent->m_p_right == p_nd&& + p_grandparent->m_p_left == p_parent); + + splay_zz_start(p_nd, p_parent, p_grandparent); + + node_pointer p_b = p_nd->m_p_left; + node_pointer p_c = p_nd->m_p_right; + + p_nd->m_p_left = p_parent; + p_parent->m_p_parent = p_nd; + + p_nd->m_p_right = p_grandparent; + p_grandparent->m_p_parent = p_nd; + + p_parent->m_p_right = p_b; + if (p_b != NULL) + p_b->m_p_parent = p_parent; + + p_grandparent->m_p_left = p_c; + if (p_c != NULL) + p_c->m_p_parent = p_grandparent; + + splay_zz_end(p_nd, p_parent, p_grandparent); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) +{ + PB_ASSOC_DBG_ASSERT(p_parent == p_nd->m_p_parent); + PB_ASSOC_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_grandparent);) + + PB_ASSOC_DBG_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); + + node_pointer p_b = p_nd->m_p_right; + node_pointer p_c = p_parent->m_p_right; + + p_nd->m_p_right = p_parent; + p_parent->m_p_parent = p_nd; + + p_parent->m_p_right = p_grandparent; + p_grandparent->m_p_parent = p_parent; + + p_parent->m_p_left = p_b; + if (p_b != NULL) + p_b->m_p_parent = p_parent; + + p_grandparent->m_p_left = p_c; + if (p_c != NULL) + p_c->m_p_parent = p_grandparent; + + splay_zz_end(p_nd, p_parent, p_grandparent); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) +{ + PB_ASSOC_DBG_ASSERT(p_parent == p_nd->m_p_parent); + PB_ASSOC_DBG_ASSERT(p_grandparent == p_parent->m_p_parent); + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_grandparent);) + + PB_ASSOC_DBG_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); + + node_pointer p_b = p_nd->m_p_left; + node_pointer p_c = p_parent->m_p_left; + + p_nd->m_p_left = p_parent; + p_parent->m_p_parent = p_nd; + + p_parent->m_p_left = p_grandparent; + p_grandparent->m_p_parent = p_parent; + + p_parent->m_p_right = p_b; + if (p_b != NULL) + p_b->m_p_parent = p_parent; + + p_grandparent->m_p_right = p_c; + if (p_c != NULL) + p_c->m_p_parent = p_grandparent; + + PB_ASSOC_BASE_C_DEC::update_to_top( + p_grandparent, (Node_Updator* )this); + + splay_zz_end(p_nd, p_parent, p_grandparent); +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zz_start(node_pointer p_nd, +#ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + node_pointer p_parent, +#else // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + node_pointer /*p_parent*/, +#endif // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + node_pointer p_grandparent) +{ + PB_ASSOC_DBG_ASSERT(p_nd != NULL); + PB_ASSOC_DBG_ASSERT(p_parent != NULL); + PB_ASSOC_DBG_ASSERT(p_grandparent != NULL); + + const bool grandparent_head = + p_grandparent->m_p_parent == PB_ASSOC_BASE_C_DEC::m_p_head; + + if (grandparent_head) + { + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent; + + p_nd->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + return; + } + + node_pointer p_greatgrandparent = p_grandparent->m_p_parent; + + p_nd->m_p_parent = p_greatgrandparent; + + if (p_grandparent == p_greatgrandparent->m_p_left) + p_greatgrandparent->m_p_left = p_nd; + else + p_greatgrandparent->m_p_right = p_nd; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +splay_zz_end(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) +{ + if (p_nd->m_p_parent == PB_ASSOC_BASE_C_DEC::m_p_head) + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_nd; + + apply_update(p_grandparent, (Node_Updator* )this); + apply_update(p_parent, (Node_Updator* )this); + apply_update(p_nd, (Node_Updator* )this); + + PB_ASSOC_DBG_ONLY(assert_node_consistent(p_nd);) + } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp new file mode 100644 index 00000000000..e6762c9d9c5 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/splay_tree_.hpp @@ -0,0 +1,342 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 splay_tree_.hpp + * Contains an implementation class for splay_tree_. + */ + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#ifndef BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#define BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#include <ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp> +#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_TRUE_INDICATOR +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#ifndef BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#define BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#include <ext/pb_assoc/detail/bin_search_tree_/bin_search_tree_.hpp> +#endif // #ifndef BIN_SEARCH_TREE_HPP__DATA_FALSE_INDICATOR +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#include <ext/pb_assoc/detail/splay_tree_/node.hpp> +#include <utility> +#include <vector> +#include <assert.h> + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class Cmp_Fn, \ + class Allocator, \ + class Node_Updator> + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + splay_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_CLASS_NAME \ + splay_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR +#define PB_ASSOC_BASE_CLASS_NAME \ + bin_search_tree_data_ +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + +#ifdef PB_ASSOC_DATA_FALSE_INDICATOR +#define PB_ASSOC_BASE_CLASS_NAME \ + bin_search_tree_no_data_ +#endif // #ifdef PB_ASSOC_DATA_FALSE_INDICATOR + +#define PB_ASSOC_CLASS_C_DEC \ + PB_ASSOC_CLASS_NAME< \ + Key, \ + Data, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + +#define PB_ASSOC_TYPES_TRAITS_C_DEC \ + types_traits< \ + Key, \ + Data, \ + Allocator> + +#define PB_ASSOC_NODE_C_DEC \ + splay_tree_node_< \ + typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type, \ + Allocator> + +#define PB_ASSOC_BASE_C_DEC \ + PB_ASSOC_BASE_CLASS_NAME< \ + Key, \ + Data, \ + PB_ASSOC_NODE_C_DEC, \ + Cmp_Fn, \ + Allocator, \ + Node_Updator> + + template<typename Key, + typename Data, + class Cmp_Fn, + class Allocator, + class Node_Updator> + struct PB_ASSOC_CLASS_NAME : public PB_ASSOC_BASE_C_DEC + { + + protected: + + typedef typename Allocator::size_type size_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_key_reference + const_key_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_type data_type; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::data_reference + data_reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_data_reference + const_data_reference; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::value_type value_type; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::pointer pointer; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_pointer + const_pointer; + + typedef typename PB_ASSOC_TYPES_TRAITS_C_DEC::reference reference; + + typedef + typename PB_ASSOC_TYPES_TRAITS_C_DEC::const_reference + const_reference; + + typedef typename PB_ASSOC_BASE_C_DEC::node_pointer node_pointer; + + typedef typename PB_ASSOC_BASE_C_DEC::find_iterator find_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_iterator + const_find_iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::iterator iterator; + + typedef typename PB_ASSOC_BASE_C_DEC::const_iterator const_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::reverse_iterator + reverse_iterator; + + typedef + typename PB_ASSOC_BASE_C_DEC::const_reverse_iterator + const_reverse_iterator; + + protected: + + PB_ASSOC_CLASS_NAME(); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn); + + PB_ASSOC_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator); + + PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + template<class It> + void + copy_from_range(It first_it, It last_it); + + void + initialize(); + + inline std::pair<find_iterator, bool> + insert(const_reference r_value); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline data_reference + subscript_imp(const_key_reference r_key); +#endif // #ifdef PB_ASSOC_DATA_TRUE + + inline find_iterator + lower_bound(const_key_reference r_key); + + inline const_find_iterator + lower_bound(const_key_reference r_key) const; + + inline find_iterator + upper_bound(const_key_reference r_key); + + inline const_find_iterator + upper_bound(const_key_reference r_key) const; + + inline find_iterator + find(const_key_reference r_key); + + inline const_find_iterator + find(const_key_reference r_key) const; + + inline size_type + erase(const_key_reference r_key); + + inline const_iterator + erase(const_iterator it); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline iterator + erase(iterator it); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + inline const_reverse_iterator + erase(const_reverse_iterator it); + +#ifdef PB_ASSOC_DATA_TRUE_INDICATOR + inline reverse_iterator + erase(reverse_iterator it); +#endif // #ifdef PB_ASSOC_DATA_TRUE_INDICATOR + + template<class Pred> + inline size_type + erase_if(Pred pred); + + inline node_pointer + leftmost(node_pointer p_nd); + + void + join(PB_ASSOC_CLASS_C_DEC& r_other); + + void + split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other); + +#ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + + virtual void + assert_valid() const; + + void + assert_special_imp(const node_pointer p_nd) const; + +#endif // #ifdef PB_ASSOC_SPLAY_TREE_DEBUG_ + + private: + + void + splay(node_pointer p_nd); + + inline void + splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + inline void + splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + inline void + splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + inline void + splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + inline void + splay_zz_start(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + inline void + splay_zz_end(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent); + + void + erase_node(node_pointer p_nd); + + }; + +#include <ext/pb_assoc/detail/splay_tree_/constructors_destructor_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/info_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/insert_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/splay_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/erase_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/find_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/debug_fn_imps.hpp> +#include <ext/pb_assoc/detail/splay_tree_/split_join_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_TYPES_TRAITS_C_DEC + +#undef PB_ASSOC_BASE_CLASS_NAME + +#undef PB_ASSOC_NODE_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + + } // namespace detail + +} // namespace pb_assoc + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/split_join_fn_imps.hpp new file mode 100644 index 00000000000..e1dd0c2eff2 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/splay_tree_/split_join_fn_imps.hpp @@ -0,0 +1,125 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_fn_imps.hpp + * Contains an implementation class for splay_tree_. + */ + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +join(PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + + if (PB_ASSOC_BASE_C_DEC::join_prep(r_other) == false) + { + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + + return; + } + + node_pointer p_target_r = r_other.leftmost(r_other.m_p_head); + + PB_ASSOC_DBG_ASSERT(p_target_r != NULL); + + r_other.splay(p_target_r); + + PB_ASSOC_DBG_ASSERT(p_target_r == r_other.m_p_head->m_p_parent); + PB_ASSOC_DBG_ASSERT(p_target_r->m_p_left == NULL); + + p_target_r->m_p_left = PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent; + + PB_ASSOC_DBG_ASSERT(p_target_r->m_p_left != NULL); + p_target_r->m_p_left->m_p_parent = p_target_r; + + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_target_r; + p_target_r->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + apply_update(p_target_r, (Node_Updator* )this); + + PB_ASSOC_BASE_C_DEC::join_finish(r_other); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();) + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid();) + } + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +split(const_key_reference r_key, PB_ASSOC_CLASS_C_DEC& r_other) +{ + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid()); + + if (PB_ASSOC_BASE_C_DEC::split_prep(r_key, r_other) == false) + { + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid()); + + return; + } + + node_pointer p_upper_bound = upper_bound(r_key).m_p_nd; + PB_ASSOC_DBG_ASSERT(p_upper_bound != NULL); + + PB_ASSOC_DBG_ASSERT(p_upper_bound->m_p_parent == + PB_ASSOC_BASE_C_DEC::m_p_head); + + node_pointer p_new_root = p_upper_bound->m_p_left; + PB_ASSOC_DBG_ASSERT(p_new_root != NULL); + + PB_ASSOC_BASE_C_DEC::m_p_head->m_p_parent = p_new_root; + p_new_root->m_p_parent = PB_ASSOC_BASE_C_DEC::m_p_head; + + r_other.m_p_head->m_p_parent = p_upper_bound; + p_upper_bound->m_p_parent = r_other.m_p_head; + p_upper_bound->m_p_left = NULL; + + apply_update(p_upper_bound, (Node_Updator* )this); + + PB_ASSOC_BASE_C_DEC::split_finish(r_other); + + PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid()); + PB_ASSOC_DBG_ONLY(r_other.PB_ASSOC_CLASS_C_DEC::assert_valid()); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/standard_policies.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/standard_policies.hpp new file mode 100644 index 00000000000..899dc74ab22 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/standard_policies.hpp @@ -0,0 +1,188 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 standard_policies.hpp + * Contains standard policies for containers. + */ + +#ifndef STANDARD_POLICIES_HPP +#define STANDARD_POLICIES_HPP + +#include <memory> +#include <ext/pb_assoc/hash_policy.hpp> +#include <ext/pb_assoc/lu_policy.hpp> +#include <ext/pb_assoc/tree_policy.hpp> +#if defined(__GNUC__) +#include <ext/hash_map> +#elif defined(_MSC_VER) +#include <hash_map> +#else +#error "Unable to determine the namespaces for your compiler. Please" \ + "Contact pbassoc@gmail.com" +#endif // #if defined(__GNUC__) + +namespace pb_assoc +{ + + namespace detail + { + +#ifdef __GNUC__ + +#define PB_ASSOC_HASH_NAMESPACE \ + __gnu_cxx + + template<typename Key> + struct def_hash_fn + { + typedef PB_ASSOC_HASH_NAMESPACE::hash<Key> type; + }; + + template<typename Key> + struct def_eq_fn + { + typedef PB_ASSOC_HASH_NAMESPACE::equal_to<Key> type; + }; + +#elif defined(_MSC_VER) + + template<typename Key> + struct hash_value_class_adapter + { + inline size_t + operator()(const Key& r_key) const + { + return (stdext::hash_value(r_key)); + } + }; + + template<typename Key> + struct def_hash_fn + { + typedef hash_value_class_adapter<Key> type; + }; + + template<typename Key> + struct def_eq_fn + { + typedef std::equal_to<Key> type; + }; + +#else // #elif defined(_MSC_VER) + +#error Sorry, cannot determine headers, namespaces, etc. for your compiler. +#error If you encounter this error, pls write to pbassoc@gmail.com + +#endif // #elif defined(_MSC_VER) + + enum + { + def_store_hash = false + }; + + struct def_comb_hash_fn + { + typedef pb_assoc::direct_mask_range_hashing<> type; + }; + + template<class Comb_Hash_Fn> + struct def_resize_policy + { + private: + typedef typename Comb_Hash_Fn::size_type size_type; + + typedef + typename pb_assoc::detail::cond_type< + pb_assoc::detail::is_same_type< + pb_assoc::direct_mask_range_hashing<size_type>, + Comb_Hash_Fn>::value, + pb_assoc::hash_exponential_size_policy< + size_type>, + pb_assoc::hash_prime_size_policy>::type + size_policy_type; + + public: + typedef + pb_assoc::hash_standard_resize_policy< + size_policy_type, + pb_assoc::hash_load_check_resize_trigger< + false, + size_type>, + false, + size_type> + type; + }; + + struct def_update_policy + { + typedef pb_assoc::move_to_front_lu_policy<> type; + }; + +#ifdef __GNUC__ +#undef PB_ASSOC_HASH_NAMESPACE +#endif // #ifdef __GNUC__ + + template<class Comb_Probe_Fn> + struct def_probe_fn + { + private: + typedef typename Comb_Probe_Fn::size_type size_type; + + public: + typedef + typename pb_assoc::detail::cond_type< + pb_assoc::detail::is_same_type< + pb_assoc::direct_mask_range_hashing<size_t>, + Comb_Probe_Fn>::value, + pb_assoc::linear_probe_fn< + size_type>, + pb_assoc::quadratic_probe_fn< + size_type> >::type + type; + }; + + typedef pb_assoc::null_node_updator def_node_updator; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef STANDARD_POLICIES_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/standard_sizes.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/standard_sizes.hpp new file mode 100644 index 00000000000..6aa63465044 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/standard_sizes.hpp @@ -0,0 +1,65 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 standard_sizes.hpp + * Contains standard sizes for containers. + */ + +#ifndef STANDARD_SIZES_HPP +#define STANDARD_SIZES_HPP + +namespace pb_assoc +{ + + namespace detail + { + + enum + { + def_init_size = 8, + def_grow_factor = 2 + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef STANDARD_SIZES_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp new file mode 100644 index 00000000000..e5f794ddd8f --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/tree_assoc_cntnr/constructor_destructor_fn_imps.hpp @@ -0,0 +1,130 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_fn_imps.hpp + * Contains implementation of rb trees + */ + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr() +{ + //Do nothing +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(const Cmp_Fn& r_cmp_fn) : + PB_ASSOC_CLASS_C_DEC::my_base(r_cmp_fn) +{ + //Do nothing +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + PB_ASSOC_CLASS_C_DEC::my_base(r_cmp_fn, r_node_updator) +{ + //Do nothing +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(It first_it, It last_it) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(It first_it, It last_it, const Cmp_Fn& r_cmp_fn) : + PB_ASSOC_CLASS_C_DEC::my_base(r_cmp_fn) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +template<class It> +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(It first_it, It last_it, const Cmp_Fn& r_cmp_fn, const Node_Updator& r_node_updator) : + PB_ASSOC_CLASS_C_DEC::my_base(r_cmp_fn, r_node_updator) +{ + my_base::copy_from_range(first_it, last_it); +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +tree_assoc_cntnr(const PB_ASSOC_CLASS_C_DEC& r_other) : + my_base((const PB_ASSOC_BASE_C_DEC& )r_other) +{ + //Do nothing +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~tree_assoc_cntnr() +{ + //Do nothing +} + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC& +PB_ASSOC_CLASS_C_DEC:: +operator=(const PB_ASSOC_CLASS_C_DEC& r_other) +{ + if (this !=& r_other) + { + PB_ASSOC_CLASS_C_DEC tmp(r_other); + + swap(tmp); + } + + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& r_other) +{ + return (my_base::swap(r_other)); +} diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/null_node_updator_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/null_node_updator_imp.hpp new file mode 100644 index 00000000000..c5662e9b0d8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/null_node_updator_imp.hpp @@ -0,0 +1,49 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_updator_imp.hpp + * Contains an implementation of null_node_updator. + */ + +inline void +null_node_updator:: +swap(null_node_updator& /*r_other*/) +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/order_statistics_imp.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/order_statistics_imp.hpp new file mode 100644 index 00000000000..d4031583c9c --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/tree_policy/order_statistics_imp.hpp @@ -0,0 +1,436 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 order_statistics_imp.hpp + * Contains forward declarations for order_statistics_key + */ + +#ifndef ORDER_STATISTICS_IMP_HPP +#define ORDER_STATISTICS_IMP_HPP + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Key, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key< \ + Key, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key(const_key_reference r_key) : + m_key(r_key), + m_rank(1) +{ } + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +operator typename PB_ASSOC_CLASS_C_DEC::key_reference() +{ + return (m_key); +} + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +operator typename PB_ASSOC_CLASS_C_DEC::key_type() const +{ + return (m_key); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cmp_Fn, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key_cmp< \ + Cmp_Fn, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key_cmp() +{ } + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +order_statistics_key_cmp(const Cmp_Fn& r_cmp_fn) : + Cmp_Fn(r_cmp_fn) +{ } + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +operator()(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const +{ + return Cmp_Fn::operator()((key_type)r_lhs_key, (key_type)r_rhs_key); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::cmp_fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() +{ + return (*this); +} + +PB_ASSOC_CLASS_T_DEC +inline const typename PB_ASSOC_CLASS_C_DEC::cmp_fn& +PB_ASSOC_CLASS_C_DEC:: +get_cmp_fn() const +{ + return (*this); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Key, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_node_updator< \ + Key, \ + Allocator> + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +operator()(const_key_pointer p_key, const_key_pointer p_l_child_key, const_key_pointer p_r_child_key) +{ + /* + * The left rank is 0 if there is no left child, + * or the rank of the left child, otherwise. + */ + const size_type l_rank =(p_l_child_key == NULL)? 0 : p_l_child_key->m_rank; + + /* + * The right rank is 0 if there is no right child, + * or the rank of the right child, otherwise. + */ + const size_type r_rank =(p_r_child_key == NULL)? 0 : p_r_child_key->m_rank; + + /* + * The rand of the entry is the sumb of the ranks of its + * children + 1 (for itself). + */ + p_key->m_rank = 1 + l_rank + r_rank; +} + +PB_ASSOC_CLASS_T_DEC +inline void +PB_ASSOC_CLASS_C_DEC:: +swap(PB_ASSOC_CLASS_C_DEC& /*r_other*/) +{ } + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + find_by_order< \ + Cntnr> + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +operator()(Cntnr& r_c, size_type order) const +{ + return find(r_c, order); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c, size_type order) const +{ + return find(r_c, order); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::const_iterator +PB_ASSOC_CLASS_C_DEC:: +find(const Cntnr& r_c, size_type order) +{ + if (order > r_c.size()) + return (r_c.end()); + + /* + * Start at the top of the tree. + */ + typename Cntnr::const_node_iterator it = r_c.node_begin(); + + /* + * Loop up to a leaf. + */ + while (it != r_c.node_end()) + { + typename Cntnr::const_node_iterator l_it = it.l_child(); + + /* + * The order of the element, o, is the rank of the left + * child (for the entry itself). + */ + const size_type o = (l_it == r_c.node_end())? + 0 :(*l_it)->m_rank; + + /* + * If the current order, o, is the order requested, + * the key has been found. + */ + if (order == o) + return (*it); + /* + * If the current order, o, is larger than the order requested, + * we should move to the left subtree. + */ + else if (order < o) + it = l_it; + /* + * Otherwise adujst the requested order and move to the right subtree. + */ + else + { + order -= o + 1; + + it = it.r_child(); + } + } + + return (r_c.end()); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::iterator +PB_ASSOC_CLASS_C_DEC:: +find(Cntnr& r_c, size_type order) +{ + if (order > r_c.size()) + return (r_c.end()); + + /* + * Start at the top of the tree. + */ + typename Cntnr::node_iterator it = r_c.node_begin(); + + /* + * Loop up to a leaf. + */ + while (it != r_c.node_end()) + { + typename Cntnr::node_iterator l_it = it.l_child(); + + /* + * The order of the element, o, is the rank of the left + * child (for the entry itself). + */ + const size_type o = (l_it == r_c.node_end())? + 0 : + r_c.extract_key(*(*l_it)).m_rank; + + /* + * If the current order, o, is the order requested, + * the key has been found. + */ + if (order == o) + return (*it); + /* + * If the current order, o, is larger than the order requested, + * we should move to the left subtree. + */ + else if (order < o) + it = l_it; + /* + * Otherwise adujst the requested order and move to the right subtree. + */ + else + { + order -= o + 1; + + it = it.r_child(); + } + } + + return (r_c.end()); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr> + +#define PB_ASSOC_CLASS_C_DEC \ + order_by_key< \ + Cntnr> + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c, const underlying_key_type& r_key) const +{ + /* + * The logic here is similar to that in order_by_key. + */ + + typename Cntnr::const_node_iterator it = r_c.node_begin(); + + size_type ord = 0; + + while (it != r_c.node_end()) + { + typename Cntnr::const_node_iterator l_it = it.l_child(); + + if (r_c.get_cmp_fn().get_cmp_fn()( + r_key, + r_c.extract_key(*(*it)).m_key)) + it = l_it; + else if (r_c.get_cmp_fn().get_cmp_fn()( + r_c.extract_key(*(*it)).m_key, + r_key)) + { + + ord += (l_it == r_c.node_end())? + 1 : + 1 + r_c.extract_key(*(*l_it)).m_rank; + + it = it.r_child(); + } + else + { + ord += (l_it == r_c.node_end())? + 0 : + r_c.extract_key(*(*l_it)).m_rank; + + it = r_c.node_end(); + } + } + + return (ord); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Cntnr, class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_key_verifier< \ + Cntnr, \ + Allocator> + +template<class Cntnr, class Allocator = std::allocator<char> > +class order_statistics_key_verifier +{ +public: + typedef Cntnr map; + + typedef Allocator allocator; + + typedef typename allocator::size_type size_type; + + typedef + typename allocator::template rebind<map>::other::const_reference + const_map_reference; + +public: + bool + operator()(const Cntnr& r_c) const; + +private: + typedef typename Cntnr::const_node_iterator const_node_iterator; + + typedef typename Cntnr::const_iterator cntnr_const_it; + + typedef std::pair<bool, size_type> stat; + +private: + static stat + verify_imp(const_node_iterator it, const_node_iterator end_it) + { + if (it == end_it) + return (std::make_pair(true, 0)); + + const stat l_ret = + verify_imp(it.l_child(), end_it); + + const stat r_ret = + verify_imp(it.r_child(), end_it); + + if (!l_ret.first || !r_ret.first) + return (std::make_pair(false, 0)); + + if ((*it)->m_rank != 1 + l_ret.second + r_ret.second) + return (std::make_pair(false, 0)); + + return (std::make_pair(true, (*it)->m_rank)); + } +}; + +PB_ASSOC_CLASS_T_DEC +bool +PB_ASSOC_CLASS_C_DEC:: +operator()(const Cntnr& r_c) const +{ + const stat top_stat = + verify_imp(r_c.node_begin(), r_c.node_end()); + + return (top_stat.first); +} + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#endif // #ifndef ORDER_STATISTICS_IMP_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/type_utils.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/type_utils.hpp new file mode 100644 index 00000000000..d288a371032 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/type_utils.hpp @@ -0,0 +1,449 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 type_utils.hpp + * Contains utilities for handnling types. All of these classes are based on + * "Modern C++" by Andrei Alxandrescu. + */ + +#ifndef TYPE_UTILS_HPP +#define TYPE_UTILS_HPP + +#include <cstddef> +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + + template<bool> + struct static_assert; + + template<> + struct static_assert<true> + { }; + + template<int> + struct static_assert_dummy_class + { + enum + { + v = 1 + }; + }; + + template<class T, class U> + class is_same_type + { + public: + enum + { + value = false + }; + }; + + template<class T> + class is_same_type< + T, + T> + { + public: + enum + { + value = true + }; + }; + + template<int n> + struct int_to_type + { + enum + { + value = n + }; + }; + + template<typename Type> + struct type_to_type + { + typedef Type type; + }; + + template<typename T> + class unconst + { + private: + template<class U> + struct unconst_imp + { + typedef U type; + }; + + template<class U> + struct unconst_imp< + const U> + { + typedef U type; + }; + public: + typedef typename unconst_imp<T>::type type; + }; + + template<typename T> + class unreference + { + private: + template<class U> + struct unreference_imp + { + typedef U type; + }; + + template<class U> + struct unreference_imp<U&> + { + typedef U type; + }; + public: + typedef typename unreference_imp<T>::type type; + }; + + /* is_const_type + * Idea by Andrei Alecsandrescu + * (Modern C++ Design: Generic Programming and Design Patterns Applied) + **/ + template<typename T> + class is_const_type + { + private: + template<class U> + struct is_const_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U> + struct is_const_type_imp<const U> + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_const_type_imp<T>::value + }; + }; + + /* is_pointer_type + **/ + template<typename T> + class is_pointer_type + { + private: + template<class U> + struct is_pointer_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U> + struct is_pointer_type_imp + <U* > + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_pointer_type_imp<T>::value + }; + }; + + /* is_pointer_type + **/ + template<typename T> + class is_const_pointer_type + { + private: + template<class U> + struct is_const_pointer_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U> + struct is_const_pointer_type_imp + <const U* > + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_const_pointer_type_imp<T>::value + }; + }; + + template<typename T> + class is_reference_type + { + private: + template<class U> + struct is_reference_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U> + struct is_reference_type_imp<U& > + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_reference_type_imp<T>::value + }; + }; + + template<typename T> + class is_const_reference_type + { + private: + template<class U> + struct is_const_reference_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U> + struct is_const_reference_type_imp<U& > + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_const_reference_type_imp<T>::value + }; + }; + + template<typename T> + class is_member_pointer_type + { + private: + template<typename U> + struct is_member_pointer_type_imp + { + enum + { + value = 0 + }; + }; + + template<typename U, typename V> + struct is_member_pointer_type_imp< + U V::*> + { + enum + { + value = 1 + }; + }; + + public: + enum + { + value = is_member_pointer_type_imp<T>::value + }; + }; + +#define PB_ASSOC_IS_SAME_TYPE(TYPE) is_same_type<T, TYPE>::value + + template<class T> + class is_simple_type + { + template<class U> + struct is_simple_type_imp + { + enum + { + value = 0 + }; + }; + + template<class U, size_t M> + struct is_simple_type_imp< + U[M]> + { + enum + { + value = is_simple_type<U>::value + }; + }; + + template<class U> + struct is_simple_type_imp< + U[]> + { + enum + { + value = is_simple_type<U>::value + }; + }; + + template<typename T0, typename T1> + struct is_simple_type_imp< + std::pair< + T0, + T1> > + { + enum + { + value = is_simple_type<T0>::value&& + is_simple_type<T1>::value + }; + }; + + public: + enum + { + value = + PB_ASSOC_IS_SAME_TYPE(void) || + PB_ASSOC_IS_SAME_TYPE(size_t) || + PB_ASSOC_IS_SAME_TYPE(const void) || + PB_ASSOC_IS_SAME_TYPE(unsigned char) || + PB_ASSOC_IS_SAME_TYPE(unsigned short int) || + PB_ASSOC_IS_SAME_TYPE(unsigned int) || + PB_ASSOC_IS_SAME_TYPE(unsigned long int) || + PB_ASSOC_IS_SAME_TYPE(signed char) || + PB_ASSOC_IS_SAME_TYPE(signed short int) || + PB_ASSOC_IS_SAME_TYPE(int) || + PB_ASSOC_IS_SAME_TYPE(long int) || + PB_ASSOC_IS_SAME_TYPE(bool) || + PB_ASSOC_IS_SAME_TYPE(char) || + PB_ASSOC_IS_SAME_TYPE(float) || + PB_ASSOC_IS_SAME_TYPE(double) || + PB_ASSOC_IS_SAME_TYPE(long double) || + PB_ASSOC_IS_SAME_TYPE(const unsigned char) || + PB_ASSOC_IS_SAME_TYPE(const unsigned short int) || + PB_ASSOC_IS_SAME_TYPE(const unsigned int) || + PB_ASSOC_IS_SAME_TYPE(const unsigned long int) || + PB_ASSOC_IS_SAME_TYPE(const signed char) || + PB_ASSOC_IS_SAME_TYPE(const signed short int) || + PB_ASSOC_IS_SAME_TYPE(const int) || + PB_ASSOC_IS_SAME_TYPE(const long int) || + PB_ASSOC_IS_SAME_TYPE(const bool) || + PB_ASSOC_IS_SAME_TYPE(const char) || + PB_ASSOC_IS_SAME_TYPE(const float) || + PB_ASSOC_IS_SAME_TYPE(const double) || + PB_ASSOC_IS_SAME_TYPE(const long double) || + is_pointer_type<T>::value || + is_const_pointer_type<T>::value || + is_member_pointer_type<T>::value || + is_simple_type_imp<T>::value + }; + }; + +#undef PB_ASSOC_IS_SAME_TYPE + + template<bool Cond, class A, class B> + struct cond_type; + + template<class A, class B> + struct cond_type< + true, + A, + B> + { + typedef A type; + }; + + template<class A, class B> + struct cond_type< + false, + A, + B> + { + typedef B type; + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef TYPE_UTILS_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist.hpp new file mode 100644 index 00000000000..213e960f3da --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist.hpp @@ -0,0 +1,220 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist.hpp + * Contains typelist_chain definitions. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_HPP +#define TYPELIST_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace pb_assoc +{ + + namespace detail + { + + struct null_type + { }; + + template<typename Hd, typename Tl> + struct typelist_chain + { + typedef Hd head; + + typedef Tl tail; + }; + + template<class Root> + struct typelist + { + typedef Root root; + }; + +#define PB_ASSOC_TYPELIST_CHAIN1(X0) pb_assoc::detail::typelist_chain<X0, pb_assoc::detail::null_type> +#define PB_ASSOC_TYPELIST_CHAIN2(X0, X1) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN1(X1) > +#define PB_ASSOC_TYPELIST_CHAIN3(X0, X1, X2) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN2(X1, X2) > +#define PB_ASSOC_TYPELIST_CHAIN4(X0, X1, X2, X3) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN3(X1, X2, X3) > +#define PB_ASSOC_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN4(X1, X2, X3, X4) > +#define PB_ASSOC_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) > +#define PB_ASSOC_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) > +#define PB_ASSOC_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) > +#define PB_ASSOC_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) > +#define PB_ASSOC_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) > +#define PB_ASSOC_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) > +#define PB_ASSOC_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) > +#define PB_ASSOC_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) > +#define PB_ASSOC_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) > +#define PB_ASSOC_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) > + +#include <ext/pb_assoc/detail/typelist/typelist_apply.hpp> + + template<class Fn, class Typelist> + void + typelist_apply(Fn& r_fn, Typelist /*tl*/) + { + detail::apply_< + Fn, + typename Typelist::root> + a; + + a(r_fn); + } + +#include <ext/pb_assoc/detail/typelist/typelist_append.hpp> + + template<class Typelist0, class Typelist1> + struct typelist_append + { + private: + typedef + typename detail::typelist_append_< + typename Typelist0::root, + typename Typelist1::root>::type + res_hd; + + public: + typedef typelist< res_hd> type; + }; + +#include <ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp> + + template<class Typelist_Typelist> + struct typelist_typelist_append + { + private: + typedef + typename detail::typelist_typelist_append_< + typename Typelist_Typelist::root>::type + res_hd; + + public: + typedef typelist< res_hd> type; + }; + +#include <ext/pb_assoc/detail/typelist/typelist_contains.hpp> + + template<class Typelist, class T> + struct typelist_contains + { + enum + { + value = + detail::typelist_contains_< + typename Typelist::root, + T>::value + }; + }; + +#include <ext/pb_assoc/detail/typelist/typelist_filter.hpp> + + template<class Typelist, template<typename T> + class Pred> + struct typelist_filter + { + private: + typedef + typename detail::typelist_chain_filter_< + typename Typelist::root, + Pred>::type + root_type; + + public: + typedef typelist< root_type> type; + }; + +#include <ext/pb_assoc/detail/typelist/typelist_at_index.hpp> + + template<class Typelist, int i> + struct typelist_at_index + { + typedef + typename detail::typelist_chain_at_index_< + typename Typelist::root, + i>::type + type; + }; + +#include <ext/pb_assoc/detail/typelist/typelist_transform.hpp> + + template<class Typelist, template<class T> + class Transform> + struct typelist_transform + { + private: + typedef + typename detail::typelist_chain_transform_< + typename Typelist::root, + Transform>::type + root_type; + + public: + typedef typelist< root_type> type; + }; + +#undef PB_ASSOC_TYPELIST_CHAIN1 +#undef PB_ASSOC_TYPELIST_CHAIN2 +#undef PB_ASSOC_TYPELIST_CHAIN3 +#undef PB_ASSOC_TYPELIST_CHAIN4 +#undef PB_ASSOC_TYPELIST_CHAIN5 +#undef PB_ASSOC_TYPELIST_CHAIN6 +#undef PB_ASSOC_TYPELIST_CHAIN7 +#undef PB_ASSOC_TYPELIST_CHAIN8 +#undef PB_ASSOC_TYPELIST_CHAIN9 +#undef PB_ASSOC_TYPELIST_CHAIN10 +#undef PB_ASSOC_TYPELIST_CHAIN11 +#undef PB_ASSOC_TYPELIST_CHAIN12 +#undef PB_ASSOC_TYPELIST_CHAIN13 +#undef PB_ASSOC_TYPELIST_CHAIN14 +#undef PB_ASSOC_TYPELIST_CHAIN15 + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef TYPELIST_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_append.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_append.hpp new file mode 100644 index 00000000000..9adc8230753 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_append.hpp @@ -0,0 +1,84 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_append.hpp + * Contains typelist_chain utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_APPEND_HPP +#define TYPELIST_APPEND_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Chain0, class Typelist_Chain1> + struct typelist_append_; + + template<typename Hd, typename Tl, class Typelist_Chain1> + struct typelist_append_< + typelist_chain<Hd, Tl>, + Typelist_Chain1> + { + typedef + typelist_chain< + Hd, + typename typelist_append_<Tl, Typelist_Chain1>::type> + type; + }; + + template<class Typelist_Chain1> + struct typelist_append_< + null_type, + Typelist_Chain1> + { + typedef Typelist_Chain1 type; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_APPEND_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_apply.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_apply.hpp new file mode 100644 index 00000000000..6d6bbf94782 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_apply.hpp @@ -0,0 +1,90 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_apply.hpp + * Contains typelist utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_APPLY_HPP +#define TYPELIST_APPLY_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Fn, class Typelist_Chain> + struct apply_; + + template<class Fn, class Hd, class Tl> + struct apply_< + Fn, + typelist_chain<Hd, Tl> > + { + void + operator()(Fn& r_fn) + { + r_fn(Hd()); + + apply_<Fn, Tl> next; + + next(r_fn); + } + }; + + template<class Fn> + struct apply_< + Fn, + null_type> + { + void + operator()(Fn& /*r_fn*/) + { } + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_APPLY_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_at_index.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_at_index.hpp new file mode 100644 index 00000000000..bb7f41e0526 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_at_index.hpp @@ -0,0 +1,80 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_at_index.hpp + * Contains typelist utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_AT_INDEX_HPP +#define TYPELIST_AT_INDEX_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Chain, int i> + struct typelist_chain_at_index_; + + template<class Hd, class Tl> + struct typelist_chain_at_index_< + typelist_chain<Hd, Tl>, + 0> + { + typedef Hd type; + }; + + template<class Hd, class Tl, int i> + struct typelist_chain_at_index_< + typelist_chain<Hd, Tl>, + i> + { + typedef typename typelist_chain_at_index_< Tl, i - 1>::type type; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_AT_INDEX_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_contains.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_contains.hpp new file mode 100644 index 00000000000..a67448ec640 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_contains.hpp @@ -0,0 +1,99 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_contains.hpp + * Contains typelist utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_CONTAINS_HPP +#define TYPELIST_CONTAINS_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Chain, class T> + struct typelist_contains_; + + template<class T> + struct typelist_contains_< + null_type, + T> + { + enum + { + value = false + }; + }; + + template<class Hd, class Tl, class T> + struct typelist_contains_< + typelist_chain<Hd, Tl>, + T> + { + enum + { + value = + typelist_contains_< + Tl, T>::value + }; + }; + + template<class Tl, class T> + struct typelist_contains_< + typelist_chain<T, Tl>, + T> + { + enum + { + value = true + }; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_CONTAINS_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_filter.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_filter.hpp new file mode 100644 index 00000000000..ea8f45d2ee4 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_filter.hpp @@ -0,0 +1,97 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_filter.hpp + * Contains typelist utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_FILTER_HPP +#define TYPELIST_FILTER_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Chain, template<typename T> + class Pred> + struct typelist_chain_filter_; + + template<template<typename T> + class Pred> + struct typelist_chain_filter_< + null_type, + Pred> + { + typedef null_type type; + }; + + template<class Hd, class Tl, template<typename T> + class Pred> + struct typelist_chain_filter_< + typelist_chain<Hd, Tl>, + Pred> + { + typedef typename typelist_chain_filter_< Tl, Pred>::type rest; + + enum + { + include_hd = Pred<Hd>::value + }; + + typedef + typename cond_type< + include_hd, + typelist_chain< + Hd, + rest>, + rest>::type + type; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_FILTER_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_transform.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_transform.hpp new file mode 100644 index 00000000000..409e69723c7 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_transform.hpp @@ -0,0 +1,87 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_transform.hpp + * Contains typelist utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_TRANSFORM_HPP +#define TYPELIST_TRANSFORM_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Chain, template<typename T> + class Transform> + struct typelist_chain_transform_; + + template<template<typename T> + class Transform> + struct typelist_chain_transform_< + null_type, + Transform> + { + typedef null_type type; + }; + + template<class Hd, class Tl, template<typename T> + class Transform> + struct typelist_chain_transform_< + typelist_chain<Hd, Tl>, + Transform> + { + typedef typename typelist_chain_transform_< Tl, Transform>::type rest; + + typedef typename Transform<Hd>::type my_type; + + typedef typelist_chain< my_type, rest> type; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_TRANSFORM_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp new file mode 100644 index 00000000000..bcc1ca249ef --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp @@ -0,0 +1,89 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist_typelist_append.hpp + * Contains typelist_chain utilities. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_TYPELIST_APPEND_HPP +#define TYPELIST_TYPELIST_APPEND_HPP + +#ifdef _MSC_VER +#pragma warning(disable: 4503) +#endif // #ifdef _MSC_VER + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace detail +{ + + template<class Typelist_Typelist_Chain> + struct typelist_typelist_append_; + + template<typename Hd> + struct typelist_typelist_append_< + typelist_chain<Hd, null_type> > + { + typedef typelist_chain< Hd, null_type> type; + }; + + template<class Hd, class Tl> + struct typelist_typelist_append_< + typelist_chain< + Hd, + Tl> > + { + private: + typedef typename typelist_typelist_append_< Tl>::type rest; + + public: + typedef + typename typelist_append< + Hd, + typelist< + rest> >::type::root + type; + }; + +} // namespace detail + +#endif // #ifndef TYPELIST_TYPELIST_APPEND_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/types_traits.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/types_traits.hpp new file mode 100644 index 00000000000..a76a5379457 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/types_traits.hpp @@ -0,0 +1,295 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 types_traits.hpp + * Contains a traits class of types used by containers. + */ + +#ifndef TYPES_TRAITS_HPP +#define TYPES_TRAITS_HPP + +#include <ext/pb_assoc/data_type.hpp> +#include <ext/pb_assoc/detail/type_utils.hpp> +#include <utility> + +namespace pb_assoc +{ + + namespace detail + { + + template<typename Data, class Allocator> + struct basic_data_types_traits + { + + public: + + typedef + typename Allocator::template rebind< + Data>::other::value_type + data_type; + + typedef + typename Allocator::template rebind< + Data>::other::pointer + data_pointer; + + typedef + typename Allocator::template rebind< + Data>::other::const_pointer + const_data_pointer; + + typedef + typename Allocator::template rebind< + Data>::other::reference + data_reference; + + typedef + typename Allocator::template rebind< + Data>::other::const_reference + const_data_reference; + + }; + + template<typename Data, class Allocator> + struct data_types_traits : public basic_data_types_traits< + Data, + Allocator> + { + + public: + + typedef Data given_data_type; + + }; + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Allocator> + +#define PB_ASSOC_CLASS_C_DEC \ + data_types_traits< \ + null_data_type, \ + Allocator> + + template<class Allocator> + struct data_types_traits< + null_data_type, + Allocator> : public basic_data_types_traits< + null_data_type, + Allocator> + { + + public: + + typedef null_data_type given_data_type; + + }; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + + template<class Cntnr, class Allocator> + struct data_types_traits< + compound_data_type< + Cntnr>, + Allocator> : public basic_data_types_traits< + Cntnr, + Allocator> + { + + public: + + typedef compound_data_type< Cntnr> given_data_type; + + }; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Key, typename Data> + +#define PB_ASSOC_CLASS_C_DEC \ + exception_throw_types_traits< \ + Key, \ + Data> + + template<typename Key, typename Data> + struct exception_throw_types_traits + { + + public: + + typedef int_to_type<false> no_throw_copies_false_indicator; + + typedef int_to_type<true> no_throw_copies_true_indicator; + + private: + enum + { + key_no_throw = is_simple_type<Key>::value, + data_no_throw = is_same_type<Data, null_data_type>::value || + is_simple_type<Data>::value, + no_throw_copies = key_no_throw&& data_no_throw + }; + + typedef int_to_type<no_throw_copies> no_throw_copies_t; + + public: + static no_throw_copies_t s_no_throw_copies_indicator; + }; + + PB_ASSOC_CLASS_T_DEC + typename PB_ASSOC_CLASS_C_DEC::no_throw_copies_t + PB_ASSOC_CLASS_C_DEC::s_no_throw_copies_indicator; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + + template<typename Key, typename Data, class Allocator> + struct value_types_traits + { + + public: + + typedef + typename Allocator::template rebind< + std::pair<const Key, Data> >::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; + + }; + + template<typename Key, class Allocator> + struct value_types_traits< + Key, + null_data_type, + Allocator> + { + + public: + + typedef + typename Allocator::template rebind< + Key>::other + value_type_allocator; + + typedef typename value_type_allocator::value_type value_type; + + typedef typename value_type_allocator::const_pointer pointer; + + typedef typename value_type_allocator::const_pointer const_pointer; + + typedef typename value_type_allocator::const_reference reference; + + typedef typename value_type_allocator::const_reference const_reference; + + }; + + template<typename Key, class Cntnr, class Allocator> + struct value_types_traits< + Key, + compound_data_type< + Cntnr>, + Allocator> + { + private: + + typedef + typename Allocator::template rebind< + std::pair<const Key, Cntnr> >::other + value_type_allocator; + + public: + + 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; + + }; + + template<typename Key, typename Data, class Allocator> + struct types_traits : public data_types_traits< + Data, + Allocator>, +public value_types_traits< + Key, + Data, + Allocator>, +public exception_throw_types_traits< + Key, + Data> + { + + public: + + typedef typename Allocator::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; + + }; + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef TYPES_TRAITS_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp new file mode 100644 index 00000000000..aa48f199bc8 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_find_iterator.hpp @@ -0,0 +1,138 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_find_iterator.hpp + * Contains an iterator class returned by the tables' const find and insert + * methods. + */ + +class find_iterator_; + +class const_find_iterator_ +{ + +public: + + typedef trivial_iterator_tag iterator_category; + + typedef trivial_iterator_difference_type difference_type; + + typedef mapped_value_type value_type; + + typedef mapped_pointer pointer; + + typedef const_mapped_pointer const_pointer; + + typedef mapped_reference reference; + + typedef const_mapped_reference const_reference; + +public: + + inline + const_find_iterator_(const_pointer p_value) : m_p_value(p_value) + { } + + inline + const_find_iterator_() + + : m_p_value(NULL) + { } + + inline + const_find_iterator_(const const_find_iterator_& r_other) + + : m_p_value(r_other.m_p_value) + { } + + inline + const_find_iterator_(const find_iterator_& r_other) + + : m_p_value(r_other.m_p_value) + { } + + inline const_pointer + operator->() const + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (m_p_value); + } + + inline const_reference + operator*() const + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (*m_p_value); + } + + inline bool + operator==(const find_iterator_& r_other) const + { + return (m_p_value == r_other.m_p_value); + } + + inline bool + operator==(const const_find_iterator_& r_other) const + { + return (m_p_value == r_other.m_p_value); + } + + inline bool + operator!=(const find_iterator_& r_other) const + { + return (m_p_value != r_other.m_p_value); + } + + inline bool + operator!=(const const_find_iterator_& r_other) const + { + return (m_p_value != r_other.m_p_value); + } + +protected: + const_pointer m_p_value; + + friend class find_iterator_; + + friend class PB_ASSOC_CLASS_C_DEC; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp new file mode 100644 index 00000000000..b137a39e8af --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/const_iterator.hpp @@ -0,0 +1,122 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_iterator.hpp + * Contains an iterator class used for const ranging over the elements of the + * table. + */ + +class const_iterator_ : + public const_find_iterator_ + +{ + +public: + + typedef std::forward_iterator_tag iterator_category; + + typedef typename Allocator::difference_type difference_type; + + typedef mapped_value_type value_type; + + typedef mapped_pointer pointer; + + typedef const_mapped_pointer const_pointer; + + typedef mapped_reference reference; + + typedef const_mapped_reference const_reference; + +public: + + inline + const_iterator_() + + : m_p_tbl(NULL) + { } + + inline const_iterator_& + operator++() + { + m_p_tbl->inc_it_state(my_base::m_p_value, m_pos); + + return (*this); + } + + inline const_iterator_ + operator++(int) + { + const_iterator_ ret =* this; + + m_p_tbl->inc_it_state(my_base::m_p_value, m_pos); + + return (ret); + } + +protected: + + typedef const_find_iterator_ my_base; + +protected: + + /** + * Constructor used by the table to initiate the generalized + * pointer and position (e.g., this is called from within a find() + * of a table. + **/ + inline + const_iterator_(const_mapped_pointer p_value, PB_ASSOC_GEN_POS pos, const PB_ASSOC_CLASS_C_DEC* p_tbl) : const_find_iterator_(p_value), + m_p_tbl(p_tbl), + m_pos(pos) + { } + +protected: + + /** + * Pointer to the table object which created the iterator (used for + * incrementing its position. + **/ + const PB_ASSOC_CLASS_C_DEC* m_p_tbl; + + PB_ASSOC_GEN_POS m_pos; + + friend class PB_ASSOC_CLASS_C_DEC; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp new file mode 100644 index 00000000000..0c65a504edf --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/find_iterator.hpp @@ -0,0 +1,147 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_iterator.hpp + * Contains an iterator class returned by the tables' find and insert + * methods. + */ + +class find_iterator_ +{ + +public: + + typedef trivial_iterator_tag iterator_category; + + typedef trivial_iterator_difference_type difference_type; + + typedef mapped_value_type value_type; + + typedef mapped_pointer pointer; + + typedef const_mapped_pointer const_pointer; + + typedef mapped_reference reference; + + typedef const_mapped_reference const_reference; + +public: + + inline + find_iterator_() + + : m_p_value(NULL) + { } + + inline + find_iterator_(const find_iterator_& r_other) + + : m_p_value(r_other.m_p_value) + { } + + inline pointer + operator->() + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (m_p_value); + } + + inline const_pointer + operator->() const + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (m_p_value); + } + + inline reference + operator*() + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (*m_p_value); + } + + inline const_reference + operator*() const + { + PB_ASSOC_DBG_ASSERT(m_p_value != NULL); + + return (*m_p_value); + } + + inline bool + operator==(const find_iterator_& r_other) const + { + return (m_p_value == r_other.m_p_value); + } + + inline bool + operator==(const const_find_iterator_& r_other) const + { + return (m_p_value == r_other.m_p_value); + } + + inline bool + operator!=(const find_iterator_& r_other) const + { + return (m_p_value != r_other.m_p_value); + } + + inline bool + operator!=(const const_find_iterator_& r_other) const + { + return (m_p_value != r_other.m_p_value); + } + + inline + find_iterator_(pointer p_value) : m_p_value(p_value) + { } + +protected: + friend class const_find_iterator_; + + friend class PB_ASSOC_CLASS_C_DEC; + +protected: + pointer m_p_value; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/iterator.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/iterator.hpp new file mode 100644 index 00000000000..e42790411e7 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/unordered_iterator/iterator.hpp @@ -0,0 +1,139 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterator.hpp + * Contains an iterator_ class used for ranging over the elements of the + * table. + */ + +class iterator_ : + public const_iterator_ + +{ + +public: + + typedef std::forward_iterator_tag iterator_category; + + typedef typename Allocator::difference_type difference_type; + + typedef mapped_value_type value_type; + + typedef mapped_pointer pointer; + + typedef const_mapped_pointer const_pointer; + + typedef mapped_reference reference; + + typedef const_mapped_reference const_reference; + +public: + + inline + iterator_() + + : const_iterator_(NULL, PB_ASSOC_GEN_POS(), NULL) + { } + + inline + operator find_iterator_() + { + return (find_iterator_( + const_cast<pointer>(const_iterator_::m_p_value))); + } + + inline + operator const find_iterator_() const + { + return (find_iterator_( + const_cast<pointer>(const_iterator_::m_p_value))); + } + + inline pointer + operator->() + { + PB_ASSOC_DBG_ASSERT(my_base::m_p_value != NULL); + + return (const_cast<pointer>(my_base::m_p_value)); + } + + inline reference + operator*() + { + PB_ASSOC_DBG_ASSERT(my_base::m_p_value != NULL); + + return (*(operator->())); + } + + inline iterator_& + operator++() + { + my_base::m_p_tbl->inc_it_state(my_base::m_p_value, my_base::m_pos); + + return (*this); + } + + inline iterator_ + operator++(int) + { + iterator_ ret =* this; + + my_base::m_p_tbl->inc_it_state(my_base::m_p_value, my_base::m_pos); + + return (ret); + } + +protected: + typedef const_iterator_ my_base; + +protected: + + /** + * Constructor used by the table to initiate the generalized + * pointer and position (e.g., this is called from within a find() + * of a table. + **/ + inline + iterator_(pointer p_value, PB_ASSOC_GEN_POS pos, PB_ASSOC_CLASS_C_DEC* p_tbl) : const_iterator_(p_value, pos, p_tbl) + { } + + friend class PB_ASSOC_CLASS_C_DEC; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/constructor_destructor_and_related.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/constructor_destructor_and_related.hpp new file mode 100644 index 00000000000..4ca05081893 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/constructor_destructor_and_related.hpp @@ -0,0 +1,183 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 constructor_destructor_and_related.hpp + * Contains an adapter of mapping levels. + */ + +PB_ASSOC_CLASS_T_DEC +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter() +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0) : + my_base(t0) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1) : + my_base(t0, t1) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1, typename T2> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2) : + my_base(t0, t1, t2) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, typename T1, typename T2, typename T3> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3) : + my_base(t0, t1, t2, t3) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) : + my_base(t0, t1, t2, t3, t4) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : + my_base(t0, + t1, + t2, + t3, + t4, + t5) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : + my_base(t0, + t1, + t2, + t3, + t4, + t5, + t6) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : + my_base(t0, + t1, + t2, + t3, + t4, + t5, + t6, + t7) +{ } + +PB_ASSOC_CLASS_T_DEC +template<typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8> +inline +PB_ASSOC_CLASS_C_DEC:: +value_type_adapter(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) : + my_base(t0, + t1, + t2, + t3, + t4, + t5, + t6, + t7, + t8) +{ } + +PB_ASSOC_CLASS_T_DEC +PB_ASSOC_CLASS_C_DEC:: +~value_type_adapter() +{ } + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_fn_imps.hpp new file mode 100644 index 00000000000..ffe4997f176 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_fn_imps.hpp @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_fn_imps.hpp + * Contains an adapter of mapping levels. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_if_pred.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_if_pred.hpp new file mode 100644 index 00000000000..b23b543f114 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/erase_if_pred.hpp @@ -0,0 +1,72 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 erase_if_pred.hpp + * Contains a bridge erase_if predicate + */ + +template<class Pred> +class erase_if_pred +{ +public: + // Tmp Ami all erase-ifs should take a reference to a predicate? + erase_if_pred(Pred& r_pred, typename my_base::iterator base_it) : m_r_pred(r_pred), + m_base_it(base_it) + { } + + inline bool + operator()(typename my_base_data_type::iterator::reference r_val) + { + it_value_type_traits_t::make_valid(m_value_type_holder, m_base_it->first, r_val); + + typename it_value_type_traits_t::pointer p_exp_val = + it_value_type_traits_t::recast(m_value_type_holder); + + return (m_r_pred(*p_exp_val)); + } + +private: + Pred& m_r_pred; + + typename my_base::iterator m_base_it; + + typename it_value_type_traits_t::value_type_holder m_value_type_holder; +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/find_fn_imps.hpp new file mode 100644 index 00000000000..4279981b39b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/find_fn_imps.hpp @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 find_fn_imps.hpp + * Contains an adapter of mapping levels. + */ diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/info_fn_imps.hpp new file mode 100644 index 00000000000..43ba91ecf6e --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/info_fn_imps.hpp @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 info_fn_imps.hpp + * Contains an adapter of mapping levels. + */ + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +size() const +{ + return (std::distance(begin(), end())); +} + +PB_ASSOC_CLASS_T_DEC +inline typename PB_ASSOC_CLASS_C_DEC::size_type +PB_ASSOC_CLASS_C_DEC:: +max_size() const +{ + return (my_base::max_size()); +} + +PB_ASSOC_CLASS_T_DEC +inline bool +PB_ASSOC_CLASS_C_DEC:: +empty() const +{ + return (size() == 0); +} + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/insert_fn_imps.hpp new file mode 100644 index 00000000000..058671ddb94 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/insert_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 insert_fn_imps.hpp + * Contains an adapter of mapping levels. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/invalidation_guarantee_selector.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/invalidation_guarantee_selector.hpp new file mode 100644 index 00000000000..7e7b3b32ad5 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/invalidation_guarantee_selector.hpp @@ -0,0 +1,128 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 invalidation_guarantee_selector.hpp + * Contains an adapter of mapping levels. + */ + +namespace pb_assoc +{ + + namespace detail + { + + template<class IG0, class IG1> + struct ig_sel; + + template<> + struct ig_sel< + basic_invalidation_guarantee, + basic_invalidation_guarantee> + { + typedef basic_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + basic_invalidation_guarantee, + find_invalidation_guarantee> + { + typedef basic_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + basic_invalidation_guarantee, + range_invalidation_guarantee> + { + typedef basic_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + find_invalidation_guarantee, + basic_invalidation_guarantee> + { + typedef basic_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + find_invalidation_guarantee, + find_invalidation_guarantee> + { + typedef find_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + find_invalidation_guarantee, + range_invalidation_guarantee> + { + typedef find_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + range_invalidation_guarantee, + basic_invalidation_guarantee> + { + typedef basic_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + range_invalidation_guarantee, + find_invalidation_guarantee> + { + typedef find_invalidation_guarantee type; + }; + + template<> + struct ig_sel< + range_invalidation_guarantee, + range_invalidation_guarantee> + { + typedef range_invalidation_guarantee type; + }; + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/it_value_type_traits.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/it_value_type_traits.hpp new file mode 100644 index 00000000000..4ca59bb13ad --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/it_value_type_traits.hpp @@ -0,0 +1,224 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 it_value_type_traits.hpp + * Contains an adapter of mapping levels. + */ + +template<class Base, bool Lowest> +struct base_it_key_type +{ + typedef typename Base::it_key_type type; +}; + +template<class Base> +struct base_it_key_type< + Base, + true> +{ + typedef typename Base::const_key_reference type; +}; + +template<typename Base_Key_, + typename Key_, + typename Data_, + typename Value_, + class Allocator_ > +struct it_value_type_traits_ +{ + typedef ref_pair< Base_Key_, Key_> key_ref_pair; + + typedef + typename Allocator_::template rebind< + key_ref_pair>::other::const_reference + key_ref_pair_val; + + typedef key_ref_pair_val key_type; + + typedef ref_pair< key_ref_pair_val, Data_> value_type; + + typedef + typename Allocator_::template rebind< + value_type>::other::reference + reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + const_reference; + + 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< + int* >::other::value_type + buf_t; + + struct value_type_holder + { + buf_t m_a_key_buf[sizeof(key_ref_pair) / sizeof(buf_t) + 1]; + + buf_t m_a_value_buf[sizeof(value_type) / sizeof(buf_t) + 1]; + }; + + typedef + typename Allocator_::template rebind< + value_type_holder>::other::reference + value_type_hoder_valerence; + + inline static pointer + recast(value_type_hoder_valerence r_holder) + { + return reinterpret_cast<pointer>(r_holder.m_a_value_buf); + } + + inline static void + make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val) + { + typedef + typename Allocator_::template rebind< + void* >::other::value_type + void_pointer; + + void_pointer p_target = r_holder.m_a_key_buf; + + new (p_target) key_ref_pair(r_bk, r_val.first); + + typedef + typename Allocator_::template rebind< + key_ref_pair>::other::pointer + key_ref_pair_pointer; + + key_ref_pair_pointer p_key = + reinterpret_cast<key_ref_pair_pointer>(r_holder.m_a_key_buf); + + p_target = r_holder.m_a_value_buf; + + new (p_target) value_type(*p_key, r_val.second); + } +}; + +template<typename Base_Key_, + typename Key_, + typename Value_, + class Allocator_> +struct it_value_type_traits_< + Base_Key_, + Key_, + null_data_type, + Value_, + Allocator_> +{ + typedef ref_pair< Base_Key_, Key_> key_ref_pair; + + typedef + typename Allocator_::template rebind< + key_ref_pair>::other::const_reference + key_ref_pair_val; + + typedef key_ref_pair_val key_type; + + typedef key_ref_pair value_type; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + const_reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_pointer + pointer; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_pointer + const_pointer; + + typedef + typename Allocator_::template rebind< + int* >::other::value_type + buf_t; + + struct value_type_holder + { + buf_t m_a_key_buf[sizeof(key_ref_pair) / sizeof(buf_t) + 1]; + + buf_t m_a_value_buf[sizeof(value_type) / sizeof(buf_t) + 1]; + }; + + typedef + typename Allocator_::template rebind< + value_type_holder>::other::reference + value_type_hoder_valerence; + + inline static pointer + recast(value_type_hoder_valerence r_holder) + { + return reinterpret_cast<pointer>(r_holder.m_a_value_buf); + } + + inline static void + make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val) + { + typedef + typename Allocator_::template rebind< + void* >::other::value_type + void_pointer; + + void_pointer p_target = r_holder.m_a_value_buf; + + new (p_target) key_ref_pair(r_bk, r_val.first); + } +}; + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator.hpp new file mode 100644 index 00000000000..e3ed301c4d9 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator.hpp @@ -0,0 +1,196 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 it_.hpp + * Contains an it_ for an adapter of mapping levels. + */ + +#define PB_ASSOC_IT_C_DEC \ + it_< \ + It0, \ + It1, \ + Has_Data, \ + Const> + +#define PB_ASSOC_OIT_T_DEC \ + template<class OIt0, class OIt1, bool OHas_Data, bool OConst> + +#define PB_ASSOC_OIT_C_DEC \ + it_< \ + OIt0, \ + OIt1, \ + OHas_Data, \ + OConst> + +template<class It0, class It1, bool Has_Data, bool Const> +class it_ +{ +public: + + typedef typename it_value_type_traits_t::value_type value_type; + + typedef typename it_value_type_traits_t::reference reference; + + typedef + typename it_value_type_traits_t::const_reference + const_reference; + + typedef typename it_value_type_traits_t::pointer pointer; + + typedef typename it_value_type_traits_t::const_pointer const_pointer; + +public: + inline + it_(It0 it0 = It0(), + It0 end_it0 = It0(), + It1 it1 = It1()) : m_it0(it0), + m_end_it0(end_it0), + m_it1(it1) + { } + + inline + it_(const PB_ASSOC_IT_C_DEC& r_other) : m_it0(r_other.m_it0), + m_end_it0(r_other.m_end_it0), + m_it1(r_other.m_it1) + { } + + PB_ASSOC_OIT_T_DEC + inline + it_(const PB_ASSOC_OIT_C_DEC& r_other) : m_it0(r_other.m_it0), + m_end_it0(r_other.m_end_it0), + m_it1(r_other.m_it1) + { } + + inline bool + operator==(const PB_ASSOC_IT_C_DEC& r_other) const + { + if (m_it0 != r_other.m_it0) + return (false); + + if (m_it0 == m_end_it0) + return (true); + + return (m_it1 == r_other.m_it1); + } + + inline bool + operator!=(const PB_ASSOC_IT_C_DEC& r_other) const + { + return (!operator==(r_other)); + } + + inline PB_ASSOC_IT_C_DEC& + operator++() + { + ++m_it1; + + if (m_it1 == m_it0->second.end()) + do + { + ++m_it0; + } + while (m_it0 != m_end_it0&& m_it0->second.empty()); + + if (m_it0 != m_end_it0&& !m_it0->second.empty()) + m_it1 = m_it0->second.begin(); + + return (*this); + } + + inline PB_ASSOC_IT_C_DEC + operator++(int) + { + PB_ASSOC_IT_C_DEC ret =* this; + + operator++(); + + return (ret); + } + + inline const_pointer + operator->() const + { + it_value_type_traits_t::make_valid(m_value_type_holder, m_it0->first, * m_it1); + + return (it_value_type_traits_t::recast(m_value_type_holder)); + } + + inline pointer + operator->() + { + // Tmp Ami PB_ASSOC_STATIC_ASSERT(non_const, !Const); + + it_value_type_traits_t::make_valid(m_value_type_holder, m_it0->first, * m_it1); + + return (it_value_type_traits_t::recast(m_value_type_holder)); + } + + inline const_reference + operator*() const + { + return (*operator->()); + } + + inline reference + operator*() + { + PB_ASSOC_STATIC_ASSERT(non_const, !Const); + + return (*operator->()); + } + +public: + mutable It0 m_it0; + It0 m_end_it0; + + mutable It1 m_it1; + + int_to_type<Has_Data> m_has_data; + +private: + mutable typename it_value_type_traits_t::value_type_holder m_value_type_holder; +}; + +#undef PB_ASSOC_IT_C_DEC + +#undef PB_ASSOC_OIT_T_DEC + +#undef PB_ASSOC_OIT_C_DEC + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator_fn_imps.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator_fn_imps.hpp new file mode 100644 index 00000000000..739cb07760b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/iterator_fn_imps.hpp @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 iterator_fn_imps.hpp + * Contains an adapter of mapping levels. + */ + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/ref_pair.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/ref_pair.hpp new file mode 100644 index 00000000000..063fb7a2b60 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/ref_pair.hpp @@ -0,0 +1,73 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ref_pair.hpp + * Contains an adapter of mapping levels. + */ + +namespace pb_assoc +{ + + namespace detail + { + + template<typename T0, typename T1> + struct ref_pair + { + public: + typedef T0 first_type; + + typedef T1 second_type; + + public: + inline + ref_pair(T0 t0, T1 t1) : first(t0), + second(t1) + { } + + public: + T0 first; + + T1 second; + }; + + } // namespace detail + +} // namespace pb_assoc diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_adapter.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_adapter.hpp new file mode 100644 index 00000000000..5bbceea9e64 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_adapter.hpp @@ -0,0 +1,600 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 value_type_adapter.hpp + * Contains an adapter of mapping levels. + */ + +#ifndef VALUE_TYPE_ADAPTER_HPP +#define VALUE_TYPE_ADAPTER_HPP + +#include <ext/pb_assoc/detail/value_type_adapter/ref_pair.hpp> +#include <ext/pb_assoc/detail/assoc_cntnr_base.hpp> +#include <ext/pb_assoc/detail/value_type_adapter/invalidation_guarantee_selector.hpp> +#include <ext/pb_assoc/detail/type_utils.hpp> +#include <utility> +#include <algorithm> + +namespace pb_assoc +{ + + namespace detail + { + +#define PB_ASSOC_STATIC_ASSERT(UNIQUE, E) \ + typedef \ + pb_assoc::detail::static_assert_dummy_class< \ + sizeof(pb_assoc::detail::static_assert<(bool)(E)>)> \ + UNIQUE##static_assert_type + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + typename Key, \ + typename Data, \ + class DS_Tag, \ + class Policy_Tl, \ + class Allocator, \ + int Mapping_Level> + +#define PB_ASSOC_CLASS_C_DEC \ + value_type_adapter< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator, \ + Mapping_Level> + +#define PB_ASSOC_BASE_C_DEC \ + cond_type< \ + Mapping_Level != 1, \ + value_type_adapter< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator, \ + Mapping_Level - 1>, \ + typename assoc_cntnr_base< \ + Key, \ + Data, \ + DS_Tag, \ + Policy_Tl, \ + Allocator>::type>::type + + template<typename Key, + typename Data, + class DS_Tag, + class Policy_Tl, + class Allocator, + int Mapping_Level> + struct value_type_adapter : public PB_ASSOC_BASE_C_DEC + { + + private: + typedef typename PB_ASSOC_BASE_C_DEC my_base; + + typedef typename my_base::data_type my_base_data_type; + + enum + { + same_alloc_type = + is_same_type< + typename my_base::allocator::template rebind< + char>::other, + typename my_base_data_type::allocator::template rebind< + char>::other>::value + }; + + PB_ASSOC_STATIC_ASSERT(wrong_level, Mapping_Level > 0); + + PB_ASSOC_STATIC_ASSERT(must_be_same_alloc, same_alloc_type); + +#include <ext/pb_assoc/detail/value_type_adapter/value_type_traits.hpp> +#include <ext/pb_assoc/detail/value_type_adapter/it_value_type_traits.hpp> + + typedef + it_value_type_traits_< + typename base_it_key_type< + my_base, + Mapping_Level == 1>::type, + typename my_base_data_type::const_key_reference, + typename cond_type< + is_same_type< + typename my_base_data_type::data_type, + null_data_type>::value, + null_data_type, + typename my_base_data_type::data_reference>::type, + typename my_base_data_type::reference, + typename my_base::allocator> + it_value_type_traits_t; + +#include <ext/pb_assoc/detail/value_type_adapter/iterator.hpp> + + typedef + value_type_traits_< + typename my_base::key_type, + typename my_base_data_type::key_type, + typename my_base_data_type::data_type, + typename my_base::allocator> + value_type_traits_t; + + enum + { + has_data = + !is_same_type< + typename my_base_data_type::data_type, + null_data_type>::value + }; + + public: + + typedef typename Allocator::size_type size_type; + + typedef typename Allocator::difference_type difference_type; + + typedef typename my_base::allocator allocator; + + typedef typename it_value_type_traits_t::key_type it_key_type; + + typedef + std::pair< + typename my_base::key_type, + typename my_base_data_type::key_type> + key_type; + + typedef + typename allocator::template rebind< + key_type>::other::reference + key_reference; + + typedef + typename allocator::template rebind< + key_type>::other::const_reference + const_key_reference; + + typedef + typename allocator::template rebind< + key_type>::other::pointer + key_pointer; + + typedef + typename allocator::template rebind< + key_type>::other::const_pointer + const_key_pointer; + + typedef typename my_base_data_type::data_type data_type; + + typedef + typename allocator::template rebind< + data_type>::other::reference + data_reference; + + typedef + typename allocator::template rebind< + data_type>::other::const_reference + const_data_reference; + + typedef + typename allocator::template rebind< + data_type>::other::pointer + data_pointer; + + typedef + typename allocator::template rebind< + data_type>::other::const_pointer + const_data_pointer; + + typedef typename value_type_traits_t::value_type value_type; + + typedef typename value_type_traits_t::reference reference; + + typedef typename value_type_traits_t::const_reference const_reference; + + typedef typename value_type_traits_t::pointer pointer; + + typedef typename value_type_traits_t::const_pointer const_pointer; + + typedef + it_< + typename my_base::const_find_iterator, + typename my_base_data_type::const_find_iterator, + has_data, + true> + const_find_iterator; + + typedef + it_< + typename my_base::find_iterator, + typename my_base_data_type::find_iterator, + has_data, + false> + find_iterator; + + typedef + it_< + typename my_base::const_iterator, + typename my_base_data_type::const_iterator, + has_data, + true> + const_iterator; + + typedef + it_< + typename my_base::iterator, + typename my_base_data_type::iterator, + has_data, + false> + iterator; + + enum + { + mapping_level = mapping_level_imp< + typename my_base::given_data_type>::value -1 + }; + + // Tmp Ami rebind + + typedef compound_ds_tag ds_category; + + typedef + typename cond_type< + mapping_level == 1, + typename cond_type< + has_data, + data_enabled_ms_tag, + basic_ms_tag>::type, + compound_data_enabled_ms_tag>::type + ms_category; + + typedef + typename cond_type< + Mapping_Level == 1, + DS_Tag, + compound_ds_tag>::type + effective_base_ds_tag; + + typedef ds_traits< my_base_data_type> base_data_ds_traits; + + enum + { + erase_can_throw = + base_data_ds_traits::erase_can_throw + }; + + enum + { + order_preserving = + order_preserving_imp< + my_base, + effective_base_ds_tag>::value&& + base_data_ds_traits::order_preserving + }; + + enum + { + erase_iterators = + base_data_ds_traits::erase_iterators + }; + + typedef + typename ig_sel< + typename invalidation_guarantee_imp< + my_base, + effective_base_ds_tag>::type, + typename ds_traits< + my_base_data_type>::invalidation_guarantee>::type + invalidation_guarantee; + + enum + { + reverse_iteration = + reverse_iteration_imp< + my_base, + effective_base_ds_tag>::value&& + base_data_ds_traits::reverse_iteration + }; + + enum + { + split_join = false + }; + + protected: + typedef typename my_base_data_type::data_pointer erase_imp_ret_t; + + private: + inline const_key_reference + extract_key_imp(const_reference r_val, int_to_type<true>) + { + return (r_val.first); + } + + inline const_key_reference + extract_key_imp(const_reference r_val, int_to_type<false>) + { + return (r_val); + } + + inline it_key_type + extract_key_imp(typename iterator::const_reference r_val, int_to_type<true>) + { + return (r_val.first); + } + + inline it_key_type + extract_key_imp(typename iterator::const_reference r_val, int_to_type<false>) + { + return (r_val); + } + + public: + + inline size_type + size() const + { + return (std::distance(begin(), end())); + } + + inline size_type + max_size() const + { + return (my_base::max_size()); + } + + inline bool + empty() const + { + return (size() == 0); + } + + inline static const_key_reference + extract_key(const_reference r_val) + { + return (extract_key_imp( + r_val, + int_to_type<has_data>())); + } + + inline it_key_type + extract_key(typename iterator::const_reference r_val) + { + return (extract_key_imp( + r_val, + int_to_type<has_data>())); + } + + inline std::pair< + find_iterator, + bool> + insert(const_reference r_val) + { + typedef std::pair< typename my_base::find_iterator, bool> base_ins_ret; + + // Tmp Ami + } + + inline data_reference + operator[](const_key_reference r_key) + { + return (subscript_imp(r_key)); + } + + inline const_find_iterator + find(const_key_reference r_key) const + { + typename my_base::const_find_iterator it = my_base::find(r_key.first); + + if (it == my_base::end()) + return (end()); + + typename my_base_data_type::const_find_iterator sec_it = + it->second.find(r_key.second); + + if (sec_it == it->second.end()) + return (end()); + + return (const_find_iterator(it, sec_it)); + } + + inline find_iterator + find(const_key_reference r_key) + { + typename my_base::find_iterator it = my_base::find(r_key.first); + + if (it == my_base::end()) + return (end()); + + typename my_base_data_type::find_iterator sec_it = + it->second.find(r_key.second); + + if (sec_it == it->second.end()) + return (end()); + + return (find_iterator(it, my_base::end(), sec_it)); + } + + inline const_data_reference + operator[](const_key_reference r_key) const + { + return (my_base::operator[](r_key.first).operator[](r_key.second)); + } + + inline size_type + erase(const_key_reference r_key) + { + typename my_base::find_iterator it = + my_base::find(r_key.first); + + if (it == my_base::end()) + return (0); + + if (it->second.find(r_key.second) == it->second.end()) + return (0); + + it->second.erase(r_key.second); + + return (1); + } + +#include <ext/pb_assoc/detail/value_type_adapter/erase_if_pred.hpp> + + template<class Pred> + inline size_type + erase_if(Pred prd) + { + typename my_base::iterator it = my_base::begin(); + + typename my_base::iterator end_it = my_base::end(); + + size_type ersd = 0; + + // Tmp Ami check erase can throw + + while (it != end_it) + { + if (it->second.empty() == false) + { + erase_if_pred<Pred> p(prd, it); + + ersd += it->second.erase_if(p); + } + + ++it; + } + + return (ersd); + } + + void + clear() + { + typename my_base::iterator it = my_base::begin(); + + typename my_base::iterator end_it = my_base::end(); + + while (it != end_it) + it->second.clear(); + } + + inline const_iterator + begin() const + { + typename my_base::const_iterator it = my_base::begin(); + + while (it != my_base::end()&& it->second.size() == 0) + ++it; + + if (it == my_base::end()) + return (end()); + + return (const_iterator(it, my_base::end(), it->second.begin())); + } + + inline iterator + begin() + { + typename my_base::iterator it = my_base::begin(); + + while (it != my_base::end()&& it->second.size() == 0) + ++it; + + if (it == my_base::end()) + return (end()); + + return (iterator(it, my_base::end(), it->second.begin())); + } + + inline const_iterator + end() const + { + return (const_iterator(my_base::end(), my_base::end())); + } + + inline iterator + end() + { + return (iterator(my_base::end(), my_base::end())); + } + + protected: + + virtual + ~value_type_adapter() + { } + +#define PB_ASSOC_CLASS_NAME value_type_adapter + +#define PB_ASSOC_DIRECT_BASE_C_DEC PB_ASSOC_BASE_C_DEC + +#define PB_ASSOC_DIRECT_BASE_CAST_C_DEC \ + typename PB_ASSOC_DIRECT_BASE_C_DEC + +#include <ext/pb_assoc/detail/constructors_destructor_fn_imps.hpp> + +#undef PB_ASSOC_CLASS_NAME + +#undef PB_ASSOC_DIRECT_BASE_C_DEC + +#undef PB_ASSOC_DIRECT_BASE_CAST_C_DEC + + data_reference + subscript_imp(const_key_reference r_key) + { + return (my_base::subscript_imp(r_key.first)[r_key.second]); + } + + private: + value_type_adapter& + operator=(const value_type_adapter& r_other); + }; + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_BASE_C_DEC + + } // namespace detail + +} // namespace pb_assoc + +#endif // #ifndef VALUE_TYPE_ADAPTER_HPP + diff --git a/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_traits.hpp b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_traits.hpp new file mode 100644 index 00000000000..75fdc42916e --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/detail/value_type_adapter/value_type_traits.hpp @@ -0,0 +1,102 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 value_type_traits.hpp + * Contains an adapter of mapping levels. + */ + +template<typename Base_Key_, + typename Key_, + typename Data_, + class Allocator_ > +struct value_type_traits_ +{ + typedef std::pair< std::pair< Base_Key_, Key_>, Data_> value_type; + + typedef + typename Allocator_::template rebind< + value_type>::other::reference + reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + const_reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::pointer + pointer; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_pointer + const_pointer; +}; + +template<typename Base_Key_, typename Key_, class Allocator_> +struct value_type_traits_< + Base_Key_, + Key_, + null_data_type, + Allocator_> +{ + typedef std::pair< Base_Key_, Key_> value_type; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_reference + const_reference; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_pointer + pointer; + + typedef + typename Allocator_::template rebind< + value_type>::other::const_pointer + const_pointer; +}; diff --git a/libstdc++-v3/include/ext/pb_assoc/ds_trait.hpp b/libstdc++-v3/include/ext/pb_assoc/ds_trait.hpp new file mode 100644 index 00000000000..403b2e558c6 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/ds_trait.hpp @@ -0,0 +1,125 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ds_trait.hpp + * Contains data-structure traits. + */ + +#ifndef DS_TRAIT_HPP +#define DS_TRAIT_HPP + +#include <ext/pb_assoc/detail/type_utils.hpp> + +namespace pb_assoc +{ + struct basic_invalidation_guarantee + { }; + + struct find_invalidation_guarantee : public basic_invalidation_guarantee + { }; + + struct range_invalidation_guarantee : public find_invalidation_guarantee + { }; + + struct basic_ds_tag + { }; + + struct basic_hash_ds_tag : public basic_ds_tag + { }; + + struct cc_hash_ds_tag : public basic_hash_ds_tag + { }; + + struct gp_hash_ds_tag : public basic_hash_ds_tag + { }; + + struct basic_tree_ds_tag : public basic_ds_tag + { }; + + struct rb_tree_ds_tag : public basic_tree_ds_tag + { }; + + struct splay_tree_ds_tag : public basic_tree_ds_tag + { }; + + struct ov_tree_ds_tag : public basic_tree_ds_tag + { }; + + struct lu_ds_tag : public basic_ds_tag + { }; + + struct compound_ds_tag : public basic_ds_tag + { }; + +#include <ext/pb_assoc/detail/ds_trait_imp.hpp> + +#define PB_ASSOC_BASE_C_DEC \ + detail::data_structure_traits<Cntnr, typename Cntnr::ds_category> + + template<typename Cntnr> + struct ds_traits + : private detail::data_structure_traits<Cntnr, typename Cntnr::ds_category> + { + public: + enum + { + erase_can_throw = PB_ASSOC_BASE_C_DEC::erase_can_throw, + order_preserving = PB_ASSOC_BASE_C_DEC::order_preserving, + erase_iterators = PB_ASSOC_BASE_C_DEC::erase_iterators, + reverse_iteration = PB_ASSOC_BASE_C_DEC::reverse_iteration, + split_join = PB_ASSOC_BASE_C_DEC::split_join + }; + + typedef typename PB_ASSOC_BASE_C_DEC::invalidation_guarantee + invalidation_guarantee; + + /* + enum + { + split_join_can_throw = PB_ASSOC_BASE_C_DEC::split_join_can_throw + }; + */ + }; + +#undef PB_ASSOC_BASE_C_DEC + +} // namespace pb_assoc + +#endif // #ifndef DS_TRAIT_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/exception.hpp b/libstdc++-v3/include/ext/pb_assoc/exception.hpp new file mode 100644 index 00000000000..ef7daf89ada --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/exception.hpp @@ -0,0 +1,69 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 pb_assoc_ex.hpp + * Contains exception classes for pb_assoc. + */ + +#ifndef EXCEPTION_HPP +#define EXCEPTION_HPP + +#include <stdexcept> + +namespace pb_assoc +{ + struct pb_assoc_ex : public std::logic_error + { + pb_assoc_ex() : std::logic_error("pb_assoc exception") { } + }; + + struct cannot_insert : public pb_assoc_ex + { }; + + // An join cannot be performed for logical reasons (i.e., the ranges of + // the two container objects being joined overlaps.) + struct cannot_join : public cannot_insert + { }; + + struct cannot_resize : public cannot_insert + { }; +} // namespace pb_assoc + +#endif // #ifndef EXCEPTION_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/hash_policy.hpp b/libstdc++-v3/include/ext/pb_assoc/hash_policy.hpp new file mode 100644 index 00000000000..43bd16e4452 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/hash_policy.hpp @@ -0,0 +1,717 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 hash_policy.hpp + * Contains hash-related policies. + */ + +#ifndef HASH_POLICY_HPP +#define HASH_POLICY_HPP + +#include <algorithm> +#include <vector> +#include <cmath> +#include <ext/pb_assoc/exception.hpp> +#include <ext/pb_assoc/detail/hash_fn/mask_based_range_hashing.hpp> +#include <ext/pb_assoc/detail/hash_fn/mod_based_range_hashing.hpp> +#include <ext/pb_assoc/detail/resize_policy/size_base.hpp> + +namespace pb_assoc +{ + struct null_hash_fn + { }; + + struct null_probe_fn + { }; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Const_Key_Ref, typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + linear_probe_fn< \ + Const_Key_Ref, \ + Size_Type> + + template<typename Const_Key_Ref, typename Size_Type = size_t> + class linear_probe_fn + { + public: + typedef Size_Type size_type; + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + inline size_type + operator()(Const_Key_Ref r_key, size_type i) const; + }; + +#include <ext/pb_assoc/detail/hash_fn/linear_probe_fn_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<class Const_Key_Ref, typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + quadratic_probe_fn<Const_Key_Ref, Size_Type> + + template<typename Const_Key_Ref, typename Size_Type = size_t> + class quadratic_probe_fn + { + public: + typedef Size_Type size_type; + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + inline size_type + operator()(Const_Key_Ref r_key, size_type i) const; + }; + +#include <ext/pb_assoc/detail/hash_fn/quadratic_probe_fn_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + direct_mask_range_hashing<Size_Type> + + template<typename Size_Type = size_t> + class direct_mask_range_hashing + : public pb_assoc::detail::mask_based_range_hashing<Size_Type> + { + public: + typedef Size_Type size_type; + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + void + notify_resized(size_type size); + + inline size_type + operator()(size_type hash) const; + + private: + typedef pb_assoc::detail::mask_based_range_hashing<Size_Type> + my_mask_based_base; + }; + +#define PB_ASSOC_MASK_BASED_C_DEC \ + pb_assoc::detail::mask_based_range_hashing< \ + Size_Type> + +#include <ext/pb_assoc/detail/hash_fn/direct_mask_range_hashing_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_MASK_BASED_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + direct_mod_range_hashing<Size_Type> + +#define PB_ASSOC_MOD_BASED_C_DEC \ + pb_assoc::detail::mod_based_range_hashing<Size_Type> + + template<typename Size_Type = size_t> + class direct_mod_range_hashing : public PB_ASSOC_MOD_BASED_C_DEC + { + public: + typedef Size_Type size_type; + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + /* + * description = "Notifies the policy object that the container's + * __size has changed to size."> + **/ + void + notify_resized(size_type size); + + inline size_type + operator()(size_type hash) const; + + private: + typedef PB_ASSOC_MOD_BASED_C_DEC my_mod_based_base; + }; + +#include <ext/pb_assoc/detail/hash_fn/direct_mod_range_hashing_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_MOD_BASED_C_DEC + +#ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG + +#define PB_ASSOC_CLASS_T_DEC \ + template<bool External_Load_Access, typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + hash_load_check_resize_trigger<External_Load_Access, Size_Type> + +#define PB_ASSOC_SIZE_BASE_C_DEC \ + pb_assoc::detail::size_base<Size_Type, External_Load_Access> + + template<bool External_Load_Access = false, typename Size_Type = size_t> + class hash_load_check_resize_trigger : private PB_ASSOC_SIZE_BASE_C_DEC + { + public: + typedef Size_Type size_type; + + enum + { + external_load_access = External_Load_Access + }; + + hash_load_check_resize_trigger(float load_min = 0.125, + float load_max = 0.5); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + virtual + ~hash_load_check_resize_trigger(); + + inline std::pair<float, float> + get_loads() const; + + void + set_loads(std::pair<float, float> load_pair); + + protected: + inline void + notify_insert_search_start(); + + inline void + notify_insert_search_collision(); + + inline void + notify_insert_search_end(); + + inline void + notify_find_search_start(); + + inline void + notify_find_search_collision(); + + inline void + notify_find_search_end(); + + inline void + notify_erase_search_start(); + + inline void + notify_erase_search_collision(); + + inline void + notify_erase_search_end(); + + inline void + notify_inserted(size_type num_entries); + + inline void + notify_erased(size_type num_entries); + + void + notify_cleared(); + + void + notify_resized(size_type new_size); + + void + notify_externally_resized(size_type new_size); + + inline bool + is_resize_needed() const; + + inline bool + is_grow_needed(size_type size, size_type num_entries) const; + + inline bool + is_shrink_needed(size_type size, size_type num_entries) const; + + typedef PB_ASSOC_SIZE_BASE_C_DEC my_size_base; + + private: + inline std::pair<float, float> + get_loads_imp(pb_assoc::detail::int_to_type<true>) const; + + void + set_loads_imp(std::pair<float, float>, + pb_assoc::detail::int_to_type<true>); + + virtual void + do_resize(size_type new_size); + +#ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG + void + assert_valid() const; +#endif // #ifdef PB_ASSOC_HT_LOAD_CHECK_RESIZE_TRIGGER_DEBUG + + float m_load_min, m_load_max; + + size_type m_next_shrink_size; + + size_type m_next_grow_size; + + bool m_resize_needed; + + static pb_assoc::detail::int_to_type<External_Load_Access> + s_external_load_access_ind; + }; + +#include <ext/pb_assoc/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_SIZE_BASE_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#ifdef PB_ASSOC_HT_MAX_COLLISION_CHECK_RESIZE_TRIGGER_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HT_MAX_COLLISION_CHECK_RESIZE_TRIGGER_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HT_MAX_COLLISION_CHECK_RESIZE_TRIGGER_POLICY_DEBUG + +#define PB_ASSOC_CLASS_T_DEC \ + template<bool External_Load_Access, typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + cc_hash_max_collision_check_resize_trigger< \ + External_Load_Access, \ + Size_Type> + + template<bool External_Load_Access = false, typename Size_Type = size_t> + class cc_hash_max_collision_check_resize_trigger + { + public: + typedef Size_Type size_type; + + enum + { + external_load_access = External_Load_Access + }; + + cc_hash_max_collision_check_resize_trigger(float load = 0.5); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline float + get_load() const; + + protected: + inline void + notify_insert_search_start(); + + inline void + notify_insert_search_collision(); + + inline void + notify_insert_search_end(); + + inline void + notify_find_search_start(); + + inline void + notify_find_search_collision(); + + inline void + notify_find_search_end(); + + inline void + notify_erase_search_start(); + + inline void + notify_erase_search_collision(); + + inline void + notify_erase_search_end(); + + inline void + notify_inserted(size_type num_entries); + + inline void + notify_erased(size_type num_entries); + + void + notify_cleared(); + + void + notify_resized(size_type new_size); + + void + notify_externally_resized(size_type new_size); + + inline bool + is_resize_needed() const; + + inline bool + is_grow_needed(size_type size, size_type num_entries) const; + + inline bool + is_shrink_needed(size_type size, size_type num_entries) const; + + private: + template<typename Key> + class max_col_checker + { + public: + max_col_checker(size_type size, size_type* p_max_col) + : m_p_max_col(p_max_col), m_a_col(size, 0) + { } + + void + operator()(const std::pair<const Key, size_type>& r_key_pos_pair) + { ++m_a_col[r_key_pos_pair.second]; } + + private: + std::vector<size_type> m_a_col; + + size_type* const m_p_max_col; + }; + + private: + inline float + get_load_imp(pb_assoc::detail::int_to_type<true>) const; + + float m_load; + + size_type m_size; + + size_type m_num_col; + + size_type m_max_col; + + bool m_resize_needed; + + static pb_assoc::detail::int_to_type<External_Load_Access> + s_external_load_access_ind; + }; + +#include <ext/pb_assoc/detail/resize_policy/cc_hash_max_collision_resize_trigger_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + hash_exponential_size_policy< \ + Size_Type> + + template<typename Size_Type = size_t> + class hash_exponential_size_policy + { + public: + typedef Size_Type size_type; + + hash_exponential_size_policy(size_type start_size = 8, + size_type grow_factor = 2); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + size_type + get_init_size(size_type suggested_size) const; + + size_type + get_nearest_larger_size(size_type cur_size) const; + + size_type + get_nearest_smaller_size(size_type cur_size) const; + +#ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG + void + assert_is_one_of_my_sizes(size_type size) const; +#endif // #ifdef PB_ASSOC_HT_EXPONENTIAL_SIZE_POLICY_DEBUG + + private: + size_type m_start_size; + size_type m_grow_factor; + }; + +#include <ext/pb_assoc/detail/resize_policy/hash_exponential_size_policy_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#define PB_ASSOC_CLASS_T_DEC + +#define PB_ASSOC_CLASS_C_DEC \ + hash_prime_size_policy + +#ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) assert(X) +#define PB_ASSOC_DBG_VERIFY(X) assert(X) +#define PB_ASSOC_DBG_ONLY(X) X +#else // #ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG +#define PB_ASSOC_DBG_ASSERT(X) +#define PB_ASSOC_DBG_VERIFY(X) {if((X)==0);} +#define PB_ASSOC_DBG_ONLY(X) ; +#endif // #ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG + + struct hash_prime_size_policy + { + typedef size_t size_type; + + inline void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + inline size_type + get_init_size(size_type suggested_size) const; + + inline size_type + get_nearest_larger_size(size_type cur_size) const; + + inline size_type + get_nearest_smaller_size(size_type cur_size) const; + + inline size_type + get_nearest_larger_size_imp(size_type size) const; + +#ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG + void + assert_is_one_of_my_sizes(size_type size) const; +#endif // #ifdef PB_ASSOC_HT_PRIME_SIZE_POLICY_DEBUG + }; + +#include <ext/pb_assoc/detail/resize_policy/hash_prime_size_policy_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +#define PB_ASSOC_CLASS_T_DEC \ + template< \ + class Size_Policy, \ + class Trigger_Policy, \ + bool External_Size_Access, \ + typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + hash_standard_resize_policy< \ + Size_Policy, \ + Trigger_Policy, \ + External_Size_Access, \ + Size_Type> + + template<class Size_Policy = pb_assoc::hash_exponential_size_policy<>, + class Trigger_Policy = pb_assoc::hash_load_check_resize_trigger<>, + bool External_Size_Access = false, + typename Size_Type = size_t> + class hash_standard_resize_policy : public Size_Policy, public Trigger_Policy + { + public: + typedef Size_Type size_type; + typedef Trigger_Policy trigger_policy; + typedef Size_Policy size_policy; + + enum + { + external_size_access = External_Size_Access + }; + + hash_standard_resize_policy(size_type suggested_size = 8); + + hash_standard_resize_policy(const Size_Policy&, + size_type suggested_size = 8); + + hash_standard_resize_policy(const Size_Policy&, const Trigger_Policy&, + size_type suggested_size = 8); + + virtual + ~hash_standard_resize_policy(); + + inline void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + Size_Policy& + get_size_policy(); + + const Size_Policy& + get_size_policy() const; + + Trigger_Policy& + get_trigger_policy(); + + const Trigger_Policy& + get_trigger_policy() const; + + inline size_type + get_actual_size() const; + + void + resize(size_type suggested_new_size); + + protected: + + inline void + notify_insert_search_start(); + + inline void + notify_insert_search_collision(); + + inline void + notify_insert_search_end(); + + inline void + notify_find_search_start(); + + inline void + notify_find_search_collision(); + + inline void + notify_find_search_end(); + + inline void + notify_erase_search_start(); + + inline void + notify_erase_search_collision(); + + inline void + notify_erase_search_end(); + + inline void + notify_inserted(size_type num_e); + + inline void + notify_erased(size_type num_e); + + void + notify_cleared(); + + void + notify_resized(size_type new_size); + + size_type + get_init_size() const; + + inline bool + is_resize_needed() const; + + size_type + get_new_size(size_type size, size_type num_used_e) const; + + private: + typedef Trigger_Policy my_trigger_policy_base; + + typedef Size_Policy my_size_policy_base; + + typedef + pb_assoc::detail::int_to_type<false> + external_resize_false_indicator; + + typedef + pb_assoc::detail::int_to_type<true> + external_resize_true_indicator; + + inline size_type + get_actual_size(external_resize_true_indicator) const; + + void + resize(size_type new_size, external_resize_true_indicator); + + virtual void + do_resize(size_type new_size); + + static pb_assoc::detail::int_to_type<External_Size_Access> + s_external_size_access_indicator; + + size_type m_size; + }; + +#include <ext/pb_assoc/detail/resize_policy/hash_standard_resize_policy_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC +#undef PB_ASSOC_CLASS_C_DEC + +#undef PB_ASSOC_DBG_ASSERT +#undef PB_ASSOC_DBG_VERIFY +#undef PB_ASSOC_DBG_ONLY + +} // namespace pb_assoc + +#endif // #ifndef HASH_POLICY_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/lu_policy.hpp b/libstdc++-v3/include/ext/pb_assoc/lu_policy.hpp new file mode 100644 index 00000000000..2c56bd98d0d --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/lu_policy.hpp @@ -0,0 +1,181 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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_policy.hpp + * Contains policies for list update containers. + */ + +#ifndef LU_POLICY_HPP +#define LU_POLICY_HPP + +namespace pb_assoc +{ + struct move_to_front_lu_metadata + { }; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Metadata_Reference> + +#define PB_ASSOC_CLASS_C_DEC \ + move_to_front_lu_policy<Metadata_Reference> + + template<typename Metadata_Reference = + std::allocator<move_to_front_lu_metadata>::reference> + class move_to_front_lu_policy + { + public: + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + protected: + typedef move_to_front_lu_metadata metadata_type; + + typedef Metadata_Reference metadata_reference; + + metadata_type + operator()() const; + + inline bool + operator()(metadata_reference r_data) const; + }; + +#include <ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + + template<typename Size_Type> + class counter_lu_policy_base; + + template<typename Size_Type = size_t> + class counter_lu_metadata + { + public: + typedef Size_Type size_type; + + private: + counter_lu_metadata(size_type init_count) : m_count(init_count) + { } + + mutable size_type m_count; + + friend class counter_lu_policy_base<Size_Type>; + }; + + template<typename Size_Type> + class counter_lu_policy_base; + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type> + +#define PB_ASSOC_CLASS_C_DEC \ + counter_lu_policy_base<Size_Type> + + 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; + + template<typename Metadata_Reference> + bool + operator()(Metadata_Reference r_data, size_type m_max_count) const; + }; + +#include <ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +#define PB_ASSOC_CLASS_T_DEC \ + template<typename Size_Type, typename Metadata_Reference> + +#define PB_ASSOC_CLASS_C_DEC \ + counter_lu_policy<Size_Type, Metadata_Reference> + + template<typename Size_Type = size_t, + typename Metadata_Reference = + typename std::allocator<counter_lu_metadata<Size_Type> >::reference> + class counter_lu_policy : private counter_lu_policy_base<Size_Type> + { + public: + typedef Size_Type size_type; + + counter_lu_policy(size_type max_count = 5); + + void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline + size_type + get_max_count() const; + + protected: + + typedef counter_lu_metadata< Size_Type> metadata_type; + + typedef Metadata_Reference metadata_reference; + + metadata_type + operator()() const; + + bool + operator()(metadata_reference r_data) const; + + private: + typedef counter_lu_policy_base< Size_Type> my_base; + + size_type m_max_count; + }; + +#include <ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp> + +#undef PB_ASSOC_CLASS_T_DEC + +#undef PB_ASSOC_CLASS_C_DEC + +} // namespace pb_assoc + +#endif // #ifndef LU_POLICY_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/ms_trait.hpp b/libstdc++-v3/include/ext/pb_assoc/ms_trait.hpp new file mode 100644 index 00000000000..dd73452ed60 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/ms_trait.hpp @@ -0,0 +1,82 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 ms_trait.hpp + * Contains mapping-semantic traits. + */ + +#ifndef MS_TRAIT_HPP +#define MS_TRAIT_HPP + +#include <ext/pb_assoc/data_type.hpp> +#include <ext/pb_assoc/detail/mapping_level_imp.hpp> + +namespace pb_assoc +{ + struct basic_ms_tag + { }; + + struct data_enabled_ms_tag : public basic_ms_tag + { }; + + struct compound_data_enabled_ms_tag : public data_enabled_ms_tag + { }; + +#include <ext/pb_assoc/detail/ms_trait_imp.hpp> + +#define PB_ASSOC_BASE_C_DEC \ + detail::mapping_semantics_traits<Cntnr, typename Cntnr::ms_category> + + template<typename Cntnr> + struct ms_traits : private PB_ASSOC_BASE_C_DEC + { + enum + { + has_data = PB_ASSOC_BASE_C_DEC::has_data, + has_compound_data = PB_ASSOC_BASE_C_DEC::has_compound_data, + mapping_level = PB_ASSOC_BASE_C_DEC::mapping_level + }; + }; + +#undef PB_ASSOC_BASE_C_DEC + +} // namespace pb_assoc + +#endif // #ifndef MS_TRAIT_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/tree_policy.hpp b/libstdc++-v3/include/ext/pb_assoc/tree_policy.hpp new file mode 100644 index 00000000000..67a37a1fc3b --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/tree_policy.hpp @@ -0,0 +1,215 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 tree_policy.hpp + * Contains tree-related policies. + */ + +#ifndef TREE_POLICY_HPP +#define TREE_POLICY_HPP + +#include <functional> +#include <ext/pb_assoc/ms_trait.hpp> + +namespace pb_assoc +{ + struct null_node_updator + { + inline void + swap(null_node_updator& r_other); + }; + +#include <ext/pb_assoc/detail/tree_policy/null_node_updator_imp.hpp> + + template<typename Key, typename Allocator = std::allocator<char> > + class order_statistics_key + { + public: + typedef Allocator allocator; + typedef Key key_type; + typedef typename allocator::template rebind<Key>::other::const_reference + const_key_reference; + typedef typename allocator::template rebind<Key>::other::reference + key_reference; + typedef typename allocator::size_type size_type; + + inline explicit + order_statistics_key(const_key_reference r_key = Key()); + + inline + operator key_reference(); + + inline + operator key_type() const; + + private: + // The logical key of the entry. + key_type m_key; + + // The number of entries in the subtree rooted at the node of + // this element. + mutable size_type m_rank; + + template<typename Cntnr> + friend class order_by_key; + + template<typename Some_Cmp_Fn, typename Some_Allocator> + friend class order_statistics_key_cmp; + + template<typename Some_Key, typename Some_Allocator> + friend class order_statistics_node_updator; + + template<typename Cntnr> + friend class find_by_order; + + template<typename Cntnr, typename Some_Allocator> + friend class order_statistics_key_verifier; + }; + + template<typename Cmp_Fn, typename Allocator = std::allocator<char> > + class order_statistics_key_cmp + : public std::binary_function< + order_statistics_key<typename Cmp_Fn::first_argument_type, Allocator>, + order_statistics_key<typename Cmp_Fn::second_argument_type, Allocator>, bool>, + private Cmp_Fn + { + public: + typedef Allocator allocator; + typedef Cmp_Fn cmp_fn; + + typedef + order_statistics_key<typename Cmp_Fn::first_argument_type, Allocator> + key_type; + + typedef + typename allocator::template rebind<key_type>::other::const_reference + const_key_reference; + + inline + order_statistics_key_cmp(); + + inline + order_statistics_key_cmp(const Cmp_Fn& r_cmp_fn); + + inline bool + operator()(const_key_reference, const_key_reference) const; + + inline cmp_fn& + get_cmp_fn(); + + inline const cmp_fn& + get_cmp_fn() const; + }; + +#define PB_ASSOC_CLASS_C_DEC \ + order_statistics_node_updator<Key, Allocator> + + template<typename Key, typename Allocator = std::allocator<char> > + class order_statistics_node_updator + { + public: + typedef Allocator allocator; + typedef order_statistics_key< Key, Allocator> key_type; + + typedef + typename Allocator::template rebind<key_type>::other::const_pointer + const_key_pointer; + + inline void + swap(PB_ASSOC_CLASS_C_DEC& r_other); + + inline void + operator()(const_key_pointer, const_key_pointer, const_key_pointer); + + private: + typedef typename Allocator::size_type size_type; + }; + +#undef PB_ASSOC_CLASS_C_DEC + + template<class Cntnr> + class find_by_order + { + public: + typedef Cntnr cntnr; + typedef typename cntnr::iterator iterator; + typedef typename cntnr::const_iterator const_iterator; + typedef typename cntnr::size_type size_type; + + inline iterator + operator()(Cntnr& r_c, size_type order) const; + + inline const_iterator + operator()(const Cntnr& r_c, size_type order) const; + + private: + typedef typename Cntnr::node_iterator node_iterator; + typedef typename Cntnr::const_iterator cntnr_const_it; + typedef typename Cntnr::iterator cntnr_it; + + inline static iterator + find(Cntnr& r_c, size_type order); + + inline static const_iterator + find(const Cntnr& r_c, size_type order); + }; + + template<class Cntnr> + class order_by_key + { + public: + typedef Cntnr cntnr; + typedef typename Cntnr::key_type order_statistics_key_type; + typedef typename order_statistics_key_type::key_type + underlying_key_type; + typedef typename cntnr::size_type size_type; + + inline size_type + operator()(const Cntnr& r_c, const underlying_key_type& r_key) const; + + private: + typedef typename cntnr::const_iterator cntnr_const_it; + typedef typename cntnr::iterator cntnr_it; + }; + +#include <ext/pb_assoc/detail/tree_policy/order_statistics_imp.hpp> +} // namespace pb_assoc + +#endif // #ifndef TREE_POLICY_HPP diff --git a/libstdc++-v3/include/ext/pb_assoc/trivial_iterator_def.hpp b/libstdc++-v3/include/ext/pb_assoc/trivial_iterator_def.hpp new file mode 100644 index 00000000000..aa7c0bb1b34 --- /dev/null +++ b/libstdc++-v3/include/ext/pb_assoc/trivial_iterator_def.hpp @@ -0,0 +1,58 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 trivial_iterator_def.hpp + * Contains definitions for "trivial"-type iterators. + */ + +#ifndef TRIVIAL_ITERATOR_DEF_HPP +#define TRIVIAL_ITERATOR_DEF_HPP + +namespace pb_assoc +{ + struct trivial_iterator_tag + { }; + + // Prohibit moving trivial iterators. + typedef void trivial_iterator_difference_type; + +} // namespace pb_assoc + +#endif // #ifndef TRIVIAL_ITERATOR_DEF_HPP diff --git a/libstdc++-v3/include/ext/typelist.h b/libstdc++-v3/include/ext/typelist.h new file mode 100644 index 00000000000..e070ce251a6 --- /dev/null +++ b/libstdc++-v3/include/ext/typelist.h @@ -0,0 +1,368 @@ +// -*- C++ -*- + +// Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 typelist.h + * Contains typelist_chain definitions. + * Typelists are an idea by Andrei Alexandrescu. + */ + +#ifndef TYPELIST_HPP +#define TYPELIST_HPP + +namespace __gnu_cxx +{ + // XXX namespace typelist + // struct typelist -> struct node + + struct null_type { }; + + template<typename Root> + struct typelist + { + typedef Root root; + }; + + // Forward declarations of functors. + template<typename Hd, typename Typelist> + struct chain + { + typedef Hd head; + typedef Typelist tail; + }; + + template<typename Typelist0, typename Typelist1> + struct append; + + template<typename Typelist_Typelist> + struct typelist_append; + + template<typename Typelist, typename T> + struct contains; + + template<typename Typelist, template<typename T> class Pred> + struct filter; + + template<typename Typelist, int i> + struct at_index; + + template<typename Fn, typename Typelist> + struct apply; + + template<typename Typelist, template<typename T> class Transform> + struct transform; +} + + +namespace __gnu_cxx +{ +namespace detail +{ + // #include <ext/detail/type_utils.h> + template<typename Type> + struct type_to_type + { + typedef Type type; + }; + + template<bool Cond, typename A, typename B> + struct cond_type; + + template<typename A, typename B> + struct cond_type<true, A, B> + { + typedef A type; + }; + + template<typename A, typename B> + struct cond_type<false, A, B> + { + typedef B type; + }; + + // #include <ext/detail/apply.h> + template<typename Fn, typename Typelist_Chain> + struct apply_; + + template<typename Fn, typename Hd, typename Tl> + struct apply_<Fn, chain<Hd, Tl> > + { + void + operator() (Fn& f) + { + f.operator()(type_to_type<Hd>()); + apply_<Fn, Tl> next; + next(f); + } + }; + + template<typename Fn> + struct apply_<Fn, null_type> + { + void + operator()(Fn&) { } + }; + + // #include <ext/detail/append.h> + template<typename Typelist_Chain0, typename Typelist_Chain1> + struct append_; + + template<typename Hd, typename Tl, typename Typelist_Chain> + struct append_<chain<Hd, Tl>, Typelist_Chain> + { + typedef append_<Tl, Typelist_Chain> append_type; + typedef chain<Hd, typename append_type::type> type; + }; + + template<typename Typelist_Chain> + struct append_<null_type, Typelist_Chain> + { + typedef Typelist_Chain type; + }; + + // #include <ext/detail/contains.h> + template<typename Typelist_Chain, typename T> + struct contains_; + + template<typename T> + struct contains_<null_type, T> + { + enum + { + value = false + }; + }; + + template<typename Hd, typename Tl, typename T> + struct contains_<chain<Hd, Tl>, T> + { + enum + { + value = contains_<Tl, T>::value + }; + }; + + template<typename Tl, typename T> + struct contains_<chain<T, Tl>, T> + { + enum + { + value = true + }; + }; + + // #include <ext/detail/filter.h> + template<typename Typelist_Chain, template<typename T> class Pred> + struct chain_filter_; + + template<template<typename T> class Pred> + struct chain_filter_<null_type, Pred> + { + typedef null_type type; + }; + + template<typename Hd, typename Tl, template<typename T> class Pred> + struct chain_filter_<chain<Hd, Tl>, Pred> + { + enum + { + include_hd = Pred<Hd>::value + }; + + typedef typename chain_filter_<Tl, Pred>::type rest_type; + typedef chain<Hd, rest_type> chain_type; + typedef typename cond_type<include_hd, chain_type, rest_type>::type type; + }; + + // #include <ext/detail/at_index.h> + template<typename Typelist_Chain, int i> + struct chain_at_index_; + + template<typename Hd, typename Tl> + struct chain_at_index_<chain<Hd, Tl>, 0> + { + typedef Hd type; + }; + + template<typename Hd, typename Tl, int i> + struct chain_at_index_<chain<Hd, Tl>, i> + { + typedef typename chain_at_index_<Tl, i - 1>::type type; + }; + + // #include <ext/detail/transform.h> + template<class Typelist_Chain, template<typename T> class Transform> + struct chain_transform_; + + template<template<typename T> class Transform> + struct chain_transform_<null_type, Transform> + { + typedef null_type type; + }; + + template<class Hd, class Tl, template<typename T> class Transform> + struct chain_transform_<chain<Hd, Tl>, Transform> + { + typedef typename chain_transform_<Tl, Transform>::type rest_type; + typedef typename Transform<Hd>::type transform_type; + typedef chain<transform_type, rest_type> type; + }; + + // #include <ext/detail/typelist_append.h> + template<typename Typelist_Typelist_Chain> + struct typelist_append_; + + template<typename Hd> + struct typelist_append_<chain<Hd, null_type> > + { + typedef chain<Hd, null_type> type; + }; + + template<typename Hd, typename Tl> + struct typelist_append_<chain< Hd, Tl> > + { + private: + typedef typename typelist_append_<Tl>::type rest; + + public: + typedef typename append<Hd, typelist<rest> >::type::root type; + }; +} // namespace detail +} + + +namespace __gnu_cxx +{ + template<typename Fn, typename Typelist> + struct apply + { + void + operator()(Fn& f) + { + typedef typename Typelist::root root_type; + detail::apply_<Fn, root_type> a; + a(f); + } + }; + + template<typename Typelist0, typename Typelist1> + struct append + { + private: + typedef typename Typelist0::root root0_type; + typedef typename Typelist1::root root1_type; + typedef detail::append_<root0_type, root1_type> append_type; + + public: + typedef typelist<typename append_type::type> type; + }; + + template<typename Typelist_Typelist> + struct typelist_append + { + private: + typedef typename Typelist_Typelist::root root_type; + typedef detail::typelist_append_<root_type> append_type; + + public: + typedef typelist<typename append_type::type> type; + }; + + template<typename Typelist, typename T> + struct contains + { + typedef typename Typelist::root root_type; + + enum + { + value = detail::contains_<root_type, T>::value + }; + }; + + template<typename Typelist, template<typename T> class Pred> + struct filter + { + private: + typedef typename Typelist::root root_type; + typedef detail::chain_filter_<root_type, Pred> filter_type; + + public: + typedef typelist<typename filter_type::type> type; + }; + + template<typename Typelist, int i> + struct at_index + { + typedef typename Typelist::root root_type; + typedef detail::chain_at_index_<root_type, i> index_type; + + typedef typename index_type::type type; + }; + + template<typename Typelist, template<typename T> class Transform> + struct transform + { + private: + typedef typename Typelist::root root_type; + typedef detail::chain_transform_<root_type, Transform> transform_type; + + public: + typedef typelist<typename transform_type::type> type; + }; +} // namespace __gnu_cxx + + +#define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::chain<X0, __gnu_cxx::null_type> +#define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN1(X1) > +#define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN2(X1, X2) > +#define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN3(X1, X2, X3) > +#define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN4(X1, X2, X3, X4) > +#define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) > +#define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) > +#define _GLIBCXX_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) > +#define _GLIBCXX_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) > +#define _GLIBCXX_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) > +#define _GLIBCXX_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) > +#define _GLIBCXX_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) > +#define _GLIBCXX_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) > +#define _GLIBCXX_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) > +#define _GLIBCXX_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) > + +#endif + |