From: bkoz Date: Fri, 6 Jun 2008 19:32:43 +0000 (+0000) Subject: 2008-06-06 Benjamin Kosnik X-Git-Tag: upstream/4.9.2~41651 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2661beb59aac112282f8d7b34dbb57342419b9f8;p=platform%2Fupstream%2Flinaro-gcc.git 2008-06-06 Benjamin Kosnik * doc/xml/manual/using.xml: Outline exception topics. * include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp: Format. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ policy_access_fn_imps.hpp: Same. * include/ext/pb_ds/priority_queue.hpp: Same. * include/ext/throw_allocator.h: Same. * include/ext/pb_ds/tag_and_trait.hpp (string_tag): New tag. (sequence_tag): New tag. Doxygen markup fixes. * testsuite/lib/libstdc++.exp: Remove twister_ran_gen.cc source file. * testsuite/performance/ext/pb_ds/text_find_timing.cc: Fix comment typo, include paths, format. * testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc: Same. * testsuite/performance/ext/pb_ds/ hash_random_int_erase_mem_usage.cc: Same. * testsuite/performance/ext/pb_ds/ random_int_subscript_find_timing.cc: Same. * testsuite/performance/ext/pb_ds/ priority_queue_text_push_timing.cc: Same. * testsuite/performance/ext/pb_ds/tree_split_join_timing.cc: Same. * testsuite/performance/ext/pb_ds/random_int_find_timing.cc: Same. * testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp * testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp * testsuite/performance/ext/pb_ds/ priority_queue_random_int_push_timing.cc: Same. * testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp * testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc: Same. * testsuite/performance/ext/pb_ds/ priority_queue_text_push_pop_timing.cc: Same. * testsuite/performance/ext/pb_ds/ priority_queue_text_join_timing.cc: Same. * testsuite/performance/ext/pb_ds/ priority_queue_random_int_push_pop_timing.cc: Same. * testsuite/performance/ext/pb_ds/ random_int_subscript_insert_timing.cc: Same. * testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc: Same. * testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp * testsuite/performance/ext/pb_ds/ priority_queue_text_pop_mem_usage.cc: Same. * testsuite/performance/ext/pb_ds/ hash_zlob_random_int_find_timing.cc: Same. * testsuite/ext/pb_ds/regression/hash_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/trie_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/priority_queue_rand.cc: Same. * testsuite/ext/pb_ds/regression/tree_data_map_rand.cc: Same. * testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc: Same. * testsuite/util/regression/trait/priority_queue/trait.hpp: Same. * testsuite/util/regression/trait/erase_if_fn.hpp: Same. * testsuite/util/regression/trait/assoc/native_type_trait.hpp: Same. * testsuite/util/regression/trait/assoc/node_update_trait.hpp: Same. * testsuite/util/regression/trait/assoc/get_set_load_trait.hpp: Same. * testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp: Same. * testsuite/util/regression/trait/assoc/trait.hpp: Same. * testsuite/util/regression/trait/assoc/resize_trait.hpp: Same. * testsuite/util/regression/trait/assoc/type_trait.hpp: Same. * testsuite/util/regression/trait/assoc/to_string.hpp: Same. * testsuite/util/regression/basic_type.hpp: Same. * testsuite/util/common_type/priority_queue/string_form.hpp: Same. * testsuite/util/common_type/priority_queue/detail/ ds_string_form.hpp: Same. * testsuite/util/common_type/assoc/string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ resize_policy_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ trigger_policy_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ comb_hash_fn_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ds_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ size_policy_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ probe_fn_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ list_update_policy_string_form.hpp: Same. * testsuite/util/common_type/assoc/detail/ store_hash_string_form.hpp: Same. * testsuite/util/common_type/assoc/native_set.hpp: Same. * testsuite/util/io/prog_bar.cc: Same. * testsuite/util/regression/rand/io: Remove. * testsuite/util/regression/rand/io/priority_queue: Same. * testsuite/util/regression/rand/io/assoc: Same. * testsuite/util/regression/rand/io/priority_queue/ xml_formatter.hpp: Consolidate this... * testsuite/util/regression/rand/io/assoc/xml_formatter.hpp: ...this * testsuite/util/regression/rand/io/xml_formatter.hpp: ... and this * testsuite/util/regression/rand/xml_formatter.hpp: ...here. * testsuite/util/regression/rand/priority_queue/ container_rand_regression_test.hpp:To ... container_rand_regression_test.h: ... this. * testsuite/util/regression/rand/priority_queue/detail/*.hpp:To ... * testsuite/util/regression/rand/priority_queue/ container_rand_regression_test.tcc: ... this. PB_DS_THROW_IF_FAIL: Change to _GLIBCXX_THROW_IF, adjust predicate. PB_DS_SET_DESTRUCT_PRINT: Fold inline. PB_DS_CANCEL_DESTRUCT_PRINT: Fold inline. * testsuite/util/regression/rand/priority_queue/ rand_regression_test.hpp: Adjust includes. * testsuite/util/regression/rand/assoc/ container_rand_regression_test.hpp: To ... * testsuite/util/regression/rand/assoc/ container_rand_regression_test.h: ... this. * testsuite/util/regression/rand/assoc/detail/*.hpp:To ... * testsuite/util/regression/rand/assoc/ container_rand_regression_test.tcc: ...this. * testsuite/util/regression/rand/assoc/rand_regression_test.hpp: Adjust includes. * testsuite/util/regression/priority_queue: Remove. * testsuite/util/regression/assoc: Remove. * testsuite/util/regression/priority_queue/ common_type.hpp: Consolidate this... * testsuite/util/regression/assoc/common_type.hpp: ... and this * testsuite/util/regression/common_type.hpp: ...here. * testsuite/util/rng: Remove. * testsuite/util/rng/twister_rand_gen.cc: Consolidate... * testsuite/util/rng/twister_rand_gen.hpp: ... and this * testsuite/util/testsuite_rng.h: ...here. * testsuite/util/native_type/priority_queue: Remove. * testsuite/util/native_type/priority_queue/ native_priority_queue.hpp: To... * testsuite/util/native_type/native_priority_queue.hpp: ...here. * testsuite/util/native_type/assoc: Remove. * testsuite/util/native_type/assoc/native_multimap.hpp: To... * testsuite/util/native_type/assoc/native_tree_tag.hpp: To... * testsuite/util/native_type/assoc/native_hash_multimap.hpp: To... * testsuite/util/native_type/assoc/native_set.hpp: To... * testsuite/util/native_type/assoc/native_map.hpp: To... * testsuite/util/native_type/assoc/native_hash_set.hpp: To... * testsuite/util/native_type/assoc/native_hash_tag.hpp: To... * testsuite/util/native_type/assoc/native_hash_map.hpp: To... * testsuite/util/native_type/native_multimap.hpp: ...here. * testsuite/util/native_type/native_tree_tag.hpp: ...here. * testsuite/util/native_type/native_hash_multimap.hpp: ...here. * testsuite/util/native_type/native_set.hpp: ...here. * testsuite/util/native_type/native_map.hpp: ...here. * testsuite/util/native_type/native_hash_set.hpp: ...here. * testsuite/util/native_type/native_hash_tag.hpp: ...here. * testsuite/util/native_type/native_hash_map.hpp: ...here. * testsuite/util/common_type/priority_queue/common_type.hpp: Make include guard distinct. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136497 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 81e6d74..0e30cfd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,161 @@ +2008-06-06 Benjamin Kosnik + + * doc/xml/manual/using.xml: Outline exception topics. + + * include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp: Format. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + policy_access_fn_imps.hpp: Same. + * include/ext/pb_ds/priority_queue.hpp: Same. + * include/ext/throw_allocator.h: Same. + + * include/ext/pb_ds/tag_and_trait.hpp (string_tag): New tag. + (sequence_tag): New tag. Doxygen markup fixes. + + * testsuite/lib/libstdc++.exp: Remove twister_ran_gen.cc source file. + + * testsuite/performance/ext/pb_ds/text_find_timing.cc: Fix + comment typo, include paths, format. + * testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + hash_random_int_erase_mem_usage.cc: Same. + * testsuite/performance/ext/pb_ds/ + random_int_subscript_find_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + priority_queue_text_push_timing.cc: Same. + * testsuite/performance/ext/pb_ds/tree_split_join_timing.cc: Same. + * testsuite/performance/ext/pb_ds/random_int_find_timing.cc: Same. + * testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp + * testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp + * testsuite/performance/ext/pb_ds/ + priority_queue_random_int_push_timing.cc: Same. + * testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp + * testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + priority_queue_text_push_pop_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + priority_queue_text_join_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + priority_queue_random_int_push_pop_timing.cc: Same. + * testsuite/performance/ext/pb_ds/ + random_int_subscript_insert_timing.cc: Same. + * testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc: Same. + * testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp + * testsuite/performance/ext/pb_ds/ + priority_queue_text_pop_mem_usage.cc: Same. + * testsuite/performance/ext/pb_ds/ + hash_zlob_random_int_find_timing.cc: Same. + * testsuite/ext/pb_ds/regression/hash_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/trie_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/priority_queue_rand.cc: Same. + * testsuite/ext/pb_ds/regression/tree_data_map_rand.cc: Same. + * testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc: Same. + * testsuite/util/regression/trait/priority_queue/trait.hpp: Same. + * testsuite/util/regression/trait/erase_if_fn.hpp: Same. + * testsuite/util/regression/trait/assoc/native_type_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/node_update_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/get_set_load_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/trait.hpp: Same. + * testsuite/util/regression/trait/assoc/resize_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/type_trait.hpp: Same. + * testsuite/util/regression/trait/assoc/to_string.hpp: Same. + * testsuite/util/regression/basic_type.hpp: Same. + * testsuite/util/common_type/priority_queue/string_form.hpp: Same. + * testsuite/util/common_type/priority_queue/detail/ + ds_string_form.hpp: Same. + * testsuite/util/common_type/assoc/string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + resize_policy_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + trigger_policy_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + comb_hash_fn_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ds_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + size_policy_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + probe_fn_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + list_update_policy_string_form.hpp: Same. + * testsuite/util/common_type/assoc/detail/ + store_hash_string_form.hpp: Same. + * testsuite/util/common_type/assoc/native_set.hpp: Same. + * testsuite/util/io/prog_bar.cc: Same. + + * testsuite/util/regression/rand/io: Remove. + * testsuite/util/regression/rand/io/priority_queue: Same. + * testsuite/util/regression/rand/io/assoc: Same. + * testsuite/util/regression/rand/io/priority_queue/ + xml_formatter.hpp: Consolidate this... + * testsuite/util/regression/rand/io/assoc/xml_formatter.hpp: ...this + * testsuite/util/regression/rand/io/xml_formatter.hpp: ... and this + * testsuite/util/regression/rand/xml_formatter.hpp: ...here. + + * testsuite/util/regression/rand/priority_queue/ + container_rand_regression_test.hpp:To ... + container_rand_regression_test.h: ... this. + * testsuite/util/regression/rand/priority_queue/detail/*.hpp:To ... + * testsuite/util/regression/rand/priority_queue/ + container_rand_regression_test.tcc: ... this. + PB_DS_THROW_IF_FAIL: Change to _GLIBCXX_THROW_IF, adjust predicate. + PB_DS_SET_DESTRUCT_PRINT: Fold inline. + PB_DS_CANCEL_DESTRUCT_PRINT: Fold inline. + * testsuite/util/regression/rand/priority_queue/ + rand_regression_test.hpp: Adjust includes. + + * testsuite/util/regression/rand/assoc/ + container_rand_regression_test.hpp: To ... + * testsuite/util/regression/rand/assoc/ + container_rand_regression_test.h: ... this. + * testsuite/util/regression/rand/assoc/detail/*.hpp:To ... + * testsuite/util/regression/rand/assoc/ + container_rand_regression_test.tcc: ...this. + * testsuite/util/regression/rand/assoc/rand_regression_test.hpp: Adjust + includes. + + * testsuite/util/regression/priority_queue: Remove. + * testsuite/util/regression/assoc: Remove. + * testsuite/util/regression/priority_queue/ + common_type.hpp: Consolidate this... + * testsuite/util/regression/assoc/common_type.hpp: ... and this + * testsuite/util/regression/common_type.hpp: ...here. + + * testsuite/util/rng: Remove. + * testsuite/util/rng/twister_rand_gen.cc: Consolidate... + * testsuite/util/rng/twister_rand_gen.hpp: ... and this + * testsuite/util/testsuite_rng.h: ...here. + + * testsuite/util/native_type/priority_queue: Remove. + * testsuite/util/native_type/priority_queue/ + native_priority_queue.hpp: To... + * testsuite/util/native_type/native_priority_queue.hpp: ...here. + + * testsuite/util/native_type/assoc: Remove. + * testsuite/util/native_type/assoc/native_multimap.hpp: To... + * testsuite/util/native_type/assoc/native_tree_tag.hpp: To... + * testsuite/util/native_type/assoc/native_hash_multimap.hpp: To... + * testsuite/util/native_type/assoc/native_set.hpp: To... + * testsuite/util/native_type/assoc/native_map.hpp: To... + * testsuite/util/native_type/assoc/native_hash_set.hpp: To... + * testsuite/util/native_type/assoc/native_hash_tag.hpp: To... + * testsuite/util/native_type/assoc/native_hash_map.hpp: To... + * testsuite/util/native_type/native_multimap.hpp: ...here. + * testsuite/util/native_type/native_tree_tag.hpp: ...here. + * testsuite/util/native_type/native_hash_multimap.hpp: ...here. + * testsuite/util/native_type/native_set.hpp: ...here. + * testsuite/util/native_type/native_map.hpp: ...here. + * testsuite/util/native_type/native_hash_set.hpp: ...here. + * testsuite/util/native_type/native_hash_tag.hpp: ...here. + * testsuite/util/native_type/native_hash_map.hpp: ...here. + + * testsuite/util/common_type/priority_queue/common_type.hpp: + Make include guard distinct. + * testsuite/util/common_type/assoc/common_type.hpp: Same. + 2008-06-06 Joseph Myers * configure.ac: Do not check for gconv.h. @@ -18,16 +176,16 @@ 2008-06-05 Johannes Singler - * include/parallel/random_shuffle.h: - (parallel_random_shuffle_drs) Get the actual number of - threads after entering the parallel region. Indentation. - * include/parallel/algo.h: (random_shuffle(begin, end)) - Add namespace qualification to avoid ambiguity. + * include/parallel/random_shuffle.h: + (parallel_random_shuffle_drs) Get the actual number of + threads after entering the parallel region. Indentation. + * include/parallel/algo.h: (random_shuffle(begin, end)) + Add namespace qualification to avoid ambiguity. 2008-06-04 Benjamin Kosnik * include/ext/pb_ds/assoc_container.hpp: Change allocator typedef - to allocator_type, as per existing conventions. + to allocator_type, as per existing conventions. * include/ext/pb_ds/detail/binomial_heap_base_/ binomial_heap_base_.hpp: Same. * include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp: Same. @@ -74,7 +232,7 @@ trie_supports_prefix_search.hpp: Same. * testsuite/util/common_type/assoc/detail/ trie_supports_order_statistics.hpp: Same. - + 2008-06-02 Sandra Loosemore Daniel Jacobowitz @@ -82,7 +240,7 @@ dg-require-fileio. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Likewise. * testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc: Likewise. - + 2008-06-02 Paolo Carlini * include/bits/vector.tcc (vector<>::_M_insert_aux): In C++0x mode, @@ -173,7 +331,7 @@ 2008-05-23 Paolo Carlini - * include/std/tuple: Replace int -> size_t throughout per DR 775. + * include/std/tuple: Replace int -> size_t throughout per DR 775. * include/tr1_impl/array: Likewise. * include/tr1_impl/utility: Likewise. * doc/xml/manual/intro.xml: Add an entry for DR 775. @@ -190,7 +348,7 @@ 2008-05-22 Paolo Carlini * include/tr1_impl/hashtable_policy.h (_Map_base<,, - std::_Select1st<_Pair>, true,>::at): Add per DR 761. + std::_Select1st<_Pair>, true,>::at): Add per DR 761. * testsuite/23_containers/unordered_map/dr761.cc: New. * doc/xml/manual/intro.xml: Add an entry for DR 761. @@ -240,7 +398,7 @@ * testsuite/20_util/is_integral/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_integral/requirements/ explicit_instantiation.cc: Likewise. - * testsuite/18_support/numeric_limits/char16_32_t.cc: Likewise. + * testsuite/18_support/numeric_limits/char16_32_t.cc: Likewise. * config/abi/pre/gnu.ver: Export new numeric_limits symbols at GLIBCXX_3.4.11. * configure: Regenerate. @@ -255,7 +413,7 @@ * include/std/ostream: Adjust error_code inserter. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove sys_nerr test. * config/abi/pre/gnu.ver: Add new exports. - + * testsuite/util/testsuite_error.h: Consolidate error testing utilities here. * testsuite/19_diagnostics/error_code/cons/1.cc: Use @@ -266,7 +424,7 @@ * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. - * testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc: + * testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. @@ -282,9 +440,9 @@ 2008-05-15 Johannes Singler - * xml/manual/parallel_mode.xml: - General revision and documentation of new compile-time - options for sorting. + * xml/manual/parallel_mode.xml: + General revision and documentation of new compile-time + options for sorting. 2008-05-14 Benjamin Kosnik @@ -313,7 +471,7 @@ * testsuite/29_atomics/atomic_flag/test_and_set/implicit.c: Same. * doc/doxygen/user.cfg.in: Remove thread include. - + 2008-05-13 David Daney * config/cpu/mips/atomicity.h: Remove file. @@ -344,7 +502,7 @@ * include/parallel/quicksort.h: (parallel_sort_qs_conquer) Explicitly request number of threads in the parallel clause. - (parallel_sort_qs) Remove setting the number of threads globally. + (parallel_sort_qs) Remove setting the number of threads globally. 2008-05-06 Benjamin Kosnik @@ -355,7 +513,7 @@ * testsuite/30_threads/mutex/cons/copy_neg.cc: Same. * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Same. * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Same. - + 2008-05-06 Benjamin Kosnik * include/std/condition_variable: New. diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index fc3c97a..861058d 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -1013,9 +1013,22 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33) - - Exception Safety + + Exceptions + + + Propagating Exceptions aka Exception Neutrality + + + + Exception Safety + + + + Support for <literal>-fno-exceptions</literal> + + diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp index 489ccc1..a32bd72 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp @@ -50,14 +50,11 @@ PB_DS_CLASS_C_DEC:: push(const_reference r_val) { _GLIBCXX_DEBUG_ONLY(assert_valid();) - - insert_value(r_val, s_no_throw_copies_ind); - - std::push_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - + insert_value(r_val, s_no_throw_copies_ind); + std::push_heap(m_a_entries, m_a_entries + m_size, + static_cast(*this)); _GLIBCXX_DEBUG_ONLY(assert_valid();) - - return point_iterator(m_a_entries); + return point_iterator(m_a_entries); } PB_DS_CLASS_T_DEC @@ -76,15 +73,10 @@ PB_DS_CLASS_C_DEC:: insert_value(const_reference r_val, false_type) { resize_for_insert_if_needed(); - pointer p_new = s_value_allocator.allocate(1); - cond_dealtor_t cond(p_new); - new (p_new) value_type(r_val); - cond.set_no_action(); - m_a_entries[m_size++] = p_new; } @@ -94,7 +86,6 @@ PB_DS_CLASS_C_DEC:: insert_entry(entry e) { resize_for_insert_if_needed(); - m_a_entries[m_size++] = e; } @@ -106,23 +97,15 @@ resize_for_insert_if_needed() if (!resize_policy::resize_needed_for_grow(m_size)) { _GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size); - return; } - const size_type new_actual_size = - resize_policy::get_new_size_for_grow(); - + const size_type new_actual_size = resize_policy::get_new_size_for_grow(); entry_pointer a_new_entries = s_entry_allocator.allocate(new_actual_size); - resize_policy::notify_grow_resize(); - std::copy(m_a_entries, m_a_entries + m_size, a_new_entries); - s_entry_allocator.deallocate(m_a_entries, m_actual_size); - m_actual_size = new_actual_size; - m_a_entries = a_new_entries; } @@ -132,13 +115,10 @@ PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { _GLIBCXX_DEBUG_ONLY(assert_valid();) - - swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); - + swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); fix(it.m_p_e); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } +} PB_DS_CLASS_T_DEC void @@ -146,55 +126,44 @@ PB_DS_CLASS_C_DEC:: fix(entry_pointer p_e) { size_type i = p_e - m_a_entries; - - if (i > 0&& entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i])) + if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i])) { size_type parent_i = parent(i); - - while (i > 0&& entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i])) + while (i > 0 + && entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i])) { std::swap(m_a_entries[i], m_a_entries[parent_i]); - i = parent_i; - parent_i = parent(i); } _GLIBCXX_DEBUG_ONLY(assert_valid();) - - return; + return; } while (i < m_size) { const size_type left_child_i = left_child(i); const size_type right_child_i = right_child(i); - _GLIBCXX_DEBUG_ASSERT(right_child_i > left_child_i); - - const bool smaller_than_left_child = - left_child_i < m_size&& + const bool smaller_than_left_child = left_child_i < m_size && entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child_i]); - const bool smaller_than_right_child = - right_child_i < m_size&& + const bool smaller_than_right_child = right_child_i < m_size && entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child_i]); - const bool swap_with_r_child = smaller_than_right_child&& (!smaller_than_left_child || - entry_cmp::operator()(m_a_entries[left_child_i], m_a_entries[right_child_i])); + const bool swap_with_r_child = smaller_than_right_child && (!smaller_than_left_child || entry_cmp::operator()(m_a_entries[left_child_i], m_a_entries[right_child_i])); - const bool swap_with_l_child = !swap_with_r_child&& smaller_than_left_child; + const bool swap_with_l_child = !swap_with_r_child && smaller_than_left_child; if (swap_with_l_child) { std::swap(m_a_entries[i], m_a_entries[left_child_i]); - i = left_child_i; } else if (swap_with_r_child) { std::swap(m_a_entries[i], m_a_entries[right_child_i]); - i = right_child_i; } else diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp index b7503c2..e17c53c 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp @@ -48,15 +48,11 @@ PB_DS_CLASS_T_DEC Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() -{ - return (*this); -} +{ return *this; } PB_DS_CLASS_T_DEC const Cmp_Fn& PB_DS_CLASS_C_DEC:: get_cmp_fn() const -{ - return (*this); -} +{ return *this; } diff --git a/libstdc++-v3/include/ext/pb_ds/priority_queue.hpp b/libstdc++-v3/include/ext/pb_ds/priority_queue.hpp index 3433f51..3b31874 100644 --- a/libstdc++-v3/include/ext/pb_ds/priority_queue.hpp +++ b/libstdc++-v3/include/ext/pb_ds/priority_queue.hpp @@ -59,7 +59,7 @@ namespace __gnu_pbds typename Tag = pairing_heap_tag, typename Allocator = std::allocator > class priority_queue - : public detail::priority_queue_base_dispatch::type + : public detail::priority_queue_base_dispatch::type { private: typedef typename detail::priority_queue_base_dispatch::type base_type; @@ -114,7 +114,7 @@ namespace __gnu_pbds priority_queue& operator=(const priority_queue& other) { - if (this !=& other) + if (this != &other) { priority_queue tmp(other); swap(tmp); diff --git a/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp b/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp index bb39d17..5b5a2f3 100644 --- a/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp +++ b/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -89,70 +89,77 @@ namespace __gnu_pbds { }; - // A mapped-policy indicating that an associative container is a set. + /// A mapped-policy indicating that an associative container is a set. // XXX should this be a trait of the form is_set ?? struct null_mapped_type { }; - // Base data structure tag. + /// Base data structure tag. struct container_tag { }; - // Basic associative-container. + /// Basic string container, inclusive of strings, ropes, etc. + struct string_tag : public container_tag { }; + + /// Basic sequence. + struct sequence_tag : public container_tag { }; + + /// Basic associative-container. struct associative_container_tag : public container_tag { }; - // Basic hash. + /// Basic hash. struct basic_hash_tag : public associative_container_tag { }; - // Collision-chaining hash. + /// Collision-chaining hash. struct cc_hash_tag : public basic_hash_tag { }; - // General-probing hash. + /// General-probing hash. struct gp_hash_tag : public basic_hash_tag { }; - // Basic tree. + /// Basic tree. struct basic_tree_tag : public associative_container_tag { }; - // tree. + /// tree. struct tree_tag : public basic_tree_tag { }; - // Red-black tree. + /// Red-black tree. struct rb_tree_tag : public tree_tag { }; - // Splay tree. + /// Splay tree. struct splay_tree_tag : public tree_tag { }; - // Ordered-vector tree. + /// Ordered-vector tree. struct ov_tree_tag : public tree_tag { }; - // trie. + /// trie. struct trie_tag : public basic_tree_tag { }; - // PATRICIA trie. + /// PATRICIA trie. struct pat_trie_tag : public trie_tag { }; - // List-update. + /// List-update. struct list_update_tag : public associative_container_tag { }; - // Basic priority-queue. + /// Basic priority-queue. struct priority_queue_tag : public container_tag { }; - // Pairing-heap. + /// Pairing-heap. struct pairing_heap_tag : public priority_queue_tag { }; - // Binomial-heap. + /// Binomial-heap. struct binomial_heap_tag : public priority_queue_tag { }; - // Redundant-counter binomial-heap. + /// Redundant-counter binomial-heap. struct rc_binomial_heap_tag : public priority_queue_tag { }; - // Binary-heap (array-based). + /// Binary-heap (array-based). struct binary_heap_tag : public priority_queue_tag { }; - // Thin heap. + /// Thin heap. struct thin_heap_tag : public priority_queue_tag { }; + /// Base traits type for containers. template struct container_traits_base; @@ -337,7 +344,8 @@ namespace __gnu_pbds }; }; - + + /// container_traits // See Matt Austern for the name, S. Meyers MEFC++ #2, others. template struct container_traits diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h index a5aa725..36dc3c0 100644 --- a/libstdc++-v3/include/ext/throw_allocator.h +++ b/libstdc++-v3/include/ext/throw_allocator.h @@ -65,19 +65,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) class twister_rand_gen - { + { + private: + std::tr1::mt19937 _M_generator; + public: - twister_rand_gen(unsigned int seed = - static_cast(std::time(0))); + twister_rand_gen(unsigned int s = static_cast(std::time(0))); void init(unsigned int); double get_prob(); - - private: - std::tr1::mt19937 _M_generator; }; /// Thown by throw_allocator. @@ -116,8 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) struct group_throw_prob_adjustor { - group_throw_prob_adjustor(size_t size) - : _M_throw_prob_orig(_S_throw_prob) + group_throw_prob_adjustor(size_t size) : _M_throw_prob_orig(_S_throw_prob) { _S_throw_prob = 1 - std::pow(double(1 - _S_throw_prob), double(0.5 / (size + 1))); @@ -297,14 +295,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) twister_rand_gen:: get_prob() { - const double eng_min = _M_generator.min(); - const double eng_range = - static_cast(_M_generator.max() - eng_min); - - const double eng_res = - static_cast(_M_generator() - eng_min); - - const double ret = eng_res / eng_range; + const double min = _M_generator.min(); + const double res = static_cast(_M_generator() - min); + const double range = static_cast(_M_generator.max() - min); + const double ret = res / range; _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1); return ret; } @@ -397,7 +391,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) while (it != _S_map.end()) { if (it->second.first == label) - print_to_string(found, *it); + { + print_to_string(found, *it); + } ++it; } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc index 606679b..ab3b624 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc index 202fe14..167d4c1 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc index 7c8bb40..221c0c8 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include int main(int argc, char* a_p_argv[]) diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc index 0d31f5a..262575f 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include int main(int argc, char* a_p_argv[]) diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc index 8f4fdaa..1d253a9 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } @@ -63,7 +63,7 @@ main(int argc, char* a_p_argv[]) { using namespace __gnu_pbds::test; return rand_regression_test(ITERATIONS, KEYS, - "tree_no_data_map_rand_regression_test", + "pq_no_data_map_rand_regression_test", pq_tl_t()); } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc index b08fb85..3bcdebf 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc index 6f1024f..acb6911 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc index bd55a83..64335b0 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc index 3407825..93b2bdd 100644 --- a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc +++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc @@ -48,7 +48,7 @@ // { dg-require-time "" } #include -#include +#include // This can take long on simulators, timing out the test. // { dg-options "-DPB_DS_REGRESSION -DITERATIONS=5" { target simulator } } diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 5f68d78..d6b372b 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -513,7 +513,7 @@ proc v3-build_support { } { # Build the support objects. set source_files [list testsuite_abi.cc testsuite_allocator.cc \ testsuite_character.cc testsuite_hooks.cc \ - rng/twister_rand_gen.cc io/verified_cmd_line_input.cc \ + io/verified_cmd_line_input.cc \ io/prog_bar.cc performance/time/elapsed_timer.cc ] foreach f $source_files { set obj [file rootname $f].o diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc index cb7720c..042072103 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_random_int_find_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_random_int_find_timing.cc index d3cebc8..ee25ce9 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_random_int_find_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_random_int_find_timing.cc @@ -46,9 +46,9 @@ #include #include -#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp index 2b8a2a9..ad068a5 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_timing.hpp @@ -47,10 +47,10 @@ #include #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp index a485a8b..8f6fc7e 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp @@ -50,10 +50,10 @@ #include #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp index f7f33f0..8e98606 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_timing.hpp @@ -47,10 +47,10 @@ #include #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc index ad6fdd1..a6e9338 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc @@ -49,8 +49,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_timing.cc index 5ab8db1..0022510a 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_random_int_push_timing.cc @@ -49,8 +49,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join_timing.cc index c5ba556..6b8904c 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join_timing.cc @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp index e8dffa6..bcec33c 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc index adbbc03..f4655fe 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc @@ -53,7 +53,7 @@ #include #include #include -#include +#include void usage(); diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop_timing.cc index 65a009c..6a222ec 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop_timing.cc @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_timing.cc index 6fcaa0d..9967c7d 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_timing.cc @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_find_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_find_timing.cc index 87d14d7..8e06155 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_find_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_find_timing.cc @@ -46,10 +46,10 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_find_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_find_timing.cc index e336114..461ce4d 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_find_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_find_timing.cc @@ -46,10 +46,10 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_insert_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_insert_timing.cc index e9554c1..a30e3c5 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_insert_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/random_int_subscript_insert_timing.cc @@ -46,10 +46,10 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/text_find_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/text_find_timing.cc index 8409a4a..e769984 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/text_find_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/text_find_timing.cc @@ -51,8 +51,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc index 2ca61ca..da1dda8 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join_timing.cc index 9c4970f..72101cf 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join_timing.cc @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc index 23a6302..b5d74f0 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert_timing.cc @@ -51,8 +51,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc index 44329b3..eb4cbba 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find_timing.cc @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp index e5af5c2..d2f7fa0 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp @@ -44,8 +44,8 @@ * Contains common types. */ -#ifndef PB_DS_COMMON_TYPES_HPP -#define PB_DS_COMMON_TYPES_HPP +#ifndef PB_DS_COMMON_TYPES_ASSOC_HPP +#define PB_DS_COMMON_TYPES_ASSOC_HPP #include #include @@ -812,7 +812,6 @@ namespace __gnu_pbds }; } // namespace test - } // namespace __gnu_pbds -#endif // #ifndef PB_DS_COMMON_TYPES_HPP +#endif // #ifndef PB_DS_COMMON_TYPES_ASSOC_HPP diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp index 41d908e..248ab3c 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp @@ -53,69 +53,55 @@ namespace __gnu_pbds { +namespace test +{ +namespace detail +{ - namespace test + template + struct comb_hash_fn_string_form + { + static std::string + name() + { return (Comb_Hash_Fn::name()); } + + static std::string + desc() + { return (Comb_Hash_Fn::desc()); } + }; + + template + struct comb_hash_fn_string_form< + direct_mask_range_hashing_t_< + Size_Type> > { + static std::string + name() + { return ("mask_"); } - namespace detail + static std::string + desc() { + return make_xml_tag("Comb_Hash_Fn", "value", "direct_mask_range_hashing"); + } + }; - template - struct comb_hash_fn_string_form - { - static std::string - name() - { - return (Comb_Hash_Fn::name()); - } - - static std::string - desc() - { - return (Comb_Hash_Fn::desc()); - } - }; - - template - struct comb_hash_fn_string_form< - direct_mask_range_hashing_t_< - Size_Type> > - { - static std::string - name() - { - return ("mask_"); - } - - static std::string - desc() - { - return (make_xml_tag( "Comb_Hash_Fn", "value", "direct_mask_range_hashing")); - } - }; - - template - struct comb_hash_fn_string_form< - direct_mod_range_hashing_t_< - Size_Type> > - { - static std::string - name() - { - return ("mod_"); - } - - static std::string - desc() - { - return (make_xml_tag( "Comb_Hash_Fn", "value", "direct_mod_range_hashing")); - } - }; - - } // namespace detail - - } // namespace test + template + struct comb_hash_fn_string_form > + { + static std::string + name() + { return ("mod_"); } + + static std::string + desc() + { + return make_xml_tag("Comb_Hash_Fn", "value", "direct_mod_range_hashing"); + } + }; +} // namespace detail +} // namespace test } // namespace __gnu_pbds #endif // #ifndef PB_DS_COMB_HASH_FN_STRING_FORM_HPP diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp index 28625af..485f413 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp @@ -61,20 +61,15 @@ namespace __gnu_pbds { - namespace test { - namespace detail { - template struct ds_string_form; template - struct ds_string_form< - Cntnr, - __gnu_pbds::cc_hash_tag> + struct ds_string_form { static std::string name() @@ -97,14 +92,12 @@ namespace __gnu_pbds const std::string store_hash_desc = store_hash_string_form::desc(); - return (make_xml_tag( "type", "value", "cc_hash_table", comb_hash_fn_desc + resize_policy_desc + store_hash_desc)); + return (make_xml_tag("type", "value", "cc_hash_table", comb_hash_fn_desc + resize_policy_desc + store_hash_desc)); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::gp_hash_tag> + struct ds_string_form { static std::string name() @@ -130,8 +123,9 @@ namespace __gnu_pbds const std::string store_hash_desc = store_hash_string_form::desc(); - - return (make_xml_tag( "type", "value", "gp_hash_table", comb_probe_fn_desc + probe_fn_desc + resize_policy_desc + store_hash_desc)); + + return make_xml_tag("type", "value", "gp_hash_table", + comb_probe_fn_desc + probe_fn_desc + resize_policy_desc + store_hash_desc); } }; @@ -143,31 +137,27 @@ namespace __gnu_pbds { if (tree_supports_order_statistics::value) return (container_category_str + "ost_"); - - return (container_category_str); + return container_category_str; } static std::string desc(const std::string container_category_str) { const std::string category_str = - make_xml_tag( "Tag", "value", container_category_str); + make_xml_tag("Tag", "value", container_category_str); const std::string node_update_str = - make_xml_tag( - "Node_Update", - "value",(tree_supports_order_statistics::value? - "tree_order_statistics_node_update" : "null_tree_node_update")); + make_xml_tag("Node_Update", + "value",(tree_supports_order_statistics::value ? + "tree_order_statistics_node_update" : "null_tree_node_update")); - return (make_xml_tag( "type", "value", "tree", category_str + node_update_str)); + return make_xml_tag("type", "value", "tree", category_str + node_update_str); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::rb_tree_tag> : private tree_ds_string_form< - Cntnr> + struct ds_string_form + : private tree_ds_string_form { private: typedef tree_ds_string_form< Cntnr> base_type; @@ -175,22 +165,16 @@ namespace __gnu_pbds public: static std::string name() - { - return (base_type::name("rb_tree_")); - } + { return base_type::name("rb_tree_"); } static std::string desc() - { - return (base_type::desc("rb_tree_tag")); - } + { return base_type::desc("rb_tree_tag"); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::splay_tree_tag> : private tree_ds_string_form< - Cntnr> + struct ds_string_form + : private tree_ds_string_form { private: typedef tree_ds_string_form< Cntnr> base_type; @@ -198,22 +182,16 @@ namespace __gnu_pbds public: static std::string name() - { - return (base_type::name("splay_tree_")); - } + { return base_type::name("splay_tree_"); } static std::string desc() - { - return (base_type::desc("splay_tree_tag")); - } + { return base_type::desc("splay_tree_tag"); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::ov_tree_tag> : private tree_ds_string_form< - Cntnr> + struct ds_string_form + : private tree_ds_string_form { private: typedef tree_ds_string_form< Cntnr> base_type; @@ -221,21 +199,15 @@ namespace __gnu_pbds public: static std::string name() - { - return (base_type::name("ov_tree_")); - } + { return (base_type::name("ov_tree_")); } static std::string desc() - { - return (base_type::desc("ov_tree_tag")); - } + { return (base_type::desc("ov_tree_tag")); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::list_update_tag> + struct ds_string_form { static std::string name() @@ -247,18 +219,13 @@ namespace __gnu_pbds static std::string desc() { - return (make_xml_tag( - "type", - "value", - "list_update", - lu_policy_string_form::desc())); + return make_xml_tag("type", "value", "list_update", + lu_policy_string_form::desc()); } }; template - struct ds_string_form< - Cntnr, - __gnu_pbds::pat_trie_tag> + struct ds_string_form { static std::string name() @@ -275,22 +242,16 @@ namespace __gnu_pbds static std::string desc() { - const std::string category_str = - make_xml_tag( "Tag", "value", "pat_trie_tag"); - - std::string node_update_desc; - + std::string category_s = make_xml_tag("Tag", "value", "pat_trie_tag"); + const char* s; if (trie_supports_order_statistics::value) - node_update_desc = - make_xml_tag( "Node_Update", "value", "trie_order_statistics_node_update"); + s = "trie_order_statistics_node_update"; else if (trie_supports_prefix_search::value) - node_update_desc = - make_xml_tag( "Node_Update", "value", "trie_prefix_search_node_update"); + s = "trie_prefix_search_node_update"; else - node_update_desc = - make_xml_tag( "Node_Update", "value", "null_trie_node_update"); - - return (make_xml_tag( "type", "value", "trie", category_str + node_update_desc)); + s = "null_trie_node_update"; + std::string node_s = make_xml_tag("Node_Update", "value", s); + return make_xml_tag("type", "value", "trie", category_s + node_s); } }; diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp index 08b6505..e5c9067 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp @@ -64,42 +64,36 @@ namespace __gnu_pbds struct lu_policy_string_form; template<> - struct lu_policy_string_form< - move_to_front_lu_policy_t_> + struct lu_policy_string_form { static std::string name() - { - return ("mtf_"); - } + { return ("mtf_"); } static std::string desc() { - return (make_xml_tag( "Update_Policy", "value", "move_to_front_lu_policy")); + return make_xml_tag("Update_Policy", "value", + "move_to_front_lu_policy"); } }; template - struct lu_policy_string_form< - counter_lu_policy_t_< - Allocator, - Max_Count> > + struct lu_policy_string_form > { static std::string name() { std::ostringstream ret; - ret << "cnt_" << Max_Count << "_"; - return (ret.str()); } static std::string desc() { - return (make_xml_tag( "Update_Policy", "value", "counter_lu_policy", "Max_Count", Max_Count)); + return (make_xml_tag("Update_Policy", "value", "counter_lu_policy", + "Max_Count", Max_Count)); } }; diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp index 84c5d04..6e335dc 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp @@ -64,58 +64,39 @@ namespace __gnu_pbds struct probe_fn_string_form; template - struct probe_fn_string_form< - linear_probe_fn_t_< - Key, - Allocator> > + struct probe_fn_string_form > { static std::string name() - { - return ("linp_"); - } + { return ("linp_"); } static std::string desc() - { - return (make_xml_tag( "Probe_Fn", "value", "linear_probe_fn")); - } + { return make_xml_tag("Probe_Fn", "value", "linear_probe_fn"); } }; template - struct probe_fn_string_form< - quadratic_probe_fn_t_< - Key, - Allocator> > + struct probe_fn_string_form > { static std::string name() - { - return ("quadp_"); - } + { return ("quadp_"); } static std::string desc() - { - return (make_xml_tag( "Probe_Fn", "value", "quadratic_probe_fn")); - } + { return make_xml_tag("Probe_Fn", "value", "quadratic_probe_fn"); } }; template<> - struct probe_fn_string_form< - __gnu_pbds::null_probe_fn> + struct probe_fn_string_form<__gnu_pbds::null_probe_fn> { static std::string name() - { - return (""); - } + { return (""); } static std::string desc() - { - return (make_xml_tag( "Probe_Fn", "value", "null_probe_fn")); - } + { return make_xml_tag("Probe_Fn", "value", "null_probe_fn"); } }; } // namespace detail diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp index 8507163..f6dc010 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp @@ -71,10 +71,7 @@ namespace __gnu_pbds typename Size_Type> struct resize_policy_string_form< __gnu_pbds::hash_standard_resize_policy< - Size_Policy, - Trigger_Policy, - External_Size_Access, - Size_Type> > + Size_Policy, Trigger_Policy, External_Size_Access, Size_Type> > { static std::string name() @@ -92,7 +89,7 @@ namespace __gnu_pbds const std::string trigger_policy_string_form_desc = trigger_policy_string_form::desc(); - return (make_xml_tag( "Resize_Policy", "value", "hash_standard_resize_policy", size_policy_string_form_desc + trigger_policy_string_form_desc)); + return (make_xml_tag("Resize_Policy", "value", "hash_standard_resize_policy", size_policy_string_form_desc + trigger_policy_string_form_desc)); } }; diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp index 876505b..3b8dffa 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp @@ -67,19 +67,16 @@ namespace __gnu_pbds template struct size_policy_string_form< - __gnu_pbds::test::hash_exponential_size_policy_t_< - Allocator> > + __gnu_pbds::test::hash_exponential_size_policy_t_ > { static std::string name() - { - return ("exp_"); - } + { return ("exp_"); } static std::string desc() { - return (make_xml_tag( "Size_Policy", "value", "hash_exponential_size_policy")); + return (make_xml_tag("Size_Policy", "value", "hash_exponential_size_policy")); } }; @@ -89,14 +86,12 @@ namespace __gnu_pbds { static std::string name() - { - return ("prime_"); - } + { return ("prime_"); } static std::string desc() { - return (make_xml_tag( "Size_Policy", "value", "hash_prime_size_policy")); + return (make_xml_tag("Size_Policy", "value", "hash_prime_size_policy")); } }; diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp index 89ef675..218362e 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp @@ -65,38 +65,27 @@ namespace __gnu_pbds { static std::string name() - { - return ("sth_"); - } + { return ("sth_"); } static std::string desc() - { - return (make_xml_tag( "Store_Hash", "value", "true")); - } + { return (make_xml_tag("Store_Hash", "value", "true")); } }; template<> - struct store_hash_string_form< - false> + struct store_hash_string_form { static std::string name() - { - return ("nsth_"); - } + { return ("nsth_"); } static std::string desc() - { - return (make_xml_tag( "Store_Hash", "value", "false")); - } + { return (make_xml_tag("Store_Hash", "value", "false")); } }; } // namespace detail - } // namespace test - } // namespace __gnu_pbds #endif // #ifndef PB_DS_STORE_HASH_STRING_FORM_HPP diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp index 8169d93..abb4f41 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp @@ -94,15 +94,14 @@ namespace __gnu_pbds desc() { const std::string ext_access_desc = - make_xml_tag( - "External_Access", + make_xml_tag("External_Access", "value",(External_Access? "true" : "false")); const std::string loads_desc = - make_xml_tag( "alpha_min", "nom", Min_Load_Nom, "denom", Min_Load_Denom) + - make_xml_tag( "alpha_max", "nom", Max_Load_Nom, "denom", Max_Load_Denom); + make_xml_tag("alpha_min", "nom", Min_Load_Nom, "denom", Min_Load_Denom) + + make_xml_tag("alpha_max", "nom", Max_Load_Nom, "denom", Max_Load_Denom); - return (make_xml_tag( "Trigger_Policy", "value", "hash_load_check_resize_trigger", ext_access_desc + loads_desc)); + return (make_xml_tag("Trigger_Policy", "value", "hash_load_check_resize_trigger", ext_access_desc + loads_desc)); } }; @@ -132,14 +131,13 @@ namespace __gnu_pbds desc() { const std::string ext_access_desc = - make_xml_tag( - "External_Access", + make_xml_tag("External_Access", "value",(External_Access? "true" : "false")); const std::string load_desc = - make_xml_tag( "alpha", "nom", Load_Nom, "denom", Load_Denom); + make_xml_tag("alpha", "nom", Load_Nom, "denom", Load_Denom); - return (make_xml_tag( "Trigger_Policy", "value", "cc_hash_max_collision_check_resize_trigger", ext_access_desc + load_desc)); + return (make_xml_tag("Trigger_Policy", "value", "cc_hash_max_collision_check_resize_trigger", ext_access_desc + load_desc)); } }; diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp index 4667c9d4..9b533a5 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp @@ -48,7 +48,7 @@ #define PB_DS_NATIVE_SET_HPP #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp index 73015b8..624faf3 100644 --- a/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp @@ -51,11 +51,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp index 80176db..4c3217d 100644 --- a/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp +++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp @@ -44,8 +44,8 @@ * Contains common types. */ -#ifndef PB_DS_COMMON_TYPES_HPP -#define PB_DS_COMMON_TYPES_HPP +#ifndef PB_DS_COMMON_TYPES_PQ_HPP +#define PB_DS_COMMON_TYPES_PQ_HPP #include #include @@ -60,8 +60,6 @@ namespace __gnu_pbds struct pq_common_types { private: - // typedef typename Allocator::size_type size_type; - typedef __gnu_pbds::priority_queue pairing_heap_t; typedef __gnu_pbds::priority_queue binomial_heap_t; @@ -84,4 +82,4 @@ namespace __gnu_pbds } // namespace test } // namespace __gnu_pbds -#endif // #ifndef PB_DS_COMMON_TYPES_HPP +#endif // #ifndef PB_DS_COMMON_TYPES_PQ_HPP diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp index bf3b688..d4846ba 100644 --- a/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp @@ -120,6 +120,18 @@ namespace __gnu_pbds { return make_xml_tag("type", "value", "binary_heap"); } }; + template + struct ds_string_form + { + static std::string + name() + { return "sequence"; } + + static std::string + desc() + { return make_xml_tag("type", "value", "sequence"); } + }; + } // namespace detail } // namespace test } // namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp index 0e5b0ce..aca597f 100644 --- a/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp +++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/io/prog_bar.cc b/libstdc++-v3/testsuite/util/io/prog_bar.cc index b306762..572d8a7 100644 --- a/libstdc++-v3/testsuite/util/io/prog_bar.cc +++ b/libstdc++-v3/testsuite/util/io/prog_bar.cc @@ -48,10 +48,8 @@ namespace __gnu_pbds { - namespace test { - prog_bar:: prog_bar(size_t max, std::ostream& r_os, bool display/*= true*/) : m_cur(0), @@ -78,11 +76,10 @@ namespace __gnu_pbds if (m_display == false) return; - while (m_cur* num_disp >= m_max* m_cur_disp&& m_cur_disp < num_disp) + while (m_cur * num_disp >= m_max * m_cur_disp && m_cur_disp < num_disp) { m_r_os << '*'; m_r_os.flush(); - ++m_cur_disp; } } diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp similarity index 98% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp rename to libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp index 5db3611..dacf3f7 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp similarity index 96% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp rename to libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp index f644ae2..0226f83 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_multimap.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include namespace __gnu_pbds @@ -76,12 +76,12 @@ namespace __gnu_pbds public: typedef native_hash_tag container_category; - typedef Allocator allocator_type; + typedef Allocator allocator; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef - typename allocator_type::template rebind::other::const_reference + typename allocator::template rebind::other::const_reference const_reference; native_hash_multimap() : base_type(Init_Size) diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp similarity index 98% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp rename to libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp index 86ad248..032fe1f 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_tag.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp similarity index 100% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_hash_tag.hpp rename to libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_map.hpp similarity index 98% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_map.hpp rename to libstdc++-v3/testsuite/util/native_type/native_map.hpp index 1be7ee5..d2ae833 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_map.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_map.hpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp similarity index 98% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp rename to libstdc++-v3/testsuite/util/native_type/native_multimap.hpp index c9e1211..c06a2ad 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_multimap.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include namespace __gnu_pbds { @@ -70,7 +70,7 @@ namespace __gnu_pbds public: typedef native_tree_tag container_category; - typedef Allocator allocator_type; + typedef Allocator allocator; typedef typename Allocator::template rebind< diff --git a/libstdc++-v3/testsuite/util/native_type/priority_queue/native_priority_queue.hpp b/libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp similarity index 100% rename from libstdc++-v3/testsuite/util/native_type/priority_queue/native_priority_queue.hpp rename to libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_set.hpp similarity index 98% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_set.hpp rename to libstdc++-v3/testsuite/util/native_type/native_set.hpp index b25f2ba..c7e8cfe 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_set.hpp +++ b/libstdc++-v3/testsuite/util/native_type/native_set.hpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_tree_tag.hpp b/libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp similarity index 100% rename from libstdc++-v3/testsuite/util/native_type/assoc/native_tree_tag.hpp rename to libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp diff --git a/libstdc++-v3/testsuite/util/regression/basic_type.hpp b/libstdc++-v3/testsuite/util/regression/basic_type.hpp index 93a1292..61b094a 100644 --- a/libstdc++-v3/testsuite/util/regression/basic_type.hpp +++ b/libstdc++-v3/testsuite/util/regression/basic_type.hpp @@ -41,7 +41,7 @@ /** * @file basic_type.hpp - * Containsert a type used for regression tests' key and data. + * Contains a type used for regression tests' key and data. */ #ifndef PB_DS_BASIC_TYPE_HPP diff --git a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp b/libstdc++-v3/testsuite/util/regression/common_type.hpp similarity index 75% rename from libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp rename to libstdc++-v3/testsuite/util/regression/common_type.hpp index 61f04a8..1bfaa30 100644 --- a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp +++ b/libstdc++-v3/testsuite/util/regression/common_type.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -47,8 +47,10 @@ #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP #define PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP +#include #include #include +#include namespace __gnu_pbds { @@ -119,7 +121,64 @@ namespace test typedef tl_t min_tl_t; }; + + // Sequence types. + typedef pq_common_types, alloc_type> pq_types; + + typedef pq_types::regression_tl pq_tl_t; + typedef pq_tl_t min_pq_tl_t; + + template + struct vector_adaptor : public std::vector<_Tp, _Alloc> + { + private: + typedef std::vector<_Tp, _Alloc> base_type; + + public: + typedef typename base_type::value_type value_type; + typedef typename base_type::pointer pointer; + typedef typename base_type::const_pointer const_pointer; + typedef typename base_type::reference reference; + typedef typename base_type::const_reference const_reference; + typedef typename base_type::iterator iterator; + typedef typename base_type::const_iterator const_iterator; + typedef typename base_type::reverse_iterator reverse_iterator; + typedef typename base_type::const_reverse_iterator const_reverse_iterator; + typedef typename base_type::size_type size_type; + typedef typename base_type::difference_type difference_type; + typedef typename base_type::allocator_type allocator_type; + + typedef __gnu_pbds::sequence_tag container_category; + typedef std::less<_Tp> cmp_fn; + + const cmp_fn& + get_cmp_fn() const + { return _M_cmp; } + + vector_adaptor() { } + vector_adaptor(iterator) { } + vector_adaptor(iterator, iterator) { } + vector_adaptor(iterator, iterator, const cmp_fn&) { } + vector_adaptor(const cmp_fn& other) { } + + using base_type::push_back; + using base_type::pop_back; + + // erase_if + + cmp_fn _M_cmp; + + }; + + namespace detail + { + + }; + + typedef vector_adaptor vector_type; + typedef __gnu_cxx::typelist::create1::type vector_tl_t; + // Associative types. typedef tree_types::tl_t tree_set_tl_t; typedef tree_types::min_tl_t min_tree_set_tl_t; typedef tree_types::tl_t tree_map_tl_t; diff --git a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp b/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp deleted file mode 100644 index 7740a91..0000000 --- a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 common_type.hpp - * Contains types used for regression tests. - */ - -#ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP -#define PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP - -#include -#include - -namespace __gnu_pbds -{ -namespace test -{ - typedef __gnu_cxx::throw_allocator alloc_type; - - typedef pq_common_types, alloc_type>::regression_tl pq_tl_t; - - typedef pq_tl_t min_pq_tl_t; -} // namespace test -} // namespace __gnu_pbds - -#endif diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h similarity index 88% rename from libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp rename to libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h index af0a8e1..c9f6186 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -40,12 +40,12 @@ // warranty. /** - * @file container_rand_regression_test.hpp + * @file container_rand_regression_test.h * Contains a random regression test for a specific container type. */ -#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_HPP -#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_HPP +#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_H +#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_H #include #include @@ -53,10 +53,10 @@ #include #include #include -#include +#include #include #include -#include +#include namespace __gnu_pbds { @@ -64,54 +64,6 @@ namespace test { namespace detail { - -#ifdef PB_DS_REGRESSION_TRACE -#define PB_DS_TRACE(X) std::cerr << X << std::endl -#else -#define PB_DS_TRACE(X) -#endif - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - container_rand_regression_test - -#define PB_DS_COND_COMPARE(L, R) \ - if (m_g.get_prob() < m_mp) \ - cmp(L, R, __FUNCTION__); - -#define PB_DS_RUN_MTHD(MTHD) \ - { \ - bool done = false; \ - \ - while (!done) \ - done = MTHD(); \ - } - -#define PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, F, L) \ - if (!(PRED)) \ - { \ - std::cerr << "Failure at " << F << ": " << L << std::endl; \ - std::cerr << MORE << std::endl; \ - std::cerr << "container:" << std::endl; \ - print_container(*(P_C)); \ - std::cerr << std::endl; \ - std::cerr << "native container:" << std::endl; \ - print_container(*(P_NC)); \ - std::cerr << std::endl; \ - throw std::logic_error("fucked!"); \ - } - -#define PB_DS_THROW_IF_FAILED(PRED, MORE, P_C, P_NC) \ - PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__) - -#define PB_DS_SET_DESTRUCT_PRINT \ - destructor_printer dest_print___(__FUNCTION__); - -#define PB_DS_CANCEL_DESTRUCT_PRINT \ - dest_print___.cancel_print(); - // Rand test specialized for a specific container. template class container_rand_regression_test @@ -129,7 +81,7 @@ namespace detail private: typedef Cntnr cntnr; - typedef typename cntnr::allocator_type allocator_type; + typedef typename cntnr::allocator_type allocator_type; typedef typename cntnr::size_type size_type; typedef regression_test_traits test_traits; typedef typename test_traits::key_type key_type; @@ -137,7 +89,7 @@ namespace detail typedef typename test_traits::value_type value_type; typedef typename test_traits::native_type native_type; typedef twister_rand_gen gen; - typedef __gnu_pbds::container_traits container_traits; + typedef __gnu_pbds::container_traits container_traits; typedef __gnu_cxx::throw_allocator alloc_t; enum op @@ -467,21 +419,54 @@ namespace detail size_t m_i; }; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifdef PB_DS_REGRESSION_TRACE +#define PB_DS_TRACE(X) std::cerr << X << std::endl +#else +#define PB_DS_TRACE(X) +#endif + +#define PB_DS_CLASS_T_DEC \ + template + +#define PB_DS_CLASS_C_DEC \ + container_rand_regression_test + +#define PB_DS_COND_COMPARE(L, R) \ + if (m_g.get_prob() < m_mp) \ + cmp(L, R, __FUNCTION__); + +#define PB_DS_RUN_MTHD(MTHD) \ + { \ + bool done = false; \ + \ + while (!done) \ + done = MTHD(); \ + } + +#define PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, F, L) \ + if (!(PRED)) \ + { \ + std::cerr << "Failure at " << F << ": " << L << std::endl; \ + std::cerr << MORE << std::endl; \ + std::cerr << "container:" << std::endl; \ + print_container(*(P_C)); \ + std::cerr << std::endl; \ + std::cerr << "native container:" << std::endl; \ + print_container(*(P_NC)); \ + std::cerr << std::endl; \ + throw std::logic_error("fucked!"); \ + } + +#define PB_DS_THROW_IF_FAILED(PRED, MORE, P_C, P_NC) \ + PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__) + +#define PB_DS_SET_DESTRUCT_PRINT \ + destructor_printer dest_print___(__FUNCTION__); + +#define PB_DS_CANCEL_DESTRUCT_PRINT \ + dest_print___.cancel_print(); + +#include #undef PB_DS_COND_COMPARE #undef PB_DS_RUN_MTHD diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc new file mode 100644 index 0000000..6d676a9 --- /dev/null +++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc @@ -0,0 +1,2143 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. +// +// This file 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 container_rand_regression_test.tcc + * Contains a random regression test for a specific container type. + */ + +#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC +#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC + +// Constructors/Destructors. +PB_DS_CLASS_T_DEC +PB_DS_CLASS_C_DEC:: +container_rand_regression_test(unsigned long seed, size_t n, size_t m, + double tp, double ip, double ep, double cp, + double mp, bool disp) +: m_seed((seed == 0) ? twister_rand_gen::get_time_determined_seed() : seed), + m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp), m_mp(mp), + m_disp(disp), m_p_c(NULL) +{ } + +PB_DS_CLASS_T_DEC +PB_DS_CLASS_C_DEC:: +~container_rand_regression_test() +{ } + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +default_constructor() +{ + PB_DS_TRACE("default_constructor"); + bool done = true; + m_alloc.set_throw_prob(m_tp); + + try + { + m_p_c = new Cntnr; + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + } + + if (m_p_c != NULL) + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +swap() +{ + PB_DS_TRACE("swap"); + m_alloc.set_throw_prob(0); + Cntnr* p_c = new Cntnr; + m_alloc.set_throw_prob(1); + p_c->swap(*m_p_c); + std::swap(p_c, m_p_c); + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +copy_constructor() +{ + PB_DS_TRACE("copy_constructor"); + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + p_c = new Cntnr(*m_p_c); + std::swap(p_c, m_p_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +assignment_operator() +{ + PB_DS_TRACE("assignment operator"); + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + p_c = new Cntnr(); + * p_c =* m_p_c; + std::swap(p_c, m_p_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor() +{ + PB_DS_TRACE("it_constructor"); + return it_constructor_imp(typename Cntnr::container_category()); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor_imp(__gnu_pbds::cc_hash_tag) +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + switch(get_next_sub_op(8)) + { + case 0: + p_c = new Cntnr(m_p_c->get_hash_fn()); + m_native_c.clear(); + break; + case 1: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn()); + m_native_c.clear(); + break; + case 2: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_hash_fn()); + m_native_c.clear(); + break; + case 3: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_hash_fn(), + m_p_c->get_resize_policy()); + m_native_c.clear(); + break; + case 4: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end()); + break; + case 5: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn()); + break; + case 6: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn()); + break; + case 7: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn()); + break; + case 8: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn(), + m_p_c->get_resize_policy()); + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + }; + std::swap(p_c, m_p_c); + } + catch (__gnu_cxx::forced_exception_error&) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor_imp(__gnu_pbds::gp_hash_tag) +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + switch(get_next_sub_op(11)) + { + case 0: + p_c = new Cntnr(m_p_c->get_hash_fn()); + m_native_c.clear(); + break; + case 1: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn()); + m_native_c.clear(); + break; + case 2: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_probe_fn()); + m_native_c.clear(); + break; + case 3: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_probe_fn()); + m_native_c.clear(); + break; + case 4: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn()); + m_native_c.clear(); + break; + case 5: + p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), + m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn(), + m_p_c->get_resize_policy()); + m_native_c.clear(); + break; + case 6: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn()); + break; + case 7: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn()); + break; + case 8: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn()); + break; + case 9: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn()); + break; + case 10: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(), + m_p_c->get_probe_fn()); + break; + case 11: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), + m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(), + m_p_c->get_probe_fn(), m_p_c->get_resize_policy()); + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + }; + std::swap(p_c, m_p_c); + } + catch (__gnu_cxx::forced_exception_error&) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor_imp(__gnu_pbds::tree_tag) +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + switch(get_next_sub_op(2)) + { + case 0: + p_c = new Cntnr(m_p_c->get_cmp_fn()); + m_native_c.clear(); + break; + case 1: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn()); + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + }; + std::swap(p_c, m_p_c); + } + catch (__gnu_cxx::forced_exception_error&) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor_imp(__gnu_pbds::list_update_tag) +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + p_c = new Cntnr(m_p_c->begin(), m_p_c->end()); + std::swap(p_c, m_p_c); + } + catch (__gnu_cxx::forced_exception_error&) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor_imp(__gnu_pbds::pat_trie_tag) +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + try + { + switch(get_next_sub_op(2)) + { + case 0: + p_c = new Cntnr(m_p_c->get_e_access_traits()); + m_native_c.clear(); + break; + case 1: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), + m_p_c->get_e_access_traits()); + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + }; + + std::swap(p_c, m_p_c); + } + catch (__gnu_cxx::forced_exception_error&) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +// Cmp. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +cmp(const Cntnr& r_c, const native_type& r_native_c, + const std::string& r_call_fn) +{ + m_alloc.set_throw_prob(1); + const size_t size = r_c.size(); + const size_t native_size = r_native_c.size(); + PB_DS_THROW_IF_FAILED(size == native_size, + size << " " << native_size, &r_c, &r_native_c); + + const bool empty = r_c.empty(); + const bool native_empty = r_native_c.empty(); + PB_DS_THROW_IF_FAILED(empty == native_empty, + empty << " " << native_empty, &r_c, &r_native_c); + + try + { + basic_cmp_(r_c, r_native_c); + cmp_(r_c, r_native_c); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "call-fn: " + r_call_fn, &r_c, &r_native_c); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +basic_cmp_(const Cntnr& r_c, const native_type& r_native_c) +{ + PB_DS_SET_DESTRUCT_PRINT + + if (static_cast(std::distance(r_c.begin(), r_c.end())) != r_c.size()) + PB_DS_THROW_IF_FAILED(false, + static_cast(std::distance(r_c.begin(), r_c.end())) << " " << static_cast(r_c.size()), &r_c, &r_native_c); + + typename native_type::const_iterator it = r_native_c.begin(); + while (it != r_native_c.end()) + { + typename native_type::key_type native_key = test_traits::extract_native_key(*it); + + m_alloc.set_throw_prob(0); + const key_type k = native_key; + m_alloc.set_throw_prob(1); + typename cntnr::const_point_iterator found_it = r_c.find(k); + PB_DS_THROW_IF_FAILED(found_it != r_c.end(), + test_traits::native_val_to_string(*it), + &r_c, &r_native_c); + + if (!test_traits::cmp(*found_it, * it)) + PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c); + + ++it; + } + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +cmp_(const Cntnr& r_c, const native_type& r_native_c) +{ + enum + { + order_preserving = container_traits::order_preserving, + back_order_preserving = container_traits::order_preserving + && + !__gnu_pbds::detail::is_same< + typename std::iterator_traits< + typename cntnr::const_iterator>::iterator_category, + std::forward_iterator_tag>::value, + reverse_iteration = container_traits::reverse_iteration, + order_statistics = test_traits::order_statistics, + prefix_search = test_traits::prefix_search, + has_mapped = !__gnu_pbds::detail::is_same< + typename Cntnr::mapped_type, + __gnu_pbds::null_mapped_type>::value + }; + + order_preserving_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + back_order_preserving_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + order_statistics_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + prefix_search_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + reverse_iteration_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + lower_bound_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); + + upper_bound_cmp_imp(r_c, r_native_c, + __gnu_pbds::detail::integral_constant()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +order_preserving_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + + typename cntnr::const_iterator b = r_c.begin(); + typename cntnr::const_iterator e = r_c.end(); + + typename native_type::const_iterator native_b = r_native_c.begin(); + typename native_type::const_iterator native_e = r_native_c.end(); + + try + { + it_cmp_imp(b, e, native_b, native_e); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c) + } + + try + { + back_it_cmp_imp(b, e, native_b, native_e); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c) + } + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +back_order_preserving_cmp_imp(const Cntnr&, const native_type&, + __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, + __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + typename cntnr::const_iterator b = r_c.begin(); + typename cntnr::const_iterator e = r_c.end(); + typename native_type::const_iterator native_b = r_native_c.begin(); + typename native_type::const_iterator native_e = r_native_c.end(); + it_cmp_imp(b, e, native_b, native_e); + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +reverse_iteration_cmp_imp(const Cntnr&, const native_type&, + __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type&r_native_c, __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + + typename cntnr::const_reverse_iterator b = r_c.rbegin(); + typename cntnr::const_reverse_iterator e = r_c.rend(); + + typename native_type::const_reverse_iterator native_b = r_native_c.rbegin(); + typename native_type::const_reverse_iterator native_e = r_native_c.rend(); + + try + { + it_cmp_imp(b, e, native_b, native_e); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c) + } + + try + { + back_it_cmp_imp(b, e, native_b, native_e); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c) + } + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +order_statistics_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) +{ + { + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(1); + const size_type order = r_c.order_of_key(k); + const size_type native_order = std::distance(r_native_c.begin(), + r_native_c.lower_bound(test_traits::native_key(k))); + + PB_DS_THROW_IF_FAILED(order == native_order, + test_traits::key_to_string(k) << " " << + static_cast(order) << " " << + static_cast(native_order), + &r_c, + &r_native_c); + } + + const size_type rand_ord = + static_cast(m_g.get_unsigned_long(0, + 2 * static_cast(m_m))); + + typename cntnr::const_iterator it = r_c.find_by_order(rand_ord); + typename native_type::const_iterator native_it = r_native_c.begin(); + std::advance(native_it, std::min(rand_ord, r_native_c.size())); + if (it == r_c.end()&& native_it != r_native_c.end()) + PB_DS_THROW_IF_FAILED(false, + static_cast(rand_ord), + m_p_c, + &m_native_c); + + if (it != r_c.end()&& native_it == r_native_c.end()) + PB_DS_THROW_IF_FAILED(false, + static_cast(rand_ord), + m_p_c, + &m_native_c); + + if (it != r_c.end()&& native_it != r_native_c.end()) + PB_DS_THROW_IF_FAILED(test_traits::cmp(*it, * native_it), + static_cast(rand_ord), + m_p_c, + &m_native_c); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +prefix_search_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(1); + try + { + typedef + std::pair + pref_ret_t; + + const pref_ret_t pref_ret = r_c.prefix_range(k); + + typename native_type::const_iterator native_start_it = r_native_c.begin(); + + while (native_start_it != r_native_c.end() && + !test_traits::prefix_match(k, + test_traits::extract_native_key(*native_start_it))) + ++native_start_it; + + typename native_type::const_iterator native_end_it = + native_start_it; + + do + { + if (native_end_it != r_native_c.end()) + ++native_end_it; + } + while (native_end_it != r_native_c.end() && + test_traits::prefix_match(k, + test_traits::extract_native_key(*native_end_it))); + + it_cmp_imp(pref_ret.first, pref_ret.second, native_start_it, native_end_it); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(false, "prefix key " << k, &r_c, &r_native_c); + } + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +template +void +PB_DS_CLASS_C_DEC:: +it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, + Const_Native_It native_e) +{ + PB_DS_SET_DESTRUCT_PRINT + + if (std::distance(b, e) != std::distance(native_b, native_e)) + { + const size_t dist = std::distance(b, e); + const size_t native_dist = std::distance(native_b, native_e); + PB_DS_THROW_IF_FAILED(false, + static_cast(dist) << " " + << static_cast(native_dist), + m_p_c, &m_native_c); + } + + while (b != e) + { + PB_DS_THROW_IF_FAILED(native_b != native_e, "", m_p_c, &m_native_c); + + if (!test_traits::cmp(*b, * native_b)) + PB_DS_THROW_IF_FAILED(false, + test_traits::val_to_string(*b) << " " << + test_traits::val_to_string(*native_b), + m_p_c, &m_native_c); + + ++b; + ++native_b; + } + + PB_DS_THROW_IF_FAILED(native_b == native_e, "", m_p_c, &m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +template +void +PB_DS_CLASS_C_DEC:: +back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, + Const_Native_It native_e) +{ + PB_DS_SET_DESTRUCT_PRINT + while (b != e) + { + PB_DS_THROW_IF_FAILED(native_b != native_e, + test_traits::val_to_string(*native_e), + m_p_c, &m_native_c); + + --e; + --native_e; + + PB_DS_THROW_IF_FAILED(test_traits::cmp(*e, * native_e), + test_traits::val_to_string(*e) << + test_traits::val_to_string(*native_e), + m_p_c, &m_native_c); + } + + PB_DS_THROW_IF_FAILED(native_b == native_e, + test_traits::val_to_string(*native_e), + m_p_c, &m_native_c); + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +lower_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(1); + typename cntnr::const_iterator it = r_c.lower_bound(k); + typename native_type::key_type native_k = test_traits::native_key(k); + typename native_type::const_iterator native_it = r_native_c.lower_bound(native_k); + + if (it != r_c.end() && native_it == r_native_c.end()) + PB_DS_THROW_IF_FAILED("", + "it: " + test_traits::val_to_string(*it) + "\n\n", + &r_c, &r_native_c); + + if (it == r_c.end() && native_it != r_native_c.end()) + PB_DS_THROW_IF_FAILED("", + "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", + &r_c, &r_native_c); + + if (it != r_c.end() && !test_traits::cmp(*it, * native_it)) + PB_DS_THROW_IF_FAILED(false, + "key: " + test_traits::key_to_string(k) + "\n\n" + + "it: " + test_traits::val_to_string(*it) + "\n\n" + + "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", + &r_c, &r_native_c); + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +upper_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) +{ + PB_DS_SET_DESTRUCT_PRINT + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(1); + typename cntnr::const_iterator it = r_c.upper_bound(k); + typename native_type::key_type native_k = test_traits::native_key(k); + typename native_type::const_iterator native_it = r_native_c.upper_bound(native_k); + + if (it == r_c.end() && native_it != r_native_c.end()) + PB_DS_THROW_IF_FAILED(false, + "key: " + test_traits::key_to_string(k) + "\n\n" + + "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", + &r_c, &r_native_c); + + if (it != r_c.end() && native_it == r_native_c.end()) + PB_DS_THROW_IF_FAILED(false, + "key: " + test_traits::key_to_string(k) + "\n\n" + + "it: " + test_traits::val_to_string(*it) + "\n\n", + &r_c, &r_native_c); + + if (it != r_c.end() && !test_traits::cmp(*it, * native_it)) + PB_DS_THROW_IF_FAILED(false, + "key: " + test_traits::key_to_string(k) + "\n\n" + + "it: " + test_traits::val_to_string(*it) + "\n\n" + + "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", + &r_c, &r_native_c); + + PB_DS_CANCEL_DESTRUCT_PRINT +} + +// Operators. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +operator()() +{ + typedef xml_result_set_regression_formatter formatter_type; + formatter_type* p_fmt = NULL; + + if (m_disp) + p_fmt = new formatter_type(string_form::name(), + string_form::desc()); + + m_g.init(m_seed); + + // Track allocation from this point only. + const size_t memory_label = 775; + m_alloc.init(m_seed); + m_alloc.set_label(memory_label); + + prog_bar pb(m_n, std::cout, m_disp); + m_i = 0; + + try + { + for (m_i = 0; m_i < m_n; ++m_i) + { + PB_DS_TRACE("Op #" << static_cast(m_i)); + allocator_type::set_label(m_i); + switch (m_i) + { + case 0: + PB_DS_RUN_MTHD(default_constructor); + break; + case 1: + defs(); + break; + case 2: + policy_access(); + break; + case 3: + it_copy(); + break; + case 4: + it_assign(); + break; + case 5: + rev_it_copy(); + break; + case 6: + rev_it_assign(); + break; + default: + switch(get_next_op()) + { + case insert_op: + switch(get_next_sub_op(2)) + { + case 0: + PB_DS_RUN_MTHD(insert) + break; + case 1: + PB_DS_RUN_MTHD(subscript) + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + } + break; + case erase_op: + switch(get_next_sub_op(4)) + { + case 0: + PB_DS_RUN_MTHD(erase) + break; + case 1: + PB_DS_RUN_MTHD(erase_if) + break; + case 2: + PB_DS_RUN_MTHD(erase_it) + break; + case 3: + PB_DS_RUN_MTHD(erase_rev_it) + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + } + break; + case clear_op: + PB_DS_RUN_MTHD(clear) + break; + case other_op: + switch(get_next_sub_op(8)) + { + case 0: + swap(); + break; + case 1: + PB_DS_RUN_MTHD(copy_constructor) + break; + case 2: + PB_DS_RUN_MTHD(it_constructor) + break; + case 3: + PB_DS_RUN_MTHD(assignment_operator) + break; + case 4: + PB_DS_RUN_MTHD(split_join) + break; + case 5: + resize(); + break; + case 6: + get_set_load(); + break; + case 7: + get_set_loads(); + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + } + break; + default: + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + }; + } + + pb.inc(); + } + } + catch (...) + { + std::cerr << "Failed at index " << static_cast(m_i) + << std::endl; + delete m_p_c; + throw; + } + + // Clean up, then check for allocation by special label, set above. + delete m_p_c; + + try + { m_alloc.check_allocated(memory_label); } + catch (...) + { + std::cerr << "detected leaks!" << std::endl; + std::cerr << m_alloc << std::endl; + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + } + + // Reset throw probability. + m_alloc.set_throw_prob(0); + + if (m_disp) + { + std::cout << std::endl; + delete p_fmt; + } +} + +PB_DS_CLASS_T_DEC +typename PB_DS_CLASS_C_DEC::op +PB_DS_CLASS_C_DEC:: +get_next_op() +{ + const double prob = m_g.get_prob(); + if (prob < m_ip) + return insert_op; + + if (prob < m_ip + m_ep) + return erase_op; + + if (prob < m_ip + m_ep + m_cp) + return clear_op; + + PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c); + return other_op; +} + +PB_DS_CLASS_T_DEC +size_t +PB_DS_CLASS_C_DEC:: +get_next_sub_op(size_t max) +{ + const double p = m_g.get_prob(); + const double delta = 1 / static_cast(max); + size_t i = 0; + while (true) + if (p <= (i + 1) * delta) + { + PB_DS_THROW_IF_FAILED(i < max, i << " " << max, m_p_c, &m_native_c); + return i; + } + else + ++i; +} + +// Insert. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +insert() +{ + PB_DS_TRACE("insert"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + try + { + m_alloc.set_throw_prob(0); + value_type v = test_traits::generate_value(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + const_key_reference r_k = test_traits::extract_key(v); + typename cntnr::const_point_iterator found_it = m_p_c->find(r_k); + const bool existed = (found_it != m_p_c->end()); + const std::pair ins_ret = m_p_c->insert(v); + + if (ins_ret.second) + { + PB_DS_THROW_IF_FAILED(!existed, "", m_p_c, &m_native_c); + } + else + { + PB_DS_THROW_IF_FAILED(existed, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(found_it == ins_ret.first, "", m_p_c, &m_native_c); + } + m_native_c.insert(test_traits::native_value(v)); + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + } + catch(__gnu_pbds::insert_error&) + { + PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +// Subscript. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +subscript() +{ + PB_DS_TRACE("subscript"); + + enum + { + no_data = __gnu_pbds::detail::is_same< + typename Cntnr::const_key_reference, + typename Cntnr::const_reference>::value + }; + + return (subscript_imp(__gnu_pbds::detail::integral_constant())); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +subscript_imp(__gnu_pbds::detail::false_type) +{ + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + + try + { + m_alloc.set_throw_prob(0); + value_type v = test_traits::generate_value(m_g, m_m); + + m_alloc.set_throw_prob(m_tp); + (*m_p_c)[v.first] = v.second; + + m_native_c[test_traits::native_value(v).first] = + test_traits::native_value(v).second; + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +subscript_imp(__gnu_pbds::detail::true_type) +{ + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + try + { + m_alloc.set_throw_prob(0); + value_type v = test_traits::generate_value(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + (*m_p_c)[v] = __gnu_pbds::null_mapped_type(); + m_native_c.insert(test_traits::native_value(v)); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +// Clear. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +clear() +{ + m_p_c->clear(); + m_native_c.clear(); + return true; +} + + +// Erase. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase() +{ + PB_DS_TRACE("erase"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + + try + { + const bool cntnd = m_p_c->find(k) != m_p_c->end(); + PB_DS_THROW_IF_FAILED(cntnd ==(m_native_c.find(test_traits::native_key(k)) != m_native_c.end()), test_traits::key_to_string(k), m_p_c, &m_native_c); + + const bool ersd = m_p_c->erase(k); + const bool native_ersd = m_native_c.erase(test_traits::native_key(k)) != 0; + + PB_DS_THROW_IF_FAILED(ersd == native_ersd, ersd << " " << native_ersd, + m_p_c, &m_native_c); + + PB_DS_THROW_IF_FAILED(m_p_c->find(k) == m_p_c->end(), "", + m_p_c, &m_native_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + + PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_if() +{ + PB_DS_TRACE("erase_if"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + + try + { + typedef + typename std::iterator_traits::reference + it_const_reference; + + typedef + typename test_traits::template erase_if_fn + erase_if_fn_t; + + m_alloc.set_throw_prob(m_tp); + + const size_t ersd = m_p_c->erase_if(erase_if_fn_t()); + const size_t native_ersd = test_traits::erase_if(m_native_c); + PB_DS_THROW_IF_FAILED(ersd == native_ersd, + ersd << " " << native_ersd, m_p_c, &m_native_c); + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw, + container_traits::erase_can_throw, + m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_it() +{ + enum + { + erase_iterators = container_traits::order_preserving + }; + + return (erase_it_imp(__gnu_pbds::detail::integral_constant())); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_it_imp(__gnu_pbds::detail::false_type) +{ + return true; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_it_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("erase_it"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + + try + { + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + + typename cntnr::iterator found_it = m_p_c->find(k); + + typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k)); + + const bool found = found_it != m_p_c->end(); + const bool native_found = native_it != m_native_c.end(); + + PB_DS_THROW_IF_FAILED( + found == native_found, + found << " " << native_found, + m_p_c, + &m_native_c); + + typename cntnr::const_iterator next_it = found_it; + if (next_it != m_p_c->end()) + ++next_it; + + typename cntnr::iterator next_ers_it = m_p_c->erase(found_it); + + if (native_it != m_native_c.end()) + m_native_c.erase(native_it); + + bool range_guarantee = __gnu_pbds::detail::is_same< + typename container_traits::invalidation_guarantee, + __gnu_pbds::range_invalidation_guarantee>::value ; + + if (range_guarantee) + PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_rev_it() +{ + enum + { + erase_iterators = container_traits::order_preserving + && container_traits::reverse_iteration + }; + + return (erase_rev_it_imp(__gnu_pbds::detail::integral_constant())); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_rev_it_imp(__gnu_pbds::detail::false_type) +{ + return true; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_rev_it_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("erase_rev_it"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + + try + { + m_alloc.set_throw_prob(0); + const key_type k = test_traits::generate_key(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + + typename cntnr::iterator found_it = m_p_c->find(k); + typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k)); + + typename cntnr::const_reverse_iterator next_it = found_it; + if (next_it != m_p_c->end()) + ++next_it; + + typename cntnr::reverse_iterator next_ers_it = + m_p_c->erase((typename cntnr::reverse_iterator)found_it); + + PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c); + + if (native_it != m_native_c.end()) + m_native_c.erase(native_it); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw, + container_traits::erase_can_throw, + m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +// Defs. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +defs() +{ + // General container types. + typedef typename Cntnr::size_type test_size_type; + typedef typename Cntnr::difference_type difference_type; + + key_defs(); + mapped_defs(); + value_defs(); + iterator_defs(); + node_iterator_defs(__gnu_pbds::detail::integral_constant()); + policy_defs(); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +key_defs() +{ + typedef typename Cntnr::key_type test_key_type; + typedef typename Cntnr::key_reference test_key_reference; + typedef typename Cntnr::const_key_reference test_const_key_reference; + typedef typename Cntnr::key_pointer test_key_pointer; + typedef typename Cntnr::const_key_pointer test_const_key_pointer; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +mapped_defs() +{ + typedef typename Cntnr::mapped_type test_mapped_type; + typedef typename Cntnr::mapped_reference test_mapped_reference; + typedef typename Cntnr::const_mapped_reference test_const_mapped_reference; + typedef typename Cntnr::mapped_pointer test_mapped_pointer; + typedef typename Cntnr::const_mapped_pointer test_const_mapped_pointer; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +value_defs() +{ + typedef typename Cntnr::value_type test_value_type; + typedef typename Cntnr::reference test_reference; + typedef typename Cntnr::const_reference test_const_reference; + typedef typename Cntnr::pointer test_pointer; + typedef typename Cntnr::const_pointer test_const_pointer; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +ds_defs() +{ + typedef __gnu_pbds::container_traits< Cntnr> test_container_traits; + + typedef typename test_container_traits::container_category test_container_category; + + typedef + typename test_container_traits::invalidation_guarantee + test_invalidation_guarantee; + + enum + { + test_order_preserving = test_container_traits::order_preserving + }; + + enum + { + test_erase_can_throw = test_container_traits::erase_can_throw + }; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +iterator_defs() +{ + typedef typename Cntnr::point_iterator test_point_iterator; + typedef typename Cntnr::const_point_iterator const_test_point_iterator; + typedef typename Cntnr::iterator test_iterator; + typedef typename Cntnr::const_iterator const_test_iterator; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +node_iterator_defs(__gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +node_iterator_defs(__gnu_pbds::detail::true_type) +{ + typedef typename Cntnr::node_iterator test_node_iterator; + typedef typename Cntnr::const_node_iterator test_const_node_iterator; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs() +{ + typedef typename Cntnr::allocator_type test_allocator; + policy_defs(typename Cntnr::container_category()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::basic_hash_tag) +{ + typedef typename Cntnr::hash_fn test_hash_fn; + typedef typename Cntnr::eq_fn test_eq_fn; + typedef typename Cntnr::resize_policy test_resize_policy; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::cc_hash_tag) +{ + policy_defs(__gnu_pbds::basic_hash_tag()); + typedef typename Cntnr::comb_hash_fn test_comb_hash_fn; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::gp_hash_tag) +{ + policy_defs(__gnu_pbds::basic_hash_tag()); + typedef typename Cntnr::comb_probe_fn test_comb_probe_fn; + typedef typename Cntnr::probe_fn test_probe_fn; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::tree_tag) +{ + typedef typename Cntnr::cmp_fn test_cmp_fn; + typedef typename Cntnr::node_update test_node_update; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::list_update_tag) +{ + typedef typename Cntnr::eq_fn test_eq_fn; + typedef typename Cntnr::update_policy test_update_policy; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs(__gnu_pbds::pat_trie_tag) +{ + typedef typename Cntnr::e_access_traits e_access_traits; +} + + +// Policy Access. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access() +{ + policy_access(typename Cntnr::container_category()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::basic_hash_tag) +{ + { + typename Cntnr::hash_fn& r_t = m_p_c->get_hash_fn(); + assert(&r_t != NULL); + } + { + const typename Cntnr::hash_fn& r_t =((const Cntnr& )*m_p_c).get_hash_fn(); + assert(&r_t != NULL); + } + + { + typename Cntnr::eq_fn& r_t = m_p_c->get_eq_fn(); + assert(&r_t != NULL); + } + { + const typename Cntnr::eq_fn& r_t =((const Cntnr& )*m_p_c).get_eq_fn(); + assert(&r_t != NULL); + } + + { + typename Cntnr::resize_policy& r_t = m_p_c->get_resize_policy(); + assert(&r_t != NULL); + } + { + const typename Cntnr::resize_policy& r_t =((const Cntnr& )*m_p_c).get_resize_policy(); + + assert(&r_t != NULL); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::cc_hash_tag) +{ + policy_access(__gnu_pbds::basic_hash_tag()); + + { + typename Cntnr::comb_hash_fn& r_t = m_p_c->get_comb_hash_fn(); + assert(&r_t != NULL); + } + { + const typename Cntnr::comb_hash_fn& r_t =((const Cntnr& )*m_p_c).get_comb_hash_fn(); + + assert(&r_t != NULL); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::gp_hash_tag) +{ + policy_access(__gnu_pbds::basic_hash_tag()); + + { + typename Cntnr::comb_probe_fn& r_t = m_p_c->get_comb_probe_fn(); + assert(&r_t != NULL); + } + { + const typename Cntnr::comb_probe_fn& r_t =((const Cntnr& )*m_p_c).get_comb_probe_fn(); + + assert(&r_t != NULL); + } + + { + typename Cntnr::probe_fn& r_t = m_p_c->get_probe_fn(); + assert(&r_t != NULL); + } + { + const typename Cntnr::probe_fn& r_t =((const Cntnr& )*m_p_c).get_probe_fn(); + assert(&r_t != NULL); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::tree_tag) +{ + { + typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn(); + assert(&r_t != NULL); + } + + { + const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn(); + assert(&r_t != NULL); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::list_update_tag) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access(__gnu_pbds::pat_trie_tag) +{ + typename Cntnr::e_access_traits& r_t = m_p_c->get_e_access_traits(); + assert(&r_t != NULL); +} + + +// Split/Join. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +split_join() +{ + enum + { + split_join = container_traits::order_preserving + }; + + return (split_join_imp(__gnu_pbds::detail::integral_constant())); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +split_join_imp(__gnu_pbds::detail::false_type) +{ + return true; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +split_join_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("split_join"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + + try + { + m_alloc.set_throw_prob(0); + Cntnr lhs(*m_p_c); + Cntnr rhs; + native_type native_lhs(m_native_c); + native_type native_rhs; + const key_type k = test_traits::generate_key(m_g, m_m); + + m_alloc.set_throw_prob(m_tp); + lhs.split(k, rhs); + + typename native_type::const_iterator it = + native_lhs.upper_bound(test_traits::native_key(k)); + + while (!native_lhs.empty()&& it != native_lhs.end()) + { + native_rhs.insert(*it); + typename native_type::const_iterator next_it = it; + ++next_it; + native_lhs.erase(test_traits::extract_native_key(*it)); + it = next_it; + } + + PB_DS_COND_COMPARE(lhs, native_lhs); + PB_DS_COND_COMPARE(rhs, native_rhs); + + m_alloc.set_throw_prob(m_tp); + + if (m_g.get_prob() < 0.5) + lhs.swap(rhs); + + lhs.join(rhs); + PB_DS_THROW_IF_FAILED(rhs.size() == 0, rhs.size(), m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(rhs.empty(), rhs.size(), m_p_c, &m_native_c); + m_p_c->swap(lhs); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + PB_DS_THROW_IF_FAILED(container_traits::split_join_can_throw, + container_traits::split_join_can_throw, + m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +// Iterator conversions. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +it_copy() +{ + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_iterator const_it(it); + PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c); + + typename cntnr::const_point_iterator const_find_it(it); + PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it(it); + PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::const_iterator const_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it(const_it); + PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::point_iterator find_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it(find_it); + PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +it_assign() +{ + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_iterator const_it; + const_it = it; + PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c); + + typename cntnr::const_point_iterator const_find_it; + const_find_it = it; + PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it; + find_it = it; + PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::const_iterator const_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it; + const_find_it = const_it; + PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::point_iterator find_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it; + const_find_it = find_it; + PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_copy() +{ + enum + { + reverse_iteration = container_traits::reverse_iteration + }; + + rev_it_copy_imp(__gnu_pbds::detail::integral_constant()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_assign() +{ + enum + { + reverse_iteration = container_traits::reverse_iteration + }; + + rev_it_assign_imp(__gnu_pbds::detail::integral_constant()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_copy_imp(__gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_copy_imp(__gnu_pbds::detail::true_type) +{ + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_reverse_iterator const_it(it); + PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c); + + typename cntnr::const_point_iterator const_find_it(it); + PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it(it); + PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_assign_imp(__gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +rev_it_assign_imp(__gnu_pbds::detail::true_type) +{ + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_reverse_iterator const_it; + const_it = it; + PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c); + + typename cntnr::const_point_iterator const_find_it; + const_find_it = it; + PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it; + find_it = it; + PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c); + PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c); + } +} + +// Resize. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +resize() +{ + typedef __gnu_pbds::detail::integral_constant resize_ind; + + return resize_imp(resize_ind()); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +resize_imp(__gnu_pbds::detail::false_type) +{ + return true; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +resize_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("resize"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + const size_t old_size = m_p_c->get_actual_size(); + + try + { + enum + { + min_new_size = 200, + max_new_size = 2000 + }; + + m_alloc.set_throw_prob(m_tp); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + const size_t new_size = m_g.get_unsigned_long(min_new_size, max_new_size); + m_p_c->resize(new_size); + const size_t actual_new_size = m_p_c->get_actual_size(); + PB_DS_THROW_IF_FAILED(actual_new_size >= new_size, + actual_new_size << " " << new_size, + m_p_c, &m_native_c); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(m_p_c->get_actual_size() == old_size, + m_p_c->get_actual_size() << " " << old_size, + m_p_c, &m_native_c); + + done = false; + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + + +// Get/Set load. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +get_set_load() +{ + typedef + __gnu_pbds::detail::integral_constant + get_set_load_ind; + + get_set_load_imp(get_set_load_ind()); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +get_set_load_imp(__gnu_pbds::detail::false_type) +{ } + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +get_set_load_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("get_set_load"); + PB_DS_SET_DESTRUCT_PRINT + m_p_c->get_load(); + m_alloc.set_throw_prob(1); + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + const float min_load = static_cast(0.05); + const float max_load = static_cast(0.9); + + const float new_load = static_cast(m_g.get_prob() * (max_load - min_load) + min_load); + + m_p_c->set_load(new_load); + PB_DS_THROW_IF_FAILED(m_p_c->get_load() == new_load, "", m_p_c, &m_native_c); + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT +} + + +// Get/Set loads. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +get_set_loads() +{ + typedef + __gnu_pbds::detail::integral_constant + get_set_loads_ind; + + return get_set_loads_imp(get_set_loads_ind()); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +get_set_loads_imp(__gnu_pbds::detail::false_type) +{ + return true; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +get_set_loads_imp(__gnu_pbds::detail::true_type) +{ + PB_DS_TRACE("get_set_loads"); + bool done = true; + PB_DS_SET_DESTRUCT_PRINT + const std::pair old_loads = m_p_c->get_loads(); + + try + { + m_alloc.set_throw_prob(m_tp); + + typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); + + const float min_min_load = static_cast(0.05); + const float max_min_load = static_cast(0.2); + + const float new_min_load = + static_cast(m_g.get_prob()* (max_min_load - min_min_load) + + min_min_load); + + const float new_max_load = static_cast(new_min_load* 2.5); + PB_DS_THROW_IF_FAILED(new_max_load < 1, new_max_load, m_p_c, &m_native_c); + m_p_c->set_loads(std::make_pair(new_min_load, new_max_load)); + } + catch(...) + { + PB_DS_THROW_IF_FAILED(old_loads == m_p_c->get_loads(), + old_loads.first << " " << old_loads.second << " " << + m_p_c->get_loads().first << " " << + m_p_c->get_loads().second, + m_p_c, &m_native_c); + + done = false; + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + PB_DS_CANCEL_DESTRUCT_PRINT + return done; +} + +// Diagnostics. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +print_container(const native_type& r_cnt, std::ostream& r_os) const +{ + m_alloc.set_throw_prob(0); + typename native_type::const_iterator it = r_cnt.begin(); + while (it != r_cnt.end()) + { + r_os << test_traits::val_to_string(*it) + "\n"; + ++it; + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +print_container(const cntnr& r_cnt, std::ostream& r_os) const +{ + m_alloc.set_throw_prob(0); + typename cntnr::const_iterator it = r_cnt.begin(); + while (it != r_cnt.end()) + { + r_os << test_traits::val_to_string(*it) + "\n"; + ++it; + } +} + +#endif diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/clear_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/clear_fn_imps.hpp deleted file mode 100644 index bbc8cbe..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/clear_fn_imps.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 clear_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -clear() -{ - m_p_c->clear(); - - m_native_c.clear(); - - return (true); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/cmp_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/cmp_fn_imps.hpp deleted file mode 100644 index 3b19a75..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/cmp_fn_imps.hpp +++ /dev/null @@ -1,601 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -cmp(const Cntnr& r_c, const native_type& r_native_c, const std::string& r_call_fn) -{ - m_alloc.set_throw_prob(1); - - const size_t size = r_c.size(); - const size_t native_size = r_native_c.size(); - - PB_DS_THROW_IF_FAILED( - size == native_size, - static_cast(size) << " " << - static_cast(native_size), - & r_c, - & r_native_c); - - const bool empty = r_c.empty(); - const bool native_empty = r_native_c.empty(); - - PB_DS_THROW_IF_FAILED( - empty == native_empty, - empty << " " << native_empty, - & r_c, - & r_native_c); - - try - { - basic_cmp_(r_c, r_native_c); - - cmp_(r_c, r_native_c); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "call-fn: " + r_call_fn, & r_c, & r_native_c); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -basic_cmp_(const Cntnr& r_c, const native_type& r_native_c) -{ - PB_DS_SET_DESTRUCT_PRINT - - if (static_cast(std::distance(r_c.begin(), r_c.end())) != - r_c.size()) - PB_DS_THROW_IF_FAILED( - false, - static_cast( - std::distance(r_c.begin(), r_c.end())) << - " " << static_cast(r_c.size()), - & r_c, - & r_native_c); - - typename native_type::const_iterator it = r_native_c.begin(); - - while (it != r_native_c.end()) - { - typename native_type::key_type native_key = - test_traits::extract_native_key(*it); - - m_alloc.set_throw_prob(0); - - const key_type k = native_key; - - m_alloc.set_throw_prob(1); - - typename cntnr::const_point_iterator found_it = r_c.find(k); - - PB_DS_THROW_IF_FAILED( - found_it != r_c.end(), - test_traits::native_val_to_string(*it), - & r_c, - & r_native_c); - - if (!test_traits::cmp(*found_it, * it)) - PB_DS_THROW_IF_FAILED( false, "", & r_c, & r_native_c); - - ++it; - } - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -cmp_(const Cntnr& r_c, const native_type& r_native_c) -{ - enum - { - order_preserving = - container_traits::order_preserving, - back_order_preserving = - container_traits::order_preserving&& - !__gnu_pbds::detail::is_same< - typename std::iterator_traits< - typename cntnr::const_iterator>::iterator_category, - std::forward_iterator_tag>::value, - reverse_iteration = container_traits::reverse_iteration, - order_statistics = test_traits::order_statistics, - prefix_search = test_traits::prefix_search, - has_mapped = !__gnu_pbds::detail::is_same< - typename Cntnr::mapped_type, - __gnu_pbds::null_mapped_type>::value - }; - - order_preserving_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - back_order_preserving_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - order_statistics_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - prefix_search_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - reverse_iteration_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - lower_bound_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); - - upper_bound_cmp_imp(r_c, r_native_c, - __gnu_pbds::detail::integral_constant()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -order_preserving_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - typename cntnr::const_iterator b = r_c.begin(); - typename cntnr::const_iterator e = r_c.end(); - - typename native_type::const_iterator native_b = r_native_c.begin(); - typename native_type::const_iterator native_e = r_native_c.end(); - - try - { - it_cmp_imp(b, e, native_b, native_e); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "", & r_c, & r_native_c) - } - - try - { - back_it_cmp_imp(b, e, native_b, native_e); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "", & r_c, & r_native_c) - } - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -back_order_preserving_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - typename cntnr::const_iterator b = r_c.begin(); - typename cntnr::const_iterator e = r_c.end(); - - typename native_type::const_iterator native_b = r_native_c.begin(); - typename native_type::const_iterator native_e = r_native_c.end(); - - it_cmp_imp(b, e, native_b, native_e); - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -reverse_iteration_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - typename cntnr::const_reverse_iterator b = r_c.rbegin(); - typename cntnr::const_reverse_iterator e = r_c.rend(); - - typename native_type::const_reverse_iterator native_b = r_native_c.rbegin(); - typename native_type::const_reverse_iterator native_e = r_native_c.rend(); - - try - { - it_cmp_imp(b, e, native_b, native_e); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "", & r_c, & r_native_c) - } - - try - { - back_it_cmp_imp(b, e, native_b, native_e); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "", & r_c, & r_native_c) - } - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -order_statistics_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - { - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(1); - - const size_type order = r_c.order_of_key(k); - - const size_type native_order = std::distance( - r_native_c.begin(), - r_native_c.lower_bound(test_traits::native_key(k))); - - PB_DS_THROW_IF_FAILED( - order == native_order, - test_traits::key_to_string(k) << " " << - static_cast(order) << " " << - static_cast(native_order), - & r_c, - & r_native_c); - } - - const size_type rand_ord = - static_cast(m_g.get_unsigned_long( - 0, - 2* static_cast(m_m))); - - typename cntnr::const_iterator it = - r_c.find_by_order(rand_ord); - - typename native_type::const_iterator native_it = - r_native_c.begin(); - - std::advance(native_it, std::min(rand_ord, r_native_c.size())); - - if (it == r_c.end()&& native_it != r_native_c.end()) - PB_DS_THROW_IF_FAILED( - false, - static_cast(rand_ord), - m_p_c, - & m_native_c); - - if (it != r_c.end()&& native_it == r_native_c.end()) - PB_DS_THROW_IF_FAILED( - false, - static_cast(rand_ord), - m_p_c, - & m_native_c); - - if (it != r_c.end()&& native_it != r_native_c.end()) - PB_DS_THROW_IF_FAILED( - test_traits::cmp(*it, * native_it), - static_cast(rand_ord), - m_p_c, - & m_native_c); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -prefix_search_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(1); - - try - { - typedef - std::pair< - typename Cntnr::const_iterator, - typename Cntnr::const_iterator> - pref_ret_t; - - const pref_ret_t pref_ret = r_c.prefix_range(k); - - typename native_type::const_iterator native_start_it = - r_native_c.begin(); - - while (native_start_it != r_native_c.end()&& - !test_traits::prefix_match( - k, - test_traits::extract_native_key(*native_start_it))) - ++native_start_it; - - typename native_type::const_iterator native_end_it = - native_start_it; - - do - { - if (native_end_it != r_native_c.end()) - ++native_end_it; - } - while (native_end_it != r_native_c.end()&& - test_traits::prefix_match( - k, - test_traits::extract_native_key(*native_end_it))); - - it_cmp_imp( pref_ret.first, pref_ret.second, native_start_it, native_end_it); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( - false, - "prefix key " << k, - & r_c, - & r_native_c); - } - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -template -void -PB_DS_CLASS_C_DEC:: -it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e) -{ - PB_DS_SET_DESTRUCT_PRINT - - if (std::distance(b, e) != std::distance(native_b, native_e)) - { - const size_t dist = std::distance(b, e); - - const size_t native_dist = std::distance(native_b, native_e); - - PB_DS_THROW_IF_FAILED( - false, - static_cast(dist) << " " - << static_cast(native_dist), - m_p_c, - & m_native_c); - } - - while (b != e) - { - PB_DS_THROW_IF_FAILED( native_b != native_e, "", m_p_c, & m_native_c); - - if (!test_traits::cmp(*b, * native_b)) - PB_DS_THROW_IF_FAILED( - false, - test_traits::val_to_string(*b) << " " << - test_traits::val_to_string(*native_b), - m_p_c, - & m_native_c); - - ++b; - ++native_b; - } - - PB_DS_THROW_IF_FAILED( native_b == native_e, "", m_p_c, & m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -template -void -PB_DS_CLASS_C_DEC:: -back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e) -{ - PB_DS_SET_DESTRUCT_PRINT - - while (b != e) - { - PB_DS_THROW_IF_FAILED( - native_b != native_e, - test_traits::val_to_string(*native_e), - m_p_c, - & m_native_c); - - --e; - --native_e; - - PB_DS_THROW_IF_FAILED( - test_traits::cmp(*e, * native_e), - test_traits::val_to_string(*e) << - test_traits::val_to_string(*native_e), - m_p_c, - & m_native_c); - } - - PB_DS_THROW_IF_FAILED( - native_b == native_e, - test_traits::val_to_string(*native_e), - m_p_c, - & m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -lower_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(1); - - typename cntnr::const_iterator it = r_c.lower_bound(k); - - typename native_type::key_type native_k = test_traits::native_key(k); - - typename native_type::const_iterator native_it = - r_native_c.lower_bound(native_k); - - if (it != r_c.end()&& native_it == r_native_c.end()) - PB_DS_THROW_IF_FAILED( - "", - "it: " + test_traits::val_to_string(*it) + "\n\n", - & r_c, - & r_native_c); - - if (it == r_c.end()&& native_it != r_native_c.end()) - PB_DS_THROW_IF_FAILED( - "", - "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", - & r_c, - & r_native_c); - - if (it != r_c.end()&& !test_traits::cmp(*it, * native_it)) - PB_DS_THROW_IF_FAILED( - false, - "key: " + test_traits::key_to_string(k) + "\n\n" + - "it: " + test_traits::val_to_string(*it) + "\n\n" + - "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", - & r_c, - & r_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -upper_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) -{ - PB_DS_SET_DESTRUCT_PRINT - - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(1); - - typename cntnr::const_iterator it = r_c.upper_bound(k); - - typename native_type::key_type native_k = test_traits::native_key(k); - - typename native_type::const_iterator native_it = - r_native_c.upper_bound(native_k); - - if (it == r_c.end()&& native_it != r_native_c.end()) - PB_DS_THROW_IF_FAILED( - false, - "key: " + test_traits::key_to_string(k) + "\n\n" + - "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", - & r_c, - & r_native_c); - - if (it != r_c.end()&& native_it == r_native_c.end()) - PB_DS_THROW_IF_FAILED( - false, - "key: " + test_traits::key_to_string(k) + "\n\n" + - "it: " + test_traits::val_to_string(*it) + "\n\n", - & r_c, - & r_native_c); - - if (it != r_c.end()&& !test_traits::cmp(*it, * native_it)) - PB_DS_THROW_IF_FAILED( - false, - "key: " + test_traits::key_to_string(k) + "\n\n" + - "it: " + test_traits::val_to_string(*it) + "\n\n" + - "native_it: " + test_traits::val_to_string(*native_it) + "\n\n", - & r_c, - & r_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - } diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp deleted file mode 100644 index c6b02b6..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp +++ /dev/null @@ -1,410 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -PB_DS_CLASS_C_DEC:: -container_rand_regression_test(unsigned long seed, size_t n, size_t m, - double tp, double ip, double ep, double cp, - double mp, bool disp) -: m_seed((seed == 0) ? twister_rand_gen::get_time_determined_seed() : seed), - m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp), m_mp(mp), - m_disp(disp), m_p_c(NULL) -{ } - -PB_DS_CLASS_T_DEC -PB_DS_CLASS_C_DEC:: -~container_rand_regression_test() -{ } - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -default_constructor() -{ - PB_DS_TRACE("default_constructor"); - bool done = true; - m_alloc.set_throw_prob(m_tp); - - try - { - m_p_c = new Cntnr; - } - catch(__gnu_cxx::forced_exception_error&) - { - done = false; - } - - if (m_p_c != NULL) - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -swap() -{ - PB_DS_TRACE("swap"); - m_alloc.set_throw_prob(0); - Cntnr* p_c = new Cntnr; - m_alloc.set_throw_prob(1); - p_c->swap(*m_p_c); - std::swap(p_c, m_p_c); - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -copy_constructor() -{ - PB_DS_TRACE("copy_constructor"); - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - p_c = new Cntnr(*m_p_c); - std::swap(p_c, m_p_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -assignment_operator() -{ - PB_DS_TRACE("assignment operator"); - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - p_c = new Cntnr(); - * p_c =* m_p_c; - std::swap(p_c, m_p_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor() -{ - PB_DS_TRACE("it_constructor"); - return it_constructor_imp(typename Cntnr::container_category()); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor_imp(__gnu_pbds::cc_hash_tag) -{ - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - switch(get_next_sub_op(8)) - { - case 0: - p_c = new Cntnr(m_p_c->get_hash_fn()); - m_native_c.clear(); - break; - case 1: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn()); - m_native_c.clear(); - break; - case 2: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_hash_fn()); - m_native_c.clear(); - break; - case 3: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_hash_fn(), - m_p_c->get_resize_policy()); - m_native_c.clear(); - break; - case 4: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end()); - break; - case 5: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn()); - break; - case 6: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn()); - break; - case 7: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn()); - break; - case 8: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn(), - m_p_c->get_resize_policy()); - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, & m_native_c); - }; - std::swap(p_c, m_p_c); - } - catch (__gnu_cxx::forced_exception_error&) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor_imp(__gnu_pbds::gp_hash_tag) -{ - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - switch(get_next_sub_op(11)) - { - case 0: - p_c = new Cntnr(m_p_c->get_hash_fn()); - m_native_c.clear(); - break; - case 1: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn()); - m_native_c.clear(); - break; - case 2: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_probe_fn()); - m_native_c.clear(); - break; - case 3: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_probe_fn()); - m_native_c.clear(); - break; - case 4: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn()); - m_native_c.clear(); - break; - case 5: - p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(), - m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn(), - m_p_c->get_resize_policy()); - m_native_c.clear(); - break; - case 6: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn()); - break; - case 7: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn()); - break; - case 8: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn()); - break; - case 9: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn()); - break; - case 10: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(), - m_p_c->get_probe_fn()); - break; - case 11: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(), - m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(), - m_p_c->get_probe_fn(), m_p_c->get_resize_policy()); - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, & m_native_c); - }; - std::swap(p_c, m_p_c); - } - catch (__gnu_cxx::forced_exception_error&) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor_imp(__gnu_pbds::tree_tag) -{ - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - switch(get_next_sub_op(2)) - { - case 0: - p_c = new Cntnr(m_p_c->get_cmp_fn()); - m_native_c.clear(); - break; - case 1: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn()); - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - }; - std::swap(p_c, m_p_c); - } - catch (__gnu_cxx::forced_exception_error&) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor_imp(__gnu_pbds::list_update_tag) -{ - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - p_c = new Cntnr(m_p_c->begin(), m_p_c->end()); - std::swap(p_c, m_p_c); - } - catch (__gnu_cxx::forced_exception_error&) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor_imp(__gnu_pbds::pat_trie_tag) -{ - bool done = true; - Cntnr* p_c = NULL; - m_alloc.set_throw_prob(m_tp); - typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); - - try - { - switch(get_next_sub_op(2)) - { - case 0: - p_c = new Cntnr(m_p_c->get_e_access_traits()); - m_native_c.clear(); - break; - case 1: - p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), - m_p_c->get_e_access_traits()); - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, & m_native_c); - }; - - std::swap(p_c, m_p_c); - } - catch (__gnu_cxx::forced_exception_error&) - { - done = false; - } - - delete p_c; - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - return done; -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/defs_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/defs_fn_imps.hpp deleted file mode 100644 index f3e01d9..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/defs_fn_imps.hpp +++ /dev/null @@ -1,248 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 defs_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -defs() -{ - // General container types. - - typedef typename Cntnr::size_type test_size_type; - - typedef typename Cntnr::difference_type difference_type; - - key_defs(); - - mapped_defs(); - - value_defs(); - - iterator_defs(); - - node_iterator_defs(__gnu_pbds::detail::integral_constant()); - - policy_defs(); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -key_defs() -{ - typedef typename Cntnr::key_type test_key_type; - - typedef typename Cntnr::key_reference test_key_reference; - - typedef typename Cntnr::const_key_reference test_const_key_reference; - - typedef typename Cntnr::key_pointer test_key_pointer; - - typedef typename Cntnr::const_key_pointer test_const_key_pointer; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -mapped_defs() -{ - typedef typename Cntnr::mapped_type test_mapped_type; - - typedef typename Cntnr::mapped_reference test_mapped_reference; - - typedef - typename Cntnr::const_mapped_reference - test_const_mapped_reference; - - typedef typename Cntnr::mapped_pointer test_mapped_pointer; - - typedef typename Cntnr::const_mapped_pointer test_const_mapped_pointer; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -value_defs() -{ - typedef typename Cntnr::value_type test_value_type; - - typedef typename Cntnr::reference test_reference; - - typedef typename Cntnr::const_reference test_const_reference; - - typedef typename Cntnr::pointer test_pointer; - - typedef typename Cntnr::const_pointer test_const_pointer; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -ds_defs() -{ - typedef __gnu_pbds::container_traits< Cntnr> test_container_traits; - - typedef typename test_container_traits::container_category test_container_category; - - typedef - typename test_container_traits::invalidation_guarantee - test_invalidation_guarantee; - - enum - { - test_order_preserving = - test_container_traits::order_preserving - }; - - enum - { - test_erase_can_throw = - test_container_traits::erase_can_throw - }; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -iterator_defs() -{ - typedef typename Cntnr::point_iterator test_point_iterator; - - typedef typename Cntnr::const_point_iterator const_test_point_iterator; - - typedef typename Cntnr::iterator test_iterator; - - typedef typename Cntnr::const_iterator const_test_iterator; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -node_iterator_defs(__gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -node_iterator_defs(__gnu_pbds::detail::true_type) -{ - typedef typename Cntnr::node_iterator test_node_iterator; - - typedef typename Cntnr::const_node_iterator test_const_node_iterator; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs() -{ - typedef typename Cntnr::allocator_type test_allocator; - - policy_defs(typename Cntnr::container_category()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::basic_hash_tag) -{ - typedef typename Cntnr::hash_fn test_hash_fn; - - typedef typename Cntnr::eq_fn test_eq_fn; - - typedef typename Cntnr::resize_policy test_resize_policy; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::cc_hash_tag) -{ - policy_defs(__gnu_pbds::basic_hash_tag()); - - typedef typename Cntnr::comb_hash_fn test_comb_hash_fn; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::gp_hash_tag) -{ - policy_defs(__gnu_pbds::basic_hash_tag()); - - typedef typename Cntnr::comb_probe_fn test_comb_probe_fn; - - typedef typename Cntnr::probe_fn test_probe_fn; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::tree_tag) -{ - typedef typename Cntnr::cmp_fn test_cmp_fn; - - typedef typename Cntnr::node_update test_node_update; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::list_update_tag) -{ - typedef typename Cntnr::eq_fn test_eq_fn; - - typedef typename Cntnr::update_policy test_update_policy; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs(__gnu_pbds::pat_trie_tag) -{ - typedef typename Cntnr::e_access_traits e_access_traits; -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/diagnostic_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/diagnostic_fn_imps.hpp deleted file mode 100644 index 0a16482..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/diagnostic_fn_imps.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 diagnostic_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -print_container(const native_type& r_cnt, std::ostream& r_os /*= std::cerr*/) const -{ - m_alloc.set_throw_prob(0); - - typename native_type::const_iterator it = r_cnt.begin(); - - while (it != r_cnt.end()) - { - r_os << test_traits::val_to_string(*it) + "\n"; - - ++it; - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -print_container(const cntnr& r_cnt, std::ostream& r_os /*= std::cerr*/) const -{ - m_alloc.set_throw_prob(0); - - typename cntnr::const_iterator it = r_cnt.begin(); - - while (it != r_cnt.end()) - { - r_os << test_traits::val_to_string(*it) + "\n"; - - ++it; - } -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp deleted file mode 100644 index 0bd39f3..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/erase_fn_imps.hpp +++ /dev/null @@ -1,319 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase() -{ - PB_DS_TRACE("erase"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - try - { - const bool cntnd = m_p_c->find(k) != m_p_c->end(); - - PB_DS_THROW_IF_FAILED( - cntnd ==(m_native_c.find(test_traits::native_key(k)) != m_native_c.end()), - test_traits::key_to_string(k), - m_p_c, - & m_native_c); - - const bool ersd = m_p_c->erase(k); - - const bool native_ersd = - m_native_c.erase(test_traits::native_key(k)) != 0; - - PB_DS_THROW_IF_FAILED( - ersd == native_ersd, - ersd << " " << native_ersd, - m_p_c, - & m_native_c); - - PB_DS_THROW_IF_FAILED( - m_p_c->find(k) == m_p_c->end(), - "", - m_p_c, - & m_native_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_if() -{ - PB_DS_TRACE("erase_if"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - typedef - typename std::iterator_traits< - typename cntnr::iterator>::reference - it_const_reference; - - typedef - typename test_traits::template erase_if_fn< - value_type> - erase_if_fn_t; - - m_alloc.set_throw_prob(m_tp); - - const size_t ersd = - m_p_c->erase_if(erase_if_fn_t()); - - const size_t native_ersd = - test_traits::erase_if(m_native_c); - - PB_DS_THROW_IF_FAILED( - ersd == native_ersd, - static_cast(ersd) << " " << - static_cast(native_ersd), - m_p_c, - & m_native_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_it() -{ - enum - { - erase_iterators = - container_traits::order_preserving - }; - - return (erase_it_imp(__gnu_pbds::detail::integral_constant())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_it_imp(__gnu_pbds::detail::false_type) -{ - return (true); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_it_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("erase_it"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - typename cntnr::iterator found_it = m_p_c->find(k); - - typename native_type::iterator native_it = m_native_c.find( - test_traits::native_key(k)); - - const bool found = found_it != m_p_c->end(); - const bool native_found = native_it != m_native_c.end(); - - PB_DS_THROW_IF_FAILED( - found == native_found, - found << " " << native_found, - m_p_c, - & m_native_c); - - typename cntnr::const_iterator next_it = found_it; - if (next_it != m_p_c->end()) - ++next_it; - - typename cntnr::iterator next_ers_it = - m_p_c->erase(found_it); - - if (native_it != m_native_c.end()) - m_native_c.erase(native_it); - - bool range_guarantee = - __gnu_pbds::detail::is_same< - typename container_traits::invalidation_guarantee, - __gnu_pbds::range_invalidation_guarantee>::value ; - - if (range_guarantee) - PB_DS_THROW_IF_FAILED( next_ers_it == next_it, "", m_p_c, & m_native_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_rev_it() -{ - enum - { - erase_iterators = - container_traits::order_preserving&& - container_traits::reverse_iteration - }; - - return (erase_rev_it_imp(__gnu_pbds::detail::integral_constant())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_rev_it_imp(__gnu_pbds::detail::false_type) -{ - return (true); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_rev_it_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("erase_rev_it"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - typename cntnr::iterator found_it = m_p_c->find(k); - - typename native_type::iterator native_it = m_native_c.find( - test_traits::native_key(k)); - - typename cntnr::const_reverse_iterator next_it = found_it; - if (next_it != m_p_c->end()) - ++next_it; - - typename cntnr::reverse_iterator next_ers_it = - m_p_c->erase((typename cntnr::reverse_iterator)found_it); - - PB_DS_THROW_IF_FAILED( next_ers_it == next_it, "", m_p_c, & m_native_c); - - if (native_it != m_native_c.end()) - m_native_c.erase(native_it); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_load_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_load_fn_imps.hpp deleted file mode 100644 index adc8727..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_load_fn_imps.hpp +++ /dev/null @@ -1,102 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 get_set_load_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -get_set_load() -{ - typedef - __gnu_pbds::detail::integral_constant - get_set_load_ind; - - get_set_load_imp(get_set_load_ind()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -get_set_load_imp(__gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -get_set_load_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("get_set_load"); - - PB_DS_SET_DESTRUCT_PRINT - - m_p_c->get_load(); - - m_alloc.set_throw_prob(1); - - typename alloc_t::group_throw_prob_adjustor adjust( - m_p_c->size()); - - const float min_load = static_cast(0.05); - const float max_load = static_cast(0.9); - - const float new_load = - static_cast( - m_g.get_prob()* (max_load - min_load) + - min_load); - - m_p_c->set_load(new_load); - - PB_DS_THROW_IF_FAILED( - m_p_c->get_load() == new_load, - "", - m_p_c, - & m_native_c); - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - } - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_loads_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_loads_fn_imps.hpp deleted file mode 100644 index 10ea2ae..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/get_set_loads_fn_imps.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 get_set_loads_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -get_set_loads() -{ - typedef - __gnu_pbds::detail::integral_constant - get_set_loads_ind; - - return (get_set_loads_imp(get_set_loads_ind())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -get_set_loads_imp(__gnu_pbds::detail::false_type) -{ - return (true); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -get_set_loads_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("get_set_loads"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - const std::pair old_loads = - m_p_c->get_loads(); - - try - { - m_alloc.set_throw_prob(m_tp); - - typename alloc_t::group_throw_prob_adjustor adjust( - m_p_c->size()); - - const float min_min_load = static_cast(0.05); - const float max_min_load = static_cast(0.2); - - const float new_min_load = - static_cast( - m_g.get_prob()* (max_min_load - min_min_load) + - min_min_load); - - const float new_max_load = static_cast(new_min_load* 2.5); - - PB_DS_THROW_IF_FAILED( new_max_load < 1, new_max_load, m_p_c, & m_native_c); - - m_p_c->set_loads( - std::make_pair( new_min_load, new_max_load)); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( - old_loads == m_p_c->get_loads(), - old_loads.first << " " << old_loads.second << " " << - m_p_c->get_loads().first << " " << - m_p_c->get_loads().second, - m_p_c, - & m_native_c); - - done = false; - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp deleted file mode 100644 index e5bf3be..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/insert_fn_imps.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -insert() -{ - PB_DS_TRACE("insert"); - bool done = true; - PB_DS_SET_DESTRUCT_PRINT - try - { - m_alloc.set_throw_prob(0); - value_type v = test_traits::generate_value(m_g, m_m); - m_alloc.set_throw_prob(m_tp); - const_key_reference r_k = test_traits::extract_key(v); - typename cntnr::const_point_iterator found_it = m_p_c->find(r_k); - const bool existed = (found_it != m_p_c->end()); - const std::pair ins_ret = m_p_c->insert(v); - - if (ins_ret.second) - { - PB_DS_THROW_IF_FAILED(!existed, "", m_p_c, &m_native_c); - } - else - { - PB_DS_THROW_IF_FAILED(existed, "", m_p_c, &m_native_c); - PB_DS_THROW_IF_FAILED(found_it == ins_ret.first, "", m_p_c, &m_native_c); - } - m_native_c.insert(test_traits::native_value(v)); - } - catch(__gnu_cxx::forced_exception_error&) - { - done = false; - } - catch(__gnu_pbds::insert_error&) - { - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - PB_DS_CANCEL_DESTRUCT_PRINT - return (done); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/it_conversion_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/it_conversion_fn_imps.hpp deleted file mode 100644 index 2a3c639..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/it_conversion_fn_imps.hpp +++ /dev/null @@ -1,307 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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_conversion_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -it_copy() -{ - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_iterator const_it(it); - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it(it); - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it(it); - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::const_iterator const_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it(const_it); - - PB_DS_THROW_IF_FAILED( const_find_it == const_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != const_it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::point_iterator find_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it(find_it); - - PB_DS_THROW_IF_FAILED( find_it == const_find_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != const_find_it), - "", - m_p_c, - & m_native_c); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -it_assign() -{ - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_iterator const_it; - const_it = it; - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = it; - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it; - find_it = it; - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::const_iterator const_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = const_it; - - PB_DS_THROW_IF_FAILED( const_find_it == const_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != const_it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::point_iterator find_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = find_it; - - PB_DS_THROW_IF_FAILED( find_it == const_find_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != const_find_it), - "", - m_p_c, - & m_native_c); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_copy() -{ - enum - { - reverse_iteration = container_traits::reverse_iteration - }; - - rev_it_copy_imp(__gnu_pbds::detail::integral_constant()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_assign() -{ - enum - { - reverse_iteration = container_traits::reverse_iteration - }; - - rev_it_assign_imp(__gnu_pbds::detail::integral_constant()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_copy_imp(__gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_copy_imp(__gnu_pbds::detail::true_type) -{ - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_reverse_iterator const_it(it); - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it(it); - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it(it); - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_assign_imp(__gnu_pbds::detail::false_type) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -rev_it_assign_imp(__gnu_pbds::detail::true_type) -{ - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_reverse_iterator const_it; - const_it = it; - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = it; - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it; - find_it = it; - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp deleted file mode 100644 index 8c11f76..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/operator_fn_imps.hpp +++ /dev/null @@ -1,246 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 operator_fn_imps.hpp - * Contains a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -operator()() -{ - typedef xml_result_set_regression_formatter formatter_type; - formatter_type* p_fmt = NULL; - - if (m_disp) - p_fmt = new formatter_type(string_form::name(), - string_form::desc()); - - m_g.init(m_seed); - - // Track allocation from this point only. - const size_t memory_label = 775; - m_alloc.init(m_seed); - m_alloc.set_label(memory_label); - - prog_bar pb(m_n, std::cout, m_disp); - m_i = 0; - - try - { - for (m_i = 0; m_i < m_n; ++m_i) - { - PB_DS_TRACE("Op #" << static_cast(m_i)); - allocator_type::set_label(m_i); - switch (m_i) - { - case 0: - PB_DS_RUN_MTHD(default_constructor); - break; - case 1: - defs(); - break; - case 2: - policy_access(); - break; - case 3: - it_copy(); - break; - case 4: - it_assign(); - break; - case 5: - rev_it_copy(); - break; - case 6: - rev_it_assign(); - break; - default: - switch(get_next_op()) - { - case insert_op: - switch(get_next_sub_op(2)) - { - case 0: - PB_DS_RUN_MTHD(insert) - break; - case 1: - PB_DS_RUN_MTHD(subscript) - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - break; - case erase_op: - switch(get_next_sub_op(4)) - { - case 0: - PB_DS_RUN_MTHD(erase) - break; - case 1: - PB_DS_RUN_MTHD(erase_if) - break; - case 2: - PB_DS_RUN_MTHD(erase_it) - break; - case 3: - PB_DS_RUN_MTHD(erase_rev_it) - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - break; - case clear_op: - PB_DS_RUN_MTHD(clear) - break; - case other_op: - switch(get_next_sub_op(8)) - { - case 0: - swap(); - break; - case 1: - PB_DS_RUN_MTHD(copy_constructor) - break; - case 2: - PB_DS_RUN_MTHD(it_constructor) - break; - case 3: - PB_DS_RUN_MTHD(assignment_operator) - break; - case 4: - PB_DS_RUN_MTHD(split_join) - break; - case 5: - resize(); - break; - case 6: - get_set_load(); - break; - case 7: - get_set_loads(); - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - }; - } - - pb.inc(); - } - } - catch (...) - { - std::cerr << "Failed at index " << static_cast(m_i) - << std::endl; - delete m_p_c; - throw; - } - - // Clean up, then check for allocation by special label, set above. - delete m_p_c; - - try - { m_alloc.check_allocated(memory_label); } - catch (...) - { - std::cerr << "detected leaks!" << std::endl; - std::cerr << m_alloc << std::endl; - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - - // Reset throw probability. - m_alloc.set_throw_prob(0); - - if (m_disp) - { - std::cout << std::endl; - delete p_fmt; - } -} - -PB_DS_CLASS_T_DEC -typename PB_DS_CLASS_C_DEC::op -PB_DS_CLASS_C_DEC:: -get_next_op() -{ - const double prob = m_g.get_prob(); - - if (prob < m_ip) - return insert_op; - - if (prob < m_ip + m_ep) - return erase_op; - - if (prob < m_ip + m_ep + m_cp) - return clear_op; - - PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c); - - return other_op; -} - -PB_DS_CLASS_T_DEC -size_t -PB_DS_CLASS_C_DEC:: -get_next_sub_op(size_t max) -{ - const double p = m_g.get_prob(); - const double delta = 1 / static_cast(max); - size_t i = 0; - while (true) - if (p <= (i + 1) * delta) - { - PB_DS_THROW_IF_FAILED(i < max, - static_cast(i) << " " << - static_cast(max), - m_p_c, &m_native_c); - - return i; - } - else - ++i; -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/policy_access_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/policy_access_fn_imps.hpp deleted file mode 100644 index 9b4f092..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/policy_access_fn_imps.hpp +++ /dev/null @@ -1,184 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access() -{ - policy_access(typename Cntnr::container_category()); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::basic_hash_tag) -{ - { - typename Cntnr::hash_fn& r_t = - m_p_c->get_hash_fn(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::hash_fn& r_t =((const Cntnr& )*m_p_c).get_hash_fn(); - - assert(&r_t != NULL); - } - - { - typename Cntnr::eq_fn& r_t = - m_p_c->get_eq_fn(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::eq_fn& r_t =((const Cntnr& )*m_p_c).get_eq_fn(); - - assert(&r_t != NULL); - } - - { - typename Cntnr::resize_policy& r_t = - m_p_c->get_resize_policy(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::resize_policy& r_t =((const Cntnr& )*m_p_c).get_resize_policy(); - - assert(&r_t != NULL); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::cc_hash_tag) -{ - policy_access(__gnu_pbds::basic_hash_tag()); - - { - typename Cntnr::comb_hash_fn& r_t = - m_p_c->get_comb_hash_fn(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::comb_hash_fn& r_t =((const Cntnr& )*m_p_c).get_comb_hash_fn(); - - assert(&r_t != NULL); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::gp_hash_tag) -{ - policy_access(__gnu_pbds::basic_hash_tag()); - - { - typename Cntnr::comb_probe_fn& r_t = - m_p_c->get_comb_probe_fn(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::comb_probe_fn& r_t =((const Cntnr& )*m_p_c).get_comb_probe_fn(); - - assert(&r_t != NULL); - } - - { - typename Cntnr::probe_fn& r_t = - m_p_c->get_probe_fn(); - - assert(&r_t != NULL); - } - { - const typename Cntnr::probe_fn& r_t =((const Cntnr& )*m_p_c).get_probe_fn(); - - assert(&r_t != NULL); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::tree_tag) -{ - { - typename Cntnr::cmp_fn& r_t = - m_p_c->get_cmp_fn(); - - assert(&r_t != NULL); - } - - { - const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn(); - - assert(&r_t != NULL); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::list_update_tag) -{ } - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access(__gnu_pbds::pat_trie_tag) -{ - typename Cntnr::e_access_traits& r_t = - m_p_c->get_e_access_traits(); - - assert(&r_t != NULL); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/resize_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/resize_fn_imps.hpp deleted file mode 100644 index 77bfcb8..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/resize_fn_imps.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -resize() -{ - typedef __gnu_pbds::detail::integral_constant resize_ind; - - return (resize_imp(resize_ind())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -resize_imp(__gnu_pbds::detail::false_type) -{ - return (true); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -resize_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("resize"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - const size_t old_size = - m_p_c->get_actual_size(); - - try - { - m_alloc.set_throw_prob(m_tp); - - typename alloc_t::group_throw_prob_adjustor - adjust(m_p_c->size()); - - enum - { - min_new_size = 200, - max_new_size = 2000 - }; - - const size_t new_size = - m_g.get_unsigned_long(min_new_size, max_new_size); - - m_p_c->resize(new_size); - - const size_t actual_new_size = - m_p_c->get_actual_size(); - - PB_DS_THROW_IF_FAILED( - actual_new_size >= new_size, - static_cast(actual_new_size) << " " << - static_cast(new_size), - m_p_c, - & m_native_c); - } - catch(...) - { - PB_DS_THROW_IF_FAILED( - m_p_c->get_actual_size() == old_size, - static_cast(m_p_c->get_actual_size()) << - " " << static_cast(old_size), - m_p_c, - & m_native_c); - - done = false; - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp deleted file mode 100644 index 8026d7c..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/split_join_fn_imps.hpp +++ /dev/null @@ -1,149 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -split_join() -{ - enum - { - split_join = container_traits::order_preserving - }; - - return (split_join_imp(__gnu_pbds::detail::integral_constant())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -split_join_imp(__gnu_pbds::detail::false_type) -{ - return (true); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -split_join_imp(__gnu_pbds::detail::true_type) -{ - PB_DS_TRACE("split_join"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - Cntnr lhs(*m_p_c); - - Cntnr rhs; - - native_type native_lhs(m_native_c); - - native_type native_rhs; - - const key_type k = - test_traits::generate_key(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - lhs.split(k, rhs); - - typename native_type::const_iterator it = - native_lhs.upper_bound(test_traits::native_key(k)); - - while (!native_lhs.empty()&& it != native_lhs.end()) - { - native_rhs.insert(*it); - - typename native_type::const_iterator next_it = it; - ++next_it; - - native_lhs.erase(test_traits::extract_native_key(*it)); - - it = next_it; - } - - PB_DS_COND_COMPARE(lhs, native_lhs); - PB_DS_COND_COMPARE(rhs, native_rhs); - - m_alloc.set_throw_prob(m_tp); - - if (m_g.get_prob() < 0.5) - lhs.swap(rhs); - - lhs.join(rhs); - - PB_DS_THROW_IF_FAILED( - rhs.size() == 0, - static_cast(rhs.size()), - m_p_c, - & m_native_c); - - PB_DS_THROW_IF_FAILED( - rhs.empty(), - static_cast(rhs.size()), - m_p_c, - & m_native_c); - - m_p_c->swap(lhs); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( container_traits::split_join_can_throw, container_traits::split_join_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp deleted file mode 100644 index e627595..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/detail/subscript_fn_imps.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 subscript_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -subscript() -{ - PB_DS_TRACE("subscript"); - - enum - { - no_data = __gnu_pbds::detail::is_same< - typename Cntnr::const_key_reference, - typename Cntnr::const_reference>::value - }; - - return (subscript_imp(__gnu_pbds::detail::integral_constant())); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -subscript_imp(__gnu_pbds::detail::false_type) -{ - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - value_type v = test_traits::generate_value(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - (*m_p_c)[v.first] = v.second; - - m_native_c[test_traits::native_value(v).first] = - test_traits::native_value(v).second; - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -subscript_imp(__gnu_pbds::detail::true_type) -{ - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - value_type v = test_traits::generate_value(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - (*m_p_c)[v] = __gnu_pbds::null_mapped_type(); - - m_native_c.insert(test_traits::native_value(v)); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp index 2f79df5..882d62b 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp @@ -49,11 +49,11 @@ #include #include -#include +#include #include #include #include -#include +#include namespace __gnu_pbds { @@ -111,7 +111,7 @@ namespace detail // Sane defaults. size_t n = iter; size_t m = keys; - size_t sd = 0; // 0 = time-determined arbitrary + size_t sd = twister_rand_gen::get_time_determined_seed(); double tp = 0.2; double ip = 0.6; double ep = 0.2; @@ -133,12 +133,10 @@ namespace detail return -2; }; + // XXX RAII, constructor takes bool for display xml_test_rand_regression_formatter* p_fmt = NULL; - if (sd == 0) - sd = twister_rand_gen::get_time_determined_seed(); if (disp) - p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, - ep, cp, mp); + p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, ep, cp, mp); try { @@ -174,12 +172,12 @@ namespace detail cerr << "* Performs the same operation on an cntnr object" << endl; cerr << "* Possibly compares the container to the cntnr object" << endl; cerr << "* Checks that exceptions (thrown by an allocator) " - "do not violate exception guarantees"; + "do not violate exception guarantees"; cerr << endl << endl; - cerr << "sd = seed for random-number generator; 0 = " - "time determined value" << endl; + cerr << "sd = seed for random-number generator; " + "0 = time determined value" << endl; cerr << "n = number of iterations" << endl; cerr << "m = number of distinct values" << endl; cerr << "tp = probability that an exception will be actively thrown" << endl; diff --git a/libstdc++-v3/testsuite/util/regression/rand/io/assoc/xml_formatter.hpp b/libstdc++-v3/testsuite/util/regression/rand/io/assoc/xml_formatter.hpp deleted file mode 100644 index db9ed28..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/io/assoc/xml_formatter.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 xml_formatter.hpp - * Contains an XML formatter for regression tests. - */ - -#ifndef PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP -#define PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP - -#include - -namespace __gnu_pbds -{ - - namespace test - { - - class xml_test_rand_regression_formatter : public xml_test_formatter - { - public: - xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, double tp, double ip, double ep, double cp, double mp); - }; - - xml_test_rand_regression_formatter:: - xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, double tp, double ip, double ep, double cp, double mp) - { - std::cout << make_xml_tag("sd", "value", sd); - std::cout << make_xml_tag("n", "value", n); - std::cout << make_xml_tag("m", "value", m); - std::cout << make_xml_tag("tp", "value", tp); - std::cout << make_xml_tag("ip", "value", ip); - std::cout << make_xml_tag("ep", "value", ep); - std::cout << make_xml_tag("cp", "value", cp); - std::cout << make_xml_tag("mp", "value", mp); - } - - } // namespace test - -} // namespace __gnu_pbds - -#endif // #ifndef PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP diff --git a/libstdc++-v3/testsuite/util/regression/rand/io/priority_queue/xml_formatter.hpp b/libstdc++-v3/testsuite/util/regression/rand/io/priority_queue/xml_formatter.hpp deleted file mode 100644 index af6f5d2..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/io/priority_queue/xml_formatter.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 xml_formatter.hpp - * Contains an XML formatter for regression tests. - */ - -#ifndef PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP -#define PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP - -#include - -namespace __gnu_pbds -{ - - namespace test - { - - class xml_test_rand_regression_formatter : public xml_test_formatter - { - public: - xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, double tp, double ip, double dp, double ep, double cp, double mp); - }; - - xml_test_rand_regression_formatter:: - xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, double tp, double ip, double dp, double ep, double cp, double mp) - { - std::cout << make_xml_tag("sd", "value", sd); - std::cout << make_xml_tag("n", "value", n); - std::cout << make_xml_tag("m", "value", m); - std::cout << make_xml_tag("tp", "value", tp); - std::cout << make_xml_tag("ip", "value", ip); - std::cout << make_xml_tag("dp", "value", dp); - std::cout << make_xml_tag("ep", "value", ep); - std::cout << make_xml_tag("cp", "value", cp); - std::cout << make_xml_tag("mp", "value", mp); - } - - } // namespace test - -} // namespace __gnu_pbds - -#endif // #ifndef PB_DS_XML_TEST_REGRESSION_FORMATTER_HPP diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h new file mode 100644 index 0000000..fe22c0c --- /dev/null +++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h @@ -0,0 +1,275 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. +// +// This file 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 container_rand_regression_test.h + * Contains a random regression test for a specific container type. + */ + +#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_H +#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace __gnu_pbds +{ +namespace test +{ +namespace detail +{ + // Rand test specialized for a specific container. + template + class container_rand_regression_test + { + private: + typedef Cntnr cntnr; + typedef typename cntnr::allocator_type allocator_type; + typedef typename cntnr::size_type size_type; + typedef twister_rand_gen gen; + typedef basic_type value_type; + typedef native_priority_queue native_type; + typedef regression_test_traits test_traits; + + enum op + { + insert_op, + modify_op, + erase_op, + clear_op, + other_op + }; + + op + get_next_op(); + + size_t + get_next_sub_op(size_t max); + + static void + defs(); + + static void + value_defs(); + + static void + ds_defs(); + + static void + iterator_defs(); + + static void + policy_defs(); + + void + policy_access(); + + void + it_copy(); + + void + it_assign(); + + bool + default_constructor(); + + void + swap(); + + bool + copy_constructor(); + + bool + assignment_operator(); + + bool + it_constructor(); + + bool + push(); + + bool + modify(); + + bool + pop(); + + bool + erase_if(); + + bool + erase_it(); + + bool + clear(); + + bool + split_join(); + + void + cmp(const Cntnr& r_container, const native_type& r_native_c, + const std::string& r_call_fn); + + void + print_container(const native_type& r_cnt, + std::ostream& r_os = std::cerr) const; + + void + print_container(const cntnr& r_cnt, + std::ostream& r_os = std::cerr) const; + + struct destructor_printer + { + destructor_printer(const std::string& r_msg) + : m_msg(r_msg), m_print(true) { } + + void + cancel() + { m_print = false; } + + ~destructor_printer() + { + if (m_print) + { + std::cerr << std::endl << "Uncaught exception: " << std::endl + << m_msg << std::endl; + } + } + + const std::string m_msg; + bool m_print; + }; + + const unsigned long m_seed; + const size_t m_n; + const size_t m_m; + const double m_tp; + const double m_ip; + const double m_dp; + const double m_ep; + const double m_cp; + const double m_mp; + const bool m_disp; + twister_rand_gen m_g; + Cntnr* m_p_c; + native_type m_native_c; + allocator_type m_alloc; + size_t m_i; + + public: + container_rand_regression_test(unsigned long seed, size_t n, size_t m, + double tp, double ip, double dp, + double ep, double cp, double mp, + bool disp); + + virtual + ~container_rand_regression_test(); + + void + operator()(); + }; + + +#ifdef PB_DS_REGRESSION_TRACE +# define PB_DS_TRACE(X) std::cerr << X << std::endl +#else +# define PB_DS_TRACE(X) +#endif + +#define PB_DS_CLASS_T_DEC \ + template + +#define PB_DS_CLASS_C_DEC \ + container_rand_regression_test + +#define PB_DS_COND_COMPARE(L, R) \ + if (m_g.get_prob() < m_mp) \ + cmp(L, R, __FUNCTION__); + +#define PB_DS_RUN_MTHD(MTHD) \ + { \ + bool done = false; \ + while (!done) \ + done = MTHD(); \ + } + +#define _GLIBCXX_THROW_IF_(PRED, MORE, P_C, P_NC, F, L) \ + if (PRED) \ + { \ + std::cerr << "Failure at " << F << ": " << L << std::endl; \ + std::cerr << MORE << std::endl; \ + std::cerr << "container:" << std::endl; \ + print_container(*(P_C)); \ + std::cerr << std::endl; \ + std::cerr << "native container:" << std::endl; \ + print_container(*(P_NC)); \ + std::cerr << std::endl; \ + throw std::logic_error("pbds throw if failed"); \ + } + +#define _GLIBCXX_THROW_IF(PRED, MORE, P_C, P_NC) \ + _GLIBCXX_THROW_IF_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__) + +#include + +#undef PB_DS_COND_COMPARE +#undef PB_DS_RUN_MTHD +#undef PB_DS_CLASS_T_DEC +#undef PB_DS_CLASS_C_DEC +#undef _GLIBCXX_THROW_IF_ +#undef _GLIBCXX_THROW_IF +#undef PB_DS_TRACE + +} // namespace detail +} // namespace test +} // namespace __gnu_pbds + +#endif diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc new file mode 100644 index 0000000..ceaa75b --- /dev/null +++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc @@ -0,0 +1,848 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. +// +// This file 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 container_rand_regression_test.tcc + * Contains a random regression test for a specific container type. + */ + +#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC +#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC + + // Constructor, copy constructor, assignment and destructor. +PB_DS_CLASS_T_DEC +PB_DS_CLASS_C_DEC:: +container_rand_regression_test(unsigned long seed, size_t n, size_t m, + double tp, double ip, double dp, double ep, + double cp, double mp, bool disp) +: m_seed(seed == 0 ? twister_rand_gen::get_time_determined_seed(): seed), + m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep), m_cp(cp), + m_mp(mp), m_disp(disp), m_p_c(NULL) +{ } + +PB_DS_CLASS_T_DEC +PB_DS_CLASS_C_DEC:: +~container_rand_regression_test() +{ } + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +default_constructor() +{ + PB_DS_TRACE("default_constructor"); + bool done = true; + m_alloc.set_throw_prob(m_tp); + + try + { + m_p_c = new Cntnr; + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + if (m_p_c != NULL) + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + + return done; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +swap() +{ + PB_DS_TRACE("swap"); + m_alloc.set_throw_prob(0); + Cntnr* p_c = new Cntnr; + m_alloc.set_throw_prob(1); + p_c->swap(*m_p_c); + std::swap(p_c, m_p_c); + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +copy_constructor() +{ + PB_DS_TRACE("copy_constructor"); + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + + typedef typename allocator_type::group_throw_prob_adjustor adjustor; + adjustor adjust(m_p_c->size()); + + try + { + p_c = new Cntnr(*m_p_c); + std::swap(p_c, m_p_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +assignment_operator() +{ + PB_DS_TRACE("assignment operator"); + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + + typedef typename allocator_type::group_throw_prob_adjustor adjustor; + adjustor adjust(m_p_c->size()); + + try + { + p_c = new Cntnr(); + *p_c = *m_p_c; + std::swap(p_c, m_p_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +it_constructor() +{ + bool done = true; + Cntnr* p_c = NULL; + m_alloc.set_throw_prob(m_tp); + typedef typename allocator_type::group_throw_prob_adjustor adjustor; + adjustor adjust(m_p_c->size()); + + try + { + switch(get_next_sub_op(3)) + { + case 0: + p_c = new Cntnr(m_p_c->get_cmp_fn()); + m_native_c.clear(); + break; + case 1: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end()); + break; + case 2: + p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn()); + break; + default: + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + }; + + std::swap(p_c, m_p_c); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + + delete p_c; + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + return done; +} + + + // Compare. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +cmp(const Cntnr& c, const native_type& native, const std::string& callfn) +{ + destructor_printer notify(__FUNCTION__); + + try + { + m_alloc.set_throw_prob(1); + + const size_t size = c.size(); + const size_t native_size = native.size(); + _GLIBCXX_THROW_IF(size != native_size, size << " " << native_size, + &c, &native); + + const bool empty = c.empty(); + const bool native_empty = native.empty(); + _GLIBCXX_THROW_IF(empty != native_empty, empty << " " << native_empty, + &c, &native); + + const size_t it_size = std::distance(c.begin(), c.end()); + _GLIBCXX_THROW_IF(it_size != size, it_size << " " << size, &c, &native); + + if (!c.empty()) + { + const std::string native_top = native.top(); + const std::string top = test_traits::native_value(c.top()); + const bool top_smaller = std::less()(top, native_top); + const bool top_larger = std::less()(native_top, top); + + if (top_smaller || top_larger) + _GLIBCXX_THROW_IF(true, top << " " << native_top, &c, &native); + } + } + catch(...) + { + _GLIBCXX_THROW_IF(true, "call-fn: " + callfn, &c, &native); + } + + notify.cancel(); +} + + // Operators. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +operator()() +{ + typedef xml_result_set_regression_formatter formatter_type; + formatter_type* p_fmt = NULL; + if (m_disp) + p_fmt = new formatter_type(string_form::name(), + string_form::desc()); + + m_g.init(m_seed); + m_alloc.init(m_seed); + + // The __throw_allocator::_S_label defaults to 0, so to make things + // easier and more precise when debugging, start at 1. + const size_t starting_label(1); + + try + { + prog_bar pb(m_n, std::cout, m_disp); + + for (m_i = starting_label; m_i <= m_n; ++m_i) + { + PB_DS_TRACE("Op #" << m_i); + + // Track allocation from this point only. + allocator_type::set_label(m_i); + switch(m_i) + { + case 1: + PB_DS_RUN_MTHD(default_constructor); + break; + case 2: + defs(); + break; + case 3: + policy_access(); + break; + case 4: + it_copy(); + break; + case 5: + it_assign(); + break; + default: + switch(get_next_op()) + { + case insert_op: + PB_DS_RUN_MTHD(push) + break; + case modify_op: + PB_DS_RUN_MTHD(modify) + break; + case erase_op: + switch(get_next_sub_op(3)) + { + case 0: + PB_DS_RUN_MTHD(pop) + break; + case 1: + PB_DS_RUN_MTHD(erase_if) + break; + case 2: + PB_DS_RUN_MTHD(erase_it) + break; + default: + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + break; + case clear_op: + PB_DS_RUN_MTHD(clear) + break; + case other_op: + switch(get_next_sub_op(5)) + { + case 0: + swap(); + break; + case 1: + PB_DS_RUN_MTHD(copy_constructor) + break; + case 2: + PB_DS_RUN_MTHD(it_constructor) + break; + case 3: + PB_DS_RUN_MTHD(assignment_operator) + break; + case 4: + PB_DS_RUN_MTHD(split_join) + break; + default: + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + break; + default: + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + }; + } + pb.inc(); + } + } + catch (...) + { + std::cerr << "Failed at index " << m_i << std::endl; + delete m_p_c; + throw; + } + + // Clean up, then check for allocation by special label, set above. + allocator_type::set_label(0); + delete m_p_c; + + try + { + for (size_t n = starting_label; n <= m_n; ++n) + m_alloc.check_allocated(n); + } + catch (std::logic_error& obj) + { + // On fail, check_allocated should throw std::logic_error. + std::cerr << obj.what() << std::endl; + std::cerr << typeid(Cntnr).name() << std::endl; + throw; + } + + // Reset throw probability. + m_alloc.set_throw_prob(0); + + if (m_disp) + { + std::cout << std::endl; + delete p_fmt; + } +} + +PB_DS_CLASS_T_DEC +typename PB_DS_CLASS_C_DEC::op +PB_DS_CLASS_C_DEC:: +get_next_op() +{ + const double prob = m_g.get_prob(); + + if (prob < m_ip) + return insert_op; + + if (prob < m_ip + m_dp) + return modify_op; + + if (prob < m_ip + m_dp + m_ep) + return erase_op; + + if (prob < m_ip + m_dp + m_ep + m_cp) + return clear_op; + + _GLIBCXX_THROW_IF(prob > 1, prob, m_p_c, &m_native_c); + return other_op; +} + +PB_DS_CLASS_T_DEC +size_t +PB_DS_CLASS_C_DEC:: +get_next_sub_op(size_t max) +{ + const double p = m_g.get_prob(); + const double delta = 1 / static_cast(max); + size_t i = 0; + while (true) + if (p <= (i + 1) * delta) + { + _GLIBCXX_THROW_IF(i >= max, i << " " << max, m_p_c, &m_native_c); + return i; + } + else + ++i; +} + + // Insert. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +push() +{ + PB_DS_TRACE("push"); + bool done = true; + destructor_printer notify(__FUNCTION__); + + try + { + m_alloc.set_throw_prob(0); + value_type v = test_traits::generate_value(m_g, m_m); + m_alloc.set_throw_prob(m_tp); + const typename cntnr::size_type sz = m_p_c->size(); + m_p_c->push(v); + _GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c); + m_native_c.push(test_traits::native_value(v)); + } + catch(__gnu_cxx::forced_exception_error& ) + { + done = false; + } + catch(...) + { + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + + + // Modify. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +modify() +{ + PB_DS_TRACE("modify"); + destructor_printer notify(__FUNCTION__); + + bool done = true; + try + { + m_alloc.set_throw_prob(0); + value_type v = test_traits::generate_value(m_g, m_m); + + m_alloc.set_throw_prob(m_tp); + typename cntnr::iterator it = m_p_c->begin(); + std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); + if (it != m_p_c->end()) + { + typedef typename test_traits::native_value_type native_value_type; + native_value_type native_v = test_traits::native_value(*it); + native_value_type new_native_v = test_traits::native_value(v); + m_p_c->modify(it, v); + m_native_c.modify(native_v, new_native_v); + } + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + + // Clear. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +clear() +{ + PB_DS_TRACE("clear"); + m_p_c->clear(); + m_native_c.clear(); + return true; +} + + // Erase. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +pop() +{ + PB_DS_TRACE("pop"); + destructor_printer notify(__FUNCTION__); + + bool done = true; + try + { + m_alloc.set_throw_prob(1); + if (!m_p_c->empty()) + { + m_p_c->pop(); + m_native_c.pop(); + } + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_if() +{ + PB_DS_TRACE("erase_if"); + destructor_printer notify(__FUNCTION__); + + bool done = true; + try + { + typedef + typename std::iterator_traits::reference + it_const_reference; + + m_alloc.set_throw_prob(1); + + typedef + typename test_traits::template erase_if_fn + erase_if_fn_t; + + const size_t ersd = m_p_c->erase_if(erase_if_fn_t()); + + typedef + typename test_traits::template erase_if_fn + native_erase_if_fn_t; + + const size_t native_ersd = m_native_c.erase_if(native_erase_if_fn_t()); + + _GLIBCXX_THROW_IF(ersd != native_ersd, ersd << " " << native_ersd, + m_p_c, &m_native_c); + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +erase_it() +{ + PB_DS_TRACE("erase_it"); + destructor_printer notify(__FUNCTION__); + + bool done = true; + try + { + m_alloc.set_throw_prob(1); + typename cntnr::iterator it = m_p_c->begin(); + std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); + + if (it != m_p_c->end()) + { + m_native_c.erase(*it); + m_p_c->erase(it); + } + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + + // Defs. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +defs() +{ + // General container types. + typedef typename Cntnr::size_type test_size_type; + typedef typename Cntnr::difference_type difference_type; + value_defs(); + iterator_defs(); + policy_defs(); +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +value_defs() +{ + typedef typename Cntnr::value_type test_value_type; + typedef typename Cntnr::reference test_reference; + typedef typename Cntnr::const_reference test_const_reference; + typedef typename Cntnr::pointer test_pointer; + typedef typename Cntnr::const_pointer test_const_pointer; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +ds_defs() +{ + typedef typename Cntnr::container_category test_container_category; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +iterator_defs() +{ + typedef typename Cntnr::point_iterator test_point_iterator; + typedef typename Cntnr::const_point_iterator const_test_point_iterator; + typedef typename Cntnr::iterator test_iterator; + typedef typename Cntnr::const_iterator const_test_iterator; +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_defs() +{ + typedef typename Cntnr::allocator_type test_allocator; + typedef typename Cntnr::cmp_fn test_cmp_fn; +} + + +// Policy access. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +policy_access() +{ + PB_DS_TRACE("policy_access"); + + { + typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn(); + assert(&r_t != NULL); + } + + { + const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn(); + assert(&r_t != NULL); + } +} + +// Split join. +PB_DS_CLASS_T_DEC +bool +PB_DS_CLASS_C_DEC:: +split_join() +{ + PB_DS_TRACE("split_join"); + destructor_printer notify(__FUNCTION__); + + bool done = true; + try + { + m_alloc.set_throw_prob(0); + Cntnr lhs(*m_p_c); + Cntnr rhs; + native_type native_lhs(m_native_c); + m_alloc.set_throw_prob(m_tp); + + typedef typename test_traits::template erase_if_fn split_fn_t; + lhs.split(split_fn_t(), rhs); + + typedef typename test_traits::template erase_if_fn + native_split_fn_t; + + native_type native_rhs; + native_lhs.split(native_split_fn_t(), native_rhs); + PB_DS_COND_COMPARE(lhs, native_lhs); + PB_DS_COND_COMPARE(rhs, native_rhs); + + m_alloc.set_throw_prob(m_tp); + + if (m_g.get_prob() < 0.5) + lhs.swap(rhs); + lhs.join(rhs); + + _GLIBCXX_THROW_IF(rhs.size() != 0, rhs.size(), m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!rhs.empty(), rhs.size(), m_p_c, &m_native_c); + } + catch(__gnu_cxx::forced_exception_error&) + { + done = false; + const bool b = __gnu_pbds::container_traits::split_join_can_throw; + _GLIBCXX_THROW_IF(!b, b, m_p_c, &m_native_c); + } + + PB_DS_COND_COMPARE(*m_p_c, m_native_c); + notify.cancel(); + return done; +} + +// Iterator conversions. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +it_copy() +{ + PB_DS_TRACE("it_copy"); + + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_iterator const_it(it); + _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::const_iterator const_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it(const_it); + _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it1(it); + _GLIBCXX_THROW_IF(const_find_it1 != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_find_it1 == it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it1(it); + _GLIBCXX_THROW_IF(find_it1 != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(find_it1 == it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it(find_it); + _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +it_assign() +{ + PB_DS_TRACE("it_assign"); + + { + typename cntnr::iterator it = m_p_c->end(); + typename cntnr::const_iterator const_it; + const_it = it; + _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c); + + typename cntnr::const_point_iterator const_find_it; + const_find_it = it; + _GLIBCXX_THROW_IF(const_find_it != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_find_it == it), "", m_p_c, &m_native_c); + + typename cntnr::point_iterator find_it; + find_it = it; + _GLIBCXX_THROW_IF(find_it != it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(find_it == it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::const_iterator const_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it; + const_find_it = const_it; + _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c); + } + + { + typename cntnr::point_iterator find_it = m_p_c->end(); + typename cntnr::const_point_iterator const_find_it; + const_find_it = find_it; + _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c); + _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c); + } +} + + +// Diagnostics. +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +print_container(const native_type& cnt, std::ostream& os) const +{ + m_alloc.set_throw_prob(0); + native_type cpy(cnt); + while (!cpy.empty()) + { + os << cpy.top() << std::endl; + cpy.pop(); + } +} + +PB_DS_CLASS_T_DEC +void +PB_DS_CLASS_C_DEC:: +print_container(const cntnr& cnt, std::ostream& os) const +{ + typedef typename cntnr::const_iterator const_iterator; + m_alloc.set_throw_prob(0); + for (const_iterator it = cnt.begin(); it != cnt.end(); ++it) + os << *it << std::endl; +} + +#endif diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/clear_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/clear_fn_imps.hpp deleted file mode 100644 index 009b56f..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/clear_fn_imps.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 clear_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -clear() -{ - PB_DS_TRACE("clear"); - - m_p_c->clear(); - - m_native_c.clear(); - - return (true); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/cmp_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/cmp_fn_imps.hpp deleted file mode 100644 index 3707b7d..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/cmp_fn_imps.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -cmp(const Cntnr& r_c, const native_type& r_native_c, const std::string& r_call_fn) -{ - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(1); - - const size_t size = r_c.size(); - const size_t native_size = r_native_c.size(); - - PB_DS_THROW_IF_FAILED( - size == native_size, - static_cast(size) << " " << - static_cast(native_size), - & r_c, - & r_native_c); - - const bool empty = r_c.empty(); - const bool native_empty = r_native_c.empty(); - - PB_DS_THROW_IF_FAILED( - empty == native_empty, - empty << " " << native_empty, - & r_c, - & r_native_c); - - const size_t it_size = std::distance(r_c.begin(), r_c.end()); - - PB_DS_THROW_IF_FAILED( - it_size == size, - it_size << " " << size, - & r_c, - & r_native_c); - - if (!r_c.empty()) - { - const std::string native_top = r_native_c.top(); - const std::string top = test_traits::native_value(r_c.top()); - - const bool top_smaller = std::less()(top, native_top); - const bool top_larger = std::less()(native_top, top); - - if (top_smaller || top_larger) - PB_DS_THROW_IF_FAILED( - false, - top << " " << native_top, - & r_c, - & r_native_c); - } - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "call-fn: " + r_call_fn, & r_c, & r_native_c); - } - - PB_DS_CANCEL_DESTRUCT_PRINT - } - diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp deleted file mode 100644 index 87282825..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/constructor_destructor_fn_imps.hpp +++ /dev/null @@ -1,235 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -PB_DS_CLASS_C_DEC:: -container_rand_regression_test(unsigned long seed, size_t n, size_t m, double tp, double ip, double dp, double ep, double cp, double mp, bool disp) : - m_seed((seed == 0)? - twister_rand_gen::get_time_determined_seed(): - seed), - m_n(n), - m_m(m), - m_tp(tp), - m_ip(ip), - m_dp(dp), - m_ep(ep), - m_cp(cp), - m_mp(mp), - m_disp(disp), - m_p_c(NULL) -{ } - -PB_DS_CLASS_T_DEC -PB_DS_CLASS_C_DEC:: -~container_rand_regression_test() -{ } - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -default_constructor() -{ - PB_DS_TRACE("default_constructor"); - - bool done = true; - - m_alloc.set_throw_prob(m_tp); - - try - { - m_p_c = new Cntnr; - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - if (m_p_c != NULL) - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - return (done); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -swap() -{ - PB_DS_TRACE("swap"); - - m_alloc.set_throw_prob(0); - - Cntnr* p_c = new Cntnr; - - m_alloc.set_throw_prob(1); - - p_c->swap(*m_p_c); - - std::swap(p_c, m_p_c); - - delete p_c; - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -copy_constructor() -{ - PB_DS_TRACE("copy_constructor"); - - bool done = true; - - Cntnr* p_c = NULL; - - m_alloc.set_throw_prob(m_tp); - - typename alloc_t::group_throw_prob_adjustor - adjust(m_p_c->size()); - - try - { - p_c = new Cntnr(*m_p_c); - - std::swap(p_c, m_p_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - delete p_c; - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -assignment_operator() -{ - PB_DS_TRACE("assignment operator"); - - bool done = true; - - Cntnr* p_c = NULL; - - m_alloc.set_throw_prob(m_tp); - - typename alloc_t::group_throw_prob_adjustor - adjust(m_p_c->size()); - - try - { - p_c = new Cntnr(); - - * p_c =* m_p_c; - - std::swap(p_c, m_p_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - delete p_c; - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -it_constructor() -{ - bool done = true; - - Cntnr* p_c = NULL; - - m_alloc.set_throw_prob(m_tp); - - typename alloc_t::group_throw_prob_adjustor - adjust(m_p_c->size()); - - try - { - switch(get_next_sub_op(3)) - { - case 0: - p_c = new Cntnr(m_p_c->get_cmp_fn()); - m_native_c.clear(); - break; - case 1: - p_c = new Cntnr(m_p_c->begin(), - m_p_c->end()); - break; - case 2: - p_c = new Cntnr(m_p_c->begin(), - m_p_c->end(), - m_p_c->get_cmp_fn()); - break; - default: - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - }; - - std::swap(p_c, m_p_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - - delete p_c; - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/defs_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/defs_fn_imps.hpp deleted file mode 100644 index ae40693..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/defs_fn_imps.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 defs_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -defs() -{ - // General container types. - typedef typename Cntnr::size_type test_size_type; - typedef typename Cntnr::difference_type difference_type; - value_defs(); - iterator_defs(); - policy_defs(); -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -value_defs() -{ - typedef typename Cntnr::value_type test_value_type; - typedef typename Cntnr::reference test_reference; - typedef typename Cntnr::const_reference test_const_reference; - typedef typename Cntnr::pointer test_pointer; - typedef typename Cntnr::const_pointer test_const_pointer; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -ds_defs() -{ - typedef typename Cntnr::container_category test_container_category; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -iterator_defs() -{ - typedef typename Cntnr::point_iterator test_point_iterator; - typedef typename Cntnr::const_point_iterator const_test_point_iterator; - typedef typename Cntnr::iterator test_iterator; - typedef typename Cntnr::const_iterator const_test_iterator; -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_defs() -{ - typedef typename Cntnr::allocator_type test_allocator; - typedef typename Cntnr::cmp_fn test_cmp_fn; -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/diagnostic_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/diagnostic_fn_imps.hpp deleted file mode 100644 index caeba09..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/diagnostic_fn_imps.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 diagnostic_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -print_container(const native_type& r_cnt, std::ostream& r_os /*= std::cerr*/) const -{ - m_alloc.set_throw_prob(0); - - native_type cpy(r_cnt); - - while (!cpy.empty()) - { - r_os << cpy.top() << std::endl; - - cpy.pop(); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -print_container(const cntnr& r_cnt, std::ostream& r_os /*= std::cerr*/) const -{ - m_alloc.set_throw_prob(0); - - for (typename cntnr::const_iterator it = r_cnt.begin(); it != r_cnt.end(); ++it) - r_os <<* it << std::endl; -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp deleted file mode 100644 index 82b126a..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/erase_fn_imps.hpp +++ /dev/null @@ -1,178 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -pop() -{ - PB_DS_TRACE("pop"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - m_alloc.set_throw_prob(1); - - try - { - if (!m_p_c->empty()) - { - m_p_c->pop(); - - m_native_c.pop(); - } - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_if() -{ - PB_DS_TRACE("erase_if"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - typedef - typename std::iterator_traits< - typename cntnr::iterator>::reference - it_const_reference; - - m_alloc.set_throw_prob(1); - - typedef - typename test_traits::template erase_if_fn< - value_type> - erase_if_fn_t; - - const size_t ersd = - m_p_c->erase_if(erase_if_fn_t()); - - typedef - typename test_traits::template erase_if_fn< - std::string> - native_erase_if_fn_t; - - const size_t native_ersd = - m_native_c.erase_if(native_erase_if_fn_t()); - - PB_DS_THROW_IF_FAILED( - ersd == native_ersd, - static_cast(ersd) << " " << - static_cast(native_ersd), - m_p_c, - & m_native_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -erase_it() -{ - PB_DS_TRACE("erase_it"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(1); - - typename cntnr::iterator it = m_p_c->begin(); - - std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); - - if (it != m_p_c->end()) - { - m_native_c.erase(*it); - - m_p_c->erase(it); - } - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp deleted file mode 100644 index 24dc649..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/insert_fn_imps.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -push() -{ - PB_DS_TRACE("push"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - value_type v = test_traits::generate_value(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - const typename cntnr::size_type sz = m_p_c->size(); - - typename cntnr::point_iterator ins_ret = m_p_c->push(v); - - PB_DS_THROW_IF_FAILED( - sz == m_p_c->size() - 1, - sz, - m_p_c, - & m_native_c); - - m_native_c.push(test_traits::native_value(v)); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - } - catch(...) - { - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/it_conversion_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/it_conversion_fn_imps.hpp deleted file mode 100644 index c59e136..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/it_conversion_fn_imps.hpp +++ /dev/null @@ -1,190 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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_conversion_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -it_copy() -{ - PB_DS_TRACE("it_copy"); - - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_iterator const_it(it); - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it(it); - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it(it); - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::const_iterator const_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it(const_it); - - PB_DS_THROW_IF_FAILED( const_find_it == const_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != const_it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::point_iterator find_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it(find_it); - - PB_DS_THROW_IF_FAILED( find_it == const_find_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != const_find_it), - "", - m_p_c, - & m_native_c); - } -} - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -it_assign() -{ - PB_DS_TRACE("it_assign"); - - { - typename cntnr::iterator it = m_p_c->end(); - - typename cntnr::const_iterator const_it; - const_it = it; - - PB_DS_THROW_IF_FAILED( const_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = it; - - PB_DS_THROW_IF_FAILED( const_find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != it), - "", - m_p_c, - & m_native_c); - - typename cntnr::point_iterator find_it; - find_it = it; - - PB_DS_THROW_IF_FAILED( find_it == it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::const_iterator const_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = const_it; - - PB_DS_THROW_IF_FAILED( const_find_it == const_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(const_find_it != const_it), - "", - m_p_c, - & m_native_c); - } - - { - typename cntnr::point_iterator find_it = m_p_c->end(); - - typename cntnr::const_point_iterator const_find_it; - const_find_it = find_it; - - PB_DS_THROW_IF_FAILED( find_it == const_find_it, "", m_p_c, & m_native_c); - - PB_DS_THROW_IF_FAILED( - !(find_it != const_find_it), - "", - m_p_c, - & m_native_c); - } -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp deleted file mode 100644 index 5e99e09..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/modify_fn_imps.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 modify_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -modify() -{ - PB_DS_TRACE("modify"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - value_type v = test_traits::generate_value(m_g, m_m); - - m_alloc.set_throw_prob(m_tp); - - typename cntnr::iterator it = m_p_c->begin(); - - std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); - - if (it != m_p_c->end()) - { - typename test_traits::native_value_type native_v = - test_traits::native_value(*it); - - typename test_traits::native_value_type new_native_v = - test_traits::native_value(v); - - m_p_c->modify(it, v); - - m_native_c.modify(native_v, new_native_v); - } - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( false, "", m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} - diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp deleted file mode 100644 index 6186991..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/operator_fn_imps.hpp +++ /dev/null @@ -1,222 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 operator_fn_imps.hpp - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -operator()() -{ - typedef xml_result_set_regression_formatter formatter_type; - formatter_type* p_fmt = NULL; - - if (m_disp) - p_fmt = new formatter_type(string_form::name(), - string_form::desc()); - - m_g.init(m_seed); - - // Track allocation from this point only. - const size_t memory_label = 775; - m_alloc.init(m_seed); - m_alloc.set_label(memory_label); - - prog_bar pb(m_n, std::cout, m_disp); - m_i = 0; - - try - { - for (m_i = 0; m_i < m_n; ++m_i) - { - PB_DS_TRACE("Op #" << static_cast(m_i)); - allocator_type::set_label(m_i); - switch(m_i) - { - case 0: - PB_DS_RUN_MTHD(default_constructor); - break; - case 1: - defs(); - break; - case 2: - policy_access(); - break; - case 3: - it_copy(); - break; - case 4: - it_assign(); - break; - default: - switch(get_next_op()) - { - case insert_op: - PB_DS_RUN_MTHD(push) - break; - case modify_op: - PB_DS_RUN_MTHD(modify) - break; - case erase_op: - switch(get_next_sub_op(3)) - { - case 0: - PB_DS_RUN_MTHD(pop) - break; - case 1: - PB_DS_RUN_MTHD(erase_if) - break; - case 2: - PB_DS_RUN_MTHD(erase_it) - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - break; - case clear_op: - PB_DS_RUN_MTHD(clear) - break; - case other_op: - switch(get_next_sub_op(5)) - { - case 0: - swap(); - break; - case 1: - PB_DS_RUN_MTHD(copy_constructor) - break; - case 2: - PB_DS_RUN_MTHD(it_constructor) - break; - case 3: - PB_DS_RUN_MTHD(assignment_operator) - break; - case 4: - PB_DS_RUN_MTHD(split_join) - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - break; - default: - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - }; - } - pb.inc(); - } - } - catch (...) - { - std::cerr << "Failed at index " << static_cast(m_i) - << std::endl; - delete m_p_c; - throw; - } - - // Clean up, then check for allocation by special label, set above. - delete m_p_c; - - try - { m_alloc.check_allocated(memory_label); } - catch (...) - { - std::cerr << "detected leaks!" << std::endl; - std::cerr << m_alloc << std::endl; - PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c); - } - - // Reset throw probability. - m_alloc.set_throw_prob(0); - - if (m_disp) - { - std::cout << std::endl; - delete p_fmt; - } -} - -PB_DS_CLASS_T_DEC -typename PB_DS_CLASS_C_DEC::op -PB_DS_CLASS_C_DEC:: -get_next_op() -{ - const double prob = m_g.get_prob(); - - if (prob < m_ip) - return (insert_op); - - if (prob < m_ip + m_dp) - return (modify_op); - - if (prob < m_ip + m_dp + m_ep) - return (erase_op); - - if (prob < m_ip + m_dp + m_ep + m_cp) - return (clear_op); - - PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c); - return other_op; -} - -PB_DS_CLASS_T_DEC -size_t -PB_DS_CLASS_C_DEC:: -get_next_sub_op(size_t max) -{ - const double p = m_g.get_prob(); - const double delta = 1 / static_cast(max); - size_t i = 0; - while (true) - if (p <= (i + 1)* delta) - { - PB_DS_THROW_IF_FAILED(i < max, - static_cast(i) << " " << - static_cast(max), - m_p_c, - & m_native_c); - return i; - } - else - ++i; -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/policy_access_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/policy_access_fn_imps.hpp deleted file mode 100644 index 40f3792..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/policy_access_fn_imps.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -void -PB_DS_CLASS_C_DEC:: -policy_access() -{ - PB_DS_TRACE("policy_access"); - - { - typename Cntnr::cmp_fn& r_t = - m_p_c->get_cmp_fn(); - - assert(&r_t != NULL); - } - - { - const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn(); - - assert(&r_t != NULL); - } -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp deleted file mode 100644 index b25394f..0000000 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/detail/split_join_fn_imps.hpp +++ /dev/null @@ -1,120 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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 - * Containsert a random regression test for a specific container type. - */ - -PB_DS_CLASS_T_DEC -bool -PB_DS_CLASS_C_DEC:: -split_join() -{ - PB_DS_TRACE("split_join"); - - bool done = true; - - PB_DS_SET_DESTRUCT_PRINT - - try - { - m_alloc.set_throw_prob(0); - - Cntnr lhs(*m_p_c); - - Cntnr rhs; - - native_type native_lhs(m_native_c); - - m_alloc.set_throw_prob(m_tp); - - typedef - typename test_traits::template erase_if_fn< - value_type> - split_fn_t; - - lhs.split(split_fn_t(), rhs); - - typedef - typename test_traits::template erase_if_fn< - std::string> - native_split_fn_t; - - native_type native_rhs; - - native_lhs.split(native_split_fn_t(), native_rhs); - - PB_DS_COND_COMPARE(lhs, native_lhs); - PB_DS_COND_COMPARE(rhs, native_rhs); - - m_alloc.set_throw_prob(m_tp); - - if (m_g.get_prob() < 0.5) - lhs.swap(rhs); - - lhs.join(rhs); - - PB_DS_THROW_IF_FAILED( - rhs.size() == 0, - static_cast(rhs.size()), - m_p_c, - & m_native_c); - - PB_DS_THROW_IF_FAILED( - rhs.empty(), - static_cast(rhs.size()), - m_p_c, - & m_native_c); - } - catch(__gnu_cxx::forced_exception_error& ) - { - done = false; - - PB_DS_THROW_IF_FAILED( __gnu_pbds::container_traits::split_join_can_throw, __gnu_pbds::container_traits::split_join_can_throw, m_p_c, & m_native_c); - } - - PB_DS_COND_COMPARE(*m_p_c, m_native_c); - - PB_DS_CANCEL_DESTRUCT_PRINT - - return (done); -} diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp index 80f941a..c74b1a0 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -49,11 +49,9 @@ #include #include -#include #include -#include -#include -#include +#include +#include namespace __gnu_pbds { diff --git a/libstdc++-v3/testsuite/util/regression/rand/io/xml_formatter.hpp b/libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp similarity index 58% rename from libstdc++-v3/testsuite/util/regression/rand/io/xml_formatter.hpp rename to libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp index 7006618..2e43eb3 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/io/xml_formatter.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp @@ -53,35 +53,58 @@ namespace __gnu_pbds { - namespace test { - - class xml_result_set_regression_formatter : public xml_result_set_formatter + // Test formatters. + struct xml_test_rand_regression_formatter : public xml_test_formatter { - public: - xml_result_set_regression_formatter(const std::string& r_container_name, const std::string& r_container_desc); - - ~xml_result_set_regression_formatter(); + // Associative. + xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, + double tp, double ip, double ep, + double cp, double mp) + { + std::cout << make_xml_tag("sd", "value", sd); + std::cout << make_xml_tag("n", "value", n); + std::cout << make_xml_tag("m", "value", m); + std::cout << make_xml_tag("tp", "value", tp); + std::cout << make_xml_tag("ip", "value", ip); + std::cout << make_xml_tag("ep", "value", ep); + std::cout << make_xml_tag("cp", "value", cp); + std::cout << make_xml_tag("mp", "value", mp); + } + + // Priority Queue. + xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m, + double tp, double ip, double dp, + double ep, double cp, double mp) + { + std::cout << make_xml_tag("sd", "value", sd); + std::cout << make_xml_tag("n", "value", n); + std::cout << make_xml_tag("m", "value", m); + std::cout << make_xml_tag("tp", "value", tp); + std::cout << make_xml_tag("ip", "value", ip); + std::cout << make_xml_tag("dp", "value", dp); + std::cout << make_xml_tag("ep", "value", ep); + std::cout << make_xml_tag("cp", "value", cp); + std::cout << make_xml_tag("mp", "value", mp); + } }; - xml_result_set_regression_formatter:: - xml_result_set_regression_formatter(const std::string& r_container_name, const std::string& r_container_desc) : - xml_result_set_formatter(r_container_name, r_container_desc) + // Result formatter. + struct xml_result_set_regression_formatter : public xml_result_set_formatter { - - std::cout << detail::make_xml_name_start_tag("progress"); - std::cout << detail::make_xml_name_start_tag_end_delimiter(); - } - - xml_result_set_regression_formatter:: - ~xml_result_set_regression_formatter() - { - std::cout << detail::make_xml_name_end_tag("progress"); - } - + xml_result_set_regression_formatter(const std::string& r_container_name, + const std::string& r_container_desc) + : xml_result_set_formatter(r_container_name, r_container_desc) + { + std::cout << detail::make_xml_name_start_tag("progress"); + std::cout << detail::make_xml_name_start_tag_end_delimiter(); + } + + ~xml_result_set_regression_formatter() + { std::cout << detail::make_xml_name_end_tag("progress"); } + }; } // namespace test - } // namespace __gnu_pbds #endif // #ifndef PB_DS_COMMON_XML_TEST_REGRESSION_FORMATTER_HPP diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp index a796b81..9e8e0f3 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp @@ -41,7 +41,7 @@ /** * @file get_set_load_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp index 389ad64..d2fd190 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp @@ -41,7 +41,7 @@ /** * @file get_set_loads_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp index d70c883..f976097 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp @@ -41,7 +41,7 @@ /** * @file native_type_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp index ff30042..b54a935 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp @@ -41,7 +41,7 @@ /** * @file node_update_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp index 932a0cc..4c7d026 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp @@ -41,7 +41,7 @@ /** * @file resize_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp index a0ba693..772fa17 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp @@ -41,7 +41,7 @@ /** * @file to_string.hpp - * Containsert classes for transforming stuff to strings. + * Contains classes for transforming stuff to strings. */ #ifndef PB_DS_REGRESSION_TEST_TO_STRING_HPP diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp index 5e97aea..1ce2a9e 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp @@ -41,13 +41,14 @@ /** * @file trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ #ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP #define PB_DS_REGRESSION_TEST_TRAIT_HPP +#include #include #include #include @@ -55,7 +56,6 @@ #include #include #include -#include namespace __gnu_pbds { @@ -104,14 +104,16 @@ namespace detail typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base; public: - typedef typename Cntnr::key_type key_type; - typedef typename Cntnr::const_key_reference const_key_reference; typedef typename Cntnr::value_type value_type; typedef typename Cntnr::const_reference const_reference; typedef typename PB_DS_NATIVE_TYPE_TRAITS_C_DEC::type native_type; - typedef typename native_type::key_type native_key_type; typedef typename native_type::value_type native_value_type; + // Only associative containers. + typedef typename Cntnr::key_type key_type; + typedef typename Cntnr::const_key_reference const_key_reference; + typedef typename native_type::key_type native_key_type; + enum { resize = PB_DS_RESIZE_TRAITS_C_DEC::value, @@ -128,8 +130,7 @@ namespace detail static size_t erase_if(native_type& r_native_c) { - typedef regression_test_erase_if_fn erase_if_fn; - + typedef regression_test_erase_if_fn erase_if_fn; typename native_type::iterator it = r_native_c.begin(); size_t num_ersd = 0; while (it != r_native_c.end()) @@ -193,13 +194,9 @@ namespace detail static bool prefix_match(const_key_reference r_key, const std::string& r_native_key) { - const size_t native_substr_len = std::min(r_key.length(), - r_native_key.length()); - - const std::string native_substr = r_native_key.substr(0, - native_substr_len); - - return native_substr == (const std::string&) r_key; + const size_t len = std::min(r_key.length(), r_native_key.length()); + const std::string substr = r_native_key.substr(0, len); + return substr == static_cast(r_key); } }; diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp index b9db4a7..2764e43 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp @@ -41,7 +41,7 @@ /** * @file type_trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp b/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp index 41618a6..994259c 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp @@ -41,7 +41,7 @@ /** * @file erase_if_fn.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp index f287510..34bf706 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp @@ -41,7 +41,7 @@ /** * @file trait.hpp - * Containsert traits for a random regression test + * Contains traits for a random regression test * for a specific container type. */ diff --git a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc b/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc deleted file mode 100644 index a0c7458..0000000 --- a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.cc +++ /dev/null @@ -1,95 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -// 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 twister_rand_gen.cc - */ - -#include -#include -#include - -namespace __gnu_pbds -{ - namespace test - { - twister_rand_gen:: - twister_rand_gen(unsigned int seed) - : m_base_generator(seed) - { - // Do nothing. - } - - void - twister_rand_gen:: - init(unsigned int seed) - { m_base_generator.seed(seed); } - - unsigned long - twister_rand_gen:: - get_unsigned_long(unsigned long min, unsigned long max) - { - _GLIBCXX_DEBUG_ASSERT(max >= min); - const double prob = get_prob(); - const unsigned long rand_word = - (unsigned long)((max - min + 1) * prob) + min; - - _GLIBCXX_DEBUG_ASSERT(rand_word <= max); - return rand_word; - } - - double - twister_rand_gen:: - get_prob() - { - const double eng_min = m_base_generator.min(); - const double eng_range = - static_cast(m_base_generator.max() - eng_min); - - const double eng_res = - static_cast(m_base_generator() - eng_min); - - const double ret = eng_res / eng_range; - _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1); - return ret; - } - } // namespace test -} // namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.hpp b/libstdc++-v3/testsuite/util/testsuite_rng.h similarity index 70% rename from libstdc++-v3/testsuite/util/rng/twister_rand_gen.hpp rename to libstdc++-v3/testsuite/util/testsuite_rng.h index 0088dac..4cc076f 100644 --- a/libstdc++-v3/testsuite/util/rng/twister_rand_gen.hpp +++ b/libstdc++-v3/testsuite/util/testsuite_rng.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -40,14 +40,15 @@ // warranty. /** - * @file twister_rand_gen.hpp + * @file testsuite_rng.h */ -#ifndef PB_DS_TWISTER_RAND_GEN_HPP -#define PB_DS_TWISTER_RAND_GEN_HPP +#ifndef _GLIBCXX_TESTSUITE_RNG_H +#define _GLIBCXX_TESTSUITE_RNG_H #include -#include +#include +#include #include namespace __gnu_pbds @@ -58,10 +59,15 @@ namespace __gnu_pbds { public: twister_rand_gen(unsigned int seed = - static_cast(std::time(0))); + static_cast(std::time(0))) + : m_base_generator(seed) + { + // Do nothing. + } void - init(unsigned int seed); + init(unsigned int seed) + { m_base_generator.seed(seed); } static unsigned int get_time_determined_seed() @@ -69,18 +75,33 @@ namespace __gnu_pbds unsigned long get_unsigned_long(unsigned long min = 0, - unsigned long max = UINT_MAX - 1); + unsigned long max = UINT_MAX - 1) + { + _GLIBCXX_DEBUG_ASSERT(max >= min); + const double prob = get_prob(); + const unsigned long r = (unsigned long)((max - min + 1) * prob) + min; + _GLIBCXX_DEBUG_ASSERT(r <= max); + return r; + } double - get_prob(); + get_prob() + { + const double min = m_base_generator.min(); + const double max = m_base_generator.max(); + const double range = static_cast(max - min); + const double res = static_cast(m_base_generator() - min); + const double ret = res / range; + _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1); + return ret; + } private: typedef std::tr1::mt19937 base_generator_t; - private: base_generator_t m_base_generator; }; } // namespace test } // namespace __gnu_pbds -#endif // #ifndef PB_DS_TWISTER_RAND_GEN_HPP +#endif // #ifndef _GLIBCXX_TESTSUITE_RNG_H