2e3f9c21d5
2008-06-06 Benjamin Kosnik <bkoz@redhat.com> * 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. From-SVN: r136497
108 lines
3.4 KiB
C++
108 lines
3.4 KiB
C++
// -*- 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, 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 testsuite_rng.h
|
|
*/
|
|
|
|
#ifndef _GLIBCXX_TESTSUITE_RNG_H
|
|
#define _GLIBCXX_TESTSUITE_RNG_H
|
|
|
|
#include <ctime>
|
|
#include <climits>
|
|
#include <debug/debug.h>
|
|
#include <tr1/random>
|
|
|
|
namespace __gnu_pbds
|
|
{
|
|
namespace test
|
|
{
|
|
class twister_rand_gen
|
|
{
|
|
public:
|
|
twister_rand_gen(unsigned int seed =
|
|
static_cast<unsigned int>(std::time(0)))
|
|
: m_base_generator(seed)
|
|
{
|
|
// Do nothing.
|
|
}
|
|
|
|
void
|
|
init(unsigned int seed)
|
|
{ m_base_generator.seed(seed); }
|
|
|
|
static unsigned int
|
|
get_time_determined_seed()
|
|
{ return(static_cast<unsigned int>(std::time(0))); }
|
|
|
|
unsigned long
|
|
get_unsigned_long(unsigned long min = 0,
|
|
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()
|
|
{
|
|
const double min = m_base_generator.min();
|
|
const double max = m_base_generator.max();
|
|
const double range = static_cast<const double>(max - min);
|
|
const double res = static_cast<const double>(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;
|
|
|
|
base_generator_t m_base_generator;
|
|
};
|
|
} // namespace test
|
|
} // namespace __gnu_pbds
|
|
|
|
#endif // #ifndef _GLIBCXX_TESTSUITE_RNG_H
|