mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
@ -178,10 +178,12 @@ C++11 support has resulted in some breaking changes:
|
|||||||
[h2 Boost 1.50.0]
|
[h2 Boost 1.50.0]
|
||||||
|
|
||||||
* Fix equality for `unordered_multiset` and `unordered_multimap`.
|
* Fix equality for `unordered_multiset` and `unordered_multimap`.
|
||||||
* [@http://svn.boost.org/trac/boost/ticket/6771 Ticket 6771]:
|
* [@https://svn.boost.org/trac/boost/ticket/6771 Ticket 6771]:
|
||||||
Avoid gcc's `-Wfloat-equal` warning.
|
Avoid gcc's `-Wfloat-equal` warning.
|
||||||
* [@http://svn.boost.org/trac/boost/ticket/6784 Ticket 6784]:
|
* [@https://svn.boost.org/trac/boost/ticket/6784 Ticket 6784]:
|
||||||
Fix some Sun specific code.
|
Fix some Sun specific code.
|
||||||
|
* [@https://svn.boost.org/trac/boost/ticket/6190 Ticket 6190]:
|
||||||
|
Avoid gcc's `-Wshadow` warning.
|
||||||
* Remove some of the smaller prime number of buckets, as they may make
|
* Remove some of the smaller prime number of buckets, as they may make
|
||||||
collisions quite probable (e.g. multiples of 5 are very common because
|
collisions quite probable (e.g. multiples of 5 are very common because
|
||||||
we used base 10).
|
we used base 10).
|
||||||
|
@ -861,22 +861,24 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
// This is called after erasing a node or group of nodes to fix up
|
// This is called after erasing a node or group of nodes to fix up
|
||||||
// the bucket pointers.
|
// the bucket pointers.
|
||||||
void fix_buckets(bucket_pointer bucket,
|
void fix_buckets(bucket_pointer this_bucket,
|
||||||
previous_pointer prev, node_pointer next)
|
previous_pointer prev, node_pointer next)
|
||||||
{
|
{
|
||||||
if (!next)
|
if (!next)
|
||||||
{
|
{
|
||||||
if (bucket->next_ == prev) bucket->next_ = node_pointer();
|
if (this_bucket->next_ == prev)
|
||||||
|
this_bucket->next_ = node_pointer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bucket_pointer next_bucket = this->get_bucket(
|
bucket_pointer next_bucket = this->get_bucket(
|
||||||
policy::to_bucket(this->bucket_count_, next->hash_));
|
policy::to_bucket(this->bucket_count_, next->hash_));
|
||||||
|
|
||||||
if (next_bucket != bucket)
|
if (next_bucket != this_bucket)
|
||||||
{
|
{
|
||||||
next_bucket->next_ = prev;
|
next_bucket->next_ = prev;
|
||||||
if (bucket->next_ == prev) bucket->next_ = node_pointer();
|
if (this_bucket->next_ == prev)
|
||||||
|
this_bucket->next_ = node_pointer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
{ \
|
{ \
|
||||||
BOOST_PP_REPEAT_##z(n, BOOST_UNORDERED_EARGS_MEMBER, _) \
|
BOOST_PP_REPEAT_##z(n, BOOST_UNORDERED_EARGS_MEMBER, _) \
|
||||||
BOOST_PP_CAT(emplace_args, n) ( \
|
BOOST_PP_CAT(emplace_args, n) ( \
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, Arg, a) \
|
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, Arg, b) \
|
||||||
) : BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_EARGS_INIT, _) \
|
) : BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_EARGS_INIT, _) \
|
||||||
{} \
|
{} \
|
||||||
\
|
\
|
||||||
@ -121,12 +121,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
inline BOOST_PP_CAT(emplace_args, n) < \
|
inline BOOST_PP_CAT(emplace_args, n) < \
|
||||||
BOOST_PP_ENUM_PARAMS_Z(z, n, A) \
|
BOOST_PP_ENUM_PARAMS_Z(z, n, A) \
|
||||||
> create_emplace_args( \
|
> create_emplace_args( \
|
||||||
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
|
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, b) \
|
||||||
) \
|
) \
|
||||||
{ \
|
{ \
|
||||||
BOOST_PP_CAT(emplace_args, n) < \
|
BOOST_PP_CAT(emplace_args, n) < \
|
||||||
BOOST_PP_ENUM_PARAMS_Z(z, n, A) \
|
BOOST_PP_ENUM_PARAMS_Z(z, n, A) \
|
||||||
> e(BOOST_PP_ENUM_PARAMS_Z(z, n, a)); \
|
> e(BOOST_PP_ENUM_PARAMS_Z(z, n, b)); \
|
||||||
return e; \
|
return e; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
#define BOOST_UNORDERED_EARGS_INIT(z, n, _) \
|
#define BOOST_UNORDERED_EARGS_INIT(z, n, _) \
|
||||||
BOOST_PP_CAT(a, n)( \
|
BOOST_PP_CAT(a, n)( \
|
||||||
boost::forward<BOOST_PP_CAT(A,n)>(BOOST_PP_CAT(a, n)))
|
boost::forward<BOOST_PP_CAT(A,n)>(BOOST_PP_CAT(b, n)))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
BOOST_PP_CAT(Arg, n) BOOST_PP_CAT(a, n);
|
BOOST_PP_CAT(Arg, n) BOOST_PP_CAT(a, n);
|
||||||
|
|
||||||
#define BOOST_UNORDERED_EARGS_INIT(z, n, _) \
|
#define BOOST_UNORDERED_EARGS_INIT(z, n, _) \
|
||||||
BOOST_PP_CAT(a, n)(BOOST_PP_CAT(a, n))
|
BOOST_PP_CAT(a, n)(BOOST_PP_CAT(b, n))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -257,12 +257,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
template <class Key, class Pred>
|
template <class Key, class Pred>
|
||||||
iterator find_node_impl(
|
iterator find_node_impl(
|
||||||
std::size_t hash,
|
std::size_t key_hash,
|
||||||
Key const& k,
|
Key const& k,
|
||||||
Pred const& eq) const
|
Pred const& eq) const
|
||||||
{
|
{
|
||||||
std::size_t bucket_index =
|
std::size_t bucket_index =
|
||||||
policy::to_bucket(this->bucket_count_, hash);
|
policy::to_bucket(this->bucket_count_, key_hash);
|
||||||
iterator n = this->get_start(bucket_index);
|
iterator n = this->get_start(bucket_index);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -270,7 +270,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if (!n.node_) return n;
|
if (!n.node_) return n;
|
||||||
|
|
||||||
std::size_t node_hash = n.node_->hash_;
|
std::size_t node_hash = n.node_->hash_;
|
||||||
if (hash == node_hash)
|
if (key_hash == node_hash)
|
||||||
{
|
{
|
||||||
if (eq(k, this->get_key(*n)))
|
if (eq(k, this->get_key(*n)))
|
||||||
return n;
|
return n;
|
||||||
@ -292,14 +292,14 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
iterator n = this->find_node(k);
|
iterator n = this->find_node(k);
|
||||||
if (!n.node_) return 0;
|
if (!n.node_) return 0;
|
||||||
|
|
||||||
std::size_t count = 0;
|
std::size_t x = 0;
|
||||||
node_pointer it = n.node_;
|
node_pointer it = n.node_;
|
||||||
do {
|
do {
|
||||||
it = static_cast<node_pointer>(it->group_prev_);
|
it = static_cast<node_pointer>(it->group_prev_);
|
||||||
++count;
|
++x;
|
||||||
} while(it != n.node_);
|
} while(it != n.node_);
|
||||||
|
|
||||||
return count;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, iterator>
|
std::pair<iterator, iterator>
|
||||||
@ -432,11 +432,11 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
inline iterator add_node(
|
inline iterator add_node(
|
||||||
node_constructor& a,
|
node_constructor& a,
|
||||||
std::size_t hash,
|
std::size_t key_hash,
|
||||||
iterator pos)
|
iterator pos)
|
||||||
{
|
{
|
||||||
node_pointer n = a.release();
|
node_pointer n = a.release();
|
||||||
n->hash_ = hash;
|
n->hash_ = key_hash;
|
||||||
if (pos.node_) {
|
if (pos.node_) {
|
||||||
this->add_after_node(n, pos.node_);
|
this->add_after_node(n, pos.node_);
|
||||||
if (n->next_) {
|
if (n->next_) {
|
||||||
@ -444,14 +444,14 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
this->bucket_count_,
|
this->bucket_count_,
|
||||||
static_cast<node_pointer>(n->next_)->hash_);
|
static_cast<node_pointer>(n->next_)->hash_);
|
||||||
if (next_bucket !=
|
if (next_bucket !=
|
||||||
policy::to_bucket(this->bucket_count_, hash)) {
|
policy::to_bucket(this->bucket_count_, key_hash)) {
|
||||||
this->get_bucket(next_bucket)->next_ = n;
|
this->get_bucket(next_bucket)->next_ = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bucket_pointer b = this->get_bucket(
|
bucket_pointer b = this->get_bucket(
|
||||||
policy::to_bucket(this->bucket_count_, hash));
|
policy::to_bucket(this->bucket_count_, key_hash));
|
||||||
|
|
||||||
if (!b->next_)
|
if (!b->next_)
|
||||||
{
|
{
|
||||||
@ -480,20 +480,20 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
iterator emplace_impl(node_constructor& a)
|
iterator emplace_impl(node_constructor& a)
|
||||||
{
|
{
|
||||||
key_type const& k = this->get_key(a.value());
|
key_type const& k = this->get_key(a.value());
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator position = this->find_node(hash, k);
|
iterator position = this->find_node(key_hash, k);
|
||||||
|
|
||||||
// reserve has basic exception safety if the hash function
|
// reserve has basic exception safety if the hash function
|
||||||
// throws, strong otherwise.
|
// throws, strong otherwise.
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return this->add_node(a, hash, position);
|
return this->add_node(a, key_hash, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void emplace_impl_no_rehash(node_constructor& a)
|
void emplace_impl_no_rehash(node_constructor& a)
|
||||||
{
|
{
|
||||||
key_type const& k = this->get_key(a.value());
|
key_type const& k = this->get_key(a.value());
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
this->add_node(a, hash, this->find_node(hash, k));
|
this->add_node(a, key_hash, this->find_node(key_hash, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
@ -567,12 +567,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
{
|
{
|
||||||
if(!this->size_) return 0;
|
if(!this->size_) return 0;
|
||||||
|
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
std::size_t bucket_index =
|
std::size_t bucket_index =
|
||||||
policy::to_bucket(this->bucket_count_, hash);
|
policy::to_bucket(this->bucket_count_, key_hash);
|
||||||
bucket_pointer bucket = this->get_bucket(bucket_index);
|
bucket_pointer this_bucket = this->get_bucket(bucket_index);
|
||||||
|
|
||||||
previous_pointer prev = bucket->next_;
|
previous_pointer prev = this_bucket->next_;
|
||||||
if (!prev) return 0;
|
if (!prev) return 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -583,7 +583,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||||
!= bucket_index)
|
!= bucket_index)
|
||||||
return 0;
|
return 0;
|
||||||
if (node_hash == hash &&
|
if (node_hash == key_hash &&
|
||||||
this->key_eq()(k, this->get_key(
|
this->key_eq()(k, this->get_key(
|
||||||
static_cast<node_pointer>(prev->next_)->value())))
|
static_cast<node_pointer>(prev->next_)->value())))
|
||||||
break;
|
break;
|
||||||
@ -596,7 +596,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
static_cast<node_pointer>(pos->group_prev_)->next_;
|
static_cast<node_pointer>(pos->group_prev_)->next_;
|
||||||
node_pointer end = static_cast<node_pointer>(end1);
|
node_pointer end = static_cast<node_pointer>(end1);
|
||||||
prev->next_ = end1;
|
prev->next_ = end1;
|
||||||
this->fix_buckets(bucket, prev, end);
|
this->fix_buckets(this_bucket, prev, end);
|
||||||
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,11 +606,11 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
iterator next(r.node_);
|
iterator next(r.node_);
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
bucket_pointer bucket = this->get_bucket(
|
bucket_pointer this_bucket = this->get_bucket(
|
||||||
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
||||||
previous_pointer prev = unlink_node(*bucket, r.node_);
|
previous_pointer prev = unlink_node(*this_bucket, r.node_);
|
||||||
|
|
||||||
this->fix_buckets(bucket, prev, next.node_);
|
this->fix_buckets(this_bucket, prev, next.node_);
|
||||||
|
|
||||||
this->delete_node(r);
|
this->delete_node(r);
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
previous_pointer prev = dst.get_previous_start();
|
previous_pointer prev = dst.get_previous_start();
|
||||||
|
|
||||||
while (n.node_) {
|
while (n.node_) {
|
||||||
std::size_t hash = n.node_->hash_;
|
std::size_t key_hash = n.node_->hash_;
|
||||||
iterator group_end(
|
iterator group_end(
|
||||||
static_cast<node_pointer>(
|
static_cast<node_pointer>(
|
||||||
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
||||||
@ -760,7 +760,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
node_pointer first_node = a.release();
|
node_pointer first_node = a.release();
|
||||||
node_pointer end = first_node;
|
node_pointer end = first_node;
|
||||||
first_node->hash_ = hash;
|
first_node->hash_ = key_hash;
|
||||||
prev->next_ = static_cast<link_pointer>(first_node);
|
prev->next_ = static_cast<link_pointer>(first_node);
|
||||||
++dst.size_;
|
++dst.size_;
|
||||||
|
|
||||||
@ -769,7 +769,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
a.construct_node();
|
a.construct_node();
|
||||||
a.construct_value2(*n);
|
a.construct_value2(*n);
|
||||||
end = a.release();
|
end = a.release();
|
||||||
end->hash_ = hash;
|
end->hash_ = key_hash;
|
||||||
add_after_node(end, first_node);
|
add_after_node(end, first_node);
|
||||||
++dst.size_;
|
++dst.size_;
|
||||||
}
|
}
|
||||||
@ -796,7 +796,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
previous_pointer prev = dst.get_previous_start();
|
previous_pointer prev = dst.get_previous_start();
|
||||||
|
|
||||||
while (n.node_) {
|
while (n.node_) {
|
||||||
std::size_t hash = n.node_->hash_;
|
std::size_t key_hash = n.node_->hash_;
|
||||||
iterator group_end(
|
iterator group_end(
|
||||||
static_cast<node_pointer>(
|
static_cast<node_pointer>(
|
||||||
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
static_cast<node_pointer>(n.node_->group_prev_)->next_
|
||||||
@ -807,7 +807,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
node_pointer first_node = a.release();
|
node_pointer first_node = a.release();
|
||||||
node_pointer end = first_node;
|
node_pointer end = first_node;
|
||||||
first_node->hash_ = hash;
|
first_node->hash_ = key_hash;
|
||||||
prev->next_ = static_cast<link_pointer>(first_node);
|
prev->next_ = static_cast<link_pointer>(first_node);
|
||||||
++dst.size_;
|
++dst.size_;
|
||||||
|
|
||||||
@ -816,7 +816,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
a.construct_node();
|
a.construct_node();
|
||||||
a.construct_value2(boost::move(*n));
|
a.construct_value2(boost::move(*n));
|
||||||
end = a.release();
|
end = a.release();
|
||||||
end->hash_ = hash;
|
end->hash_ = key_hash;
|
||||||
add_after_node(end, first_node);
|
add_after_node(end, first_node);
|
||||||
++dst.size_;
|
++dst.size_;
|
||||||
}
|
}
|
||||||
|
@ -348,21 +348,21 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template <typename Key, typename Hash, typename Pred>
|
template <typename Key, typename Hash, typename Pred>
|
||||||
iterator generic_find_node(
|
iterator generic_find_node(
|
||||||
Key const& k,
|
Key const& k,
|
||||||
Hash const& hash_function,
|
Hash const& hf,
|
||||||
Pred const& eq) const
|
Pred const& eq) const
|
||||||
{
|
{
|
||||||
if (!this->size_) return iterator();
|
if (!this->size_) return iterator();
|
||||||
return static_cast<table_impl const*>(this)->
|
return static_cast<table_impl const*>(this)->
|
||||||
find_node_impl(policy::apply_hash(hash_function, k), k, eq);
|
find_node_impl(policy::apply_hash(hf, k), k, eq);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator find_node(
|
iterator find_node(
|
||||||
std::size_t hash,
|
std::size_t key_hash,
|
||||||
key_type const& k) const
|
key_type const& k) const
|
||||||
{
|
{
|
||||||
if (!this->size_) return iterator();
|
if (!this->size_) return iterator();
|
||||||
return static_cast<table_impl const*>(this)->
|
return static_cast<table_impl const*>(this)->
|
||||||
find_node_impl(hash, k, this->key_eq());
|
find_node_impl(key_hash, k, this->key_eq());
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator find_node(key_type const& k) const
|
iterator find_node(key_type const& k) const
|
||||||
|
@ -253,12 +253,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
template <class Key, class Pred>
|
template <class Key, class Pred>
|
||||||
iterator find_node_impl(
|
iterator find_node_impl(
|
||||||
std::size_t hash,
|
std::size_t key_hash,
|
||||||
Key const& k,
|
Key const& k,
|
||||||
Pred const& eq) const
|
Pred const& eq) const
|
||||||
{
|
{
|
||||||
std::size_t bucket_index =
|
std::size_t bucket_index =
|
||||||
policy::to_bucket(this->bucket_count_, hash);
|
policy::to_bucket(this->bucket_count_, key_hash);
|
||||||
iterator n = this->get_start(bucket_index);
|
iterator n = this->get_start(bucket_index);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -266,7 +266,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if (!n.node_) return n;
|
if (!n.node_) return n;
|
||||||
|
|
||||||
std::size_t node_hash = n.node_->hash_;
|
std::size_t node_hash = n.node_->hash_;
|
||||||
if (hash == node_hash)
|
if (key_hash == node_hash)
|
||||||
{
|
{
|
||||||
if (eq(k, this->get_key(*n)))
|
if (eq(k, this->get_key(*n)))
|
||||||
return n;
|
return n;
|
||||||
@ -334,13 +334,13 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
inline iterator add_node(
|
inline iterator add_node(
|
||||||
node_constructor& a,
|
node_constructor& a,
|
||||||
std::size_t hash)
|
std::size_t key_hash)
|
||||||
{
|
{
|
||||||
node_pointer n = a.release();
|
node_pointer n = a.release();
|
||||||
n->hash_ = hash;
|
n->hash_ = key_hash;
|
||||||
|
|
||||||
bucket_pointer b = this->get_bucket(
|
bucket_pointer b = this->get_bucket(
|
||||||
policy::to_bucket(this->bucket_count_, hash));
|
policy::to_bucket(this->bucket_count_, key_hash));
|
||||||
|
|
||||||
if (!b->next_)
|
if (!b->next_)
|
||||||
{
|
{
|
||||||
@ -370,8 +370,8 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
{
|
{
|
||||||
typedef typename value_type::second_type mapped_type;
|
typedef typename value_type::second_type mapped_type;
|
||||||
|
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
if (pos.node_) return *pos;
|
if (pos.node_) return *pos;
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return *add_node(a, hash);
|
return *add_node(a, key_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
@ -431,8 +431,8 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
emplace_return emplace_impl(key_type const& k,
|
emplace_return emplace_impl(key_type const& k,
|
||||||
BOOST_UNORDERED_EMPLACE_ARGS)
|
BOOST_UNORDERED_EMPLACE_ARGS)
|
||||||
{
|
{
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
if (pos.node_) return emplace_return(pos, false);
|
if (pos.node_) return emplace_return(pos, false);
|
||||||
|
|
||||||
@ -445,21 +445,21 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
// reserve has basic exception safety if the hash function
|
// reserve has basic exception safety if the hash function
|
||||||
// throws, strong otherwise.
|
// throws, strong otherwise.
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return emplace_return(this->add_node(a, hash), true);
|
return emplace_return(this->add_node(a, key_hash), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
emplace_return emplace_impl_with_node(node_constructor& a)
|
emplace_return emplace_impl_with_node(node_constructor& a)
|
||||||
{
|
{
|
||||||
key_type const& k = this->get_key(a.value());
|
key_type const& k = this->get_key(a.value());
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
if (pos.node_) return emplace_return(pos, false);
|
if (pos.node_) return emplace_return(pos, false);
|
||||||
|
|
||||||
// reserve has basic exception safety if the hash function
|
// reserve has basic exception safety if the hash function
|
||||||
// throws, strong otherwise.
|
// throws, strong otherwise.
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return emplace_return(this->add_node(a, hash), true);
|
return emplace_return(this->add_node(a, key_hash), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||||
@ -515,12 +515,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
void insert_range_empty(node_constructor& a, key_type const& k,
|
void insert_range_empty(node_constructor& a, key_type const& k,
|
||||||
InputIt i, InputIt j)
|
InputIt i, InputIt j)
|
||||||
{
|
{
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
a.construct_node();
|
a.construct_node();
|
||||||
a.construct_value2(*i);
|
a.construct_value2(*i);
|
||||||
this->reserve_for_insert(this->size_ +
|
this->reserve_for_insert(this->size_ +
|
||||||
boost::unordered::detail::insert_size(i, j));
|
boost::unordered::detail::insert_size(i, j));
|
||||||
this->add_node(a, hash);
|
this->add_node(a, key_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InputIt>
|
template <class InputIt>
|
||||||
@ -528,8 +528,8 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
InputIt i, InputIt j)
|
InputIt i, InputIt j)
|
||||||
{
|
{
|
||||||
// No side effects in this initial code
|
// No side effects in this initial code
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
if (!pos.node_) {
|
if (!pos.node_) {
|
||||||
a.construct_node();
|
a.construct_node();
|
||||||
@ -540,7 +540,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
boost::unordered::detail::insert_size(i, j));
|
boost::unordered::detail::insert_size(i, j));
|
||||||
|
|
||||||
// Nothing after this point can throw.
|
// Nothing after this point can throw.
|
||||||
this->add_node(a, hash);
|
this->add_node(a, key_hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,12 +565,12 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
{
|
{
|
||||||
if(!this->size_) return 0;
|
if(!this->size_) return 0;
|
||||||
|
|
||||||
std::size_t hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
std::size_t bucket_index =
|
std::size_t bucket_index =
|
||||||
policy::to_bucket(this->bucket_count_, hash);
|
policy::to_bucket(this->bucket_count_, key_hash);
|
||||||
bucket_pointer bucket = this->get_bucket(bucket_index);
|
bucket_pointer this_bucket = this->get_bucket(bucket_index);
|
||||||
|
|
||||||
previous_pointer prev = bucket->next_;
|
previous_pointer prev = this_bucket->next_;
|
||||||
if (!prev) return 0;
|
if (!prev) return 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -581,7 +581,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if (policy::to_bucket(this->bucket_count_, node_hash)
|
if (policy::to_bucket(this->bucket_count_, node_hash)
|
||||||
!= bucket_index)
|
!= bucket_index)
|
||||||
return 0;
|
return 0;
|
||||||
if (node_hash == hash &&
|
if (node_hash == key_hash &&
|
||||||
this->key_eq()(k, this->get_key(
|
this->key_eq()(k, this->get_key(
|
||||||
static_cast<node_pointer>(prev->next_)->value())))
|
static_cast<node_pointer>(prev->next_)->value())))
|
||||||
break;
|
break;
|
||||||
@ -591,7 +591,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
node_pointer pos = static_cast<node_pointer>(prev->next_);
|
node_pointer pos = static_cast<node_pointer>(prev->next_);
|
||||||
node_pointer end = static_cast<node_pointer>(pos->next_);
|
node_pointer end = static_cast<node_pointer>(pos->next_);
|
||||||
prev->next_ = pos->next_;
|
prev->next_ = pos->next_;
|
||||||
this->fix_buckets(bucket, prev, end);
|
this->fix_buckets(this_bucket, prev, end);
|
||||||
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
return this->delete_nodes(c_iterator(pos), c_iterator(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,11 +601,11 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
iterator next(r.node_);
|
iterator next(r.node_);
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
bucket_pointer bucket = this->get_bucket(
|
bucket_pointer this_bucket = this->get_bucket(
|
||||||
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
policy::to_bucket(this->bucket_count_, r.node_->hash_));
|
||||||
previous_pointer prev = unlink_node(*bucket, r.node_);
|
previous_pointer prev = unlink_node(*this_bucket, r.node_);
|
||||||
|
|
||||||
this->fix_buckets(bucket, prev, next.node_);
|
this->fix_buckets(this_bucket, prev, next.node_);
|
||||||
|
|
||||||
this->delete_node(r);
|
this->delete_node(r);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#pragma warning(disable:4512) // assignment operator could not be generated
|
#pragma warning(disable:4512) // assignment operator could not be generated
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test::seed_t seed(12847);
|
test::seed_t initialize_seed(12847);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct self_assign_base : public test::exception_base
|
struct self_assign_base : public test::exception_base
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
template <typename T> inline void avoid_unused_warning(T const&) {}
|
template <typename T> inline void avoid_unused_warning(T const&) {}
|
||||||
|
|
||||||
test::seed_t seed(91274);
|
test::seed_t initialize_seed(91274);
|
||||||
|
|
||||||
struct objects
|
struct objects
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
template <typename T> inline void avoid_unused_warning(T const&) {}
|
template <typename T> inline void avoid_unused_warning(T const&) {}
|
||||||
|
|
||||||
test::seed_t seed(73041);
|
test::seed_t initialize_seed(73041);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct copy_test1 : public test::exception_base
|
struct copy_test1 : public test::exception_base
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "../helpers/invariants.hpp"
|
#include "../helpers/invariants.hpp"
|
||||||
#include "../helpers/helpers.hpp"
|
#include "../helpers/helpers.hpp"
|
||||||
|
|
||||||
test::seed_t seed(835193);
|
test::seed_t initialize_seed(835193);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct erase_test_base : public test::exception_base
|
struct erase_test_base : public test::exception_base
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
test::seed_t seed(747373);
|
test::seed_t initialize_seed(747373);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct insert_test_base : public test::exception_base
|
struct insert_test_base : public test::exception_base
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
test::seed_t seed(3298597);
|
test::seed_t initialize_seed(3298597);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct rehash_test_base : public test::exception_base
|
struct rehash_test_base : public test::exception_base
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#pragma warning(disable:4512) // assignment operator could not be generated
|
#pragma warning(disable:4512) // assignment operator could not be generated
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test::seed_t seed(9387);
|
test::seed_t initialize_seed(9387);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct self_swap_base : public test::exception_base
|
struct self_swap_base : public test::exception_base
|
||||||
|
@ -219,14 +219,14 @@ namespace test
|
|||||||
data_.last_ptr_ = &data_.first_;
|
data_.last_ptr_ = &data_.first_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(const_iterator start, const_iterator end) {
|
void erase(const_iterator i, const_iterator j) {
|
||||||
node** ptr = &data_.first_;
|
node** ptr = &data_.first_;
|
||||||
|
|
||||||
while(*ptr != start.ptr_) {
|
while(*ptr != i.ptr_) {
|
||||||
ptr = &(*ptr)->next_;
|
ptr = &(*ptr)->next_;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(*ptr != end.ptr_) {
|
while(*ptr != j.ptr_) {
|
||||||
node* to_delete = *ptr;
|
node* to_delete = *ptr;
|
||||||
*ptr = (*ptr)->next_;
|
*ptr = (*ptr)->next_;
|
||||||
--data_.size_;
|
--data_.size_;
|
||||||
|
@ -124,8 +124,8 @@ namespace test
|
|||||||
: base()
|
: base()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit ordered(key_compare const& compare)
|
explicit ordered(key_compare const& kc)
|
||||||
: base(compare)
|
: base(kc)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void compare(X const& x)
|
void compare(X const& x)
|
||||||
@ -143,10 +143,10 @@ namespace test
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class It>
|
template <class It>
|
||||||
void insert_range(It begin, It end) {
|
void insert_range(It b, It e) {
|
||||||
while(begin != end) {
|
while(b != e) {
|
||||||
this->insert(*begin);
|
this->insert(*b);
|
||||||
++begin;
|
++b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace assign_tests {
|
namespace assign_tests {
|
||||||
|
|
||||||
test::seed_t seed(96785);
|
test::seed_t initialize_seed(96785);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void assign_tests1(T*,
|
void assign_tests1(T*,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace bucket_tests {
|
namespace bucket_tests {
|
||||||
|
|
||||||
test::seed_t seed(54635);
|
test::seed_t initialize_seed(54635);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
void tests(X* = 0, test::random_generator generator = test::default_generator)
|
void tests(X* = 0, test::random_generator generator = test::default_generator)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
namespace constructor_tests {
|
namespace constructor_tests {
|
||||||
|
|
||||||
test::seed_t seed(356730);
|
test::seed_t initialize_seed(356730);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void constructor_tests1(T*,
|
void constructor_tests1(T*,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "../helpers/equivalent.hpp"
|
#include "../helpers/equivalent.hpp"
|
||||||
#include "../helpers/invariants.hpp"
|
#include "../helpers/invariants.hpp"
|
||||||
|
|
||||||
test::seed_t seed(9063);
|
test::seed_t initialize_seed(9063);
|
||||||
|
|
||||||
namespace copy_tests
|
namespace copy_tests
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
namespace erase_tests
|
namespace erase_tests
|
||||||
{
|
{
|
||||||
|
|
||||||
test::seed_t seed(85638);
|
test::seed_t initialize_seed(85638);
|
||||||
|
|
||||||
template <class Container>
|
template <class Container>
|
||||||
void erase_tests1(Container*,
|
void erase_tests1(Container*,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
namespace find_tests
|
namespace find_tests
|
||||||
{
|
{
|
||||||
|
|
||||||
test::seed_t seed(78937);
|
test::seed_t initialize_seed(78937);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
void find_tests1(X*, test::random_generator generator = test::default_generator)
|
void find_tests1(X*, test::random_generator generator = test::default_generator)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace insert_tests {
|
namespace insert_tests {
|
||||||
|
|
||||||
test::seed_t seed(243432);
|
test::seed_t initialize_seed(243432);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
void unique_insert_tests1(X*,
|
void unique_insert_tests1(X*,
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
namespace load_factor_tests
|
namespace load_factor_tests
|
||||||
{
|
{
|
||||||
|
|
||||||
test::seed_t seed(783656);
|
test::seed_t initialize_seed(783656);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
void set_load_factor_tests(X* = 0)
|
void set_load_factor_tests(X* = 0)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
namespace move_tests
|
namespace move_tests
|
||||||
{
|
{
|
||||||
test::seed_t seed(98624);
|
test::seed_t initialize_seed(98624);
|
||||||
#if defined(BOOST_UNORDERED_USE_MOVE) || !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_UNORDERED_USE_MOVE) || !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
#define BOOST_UNORDERED_TEST_MOVING 1
|
#define BOOST_UNORDERED_TEST_MOVING 1
|
||||||
#else
|
#else
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
namespace rehash_tests
|
namespace rehash_tests
|
||||||
{
|
{
|
||||||
|
|
||||||
test::seed_t seed(2974);
|
test::seed_t initialize_seed(2974);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
|
bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
namespace swap_tests
|
namespace swap_tests
|
||||||
{
|
{
|
||||||
|
|
||||||
test::seed_t seed(783472);
|
test::seed_t initialize_seed(783472);
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
void swap_test_impl(X& x1, X& x2)
|
void swap_test_impl(X& x1, X& x2)
|
||||||
|
Reference in New Issue
Block a user