Commit 5580c6e7 by Benjamin Kosnik Committed by Benjamin Kosnik

throw_allocator.h: Rework.

2009-06-04  Benjamin Kosnik  <bkoz@redhat.com>

	* include/ext/throw_allocator.h: Rework.
	* include/ext/pb_ds/detail/debug_map_base.hpp: Adjust usage.
	* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
	* testsuite/23_containers/list/modifiers/insert/25288.cc: Same.
	* testsuite/util/regression/rand/priority_queue/
	container_rand_regression_test.tcc: Inline functions.
	* testsuite/util/regression/rand/assoc/
	container_rand_regression_test.tcc: Same.

From-SVN: r148204
parent 2771246a
2009-06-04 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/throw_allocator.h: Rework.
* include/ext/pb_ds/detail/debug_map_base.hpp: Adjust usage.
* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Same.
* testsuite/23_containers/list/modifiers/insert/25288.cc: Same.
* testsuite/util/regression/rand/priority_queue/
container_rand_regression_test.tcc: Inline functions.
* testsuite/util/regression/rand/assoc/
container_rand_regression_test.tcc: Same.
2009-06-03 Benjamin Kosnik <bkoz@redhat.com> 2009-06-03 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/23_containers/list/cons/6.cc: Adjust test name. * testsuite/23_containers/list/cons/6.cc: Adjust test name.
......
...@@ -154,8 +154,8 @@ namespace __gnu_pbds ...@@ -154,8 +154,8 @@ namespace __gnu_pbds
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
__gnu_cxx::throw_allocator<char> alloc; __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob(); const double orig_throw_prob = alloc.get_probability();
alloc.set_throw_prob(0); alloc.set_probability(0);
if (find(r_key) != m_key_set.end()) if (find(r_key) != m_key_set.end())
{ {
std::cerr << "insert_new" << r_key << std::endl; std::cerr << "insert_new" << r_key << std::endl;
...@@ -171,7 +171,7 @@ namespace __gnu_pbds ...@@ -171,7 +171,7 @@ namespace __gnu_pbds
std::cerr << "insert_new" << r_key << std::endl; std::cerr << "insert_new" << r_key << std::endl;
std::abort(); std::abort();
} }
alloc.set_throw_prob(orig_throw_prob); alloc.set_probability(orig_throw_prob);
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
...@@ -315,8 +315,8 @@ namespace __gnu_pbds ...@@ -315,8 +315,8 @@ namespace __gnu_pbds
split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other) split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
{ {
__gnu_cxx::throw_allocator<char> alloc; __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob(); const double orig_throw_prob = alloc.get_probability();
alloc.set_throw_prob(0); alloc.set_probability(0);
other.clear(); other.clear();
key_set_iterator it = m_key_set.begin(); key_set_iterator it = m_key_set.begin();
while (it != m_key_set.end()) while (it != m_key_set.end())
...@@ -327,7 +327,7 @@ namespace __gnu_pbds ...@@ -327,7 +327,7 @@ namespace __gnu_pbds
} }
else else
++it; ++it;
alloc.set_throw_prob(orig_throw_prob); alloc.set_probability(orig_throw_prob);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -336,8 +336,8 @@ namespace __gnu_pbds ...@@ -336,8 +336,8 @@ namespace __gnu_pbds
join(PB_DS_CLASS_C_DEC& other) join(PB_DS_CLASS_C_DEC& other)
{ {
__gnu_cxx::throw_allocator<char> alloc; __gnu_cxx::throw_allocator<char> alloc;
const double orig_throw_prob = alloc.get_throw_prob(); const double orig_throw_prob = alloc.get_probability();
alloc.set_throw_prob(0); alloc.set_probability(0);
key_set_iterator it = other.m_key_set.begin(); key_set_iterator it = other.m_key_set.begin();
while (it != other.m_key_set.end()) while (it != other.m_key_set.end())
{ {
...@@ -345,7 +345,7 @@ namespace __gnu_pbds ...@@ -345,7 +345,7 @@ namespace __gnu_pbds
it = other.m_key_set.erase(it); it = other.m_key_set.erase(it);
} }
_GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty()); _GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty());
alloc.set_throw_prob(orig_throw_prob); alloc.set_probability(orig_throw_prob);
} }
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
......
...@@ -79,7 +79,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -79,7 +79,7 @@ PB_DS_CLASS_C_DEC::
resize_imp(size_type new_size) resize_imp(size_type new_size)
{ {
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_num_e); typename Allocator::group_adjustor adjust(m_num_e);
#endif #endif
if (new_size == m_num_e) if (new_size == m_num_e)
......
...@@ -71,7 +71,7 @@ erase_if(Pred pred) ...@@ -71,7 +71,7 @@ erase_if(Pred pred)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
#endif #endif
size_type new_size = 0; size_type new_size = 0;
...@@ -133,7 +133,7 @@ erase_imp(It it) ...@@ -133,7 +133,7 @@ erase_imp(It it)
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));) _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));)
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
#endif #endif
_GLIBCXX_DEBUG_ASSERT(m_size > 0); _GLIBCXX_DEBUG_ASSERT(m_size > 0);
......
...@@ -414,7 +414,7 @@ namespace __gnu_pbds ...@@ -414,7 +414,7 @@ namespace __gnu_pbds
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
#ifdef PB_DS_REGRESSION #ifdef PB_DS_REGRESSION
typename Allocator::group_throw_prob_adjustor adjust(m_size); typename Allocator::group_adjustor adjust(m_size);
#endif #endif
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_value))); _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_value)));
......
...@@ -51,27 +51,18 @@ ...@@ -51,27 +51,18 @@
#include <ostream> #include <ostream>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <tr1/random>
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/move.h> #include <bits/move.h>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
# include <functional>
# include <random>
#else
# include <tr1/functional>
# include <tr1/random>
#endif
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
class twister_rand_gen
{
private:
std::tr1::mt19937 _M_generator;
public:
twister_rand_gen(unsigned int s = static_cast<unsigned int>(std::time(0)));
void
init(unsigned int);
double
get_prob();
};
/** /**
* @brief Thown by throw_allocator. * @brief Thown by throw_allocator.
* @ingroup exceptions * @ingroup exceptions
...@@ -90,94 +81,277 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -90,94 +81,277 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
#endif #endif
} }
/// Base class. // Base class for checking address and label information about
class throw_allocator_base // allocations. Create a std::map between the allocated address
// (void*) and a datum for annotations, which are a pair of numbers
// corresponding to label and allocated size.
struct annotate_base
{ {
public: annotate_base()
void {
init(unsigned long seed); label();
map();
}
static void static void
set_throw_prob(double throw_prob); set_label(size_t l)
{ label() = l; }
static double static size_t
get_throw_prob(); get_label()
{ return label(); }
static void void
set_label(size_t l); insert(void* p, size_t size)
{
if (p == NULL)
{
std::string error("throw_allocator_base::insert null insert!\n");
log_to_string(error, make_entry(p, size));
std::__throw_logic_error(error.c_str());
}
static bool const_iterator found = map().find(p);
empty(); if (found != map().end())
{
std::string error("throw_allocator_base::insert double insert!\n");
log_to_string(error, make_entry(p, size));
log_to_string(error, *found);
std::__throw_logic_error(error.c_str());
}
struct group_throw_prob_adjustor map().insert(make_entry(p, size));
}
void
erase(void* p, size_t size)
{ {
group_throw_prob_adjustor(size_t size) : _M_throw_prob_orig(_S_throw_prob) check_allocated(p, size);
map().erase(p);
}
// See if a particular address and size has been allocated.
inline void
check_allocated(void* p, size_t size)
{
const_iterator found = map().find(p);
if (found == map().end())
{ {
_S_throw_prob = std::string error("annotate_base::check_allocated by value "
1 - std::pow(double(1 - _S_throw_prob), double(0.5 / (size + 1))); "null erase!\n");
log_to_string(error, make_entry(p, size));
std::__throw_logic_error(error.c_str());
} }
~group_throw_prob_adjustor() if (found->second.second != size)
{ _S_throw_prob = _M_throw_prob_orig; } {
std::string error("annotate_base::check_allocated by value "
"wrong-size erase!\n");
log_to_string(error, make_entry(p, size));
log_to_string(error, *found);
std::__throw_logic_error(error.c_str());
}
}
// See if a given label has been allocated.
inline void
check_allocated(size_t label)
{
const_iterator beg = map().begin();
const_iterator end = map().end();
std::string found;
while (beg != end)
{
if (beg->second.first == label)
log_to_string(found, *beg);
++beg;
}
if (!found.empty())
{
std::string error("annotate_base::check_allocated by label\n");
error += found;
std::__throw_logic_error(error.c_str());
}
}
private: private:
const double _M_throw_prob_orig; typedef std::pair<size_t, size_t> data_type;
}; typedef std::map<void*, data_type> map_type;
typedef map_type::value_type entry_type;
typedef map_type::const_iterator const_iterator;
typedef map_type::const_reference const_reference;
friend std::ostream&
operator<<(std::ostream&, const annotate_base&);
entry_type
make_entry(void* p, size_t size)
{ return std::make_pair(p, data_type(get_label(), size)); }
struct zero_throw_prob_adjustor void
log_to_string(std::string& s, const_reference ref) const
{ {
zero_throw_prob_adjustor() : _M_throw_prob_orig(_S_throw_prob) char buf[40];
{ _S_throw_prob = 0; } const char tab('\t');
s += "label: ";
unsigned long l = static_cast<unsigned long>(ref.second.first);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "size: ";
l = static_cast<unsigned long>(ref.second.second);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "address: ";
__builtin_sprintf(buf, "%p", ref.first);
s += buf;
s += '\n';
}
static size_t&
label()
{
static size_t ll;
return ll;
}
static map_type&
map()
{
static map_type mp;
return mp;
}
};
~zero_throw_prob_adjustor() inline std::ostream&
{ _S_throw_prob = _M_throw_prob_orig; } operator<<(std::ostream& os, const annotate_base& __b)
{
std::string error;
typedef annotate_base base_type;
base_type::const_iterator beg = __b.map().begin();
base_type::const_iterator end = __b.map().end();
for (; beg != end; ++beg)
__b.log_to_string(error, *beg);
return os << error;
}
/// Base class for probability control and throw.
struct probability_base
{
// Scope-level probability adjustor objects: set probability for
// throw at the beginning of a scope block, and restores to
// previous probability when object is destroyed on exiting the
// block.
struct adjustor_base
{
private: private:
const double _M_throw_prob_orig; const double _M_prob;
public:
adjustor_base() : _M_prob(get_probability()) { }
virtual ~adjustor_base()
{ set_probability(_M_prob); }
}; };
protected: // Group condition.
static void struct group_adjustor : public adjustor_base
insert(void*, size_t); {
group_adjustor(size_t size)
{ set_probability(1 - std::pow(double(1 - get_probability()),
double(0.5 / (size + 1))));
}
};
static void // Never enter the condition.
erase(void*, size_t); struct never_adjustor : public adjustor_base
{
never_adjustor() { set_probability(0); }
};
static void // Always enter the condition.
throw_conditionally(); struct always_adjustor : public adjustor_base
{
always_adjustor() { set_probability(1); }
};
// See if a particular address and size has been allocated by this probability_base()
// allocator. {
static void probability();
check_allocated(void*, size_t); engine();
}
// See if a given label has been allocated by this allocator.
static void static void
check_allocated(size_t); set_probability(double __p)
{ probability() = __p; }
static double&
get_probability()
{ return probability(); }
void
throw_conditionally()
{
if (generate() < get_probability())
__throw_forced_exception_error();
}
void
seed(unsigned long __s)
{ engine().seed(__s); }
private: private:
typedef std::pair<size_t, size_t> alloc_data_type; #ifdef __GXX_EXPERIMENTAL_CXX0X__
typedef std::map<void*, alloc_data_type> map_type; typedef std::uniform_real_distribution<double> distribution_type;
typedef map_type::value_type entry_type; typedef std::mt19937 engine_type;
typedef map_type::const_iterator const_iterator; #else
typedef map_type::const_reference const_reference; typedef std::tr1::uniform_real<double> distribution_type;
typedef std::tr1::mt19937 engine_type;
#endif
friend std::ostream& double
operator<<(std::ostream&, const throw_allocator_base&); generate()
{
#ifdef __GXX_EXPERIMENTAL_CXX0X__
const distribution_type distribution(0, 1);
static auto generator = std::bind(distribution, engine());
#else
// Use variate_generator to get normalized results.
typedef std::tr1::variate_generator<engine_type, distribution_type> gen_t;
distribution_type distribution(0, 1);
static gen_t generator(engine(), distribution);
#endif
static entry_type double random = generator();
make_entry(void*, size_t); if (random < distribution.min() || random > distribution.max())
{
std::string __s("throw_allocator::throw_conditionally");
__s += "\n";
__s += "random number generated is: ";
char buf[40];
__builtin_sprintf(buf, "%f", random);
__s += buf;
std::__throw_out_of_range(__s.c_str());
}
static void return random;
print_to_string(std::string&); }
static void static double&
print_to_string(std::string&, const_reference); probability()
{
static double __p;
return __p;
}
static twister_rand_gen _S_g; static engine_type&
static map_type _S_map; engine()
static double _S_throw_prob; {
static size_t _S_label; static engine_type __e;
return __e;
}
}; };
/** /**
...@@ -185,7 +359,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -185,7 +359,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
* @ingroup allocators * @ingroup allocators
*/ */
template<typename T> template<typename T>
class throw_allocator : public throw_allocator_base class throw_allocator
: public probability_base, public annotate_base
{ {
public: public:
typedef size_t size_type; typedef size_t size_type;
...@@ -196,7 +371,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -196,7 +371,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
private:
std::allocator<value_type> _M_allocator;
public:
template<typename U> template<typename U>
struct rebind struct rebind
{ {
...@@ -214,7 +392,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -214,7 +392,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
size_type size_type
max_size() const throw() max_size() const throw()
{ return std::allocator<value_type>().max_size(); } { return _M_allocator.max_size(); }
pointer pointer
allocate(size_type __n, std::allocator<void>::const_pointer hint = 0) allocate(size_type __n, std::allocator<void>::const_pointer hint = 0)
...@@ -223,43 +401,41 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -223,43 +401,41 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
std::__throw_bad_alloc(); std::__throw_bad_alloc();
throw_conditionally(); throw_conditionally();
value_type* const a = std::allocator<value_type>().allocate(__n, hint); pointer const a = _M_allocator.allocate(__n, hint);
insert(a, sizeof(value_type) * __n); insert(a, sizeof(value_type) * __n);
return a; return a;
} }
void void
construct(pointer __p, const T& val) construct(pointer __p, const T& val)
{ return std::allocator<value_type>().construct(__p, val); } { return _M_allocator.construct(__p, val); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename... _Args> template<typename... _Args>
void void
construct(pointer __p, _Args&&... __args) construct(pointer __p, _Args&&... __args)
{ { return _M_allocator.construct(__p, std::forward<_Args>(__args)...); }
return std::allocator<value_type>().
construct(__p, std::forward<_Args>(__args)...);
}
#endif #endif
void void
destroy(pointer __p) destroy(pointer __p)
{ std::allocator<value_type>().destroy(__p); } { _M_allocator.destroy(__p); }
void void
deallocate(pointer __p, size_type __n) deallocate(pointer __p, size_type __n)
{ {
erase(__p, sizeof(value_type) * __n); erase(__p, sizeof(value_type) * __n);
std::allocator<value_type>().deallocate(__p, __n); _M_allocator.deallocate(__p, __n);
} }
void void
check_allocated(pointer __p, size_type __n) check_allocated(pointer __p, size_type __n)
{ throw_allocator_base::check_allocated(__p, sizeof(value_type) * __n); } {
size_type __t = sizeof(value_type) * __n;
annotate_base::check_allocated(__p, __t);
}
void using annotate_base::check_allocated;
check_allocated(size_type label)
{ throw_allocator_base::check_allocated(label); }
}; };
template<typename T> template<typename T>
...@@ -272,176 +448,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -272,176 +448,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
operator!=(const throw_allocator<T>&, const throw_allocator<T>&) operator!=(const throw_allocator<T>&, const throw_allocator<T>&)
{ return false; } { return false; }
std::ostream&
operator<<(std::ostream& os, const throw_allocator_base& alloc)
{
std::string error;
throw_allocator_base::print_to_string(error);
os << error;
return os;
}
// XXX Should be in .cc.
twister_rand_gen::
twister_rand_gen(unsigned int seed) : _M_generator(seed) { }
void
twister_rand_gen::
init(unsigned int seed)
{ _M_generator.seed(seed); }
double
twister_rand_gen::
get_prob()
{
const double min = _M_generator.min();
const double res = static_cast<const double>(_M_generator() - min);
const double range = static_cast<const double>(_M_generator.max() - min);
const double ret = res / range;
_GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1);
return ret;
}
twister_rand_gen throw_allocator_base::_S_g;
throw_allocator_base::map_type
throw_allocator_base::_S_map;
double throw_allocator_base::_S_throw_prob;
size_t throw_allocator_base::_S_label = 0;
throw_allocator_base::entry_type
throw_allocator_base::make_entry(void* p, size_t size)
{ return std::make_pair(p, alloc_data_type(_S_label, size)); }
void
throw_allocator_base::init(unsigned long seed)
{ _S_g.init(seed); }
void
throw_allocator_base::set_throw_prob(double throw_prob)
{ _S_throw_prob = throw_prob; }
double
throw_allocator_base::get_throw_prob()
{ return _S_throw_prob; }
void
throw_allocator_base::set_label(size_t l)
{ _S_label = l; }
void
throw_allocator_base::insert(void* p, size_t size)
{
const_iterator found_it = _S_map.find(p);
if (found_it != _S_map.end())
{
std::string error("throw_allocator_base::insert");
error += "double insert!";
error += '\n';
print_to_string(error, make_entry(p, size));
print_to_string(error, *found_it);
std::__throw_logic_error(error.c_str());
}
_S_map.insert(make_entry(p, size));
}
bool
throw_allocator_base::empty()
{ return _S_map.empty(); }
void
throw_allocator_base::erase(void* p, size_t size)
{
check_allocated(p, size);
_S_map.erase(p);
}
void
throw_allocator_base::check_allocated(void* p, size_t size)
{
const_iterator found_it = _S_map.find(p);
if (found_it == _S_map.end())
{
std::string error("throw_allocator_base::check_allocated by value ");
error += "null erase!";
error += '\n';
print_to_string(error, make_entry(p, size));
std::__throw_logic_error(error.c_str());
}
if (found_it->second.second != size)
{
std::string error("throw_allocator_base::check_allocated by value ");
error += "wrong-size erase!";
error += '\n';
print_to_string(error, make_entry(p, size));
print_to_string(error, *found_it);
std::__throw_logic_error(error.c_str());
}
}
void
throw_allocator_base::check_allocated(size_t label)
{
std::string found;
const_iterator it = _S_map.begin();
while (it != _S_map.end())
{
if (it->second.first == label)
{
print_to_string(found, *it);
}
++it;
}
if (!found.empty())
{
std::string error("throw_allocator_base::check_allocated by label ");
error += '\n';
error += found;
std::__throw_logic_error(error.c_str());
}
}
void
throw_allocator_base::throw_conditionally()
{
if (_S_g.get_prob() < _S_throw_prob)
__throw_forced_exception_error();
}
void
throw_allocator_base::print_to_string(std::string& s)
{
const_iterator begin = throw_allocator_base::_S_map.begin();
const_iterator end = throw_allocator_base::_S_map.end();
for (; begin != end; ++begin)
print_to_string(s, *begin);
}
void
throw_allocator_base::print_to_string(std::string& s, const_reference ref)
{
char buf[40];
const char tab('\t');
s += "address: ";
__builtin_sprintf(buf, "%p", ref.first);
s += buf;
s += tab;
s += "label: ";
unsigned long l = static_cast<unsigned long>(ref.second.first);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += tab;
s += "size: ";
l = static_cast<unsigned long>(ref.second.second);
__builtin_sprintf(buf, "%lu", l);
s += buf;
s += '\n';
}
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#endif #endif
...@@ -38,7 +38,7 @@ void insert1() ...@@ -38,7 +38,7 @@ void insert1()
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
allocator_type alloc1; allocator_type alloc1;
typename allocator_type::zero_throw_prob_adjustor adjust1; typename allocator_type::never_adjustor adjust1;
list_type list1(alloc1); list_type list1(alloc1);
for (int k = 0; k < j; ++k) for (int k = 0; k < j; ++k)
...@@ -46,7 +46,7 @@ void insert1() ...@@ -46,7 +46,7 @@ void insert1()
try try
{ {
alloc1.set_throw_prob(1); typename allocator_type::always_adjustor adjust2;
list1.insert(list1.begin(), 10, 99); list1.insert(list1.begin(), 10, 99);
VERIFY( false ); VERIFY( false );
} }
...@@ -56,7 +56,7 @@ void insert1() ...@@ -56,7 +56,7 @@ void insert1()
} }
catch (...) catch (...)
{ {
VERIFY( false ); __throw_exception_again;
} }
VERIFY( list1.size() == size_type(j) ); VERIFY( list1.size() == size_type(j) );
...@@ -64,7 +64,6 @@ void insert1() ...@@ -64,7 +64,6 @@ void insert1()
VERIFY( list1.size() == 0 || list1.front() == -1 ); VERIFY( list1.size() == 0 || list1.front() == -1 );
allocator_type alloc2; allocator_type alloc2;
typename allocator_type::zero_throw_prob_adjustor adjust2;
list_type list2(alloc2); list_type list2(alloc2);
const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
...@@ -74,7 +73,7 @@ void insert1() ...@@ -74,7 +73,7 @@ void insert1()
try try
{ {
alloc2.set_throw_prob(1); typename allocator_type::always_adjustor adjust3;
list2.insert(list2.begin(), data, data + 10); list2.insert(list2.begin(), data, data + 10);
VERIFY( false ); VERIFY( false );
} }
......
...@@ -60,7 +60,7 @@ default_constructor() ...@@ -60,7 +60,7 @@ default_constructor()
{ {
PB_DS_TRACE("default_constructor"); PB_DS_TRACE("default_constructor");
bool done = true; bool done = true;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
try try
{ {
...@@ -82,9 +82,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -82,9 +82,9 @@ PB_DS_CLASS_C_DEC::
swap() swap()
{ {
PB_DS_TRACE("swap"); PB_DS_TRACE("swap");
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
Cntnr* p_c = new Cntnr; Cntnr* p_c = new Cntnr;
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
p_c->swap(*m_p_c); p_c->swap(*m_p_c);
std::swap(p_c, m_p_c); std::swap(p_c, m_p_c);
delete p_c; delete p_c;
...@@ -99,8 +99,8 @@ copy_constructor() ...@@ -99,8 +99,8 @@ copy_constructor()
PB_DS_TRACE("copy_constructor"); PB_DS_TRACE("copy_constructor");
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -125,8 +125,8 @@ assignment_operator() ...@@ -125,8 +125,8 @@ assignment_operator()
PB_DS_TRACE("assignment operator"); PB_DS_TRACE("assignment operator");
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -160,8 +160,8 @@ it_constructor_imp(__gnu_pbds::cc_hash_tag) ...@@ -160,8 +160,8 @@ it_constructor_imp(__gnu_pbds::cc_hash_tag)
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -227,8 +227,8 @@ it_constructor_imp(__gnu_pbds::gp_hash_tag) ...@@ -227,8 +227,8 @@ it_constructor_imp(__gnu_pbds::gp_hash_tag)
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -310,8 +310,8 @@ it_constructor_imp(__gnu_pbds::tree_tag) ...@@ -310,8 +310,8 @@ it_constructor_imp(__gnu_pbds::tree_tag)
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -346,8 +346,8 @@ it_constructor_imp(__gnu_pbds::list_update_tag) ...@@ -346,8 +346,8 @@ it_constructor_imp(__gnu_pbds::list_update_tag)
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -371,8 +371,8 @@ it_constructor_imp(__gnu_pbds::pat_trie_tag) ...@@ -371,8 +371,8 @@ it_constructor_imp(__gnu_pbds::pat_trie_tag)
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
try try
{ {
...@@ -409,7 +409,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -409,7 +409,7 @@ PB_DS_CLASS_C_DEC::
cmp(const Cntnr& r_c, const native_type& r_native_c, cmp(const Cntnr& r_c, const native_type& r_native_c,
const std::string& r_call_fn) const std::string& r_call_fn)
{ {
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
const size_t size = r_c.size(); const size_t size = r_c.size();
const size_t native_size = r_native_c.size(); const size_t native_size = r_native_c.size();
PB_DS_THROW_IF_FAILED(size == native_size, PB_DS_THROW_IF_FAILED(size == native_size,
...@@ -447,9 +447,9 @@ basic_cmp_(const Cntnr& r_c, const native_type& r_native_c) ...@@ -447,9 +447,9 @@ basic_cmp_(const Cntnr& r_c, const native_type& r_native_c)
{ {
typename native_type::key_type native_key = test_traits::extract_native_key(*it); typename native_type::key_type native_key = test_traits::extract_native_key(*it);
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = native_key; const key_type k = native_key;
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typename cntnr::const_point_iterator found_it = r_c.find(k); typename cntnr::const_point_iterator found_it = r_c.find(k);
PB_DS_THROW_IF_FAILED(found_it != r_c.end(), PB_DS_THROW_IF_FAILED(found_it != r_c.end(),
test_traits::native_val_to_string(*it), test_traits::native_val_to_string(*it),
...@@ -622,9 +622,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -622,9 +622,9 @@ PB_DS_CLASS_C_DEC::
order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) 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); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
const size_type order = r_c.order_of_key(k); const size_type order = r_c.order_of_key(k);
const size_type native_order = std::distance(r_native_c.begin(), const size_type native_order = std::distance(r_native_c.begin(),
r_native_c.lower_bound(test_traits::native_key(k))); r_native_c.lower_bound(test_traits::native_key(k)));
...@@ -675,9 +675,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -675,9 +675,9 @@ PB_DS_CLASS_C_DEC::
prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
{ {
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
try try
{ {
typedef typedef
...@@ -794,9 +794,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -794,9 +794,9 @@ PB_DS_CLASS_C_DEC::
lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
{ {
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typename cntnr::const_iterator it = r_c.lower_bound(k); 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::key_type native_k = test_traits::native_key(k);
typename native_type::const_iterator native_it = r_native_c.lower_bound(native_k); typename native_type::const_iterator native_it = r_native_c.lower_bound(native_k);
...@@ -833,9 +833,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -833,9 +833,9 @@ PB_DS_CLASS_C_DEC::
upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type) upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
{ {
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typename cntnr::const_iterator it = r_c.upper_bound(k); 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::key_type native_k = test_traits::native_key(k);
typename native_type::const_iterator native_it = r_native_c.upper_bound(native_k); typename native_type::const_iterator native_it = r_native_c.upper_bound(native_k);
...@@ -879,7 +879,7 @@ operator()() ...@@ -879,7 +879,7 @@ operator()()
// Track allocation from this point only. // Track allocation from this point only.
const size_t memory_label = 775; const size_t memory_label = 775;
m_alloc.init(m_seed); m_alloc.seed(m_seed);
m_alloc.set_label(memory_label); m_alloc.set_label(memory_label);
prog_bar pb(m_n, std::cout, m_disp); prog_bar pb(m_n, std::cout, m_disp);
...@@ -1012,7 +1012,7 @@ operator()() ...@@ -1012,7 +1012,7 @@ operator()()
} }
// Reset throw probability. // Reset throw probability.
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
if (m_disp) if (m_disp)
{ {
...@@ -1069,9 +1069,9 @@ insert() ...@@ -1069,9 +1069,9 @@ insert()
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m); value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
const_key_reference r_k = test_traits::extract_key(v); const_key_reference r_k = test_traits::extract_key(v);
typename cntnr::const_point_iterator found_it = m_p_c->find(r_k); typename cntnr::const_point_iterator found_it = m_p_c->find(r_k);
const bool existed = (found_it != m_p_c->end()); const bool existed = (found_it != m_p_c->end());
...@@ -1130,10 +1130,10 @@ subscript_imp(__gnu_pbds::detail::false_type) ...@@ -1130,10 +1130,10 @@ subscript_imp(__gnu_pbds::detail::false_type)
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m); value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
(*m_p_c)[v.first] = v.second; (*m_p_c)[v.first] = v.second;
m_native_c[test_traits::native_value(v).first] = m_native_c[test_traits::native_value(v).first] =
...@@ -1158,9 +1158,9 @@ subscript_imp(__gnu_pbds::detail::true_type) ...@@ -1158,9 +1158,9 @@ subscript_imp(__gnu_pbds::detail::true_type)
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m); value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
(*m_p_c)[v] = __gnu_pbds::null_mapped_type(); (*m_p_c)[v] = __gnu_pbds::null_mapped_type();
m_native_c.insert(test_traits::native_value(v)); m_native_c.insert(test_traits::native_value(v));
} }
...@@ -1195,9 +1195,9 @@ erase() ...@@ -1195,9 +1195,9 @@ erase()
PB_DS_TRACE("erase"); PB_DS_TRACE("erase");
bool done = true; bool done = true;
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
try try
{ {
...@@ -1244,7 +1244,7 @@ erase_if() ...@@ -1244,7 +1244,7 @@ erase_if()
typename test_traits::template erase_if_fn<value_type> typename test_traits::template erase_if_fn<value_type>
erase_if_fn_t; erase_if_fn_t;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
const size_t ersd = m_p_c->erase_if(erase_if_fn_t()); 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); const size_t native_ersd = test_traits::erase_if(m_native_c);
...@@ -1296,9 +1296,9 @@ erase_it_imp(__gnu_pbds::detail::true_type) ...@@ -1296,9 +1296,9 @@ erase_it_imp(__gnu_pbds::detail::true_type)
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename cntnr::iterator found_it = m_p_c->find(k); typename cntnr::iterator found_it = m_p_c->find(k);
...@@ -1373,9 +1373,9 @@ erase_rev_it_imp(__gnu_pbds::detail::true_type) ...@@ -1373,9 +1373,9 @@ erase_rev_it_imp(__gnu_pbds::detail::true_type)
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename cntnr::iterator found_it = m_p_c->find(k); 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 native_type::iterator native_it = m_native_c.find(test_traits::native_key(k));
...@@ -1728,14 +1728,14 @@ split_join_imp(__gnu_pbds::detail::true_type) ...@@ -1728,14 +1728,14 @@ split_join_imp(__gnu_pbds::detail::true_type)
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
Cntnr lhs(*m_p_c); Cntnr lhs(*m_p_c);
Cntnr rhs; Cntnr rhs;
native_type native_lhs(m_native_c); native_type native_lhs(m_native_c);
native_type native_rhs; native_type native_rhs;
const key_type k = test_traits::generate_key(m_g, m_m); const key_type k = test_traits::generate_key(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
lhs.split(k, rhs); lhs.split(k, rhs);
typename native_type::const_iterator it = typename native_type::const_iterator it =
...@@ -1753,7 +1753,7 @@ split_join_imp(__gnu_pbds::detail::true_type) ...@@ -1753,7 +1753,7 @@ split_join_imp(__gnu_pbds::detail::true_type)
PB_DS_COND_COMPARE(lhs, native_lhs); PB_DS_COND_COMPARE(lhs, native_lhs);
PB_DS_COND_COMPARE(rhs, native_rhs); PB_DS_COND_COMPARE(rhs, native_rhs);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
if (m_g.get_prob() < 0.5) if (m_g.get_prob() < 0.5)
lhs.swap(rhs); lhs.swap(rhs);
...@@ -1972,8 +1972,8 @@ resize_imp(__gnu_pbds::detail::true_type) ...@@ -1972,8 +1972,8 @@ resize_imp(__gnu_pbds::detail::true_type)
max_new_size = 2000 max_new_size = 2000
}; };
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
const size_t new_size = m_g.get_unsigned_long(min_new_size, max_new_size); const size_t new_size = m_g.get_unsigned_long(min_new_size, max_new_size);
m_p_c->resize(new_size); m_p_c->resize(new_size);
const size_t actual_new_size = m_p_c->get_actual_size(); const size_t actual_new_size = m_p_c->get_actual_size();
...@@ -2023,8 +2023,8 @@ get_set_load_imp(__gnu_pbds::detail::true_type) ...@@ -2023,8 +2023,8 @@ get_set_load_imp(__gnu_pbds::detail::true_type)
PB_DS_TRACE("get_set_load"); PB_DS_TRACE("get_set_load");
PB_DS_SET_DESTRUCT_PRINT PB_DS_SET_DESTRUCT_PRINT
m_p_c->get_load(); m_p_c->get_load();
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
const float min_load = static_cast<float>(0.05); const float min_load = static_cast<float>(0.05);
const float max_load = static_cast<float>(0.9); const float max_load = static_cast<float>(0.9);
...@@ -2070,9 +2070,9 @@ get_set_loads_imp(__gnu_pbds::detail::true_type) ...@@ -2070,9 +2070,9 @@ get_set_loads_imp(__gnu_pbds::detail::true_type)
try try
{ {
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename alloc_t::group_throw_prob_adjustor adjust(m_p_c->size()); typename alloc_t::group_adjustor adjust(m_p_c->size());
const float min_min_load = static_cast<float>(0.05); const float min_min_load = static_cast<float>(0.05);
const float max_min_load = static_cast<float>(0.2); const float max_min_load = static_cast<float>(0.2);
...@@ -2107,7 +2107,7 @@ void ...@@ -2107,7 +2107,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
print_container(const native_type& r_cnt, std::ostream& r_os) const print_container(const native_type& r_cnt, std::ostream& r_os) const
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
typename native_type::const_iterator it = r_cnt.begin(); typename native_type::const_iterator it = r_cnt.begin();
while (it != r_cnt.end()) while (it != r_cnt.end())
{ {
...@@ -2121,7 +2121,7 @@ void ...@@ -2121,7 +2121,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
print_container(const cntnr& r_cnt, std::ostream& r_os) const print_container(const cntnr& r_cnt, std::ostream& r_os) const
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
typename cntnr::const_iterator it = r_cnt.begin(); typename cntnr::const_iterator it = r_cnt.begin();
while (it != r_cnt.end()) while (it != r_cnt.end())
{ {
......
...@@ -148,7 +148,7 @@ namespace detail ...@@ -148,7 +148,7 @@ namespace detail
namespace detail namespace detail
{ {
void inline void
usage(const std::string& name) usage(const std::string& name)
{ {
using namespace std; using namespace std;
...@@ -179,7 +179,7 @@ namespace detail ...@@ -179,7 +179,7 @@ namespace detail
cerr << "'t' or 'f' determine whether progress will be displayed" << endl; cerr << "'t' or 'f' determine whether progress will be displayed" << endl;
} }
void inline void
verify_params(size_t& r_seed, size_t& r_n, verify_params(size_t& r_seed, size_t& r_n,
size_t& r_m, double& r_tp, double& r_ip, double& r_ep, size_t& r_m, double& r_tp, double& r_ip, double& r_ep,
double& r_cp, double& r_mp, bool& r_d) double& r_cp, double& r_mp, bool& r_d)
......
...@@ -60,7 +60,7 @@ default_constructor() ...@@ -60,7 +60,7 @@ default_constructor()
{ {
PB_DS_TRACE("default_constructor"); PB_DS_TRACE("default_constructor");
bool done = true; bool done = true;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
try try
{ {
...@@ -83,9 +83,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -83,9 +83,9 @@ PB_DS_CLASS_C_DEC::
swap() swap()
{ {
PB_DS_TRACE("swap"); PB_DS_TRACE("swap");
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
Cntnr* p_c = new Cntnr; Cntnr* p_c = new Cntnr;
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
p_c->swap(*m_p_c); p_c->swap(*m_p_c);
std::swap(p_c, m_p_c); std::swap(p_c, m_p_c);
delete p_c; delete p_c;
...@@ -100,9 +100,9 @@ copy_constructor() ...@@ -100,9 +100,9 @@ copy_constructor()
PB_DS_TRACE("copy_constructor"); PB_DS_TRACE("copy_constructor");
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typedef typename allocator_type::group_throw_prob_adjustor adjustor; typedef typename allocator_type::group_adjustor adjustor;
adjustor adjust(m_p_c->size()); adjustor adjust(m_p_c->size());
try try
...@@ -128,9 +128,9 @@ assignment_operator() ...@@ -128,9 +128,9 @@ assignment_operator()
PB_DS_TRACE("assignment operator"); PB_DS_TRACE("assignment operator");
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typedef typename allocator_type::group_throw_prob_adjustor adjustor; typedef typename allocator_type::group_adjustor adjustor;
adjustor adjust(m_p_c->size()); adjustor adjust(m_p_c->size());
try try
...@@ -156,8 +156,8 @@ it_constructor() ...@@ -156,8 +156,8 @@ it_constructor()
{ {
bool done = true; bool done = true;
Cntnr* p_c = NULL; Cntnr* p_c = NULL;
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typedef typename allocator_type::group_throw_prob_adjustor adjustor; typedef typename allocator_type::group_adjustor adjustor;
adjustor adjust(m_p_c->size()); adjustor adjust(m_p_c->size());
try try
...@@ -201,7 +201,7 @@ cmp(const Cntnr& c, const native_type& native, const std::string& callfn) ...@@ -201,7 +201,7 @@ cmp(const Cntnr& c, const native_type& native, const std::string& callfn)
try try
{ {
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
const size_t size = c.size(); const size_t size = c.size();
const size_t native_size = native.size(); const size_t native_size = native.size();
...@@ -248,7 +248,7 @@ operator()() ...@@ -248,7 +248,7 @@ operator()()
string_form<Cntnr>::desc()); string_form<Cntnr>::desc());
m_g.init(m_seed); m_g.init(m_seed);
m_alloc.init(m_seed); m_alloc.seed(m_seed);
// The __throw_allocator::_S_label defaults to 0, so to make things // The __throw_allocator::_S_label defaults to 0, so to make things
// easier and more precise when debugging, start at 1. // easier and more precise when debugging, start at 1.
...@@ -363,7 +363,7 @@ operator()() ...@@ -363,7 +363,7 @@ operator()()
} }
// Reset throw probability. // Reset throw probability.
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
if (m_disp) if (m_disp)
{ {
...@@ -425,9 +425,9 @@ push() ...@@ -425,9 +425,9 @@ push()
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m); value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
const typename cntnr::size_type sz = m_p_c->size(); const typename cntnr::size_type sz = m_p_c->size();
m_p_c->push(v); m_p_c->push(v);
_GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c); _GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c);
...@@ -460,10 +460,10 @@ modify() ...@@ -460,10 +460,10 @@ modify()
bool done = true; bool done = true;
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
value_type v = test_traits::generate_value(m_g, m_m); value_type v = test_traits::generate_value(m_g, m_m);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typename cntnr::iterator it = m_p_c->begin(); typename cntnr::iterator it = m_p_c->begin();
std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
if (it != m_p_c->end()) if (it != m_p_c->end())
...@@ -510,7 +510,7 @@ pop() ...@@ -510,7 +510,7 @@ pop()
bool done = true; bool done = true;
try try
{ {
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
if (!m_p_c->empty()) if (!m_p_c->empty())
{ {
m_p_c->pop(); m_p_c->pop();
...@@ -543,7 +543,7 @@ erase_if() ...@@ -543,7 +543,7 @@ erase_if()
typename std::iterator_traits<typename cntnr::iterator>::reference typename std::iterator_traits<typename cntnr::iterator>::reference
it_const_reference; it_const_reference;
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typedef typedef
typename test_traits::template erase_if_fn<value_type> typename test_traits::template erase_if_fn<value_type>
...@@ -582,7 +582,7 @@ erase_it() ...@@ -582,7 +582,7 @@ erase_it()
bool done = true; bool done = true;
try try
{ {
m_alloc.set_throw_prob(1); m_alloc.set_probability(1);
typename cntnr::iterator it = m_p_c->begin(); typename cntnr::iterator it = m_p_c->begin();
std::advance(it, m_g.get_unsigned_long(0, m_p_c->size())); std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
...@@ -689,11 +689,11 @@ split_join() ...@@ -689,11 +689,11 @@ split_join()
bool done = true; bool done = true;
try try
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
Cntnr lhs(*m_p_c); Cntnr lhs(*m_p_c);
Cntnr rhs; Cntnr rhs;
native_type native_lhs(m_native_c); native_type native_lhs(m_native_c);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
typedef typename test_traits::template erase_if_fn<value_type> split_fn_t; typedef typename test_traits::template erase_if_fn<value_type> split_fn_t;
lhs.split(split_fn_t(), rhs); lhs.split(split_fn_t(), rhs);
...@@ -706,7 +706,7 @@ split_join() ...@@ -706,7 +706,7 @@ split_join()
PB_DS_COND_COMPARE(lhs, native_lhs); PB_DS_COND_COMPARE(lhs, native_lhs);
PB_DS_COND_COMPARE(rhs, native_rhs); PB_DS_COND_COMPARE(rhs, native_rhs);
m_alloc.set_throw_prob(m_tp); m_alloc.set_probability(m_tp);
if (m_g.get_prob() < 0.5) if (m_g.get_prob() < 0.5)
lhs.swap(rhs); lhs.swap(rhs);
...@@ -815,7 +815,7 @@ void ...@@ -815,7 +815,7 @@ void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
print_container(const native_type& cnt, std::ostream& os) const print_container(const native_type& cnt, std::ostream& os) const
{ {
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
native_type cpy(cnt); native_type cpy(cnt);
while (!cpy.empty()) while (!cpy.empty())
{ {
...@@ -830,7 +830,7 @@ PB_DS_CLASS_C_DEC:: ...@@ -830,7 +830,7 @@ PB_DS_CLASS_C_DEC::
print_container(const cntnr& cnt, std::ostream& os) const print_container(const cntnr& cnt, std::ostream& os) const
{ {
typedef typename cntnr::const_iterator const_iterator; typedef typename cntnr::const_iterator const_iterator;
m_alloc.set_throw_prob(0); m_alloc.set_probability(0);
for (const_iterator it = cnt.begin(); it != cnt.end(); ++it) for (const_iterator it = cnt.begin(); it != cnt.end(); ++it)
os << *it << std::endl; os << *it << std::endl;
} }
......
...@@ -150,7 +150,7 @@ namespace detail ...@@ -150,7 +150,7 @@ namespace detail
namespace detail namespace detail
{ {
void inline void
usage(const std::string& name) usage(const std::string& name)
{ {
using namespace std; using namespace std;
...@@ -182,7 +182,7 @@ namespace detail ...@@ -182,7 +182,7 @@ namespace detail
cerr << "'t' or 'f' determine whether progress will be displayed" << endl; cerr << "'t' or 'f' determine whether progress will be displayed" << endl;
} }
void inline void
verify_params(size_t& r_seed, size_t& r_n, verify_params(size_t& r_seed, size_t& r_n,
size_t& r_m, double& r_tp, double& r_ip, double& r_dp, size_t& r_m, double& r_tp, double& r_ip, double& r_dp,
double& r_ep, double& r_cp, double& r_mp, bool& r_d) double& r_ep, double& r_cp, double& r_mp, bool& r_d)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment