mirror of
https://github.com/boostorg/unordered.git
synced 2025-08-01 04:14:29 +02:00
adjusted hysteresis factor in unchecked_emplace_with_rehash
This commit is contained in:
@@ -1654,11 +1654,15 @@ private:
|
|||||||
/* Due to the anti-drift mechanism (see recover_slot), new_arrays_ may be
|
/* Due to the anti-drift mechanism (see recover_slot), new_arrays_ may be
|
||||||
* of the same size as the old arrays; in the limit, erasing one element at
|
* of the same size as the old arrays; in the limit, erasing one element at
|
||||||
* full load and then inserting could bring us back to the same capacity
|
* full load and then inserting could bring us back to the same capacity
|
||||||
* after a costly rehash. We introduce a 10% level of hysteresis to avoid
|
* after a costly rehash. To avoid this, we jump to the next capacity level
|
||||||
* that (the size_/10 addendum).
|
* when the number of erased elements is <= 10% of total elements at full
|
||||||
|
* load, which is implemented by requesting additional F*size elements,
|
||||||
|
* with F = P * 10% / (1 - P * 10%), where P is the probability of an
|
||||||
|
* element having caused overflow; P has been determined to be ~0.187 via
|
||||||
|
* simulation, yielding F ~ 0.019 ~ 1/52.
|
||||||
*/
|
*/
|
||||||
auto new_arrays_=new_arrays(std::size_t(
|
auto new_arrays_=new_arrays(std::size_t(
|
||||||
std::ceil(static_cast<float>(size_+size_/10+1)/mlf)));
|
std::ceil(static_cast<float>(size_+size_/52+1)/mlf)));
|
||||||
iterator it;
|
iterator it;
|
||||||
BOOST_TRY{
|
BOOST_TRY{
|
||||||
/* strong exception guarantee -> try insertion before rehash */
|
/* strong exception guarantee -> try insertion before rehash */
|
||||||
|
Reference in New Issue
Block a user