forked from boostorg/unordered
Expand calls to erase implementation
Doesn't work as well as the previous changes.
This commit is contained in:
@ -2708,6 +2708,8 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Data access
|
// Data access
|
||||||
|
|
||||||
|
static node_pointer get_node(c_iterator it) { return it.node_; }
|
||||||
|
|
||||||
bucket_allocator const& bucket_alloc() const { return allocators_.first(); }
|
bucket_allocator const& bucket_alloc() const { return allocators_.first(); }
|
||||||
|
|
||||||
node_allocator const& node_alloc() const { return allocators_.second(); }
|
node_allocator const& node_alloc() const { return allocators_.second(); }
|
||||||
@ -4175,22 +4177,6 @@ struct table_unique : boost::unordered::detail::table<Types>
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator erase(c_iterator r)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(r.node_);
|
|
||||||
node_pointer next = node_algo::next_node(r.node_);
|
|
||||||
erase_nodes(r.node_, next);
|
|
||||||
return iterator(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator erase_range(c_iterator r1, c_iterator r2)
|
|
||||||
{
|
|
||||||
if (r1 == r2)
|
|
||||||
return iterator(r2.node_);
|
|
||||||
erase_nodes(r1.node_, r2.node_);
|
|
||||||
return iterator(r2.node_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void erase_nodes(node_pointer i, node_pointer j)
|
void erase_nodes(node_pointer i, node_pointer j)
|
||||||
{
|
{
|
||||||
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
||||||
@ -4832,22 +4818,6 @@ struct table_equiv : boost::unordered::detail::table<Types>
|
|||||||
return deleted_count;
|
return deleted_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator erase(c_iterator r)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(r.node_);
|
|
||||||
node_pointer next = node_algo::next_node(r.node_);
|
|
||||||
erase_nodes(r.node_, next);
|
|
||||||
return iterator(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator erase_range(c_iterator r1, c_iterator r2)
|
|
||||||
{
|
|
||||||
if (r1 == r2)
|
|
||||||
return iterator(r2.node_);
|
|
||||||
erase_nodes(r1.node_, r2.node_);
|
|
||||||
return iterator(r2.node_);
|
|
||||||
}
|
|
||||||
|
|
||||||
link_pointer erase_nodes(node_pointer i, node_pointer j)
|
link_pointer erase_nodes(node_pointer i, node_pointer j)
|
||||||
{
|
{
|
||||||
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
|
||||||
|
@ -55,6 +55,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
|||||||
typedef boost::unordered::detail::map<A, K, T, H, P> types;
|
typedef boost::unordered::detail::map<A, K, T, H, P> types;
|
||||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||||
typedef typename types::table table;
|
typedef typename types::table table;
|
||||||
|
typedef typename table::node_pointer node_pointer;
|
||||||
typedef typename table::link_pointer link_pointer;
|
typedef typename table::link_pointer link_pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -837,6 +838,7 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
|||||||
typedef boost::unordered::detail::multimap<A, K, T, H, P> types;
|
typedef boost::unordered::detail::multimap<A, K, T, H, P> types;
|
||||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||||
typedef typename types::table table;
|
typedef typename types::table table;
|
||||||
|
typedef typename table::node_pointer node_pointer;
|
||||||
typedef typename table::link_pointer link_pointer;
|
typedef typename table::link_pointer link_pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1531,14 +1533,22 @@ template <class K, class T, class H, class P, class A>
|
|||||||
typename unordered_map<K, T, H, P, A>::iterator
|
typename unordered_map<K, T, H, P, A>::iterator
|
||||||
unordered_map<K, T, H, P, A>::erase(iterator position)
|
unordered_map<K, T, H, P, A>::erase(iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
typename unordered_map<K, T, H, P, A>::iterator
|
typename unordered_map<K, T, H, P, A>::iterator
|
||||||
unordered_map<K, T, H, P, A>::erase(const_iterator position)
|
unordered_map<K, T, H, P, A>::erase(const_iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
@ -1552,7 +1562,11 @@ template <class K, class T, class H, class P, class A>
|
|||||||
typename unordered_map<K, T, H, P, A>::iterator
|
typename unordered_map<K, T, H, P, A>::iterator
|
||||||
unordered_map<K, T, H, P, A>::erase(const_iterator first, const_iterator last)
|
unordered_map<K, T, H, P, A>::erase(const_iterator first, const_iterator last)
|
||||||
{
|
{
|
||||||
return table_.erase_range(first, last);
|
node_pointer last_node = table::get_node(last);
|
||||||
|
if (first == last)
|
||||||
|
return iterator(last_node);
|
||||||
|
table_.erase_nodes(table::get_node(first), last_node);
|
||||||
|
return iterator(last_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
@ -1974,14 +1988,22 @@ template <class K, class T, class H, class P, class A>
|
|||||||
typename unordered_multimap<K, T, H, P, A>::iterator
|
typename unordered_multimap<K, T, H, P, A>::iterator
|
||||||
unordered_multimap<K, T, H, P, A>::erase(iterator position)
|
unordered_multimap<K, T, H, P, A>::erase(iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
typename unordered_multimap<K, T, H, P, A>::iterator
|
typename unordered_multimap<K, T, H, P, A>::iterator
|
||||||
unordered_multimap<K, T, H, P, A>::erase(const_iterator position)
|
unordered_multimap<K, T, H, P, A>::erase(const_iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
@ -1996,7 +2018,11 @@ typename unordered_multimap<K, T, H, P, A>::iterator
|
|||||||
unordered_multimap<K, T, H, P, A>::erase(
|
unordered_multimap<K, T, H, P, A>::erase(
|
||||||
const_iterator first, const_iterator last)
|
const_iterator first, const_iterator last)
|
||||||
{
|
{
|
||||||
return table_.erase_range(first, last);
|
node_pointer last_node = table::get_node(last);
|
||||||
|
if (first == last)
|
||||||
|
return iterator(last_node);
|
||||||
|
table_.erase_nodes(table::get_node(first), last_node);
|
||||||
|
return iterator(last_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
|
@ -53,6 +53,7 @@ template <class T, class H, class P, class A> class unordered_set
|
|||||||
typedef boost::unordered::detail::set<A, T, H, P> types;
|
typedef boost::unordered::detail::set<A, T, H, P> types;
|
||||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||||
typedef typename types::table table;
|
typedef typename types::table table;
|
||||||
|
typedef typename table::node_pointer node_pointer;
|
||||||
typedef typename table::link_pointer link_pointer;
|
typedef typename table::link_pointer link_pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -563,6 +564,7 @@ template <class T, class H, class P, class A> class unordered_multiset
|
|||||||
typedef boost::unordered::detail::multiset<A, T, H, P> types;
|
typedef boost::unordered::detail::multiset<A, T, H, P> types;
|
||||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||||
typedef typename types::table table;
|
typedef typename types::table table;
|
||||||
|
typedef typename table::node_pointer node_pointer;
|
||||||
typedef typename table::link_pointer link_pointer;
|
typedef typename table::link_pointer link_pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1226,7 +1228,11 @@ template <class T, class H, class P, class A>
|
|||||||
typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
|
typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
|
||||||
const_iterator position)
|
const_iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
@ -1240,7 +1246,11 @@ template <class T, class H, class P, class A>
|
|||||||
typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
|
typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
|
||||||
const_iterator first, const_iterator last)
|
const_iterator first, const_iterator last)
|
||||||
{
|
{
|
||||||
return table_.erase_range(first, last);
|
node_pointer last_node = table::get_node(last);
|
||||||
|
if (first == last)
|
||||||
|
return iterator(last_node);
|
||||||
|
table_.erase_nodes(table::get_node(first), last_node);
|
||||||
|
return iterator(last_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
@ -1608,7 +1618,11 @@ template <class T, class H, class P, class A>
|
|||||||
typename unordered_multiset<T, H, P, A>::iterator
|
typename unordered_multiset<T, H, P, A>::iterator
|
||||||
unordered_multiset<T, H, P, A>::erase(const_iterator position)
|
unordered_multiset<T, H, P, A>::erase(const_iterator position)
|
||||||
{
|
{
|
||||||
return table_.erase(position);
|
node_pointer node = table::get_node(position);
|
||||||
|
BOOST_ASSERT(node);
|
||||||
|
node_pointer next = table::node_algo::next_node(node);
|
||||||
|
table_.erase_nodes(node, next);
|
||||||
|
return iterator(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
@ -1622,7 +1636,11 @@ template <class T, class H, class P, class A>
|
|||||||
typename unordered_multiset<T, H, P, A>::iterator
|
typename unordered_multiset<T, H, P, A>::iterator
|
||||||
unordered_multiset<T, H, P, A>::erase(const_iterator first, const_iterator last)
|
unordered_multiset<T, H, P, A>::erase(const_iterator first, const_iterator last)
|
||||||
{
|
{
|
||||||
return table_.erase_range(first, last);
|
node_pointer last_node = table::get_node(last);
|
||||||
|
if (first == last)
|
||||||
|
return iterator(last_node);
|
||||||
|
table_.erase_nodes(table::get_node(first), last_node);
|
||||||
|
return iterator(last_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
|
Reference in New Issue
Block a user