mirror of
https://github.com/boostorg/unordered.git
synced 2026-04-28 18:02:21 +02:00
@@ -387,6 +387,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
void reserve_for_insert(std::size_t);
|
||||
void rehash(std::size_t);
|
||||
void reserve(std::size_t);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -402,7 +403,9 @@ namespace boost { namespace unordered { namespace detail {
|
||||
this->create_buckets();
|
||||
this->max_load_ = this->calculate_max_load();
|
||||
}
|
||||
else if(size >= max_load_) {
|
||||
// According to the standard this should be 'size >= max_load_',
|
||||
// but I think this is better, defect report filed.
|
||||
else if(size > max_load_) {
|
||||
std::size_t num_buckets
|
||||
= this->min_buckets_for_size((std::max)(size,
|
||||
this->size_ + (this->size_ >> 1)));
|
||||
@@ -417,7 +420,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// strong otherwise.
|
||||
|
||||
template <typename Types>
|
||||
void table<Types>::rehash(std::size_t min_buckets)
|
||||
inline void table<Types>::rehash(std::size_t min_buckets)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
@@ -437,6 +440,13 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Types>
|
||||
inline void table<Types>::reserve(std::size_t num_elements)
|
||||
{
|
||||
rehash(static_cast<std::size_t>(
|
||||
std::ceil(static_cast<double>(num_elements) / this->mlf_)));
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -515,6 +515,7 @@ namespace unordered
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
||||
friend bool operator==<K,T,H,P,A>(
|
||||
@@ -997,6 +998,7 @@ namespace unordered
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
||||
friend bool operator==<K,T,H,P,A>(
|
||||
@@ -1300,6 +1302,12 @@ namespace unordered
|
||||
table_.rehash(n);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_map<K,T,H,P,A>::reserve(size_type n)
|
||||
{
|
||||
table_.reserve(n);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
inline bool operator==(
|
||||
unordered_map<K,T,H,P,A> const& m1,
|
||||
@@ -1606,6 +1614,12 @@ namespace unordered
|
||||
table_.rehash(n);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_multimap<K,T,H,P,A>::reserve(size_type n)
|
||||
{
|
||||
table_.reserve(n);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
inline bool operator==(
|
||||
unordered_multimap<K,T,H,P,A> const& m1,
|
||||
|
||||
@@ -500,6 +500,7 @@ namespace unordered
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
||||
friend bool operator==<T,H,P,A>(
|
||||
@@ -972,6 +973,7 @@ namespace unordered
|
||||
float load_factor() const;
|
||||
void max_load_factor(float);
|
||||
void rehash(size_type);
|
||||
void reserve(size_type);
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
||||
friend bool operator==<T,H,P,A>(
|
||||
@@ -1226,6 +1228,12 @@ namespace unordered
|
||||
table_.rehash(n);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_set<T,H,P,A>::reserve(size_type n)
|
||||
{
|
||||
table_.reserve(n);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
inline bool operator==(
|
||||
unordered_set<T,H,P,A> const& m1,
|
||||
@@ -1504,6 +1512,12 @@ namespace unordered
|
||||
table_.rehash(n);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_multiset<T,H,P,A>::reserve(size_type n)
|
||||
{
|
||||
table_.reserve(n);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
inline bool operator==(
|
||||
unordered_multiset<T,H,P,A> const& m1,
|
||||
|
||||
Reference in New Issue
Block a user