Expand calls to clear implementation

This commit is contained in:
Daniel James
2017-04-23 10:09:18 +01:00
parent f6f5ecdc00
commit 814926ef31
3 changed files with 29 additions and 24 deletions

View File

@ -3078,17 +3078,6 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
BOOST_ASSERT(!size_);
}
void clear()
{
if (!size_)
return;
clear_buckets();
delete_nodes(get_previous_start(), link_pointer());
BOOST_ASSERT(!size_);
}
void destroy_buckets()
{
bucket_pointer end = get_bucket(bucket_count_ + 1);

View File

@ -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 typename types::value_allocator_traits value_allocator_traits;
typedef typename types::table table;
typedef typename table::link_pointer link_pointer;
public:
typedef typename value_allocator_traits::pointer pointer;
@ -836,6 +837,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 typename types::value_allocator_traits value_allocator_traits;
typedef typename types::table table;
typedef typename table::link_pointer link_pointer;
public:
typedef typename value_allocator_traits::pointer pointer;
@ -1483,7 +1485,7 @@ template <class K, class T, class H, class P, class A>
unordered_map<K, T, H, P, A>& unordered_map<K, T, H, P, A>::operator=(
std::initializer_list<value_type> list)
{
table_.clear();
this->clear();
table_.insert_range(list.begin(), list.end());
return *this;
}
@ -1557,7 +1559,10 @@ void unordered_map<K, T, H, P, A>::swap(unordered_map& other)
template <class K, class T, class H, class P, class A>
void unordered_map<K, T, H, P, A>::clear() BOOST_NOEXCEPT
{
table_.clear();
if (table_.size_) {
table_.clear_buckets();
table_.delete_nodes(table_.get_previous_start(), link_pointer());
}
}
template <class K, class T, class H, class P, class A>
@ -1912,7 +1917,7 @@ template <class K, class T, class H, class P, class A>
unordered_multimap<K, T, H, P, A>& unordered_multimap<K, T, H, P, A>::operator=(
std::initializer_list<value_type> list)
{
table_.clear();
this->clear();
table_.insert_range(list.begin(), list.end());
return *this;
}
@ -1987,7 +1992,10 @@ void unordered_multimap<K, T, H, P, A>::swap(unordered_multimap& other)
template <class K, class T, class H, class P, class A>
void unordered_multimap<K, T, H, P, A>::clear() BOOST_NOEXCEPT
{
table_.clear();
if (table_.size_) {
table_.clear_buckets();
table_.delete_nodes(table_.get_previous_start(), link_pointer());
}
}
// observers

View File

@ -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 typename types::value_allocator_traits value_allocator_traits;
typedef typename types::table table;
typedef typename table::link_pointer link_pointer;
public:
typedef typename value_allocator_traits::pointer pointer;
@ -562,6 +563,7 @@ template <class T, class H, class P, class A> class unordered_multiset
typedef boost::unordered::detail::multiset<A, T, H, P> types;
typedef typename types::value_allocator_traits value_allocator_traits;
typedef typename types::table table;
typedef typename table::link_pointer link_pointer;
public:
typedef typename value_allocator_traits::pointer pointer;
@ -1179,7 +1181,7 @@ template <class T, class H, class P, class A>
unordered_set<T, H, P, A>& unordered_set<T, H, P, A>::operator=(
std::initializer_list<value_type> list)
{
table_.clear();
this->clear();
table_.insert_range(list.begin(), list.end());
return *this;
}
@ -1245,13 +1247,10 @@ void unordered_set<T, H, P, A>::swap(unordered_set& other)
template <class T, class H, class P, class A>
void unordered_set<T, H, P, A>::clear() BOOST_NOEXCEPT
{
table_.clear();
}
template <class T, class H, class P, class A>
void unordered_multiset<T, H, P, A>::clear() BOOST_NOEXCEPT
{
table_.clear();
if (table_.size_) {
table_.clear_buckets();
table_.delete_nodes(table_.get_previous_start(), link_pointer());
}
}
// observers
@ -1553,7 +1552,7 @@ template <class T, class H, class P, class A>
unordered_multiset<T, H, P, A>& unordered_multiset<T, H, P, A>::operator=(
std::initializer_list<value_type> list)
{
table_.clear();
this->clear();
table_.insert_range(list.begin(), list.end());
return *this;
}
@ -1617,6 +1616,15 @@ void unordered_multiset<T, H, P, A>::swap(unordered_multiset& other)
table_.swap(other.table_);
}
template <class T, class H, class P, class A>
void unordered_multiset<T, H, P, A>::clear() BOOST_NOEXCEPT
{
if (table_.size_) {
table_.clear_buckets();
table_.delete_nodes(table_.get_previous_start(), link_pointer());
}
}
// observers
template <class T, class H, class P, class A>