3 // Copyright (C) 2005-2014 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
23 // Permission to use, copy, modify, sell, and distribute this software
24 // is hereby granted without fee, provided that the above copyright
25 // notice appears in all copies, and that both that copyright notice
26 // and this permission notice appear in supporting documentation. None
27 // of the above authors, nor IBM Haifa Research Laboratories, make any
28 // representation about the suitability of this software for any
29 // purpose. It is provided "as is" without express or implied
33 * @file container_rand_regression_test.tcc
34 * Contains a random regression test for a specific container type.
37 #ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
38 #define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
40 // Constructors/Destructors.
43 container_rand_regression_test(unsigned long seed, size_t n, size_t m,
44 double tp, double ip, double ep, double cp,
46 : m_seed((seed == 0) ? twister_rand_gen::get_time_determined_seed() : seed),
47 m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp), m_mp(mp),
48 m_disp(disp), m_p_c(0)
53 ~container_rand_regression_test()
61 PB_DS_TRACE("default_constructor");
63 m_alloc.set_probability(m_tp);
69 catch(__gnu_cxx::forced_error&)
75 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
85 m_alloc.set_probability(0);
86 Cntnr* p_c = new Cntnr;
87 m_alloc.set_probability(1);
89 std::swap(p_c, m_p_c);
91 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
99 PB_DS_TRACE("copy_constructor");
102 m_alloc.set_probability(m_tp);
103 typename alloc_t::group_adjustor adjust(m_p_c->size());
107 p_c = new Cntnr(*m_p_c);
108 std::swap(p_c, m_p_c);
110 catch(__gnu_cxx::forced_error&)
116 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
123 assignment_operator()
125 PB_DS_TRACE("assignment operator");
128 m_alloc.set_probability(m_tp);
129 typename alloc_t::group_adjustor adjust(m_p_c->size());
135 std::swap(p_c, m_p_c);
137 catch(__gnu_cxx::forced_error&)
143 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
152 PB_DS_TRACE("it_constructor");
153 return it_constructor_imp(typename Cntnr::container_category());
159 it_constructor_imp(__gnu_pbds::cc_hash_tag)
163 m_alloc.set_probability(m_tp);
164 typename alloc_t::group_adjustor adjust(m_p_c->size());
168 switch(get_next_sub_op(8))
171 p_c = new Cntnr(m_p_c->get_hash_fn());
175 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn());
179 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
180 m_p_c->get_comb_hash_fn());
184 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
185 m_p_c->get_comb_hash_fn(),
186 m_p_c->get_resize_policy());
190 p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
193 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn());
196 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
200 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
201 m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn());
204 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
205 m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn(),
206 m_p_c->get_resize_policy());
209 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
211 std::swap(p_c, m_p_c);
213 catch (__gnu_cxx::forced_error&)
219 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
226 it_constructor_imp(__gnu_pbds::gp_hash_tag)
230 m_alloc.set_probability(m_tp);
231 typename alloc_t::group_adjustor adjust(m_p_c->size());
235 switch(get_next_sub_op(11))
238 p_c = new Cntnr(m_p_c->get_hash_fn());
242 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn());
246 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
247 m_p_c->get_comb_probe_fn());
251 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
252 m_p_c->get_comb_probe_fn());
256 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
257 m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn());
261 p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
262 m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn(),
263 m_p_c->get_resize_policy());
267 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn());
270 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
274 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
275 m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn());
278 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
279 m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn());
282 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
283 m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(),
284 m_p_c->get_probe_fn());
287 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
288 m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(),
289 m_p_c->get_probe_fn(), m_p_c->get_resize_policy());
292 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
294 std::swap(p_c, m_p_c);
296 catch (__gnu_cxx::forced_error&)
302 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
309 it_constructor_imp(__gnu_pbds::tree_tag)
313 m_alloc.set_probability(m_tp);
314 typename alloc_t::group_adjustor adjust(m_p_c->size());
318 switch(get_next_sub_op(2))
321 p_c = new Cntnr(m_p_c->get_cmp_fn());
325 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn());
328 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
330 std::swap(p_c, m_p_c);
332 catch (__gnu_cxx::forced_error&)
338 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
345 it_constructor_imp(__gnu_pbds::list_update_tag)
349 m_alloc.set_probability(m_tp);
350 typename alloc_t::group_adjustor adjust(m_p_c->size());
354 p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
355 std::swap(p_c, m_p_c);
357 catch (__gnu_cxx::forced_error&)
363 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
370 it_constructor_imp(__gnu_pbds::pat_trie_tag)
374 m_alloc.set_probability(m_tp);
375 typename alloc_t::group_adjustor adjust(m_p_c->size());
379 switch(get_next_sub_op(2))
382 p_c = new Cntnr(m_p_c->get_access_traits());
386 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(),
387 m_p_c->get_access_traits());
390 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
393 std::swap(p_c, m_p_c);
395 catch (__gnu_cxx::forced_error&)
401 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
409 cmp(const Cntnr& r_c, const native_type& r_native_c,
410 const std::string& r_call_fn)
412 m_alloc.set_probability(1);
413 const size_t size = r_c.size();
414 const size_t native_size = r_native_c.size();
415 PB_DS_THROW_IF_FAILED(size == native_size,
416 size << " " << native_size, &r_c, &r_native_c);
418 const bool empty = r_c.empty();
419 const bool native_empty = r_native_c.empty();
420 PB_DS_THROW_IF_FAILED(empty == native_empty,
421 empty << " " << native_empty, &r_c, &r_native_c);
425 basic_cmp_(r_c, r_native_c);
426 cmp_(r_c, r_native_c);
430 PB_DS_THROW_IF_FAILED(false, "call-fn: " + r_call_fn, &r_c, &r_native_c);
437 basic_cmp_(const Cntnr& r_c, const native_type& r_native_c)
439 PB_DS_SET_DESTRUCT_PRINT
441 if (static_cast<size_t>(std::distance(r_c.begin(), r_c.end())) != r_c.size())
442 PB_DS_THROW_IF_FAILED(false,
443 static_cast<unsigned long>(std::distance(r_c.begin(), r_c.end())) << " " << static_cast<unsigned long>(r_c.size()), &r_c, &r_native_c);
445 typename native_type::const_iterator it = r_native_c.begin();
446 while (it != r_native_c.end())
448 typename native_type::key_type native_key = test_traits::extract_native_key(*it);
450 m_alloc.set_probability(0);
451 const key_type k = native_key;
452 m_alloc.set_probability(1);
453 typename cntnr::point_const_iterator found_it = r_c.find(k);
454 PB_DS_THROW_IF_FAILED(found_it != r_c.end(),
455 test_traits::native_val_to_string(*it),
458 if (!test_traits::cmp(*found_it, * it))
459 PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c);
463 PB_DS_CANCEL_DESTRUCT_PRINT
469 cmp_(const Cntnr& r_c, const native_type& r_native_c)
473 order_preserving = container_traits::order_preserving,
474 back_order_preserving = container_traits::order_preserving
476 !__gnu_pbds::detail::is_same<
477 typename std::iterator_traits<
478 typename cntnr::const_iterator>::iterator_category,
479 std::forward_iterator_tag>::value,
480 reverse_iteration = container_traits::reverse_iteration,
481 order_statistics = test_traits::order_statistics,
482 prefix_search = test_traits::prefix_search,
483 has_mapped = !__gnu_pbds::detail::is_same<
484 typename Cntnr::mapped_type,
485 __gnu_pbds::null_type>::value
488 order_preserving_cmp_imp(r_c, r_native_c,
489 __gnu_pbds::detail::integral_constant<int,order_preserving>());
491 back_order_preserving_cmp_imp(r_c, r_native_c,
492 __gnu_pbds::detail::integral_constant<int,back_order_preserving>());
494 order_statistics_cmp_imp(r_c, r_native_c,
495 __gnu_pbds::detail::integral_constant<int,order_statistics>());
497 prefix_search_cmp_imp(r_c, r_native_c,
498 __gnu_pbds::detail::integral_constant<int,prefix_search>());
500 reverse_iteration_cmp_imp(r_c, r_native_c,
501 __gnu_pbds::detail::integral_constant<int,reverse_iteration>());
503 lower_bound_cmp_imp(r_c, r_native_c,
504 __gnu_pbds::detail::integral_constant<int,order_preserving>());
506 upper_bound_cmp_imp(r_c, r_native_c,
507 __gnu_pbds::detail::integral_constant<int,order_preserving>());
513 order_preserving_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
519 order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
521 PB_DS_SET_DESTRUCT_PRINT
523 typename cntnr::const_iterator b = r_c.begin();
524 typename cntnr::const_iterator e = r_c.end();
526 typename native_type::const_iterator native_b = r_native_c.begin();
527 typename native_type::const_iterator native_e = r_native_c.end();
531 it_cmp_imp(b, e, native_b, native_e);
535 PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
540 back_it_cmp_imp(b, e, native_b, native_e);
544 PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
547 PB_DS_CANCEL_DESTRUCT_PRINT
553 back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
554 __gnu_pbds::detail::false_type)
560 back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c,
561 __gnu_pbds::detail::true_type)
563 PB_DS_SET_DESTRUCT_PRINT
564 typename cntnr::const_iterator b = r_c.begin();
565 typename cntnr::const_iterator e = r_c.end();
566 typename native_type::const_iterator native_b = r_native_c.begin();
567 typename native_type::const_iterator native_e = r_native_c.end();
568 it_cmp_imp(b, e, native_b, native_e);
569 PB_DS_CANCEL_DESTRUCT_PRINT
575 reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
576 __gnu_pbds::detail::false_type)
582 reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type&r_native_c, __gnu_pbds::detail::true_type)
584 PB_DS_SET_DESTRUCT_PRINT
586 typename cntnr::const_reverse_iterator b = r_c.rbegin();
587 typename cntnr::const_reverse_iterator e = r_c.rend();
589 typename native_type::const_reverse_iterator native_b = r_native_c.rbegin();
590 typename native_type::const_reverse_iterator native_e = r_native_c.rend();
594 it_cmp_imp(b, e, native_b, native_e);
598 PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
603 back_it_cmp_imp(b, e, native_b, native_e);
607 PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
610 PB_DS_CANCEL_DESTRUCT_PRINT
616 order_statistics_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
622 order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
625 m_alloc.set_probability(0);
626 const key_type k = test_traits::generate_key(m_g, m_m);
627 m_alloc.set_probability(1);
628 const size_type order = r_c.order_of_key(k);
629 const size_type native_order = std::distance(r_native_c.begin(),
630 r_native_c.lower_bound(test_traits::native_key(k)));
632 PB_DS_THROW_IF_FAILED(order == native_order,
633 test_traits::key_to_string(k) << " " <<
634 static_cast<unsigned long>(order) << " " <<
635 static_cast<unsigned long>(native_order),
640 const size_type rand_ord =
641 static_cast<size_t>(m_g.get_unsigned_long(0,
642 2 * static_cast<unsigned long>(m_m)));
644 typename cntnr::const_iterator it = r_c.find_by_order(rand_ord);
645 typename native_type::const_iterator native_it = r_native_c.begin();
646 std::advance(native_it, std::min(rand_ord, r_native_c.size()));
647 if (it == r_c.end()&& native_it != r_native_c.end())
648 PB_DS_THROW_IF_FAILED(false,
649 static_cast<unsigned long>(rand_ord),
653 if (it != r_c.end()&& native_it == r_native_c.end())
654 PB_DS_THROW_IF_FAILED(false,
655 static_cast<unsigned long>(rand_ord),
659 if (it != r_c.end()&& native_it != r_native_c.end())
660 PB_DS_THROW_IF_FAILED(test_traits::cmp(*it, * native_it),
661 static_cast<unsigned long>(rand_ord),
669 prefix_search_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
675 prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
677 PB_DS_SET_DESTRUCT_PRINT
678 m_alloc.set_probability(0);
679 const key_type k = test_traits::generate_key(m_g, m_m);
680 m_alloc.set_probability(1);
684 std::pair<typename Cntnr::const_iterator, typename Cntnr::const_iterator>
687 const pref_ret_t pref_ret = r_c.prefix_range(k);
689 typename native_type::const_iterator native_start_it = r_native_c.begin();
691 while (native_start_it != r_native_c.end() &&
692 !test_traits::prefix_match(k,
693 test_traits::extract_native_key(*native_start_it)))
696 typename native_type::const_iterator native_end_it =
701 if (native_end_it != r_native_c.end())
704 while (native_end_it != r_native_c.end() &&
705 test_traits::prefix_match(k,
706 test_traits::extract_native_key(*native_end_it)));
708 it_cmp_imp(pref_ret.first, pref_ret.second, native_start_it, native_end_it);
712 PB_DS_THROW_IF_FAILED(false, "prefix key " << k, &r_c, &r_native_c);
715 PB_DS_CANCEL_DESTRUCT_PRINT
719 template<typename Const_It, class Const_Native_It>
722 it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b,
723 Const_Native_It native_e)
725 PB_DS_SET_DESTRUCT_PRINT
727 if (std::distance(b, e) != std::distance(native_b, native_e))
729 const size_t dist = std::distance(b, e);
730 const size_t native_dist = std::distance(native_b, native_e);
731 PB_DS_THROW_IF_FAILED(false,
732 static_cast<unsigned long>(dist) << " "
733 << static_cast<unsigned long>(native_dist),
739 PB_DS_THROW_IF_FAILED(native_b != native_e, "", m_p_c, &m_native_c);
741 if (!test_traits::cmp(*b, * native_b))
742 PB_DS_THROW_IF_FAILED(false,
743 test_traits::val_to_string(*b) << " " <<
744 test_traits::val_to_string(*native_b),
751 PB_DS_THROW_IF_FAILED(native_b == native_e, "", m_p_c, &m_native_c);
752 PB_DS_CANCEL_DESTRUCT_PRINT
756 template<typename Const_It, class Const_Native_It>
759 back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b,
760 Const_Native_It native_e)
762 PB_DS_SET_DESTRUCT_PRINT
765 PB_DS_THROW_IF_FAILED(native_b != native_e,
766 test_traits::val_to_string(*native_e),
772 PB_DS_THROW_IF_FAILED(test_traits::cmp(*e, * native_e),
773 test_traits::val_to_string(*e) <<
774 test_traits::val_to_string(*native_e),
778 PB_DS_THROW_IF_FAILED(native_b == native_e,
779 test_traits::val_to_string(*native_e),
782 PB_DS_CANCEL_DESTRUCT_PRINT
788 lower_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
794 lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
796 PB_DS_SET_DESTRUCT_PRINT
797 m_alloc.set_probability(0);
798 const key_type k = test_traits::generate_key(m_g, m_m);
799 m_alloc.set_probability(1);
800 typename cntnr::const_iterator it = r_c.lower_bound(k);
801 typename native_type::key_type native_k = test_traits::native_key(k);
802 typename native_type::const_iterator native_it = r_native_c.lower_bound(native_k);
804 if (it != r_c.end() && native_it == r_native_c.end())
805 PB_DS_THROW_IF_FAILED("",
806 "it: " + test_traits::val_to_string(*it) + "\n\n",
809 if (it == r_c.end() && native_it != r_native_c.end())
810 PB_DS_THROW_IF_FAILED("",
811 "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
814 if (it != r_c.end() && !test_traits::cmp(*it, * native_it))
815 PB_DS_THROW_IF_FAILED(false,
816 "key: " + test_traits::key_to_string(k) + "\n\n" +
817 "it: " + test_traits::val_to_string(*it) + "\n\n" +
818 "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
821 PB_DS_CANCEL_DESTRUCT_PRINT
827 upper_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
833 upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
835 PB_DS_SET_DESTRUCT_PRINT
836 m_alloc.set_probability(0);
837 const key_type k = test_traits::generate_key(m_g, m_m);
838 m_alloc.set_probability(1);
839 typename cntnr::const_iterator it = r_c.upper_bound(k);
840 typename native_type::key_type native_k = test_traits::native_key(k);
841 typename native_type::const_iterator native_it = r_native_c.upper_bound(native_k);
843 if (it == r_c.end() && native_it != r_native_c.end())
844 PB_DS_THROW_IF_FAILED(false,
845 "key: " + test_traits::key_to_string(k) + "\n\n" +
846 "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
849 if (it != r_c.end() && native_it == r_native_c.end())
850 PB_DS_THROW_IF_FAILED(false,
851 "key: " + test_traits::key_to_string(k) + "\n\n" +
852 "it: " + test_traits::val_to_string(*it) + "\n\n",
855 if (it != r_c.end() && !test_traits::cmp(*it, * native_it))
856 PB_DS_THROW_IF_FAILED(false,
857 "key: " + test_traits::key_to_string(k) + "\n\n" +
858 "it: " + test_traits::val_to_string(*it) + "\n\n" +
859 "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
862 PB_DS_CANCEL_DESTRUCT_PRINT
871 typedef xml_result_set_regression_formatter formatter_type;
872 formatter_type* p_fmt = 0;
875 p_fmt = new formatter_type(string_form<Cntnr>::name(),
876 string_form<Cntnr>::desc());
880 // Track allocation from this point only.
881 const size_t memory_label = 775;
882 m_alloc.seed(m_seed);
883 m_alloc.set_label(memory_label);
885 prog_bar pb(m_n, std::cout, m_disp);
890 for (m_i = 0; m_i < m_n; ++m_i)
892 PB_DS_TRACE("Op #" << static_cast<unsigned long>(m_i));
893 allocator_type::set_label(m_i);
897 PB_DS_RUN_MTHD(default_constructor);
918 switch(get_next_op())
921 switch(get_next_sub_op(2))
924 PB_DS_RUN_MTHD(insert)
927 PB_DS_RUN_MTHD(subscript)
930 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
934 switch(get_next_sub_op(4))
937 PB_DS_RUN_MTHD(erase)
940 PB_DS_RUN_MTHD(erase_if)
943 PB_DS_RUN_MTHD(erase_it)
946 PB_DS_RUN_MTHD(erase_rev_it)
949 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
953 PB_DS_RUN_MTHD(clear)
956 switch(get_next_sub_op(8))
962 PB_DS_RUN_MTHD(copy_constructor)
965 PB_DS_RUN_MTHD(it_constructor)
968 PB_DS_RUN_MTHD(assignment_operator)
971 PB_DS_RUN_MTHD(split_join)
983 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
987 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
996 std::cerr << "Failed at index " << static_cast<unsigned long>(m_i)
1002 // Clean up, then check for allocation by special label, set above.
1006 { m_alloc.check(memory_label); }
1009 std::cerr << "detected leaks!" << std::endl;
1010 std::cerr << m_alloc << std::endl;
1011 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
1014 // Reset throw probability.
1015 m_alloc.set_probability(0);
1019 std::cout << std::endl;
1025 typename PB_DS_CLASS_C_DEC::op
1029 const double prob = m_g.get_prob();
1033 if (prob < m_ip + m_ep)
1036 if (prob < m_ip + m_ep + m_cp)
1039 PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c);
1046 get_next_sub_op(size_t max)
1048 const double p = m_g.get_prob();
1049 const double delta = 1 / static_cast<double>(max);
1052 if (p <= (i + 1) * delta)
1054 PB_DS_THROW_IF_FAILED(i < max, i << " " << max, m_p_c, &m_native_c);
1067 PB_DS_TRACE("insert");
1069 PB_DS_SET_DESTRUCT_PRINT
1072 m_alloc.set_probability(0);
1073 value_type v = test_traits::generate_value(m_g, m_m);
1074 m_alloc.set_probability(m_tp);
1075 key_const_reference r_k = test_traits::extract_key(v);
1076 typename cntnr::point_const_iterator found_it = m_p_c->find(r_k);
1077 const bool existed = (found_it != m_p_c->end());
1078 const std::pair<typename cntnr::point_iterator, bool> ins_ret = m_p_c->insert(v);
1082 PB_DS_THROW_IF_FAILED(!existed, "", m_p_c, &m_native_c);
1086 PB_DS_THROW_IF_FAILED(existed, "", m_p_c, &m_native_c);
1087 PB_DS_THROW_IF_FAILED(found_it == ins_ret.first, "", m_p_c, &m_native_c);
1089 m_native_c.insert(test_traits::native_value(v));
1091 catch(__gnu_cxx::forced_error&)
1095 catch(__gnu_pbds::insert_error&)
1097 PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
1100 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1101 PB_DS_CANCEL_DESTRUCT_PRINT
1111 PB_DS_TRACE("subscript");
1115 no_data = __gnu_pbds::detail::is_same<
1116 typename Cntnr::key_const_reference,
1117 typename Cntnr::const_reference>::value
1120 return (subscript_imp(__gnu_pbds::detail::integral_constant<int,no_data>()));
1126 subscript_imp(__gnu_pbds::detail::false_type)
1129 PB_DS_SET_DESTRUCT_PRINT
1133 m_alloc.set_probability(0);
1134 value_type v = test_traits::generate_value(m_g, m_m);
1136 m_alloc.set_probability(m_tp);
1137 (*m_p_c)[v.first] = v.second;
1139 m_native_c[test_traits::native_value(v).first] =
1140 test_traits::native_value(v).second;
1142 catch(__gnu_cxx::forced_error&)
1147 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1148 PB_DS_CANCEL_DESTRUCT_PRINT
1155 subscript_imp(__gnu_pbds::detail::true_type)
1158 PB_DS_SET_DESTRUCT_PRINT
1161 m_alloc.set_probability(0);
1162 value_type v = test_traits::generate_value(m_g, m_m);
1163 m_alloc.set_probability(m_tp);
1164 (*m_p_c)[v] = __gnu_pbds::null_type();
1165 m_native_c.insert(test_traits::native_value(v));
1167 catch(__gnu_cxx::forced_error&)
1172 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1173 PB_DS_CANCEL_DESTRUCT_PRINT
1195 PB_DS_TRACE("erase");
1197 PB_DS_SET_DESTRUCT_PRINT
1198 m_alloc.set_probability(0);
1199 const key_type k = test_traits::generate_key(m_g, m_m);
1200 m_alloc.set_probability(m_tp);
1204 const bool cntnd = m_p_c->find(k) != m_p_c->end();
1205 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);
1207 const bool ersd = m_p_c->erase(k);
1208 const bool native_ersd = m_native_c.erase(test_traits::native_key(k)) != 0;
1210 PB_DS_THROW_IF_FAILED(ersd == native_ersd, ersd << " " << native_ersd,
1211 m_p_c, &m_native_c);
1213 PB_DS_THROW_IF_FAILED(m_p_c->find(k) == m_p_c->end(), "",
1214 m_p_c, &m_native_c);
1216 catch(__gnu_cxx::forced_error&)
1220 PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c);
1223 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1224 PB_DS_CANCEL_DESTRUCT_PRINT
1233 PB_DS_TRACE("erase_if");
1235 PB_DS_SET_DESTRUCT_PRINT
1240 typename std::iterator_traits<typename cntnr::iterator>::reference
1244 typename test_traits::template erase_if_fn<value_type>
1247 m_alloc.set_probability(m_tp);
1249 const size_t ersd = m_p_c->erase_if(erase_if_fn_t());
1250 const size_t native_ersd = test_traits::erase_if(m_native_c);
1251 PB_DS_THROW_IF_FAILED(ersd == native_ersd,
1252 ersd << " " << native_ersd, m_p_c, &m_native_c);
1254 catch(__gnu_cxx::forced_error&)
1257 PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw,
1258 container_traits::erase_can_throw,
1259 m_p_c, &m_native_c);
1262 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1263 PB_DS_CANCEL_DESTRUCT_PRINT
1274 erase_iterators = container_traits::order_preserving
1277 return (erase_it_imp(__gnu_pbds::detail::integral_constant<int,erase_iterators>()));
1283 erase_it_imp(__gnu_pbds::detail::false_type)
1291 erase_it_imp(__gnu_pbds::detail::true_type)
1293 PB_DS_TRACE("erase_it");
1295 PB_DS_SET_DESTRUCT_PRINT
1299 m_alloc.set_probability(0);
1300 const key_type k = test_traits::generate_key(m_g, m_m);
1301 m_alloc.set_probability(m_tp);
1303 typename cntnr::iterator found_it = m_p_c->find(k);
1305 typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k));
1307 const bool found = found_it != m_p_c->end();
1308 const bool native_found = native_it != m_native_c.end();
1310 PB_DS_THROW_IF_FAILED(
1311 found == native_found,
1312 found << " " << native_found,
1316 typename cntnr::const_iterator next_it = found_it;
1317 if (next_it != m_p_c->end())
1320 typename cntnr::iterator next_ers_it = m_p_c->erase(found_it);
1322 if (native_it != m_native_c.end())
1323 m_native_c.erase(native_it);
1325 bool range_guarantee = __gnu_pbds::detail::is_same<
1326 typename container_traits::invalidation_guarantee,
1327 __gnu_pbds::range_invalidation_guarantee>::value ;
1329 if (range_guarantee)
1330 PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c);
1332 catch(__gnu_cxx::forced_error&)
1335 PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c);
1338 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1339 PB_DS_CANCEL_DESTRUCT_PRINT
1350 erase_iterators = container_traits::order_preserving
1351 && container_traits::reverse_iteration
1354 return (erase_rev_it_imp(__gnu_pbds::detail::integral_constant<int,erase_iterators>()));
1360 erase_rev_it_imp(__gnu_pbds::detail::false_type)
1368 erase_rev_it_imp(__gnu_pbds::detail::true_type)
1370 PB_DS_TRACE("erase_rev_it");
1372 PB_DS_SET_DESTRUCT_PRINT
1376 m_alloc.set_probability(0);
1377 const key_type k = test_traits::generate_key(m_g, m_m);
1378 m_alloc.set_probability(m_tp);
1380 typename cntnr::iterator found_it = m_p_c->find(k);
1381 typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k));
1383 typename cntnr::const_reverse_iterator next_it = found_it;
1384 if (next_it != m_p_c->end())
1387 typename cntnr::reverse_iterator next_ers_it =
1388 m_p_c->erase((typename cntnr::reverse_iterator)found_it);
1390 PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c);
1392 if (native_it != m_native_c.end())
1393 m_native_c.erase(native_it);
1395 catch(__gnu_cxx::forced_error&)
1398 PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw,
1399 container_traits::erase_can_throw,
1400 m_p_c, &m_native_c);
1403 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1404 PB_DS_CANCEL_DESTRUCT_PRINT
1414 // General container types.
1415 typedef typename Cntnr::size_type test_size_type;
1416 typedef typename Cntnr::difference_type difference_type;
1422 node_iterator_defs(__gnu_pbds::detail::integral_constant<int,
1423 container_traits::order_preserving>());
1432 typedef typename Cntnr::key_type test_key_type;
1433 typedef typename Cntnr::key_reference test_key_reference;
1434 typedef typename Cntnr::key_const_reference test_key_const_reference;
1435 typedef typename Cntnr::key_pointer test_key_pointer;
1436 typedef typename Cntnr::key_const_pointer test_key_const_pointer;
1444 typedef typename Cntnr::mapped_type test_mapped_type;
1445 typedef typename Cntnr::mapped_reference test_mapped_reference;
1446 typedef typename Cntnr::mapped_const_reference test_mapped_const_reference;
1447 typedef typename Cntnr::mapped_pointer test_mapped_pointer;
1448 typedef typename Cntnr::mapped_const_pointer test_mapped_const_pointer;
1456 typedef typename Cntnr::value_type test_value_type;
1457 typedef typename Cntnr::reference test_reference;
1458 typedef typename Cntnr::const_reference test_const_reference;
1459 typedef typename Cntnr::pointer test_pointer;
1460 typedef typename Cntnr::const_pointer test_const_pointer;
1468 typedef __gnu_pbds::container_traits< Cntnr> test_container_traits;
1470 typedef typename test_container_traits::container_category test_container_category;
1473 typename test_container_traits::invalidation_guarantee
1474 test_invalidation_guarantee;
1478 test_order_preserving = test_container_traits::order_preserving
1483 test_erase_can_throw = test_container_traits::erase_can_throw
1492 typedef typename Cntnr::point_iterator test_point_iterator;
1493 typedef typename Cntnr::point_const_iterator const_test_point_iterator;
1494 typedef typename Cntnr::iterator test_iterator;
1495 typedef typename Cntnr::const_iterator const_test_iterator;
1501 node_iterator_defs(__gnu_pbds::detail::false_type)
1507 node_iterator_defs(__gnu_pbds::detail::true_type)
1509 typedef typename Cntnr::node_iterator test_node_iterator;
1510 typedef typename Cntnr::node_const_iterator test_node_const_iterator;
1518 typedef typename Cntnr::allocator_type test_allocator;
1519 policy_defs(typename Cntnr::container_category());
1525 policy_defs(__gnu_pbds::basic_hash_tag)
1527 typedef typename Cntnr::hash_fn test_hash_fn;
1528 typedef typename Cntnr::eq_fn test_eq_fn;
1529 typedef typename Cntnr::resize_policy test_resize_policy;
1535 policy_defs(__gnu_pbds::cc_hash_tag)
1537 policy_defs(__gnu_pbds::basic_hash_tag());
1538 typedef typename Cntnr::comb_hash_fn test_comb_hash_fn;
1544 policy_defs(__gnu_pbds::gp_hash_tag)
1546 policy_defs(__gnu_pbds::basic_hash_tag());
1547 typedef typename Cntnr::comb_probe_fn test_comb_probe_fn;
1548 typedef typename Cntnr::probe_fn test_probe_fn;
1554 policy_defs(__gnu_pbds::tree_tag)
1556 typedef typename Cntnr::cmp_fn test_cmp_fn;
1557 typedef typename Cntnr::node_update test_node_update;
1563 policy_defs(__gnu_pbds::list_update_tag)
1565 typedef typename Cntnr::eq_fn test_eq_fn;
1566 typedef typename Cntnr::update_policy test_update_policy;
1572 policy_defs(__gnu_pbds::pat_trie_tag)
1574 typedef typename Cntnr::access_traits access_traits;
1584 policy_access(typename Cntnr::container_category());
1590 policy_access(__gnu_pbds::basic_hash_tag)
1593 typename Cntnr::hash_fn& r_t = m_p_c->get_hash_fn();
1597 const typename Cntnr::hash_fn& r_t =((const Cntnr& )*m_p_c).get_hash_fn();
1602 typename Cntnr::eq_fn& r_t = m_p_c->get_eq_fn();
1606 const typename Cntnr::eq_fn& r_t =((const Cntnr& )*m_p_c).get_eq_fn();
1611 typename Cntnr::resize_policy& r_t = m_p_c->get_resize_policy();
1615 const typename Cntnr::resize_policy& r_t =((const Cntnr& )*m_p_c).get_resize_policy();
1624 policy_access(__gnu_pbds::cc_hash_tag)
1626 policy_access(__gnu_pbds::basic_hash_tag());
1629 typename Cntnr::comb_hash_fn& r_t = m_p_c->get_comb_hash_fn();
1633 const typename Cntnr::comb_hash_fn& r_t =((const Cntnr& )*m_p_c).get_comb_hash_fn();
1642 policy_access(__gnu_pbds::gp_hash_tag)
1644 policy_access(__gnu_pbds::basic_hash_tag());
1647 typename Cntnr::comb_probe_fn& r_t = m_p_c->get_comb_probe_fn();
1651 const typename Cntnr::comb_probe_fn& r_t =((const Cntnr& )*m_p_c).get_comb_probe_fn();
1657 typename Cntnr::probe_fn& r_t = m_p_c->get_probe_fn();
1661 const typename Cntnr::probe_fn& r_t =((const Cntnr& )*m_p_c).get_probe_fn();
1669 policy_access(__gnu_pbds::tree_tag)
1672 typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn();
1677 const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn();
1685 policy_access(__gnu_pbds::list_update_tag)
1691 policy_access(__gnu_pbds::pat_trie_tag)
1693 typename Cntnr::access_traits& r_t = m_p_c->get_access_traits();
1706 split_join = container_traits::order_preserving
1709 typedef __gnu_pbds::detail::integral_constant<int, split_join> __true_type;
1710 return split_join_imp(__true_type());
1716 split_join_imp(__gnu_pbds::detail::false_type)
1724 split_join_imp(__gnu_pbds::detail::true_type)
1726 PB_DS_TRACE("split_join");
1728 PB_DS_SET_DESTRUCT_PRINT
1732 m_alloc.set_probability(0);
1735 native_type native_lhs(m_native_c);
1736 native_type native_rhs;
1737 const key_type k = test_traits::generate_key(m_g, m_m);
1739 m_alloc.set_probability(m_tp);
1742 typename native_type::const_iterator it =
1743 native_lhs.upper_bound(test_traits::native_key(k));
1745 while (!native_lhs.empty()&& it != native_lhs.end())
1747 native_rhs.insert(*it);
1748 typename native_type::const_iterator next_it = it;
1750 native_lhs.erase(test_traits::extract_native_key(*it));
1754 PB_DS_COND_COMPARE(lhs, native_lhs);
1755 PB_DS_COND_COMPARE(rhs, native_rhs);
1757 m_alloc.set_probability(m_tp);
1759 if (m_g.get_prob() < 0.5)
1763 PB_DS_THROW_IF_FAILED(rhs.size() == 0, rhs.size(), m_p_c, &m_native_c);
1764 PB_DS_THROW_IF_FAILED(rhs.empty(), rhs.size(), m_p_c, &m_native_c);
1767 catch(__gnu_cxx::forced_error&)
1770 PB_DS_THROW_IF_FAILED(container_traits::split_join_can_throw,
1771 container_traits::split_join_can_throw,
1772 m_p_c, &m_native_c);
1775 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1776 PB_DS_CANCEL_DESTRUCT_PRINT
1780 // Iterator conversions.
1787 typename cntnr::iterator it = m_p_c->end();
1788 typename cntnr::const_iterator const_it(it);
1789 PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
1790 PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
1792 typename cntnr::point_const_iterator const_find_it(it);
1793 PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
1794 PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
1796 typename cntnr::point_iterator find_it(it);
1797 PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
1798 PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
1802 typename cntnr::const_iterator const_it = m_p_c->end();
1803 typename cntnr::point_const_iterator const_find_it(const_it);
1804 PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
1805 PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
1809 typename cntnr::point_iterator find_it = m_p_c->end();
1810 typename cntnr::point_const_iterator const_find_it(find_it);
1811 PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
1812 PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
1822 typename cntnr::iterator it = m_p_c->end();
1823 typename cntnr::const_iterator const_it;
1825 PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
1826 PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
1828 typename cntnr::point_const_iterator const_find_it;
1830 PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
1831 PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
1833 typename cntnr::point_iterator find_it;
1835 PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
1836 PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
1840 typename cntnr::const_iterator const_it = m_p_c->end();
1841 typename cntnr::point_const_iterator const_find_it;
1842 const_find_it = const_it;
1843 PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
1844 PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
1848 typename cntnr::point_iterator find_it = m_p_c->end();
1849 typename cntnr::point_const_iterator const_find_it;
1850 const_find_it = find_it;
1851 PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
1852 PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
1863 reverse_iteration = container_traits::reverse_iteration
1866 rev_it_copy_imp(__gnu_pbds::detail::integral_constant<int,reverse_iteration>());
1876 reverse_iteration = container_traits::reverse_iteration
1879 rev_it_assign_imp(__gnu_pbds::detail::integral_constant<int,reverse_iteration>());
1885 rev_it_copy_imp(__gnu_pbds::detail::false_type)
1891 rev_it_copy_imp(__gnu_pbds::detail::true_type)
1894 typename cntnr::iterator it = m_p_c->end();
1895 typename cntnr::const_reverse_iterator const_it(it);
1896 PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
1897 PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
1899 typename cntnr::point_const_iterator const_find_it(it);
1900 PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
1901 PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
1903 typename cntnr::point_iterator find_it(it);
1904 PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
1905 PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
1912 rev_it_assign_imp(__gnu_pbds::detail::false_type)
1918 rev_it_assign_imp(__gnu_pbds::detail::true_type)
1921 typename cntnr::iterator it = m_p_c->end();
1922 typename cntnr::const_reverse_iterator const_it;
1924 PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
1925 PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
1927 typename cntnr::point_const_iterator const_find_it;
1929 PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
1930 PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
1932 typename cntnr::point_iterator find_it;
1934 PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
1935 PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
1945 typedef __gnu_pbds::detail::integral_constant<int, test_traits::resize> resize_ind;
1947 return resize_imp(resize_ind());
1953 resize_imp(__gnu_pbds::detail::false_type)
1961 resize_imp(__gnu_pbds::detail::true_type)
1963 PB_DS_TRACE("resize");
1965 PB_DS_SET_DESTRUCT_PRINT
1966 const size_t old_size = m_p_c->get_actual_size();
1976 m_alloc.set_probability(m_tp);
1977 typename alloc_t::group_adjustor adjust(m_p_c->size());
1978 const size_t new_size = m_g.get_unsigned_long(min_new_size, max_new_size);
1979 m_p_c->resize(new_size);
1980 const size_t actual_new_size = m_p_c->get_actual_size();
1981 PB_DS_THROW_IF_FAILED(actual_new_size >= new_size,
1982 actual_new_size << " " << new_size,
1983 m_p_c, &m_native_c);
1987 PB_DS_THROW_IF_FAILED(m_p_c->get_actual_size() == old_size,
1988 m_p_c->get_actual_size() << " " << old_size,
1989 m_p_c, &m_native_c);
1994 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
1995 PB_DS_CANCEL_DESTRUCT_PRINT
2007 __gnu_pbds::detail::integral_constant<int, test_traits::get_set_load>
2010 get_set_load_imp(get_set_load_ind());
2016 get_set_load_imp(__gnu_pbds::detail::false_type)
2022 get_set_load_imp(__gnu_pbds::detail::true_type)
2024 PB_DS_TRACE("get_set_load");
2025 PB_DS_SET_DESTRUCT_PRINT
2027 m_alloc.set_probability(1);
2028 typename alloc_t::group_adjustor adjust(m_p_c->size());
2029 const float min_load = static_cast<float>(0.05);
2030 const float max_load = static_cast<float>(0.9);
2032 const float new_load = static_cast<float>(m_g.get_prob() * (max_load - min_load) + min_load);
2034 m_p_c->set_load(new_load);
2035 PB_DS_THROW_IF_FAILED(m_p_c->get_load() == new_load, "", m_p_c, &m_native_c);
2036 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
2037 PB_DS_CANCEL_DESTRUCT_PRINT
2048 __gnu_pbds::detail::integral_constant<int, test_traits::get_set_loads>
2051 return get_set_loads_imp(get_set_loads_ind());
2057 get_set_loads_imp(__gnu_pbds::detail::false_type)
2065 get_set_loads_imp(__gnu_pbds::detail::true_type)
2067 PB_DS_TRACE("get_set_loads");
2069 PB_DS_SET_DESTRUCT_PRINT
2070 const std::pair<float, float> old_loads = m_p_c->get_loads();
2074 m_alloc.set_probability(m_tp);
2076 typename alloc_t::group_adjustor adjust(m_p_c->size());
2078 const float min_min_load = static_cast<float>(0.05);
2079 const float max_min_load = static_cast<float>(0.2);
2081 const float new_min_load =
2082 static_cast<float>(m_g.get_prob()* (max_min_load - min_min_load) +
2085 const float new_max_load = static_cast<float>(new_min_load* 2.5);
2086 PB_DS_THROW_IF_FAILED(new_max_load < 1, new_max_load, m_p_c, &m_native_c);
2087 m_p_c->set_loads(std::make_pair(new_min_load, new_max_load));
2091 PB_DS_THROW_IF_FAILED(old_loads == m_p_c->get_loads(),
2092 old_loads.first << " " << old_loads.second << " " <<
2093 m_p_c->get_loads().first << " " <<
2094 m_p_c->get_loads().second,
2095 m_p_c, &m_native_c);
2100 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
2101 PB_DS_CANCEL_DESTRUCT_PRINT
2109 print_container(const native_type& r_cnt, std::ostream& r_os) const
2111 m_alloc.set_probability(0);
2112 typename native_type::const_iterator it = r_cnt.begin();
2113 while (it != r_cnt.end())
2115 r_os << test_traits::val_to_string(*it) + "\n";
2123 print_container(const cntnr& r_cnt, std::ostream& r_os) const
2125 m_alloc.set_probability(0);
2126 typename cntnr::const_iterator it = r_cnt.begin();
2127 while (it != r_cnt.end())
2129 r_os << test_traits::val_to_string(*it) + "\n";