Change the load factor of the hash set. If the current load factor is greater than the max specified, then we resize the hash table storage.
| 500 | // Change the load factor of the hash set. If the current load factor is greater than the max |
| 501 | // specified, then we resize the hash table storage. |
| 502 | void SetLoadFactor(double min_load_factor, double max_load_factor) { |
| 503 | DCHECK_LT(min_load_factor, max_load_factor); |
| 504 | DCHECK_GT(min_load_factor, 0.0); |
| 505 | DCHECK_LT(max_load_factor, 1.0); |
| 506 | min_load_factor_ = min_load_factor; |
| 507 | max_load_factor_ = max_load_factor; |
| 508 | elements_until_expand_ = NumBuckets() * max_load_factor_; |
| 509 | // If the current load factor isn't in the range, then resize to the mean of the minimum and |
| 510 | // maximum load factor. |
| 511 | const double load_factor = CalculateLoadFactor(); |
| 512 | if (load_factor > max_load_factor_) { |
| 513 | Resize(Size() / ((min_load_factor_ + max_load_factor_) * 0.5)); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | // The hash set expands when Size() reaches ElementsUntilExpand(). |
| 518 | size_t ElementsUntilExpand() const { |
nothing calls this directly
no outgoing calls
no test coverage detected