MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / Reserve

Method Reserve

Bcore/src/main/cpp/base/hash_set.h:438–447  ·  view source on GitHub ↗

Reserve enough room to insert until Size() == num_elements without requiring to grow the hash set. No-op if the hash set is already large enough to do this.

Source from the content-addressed store, hash-verified

436 // Reserve enough room to insert until Size() == num_elements without requiring to grow the hash
437 // set. No-op if the hash set is already large enough to do this.
438 void Reserve(size_t num_elements) {
439 size_t num_buckets = num_elements / max_load_factor_;
440 // Deal with rounding errors. Add one for rounding.
441 while (static_cast<size_t>(num_buckets * max_load_factor_) <= num_elements + 1u) {
442 ++num_buckets;
443 }
444 if (num_buckets > NumBuckets()) {
445 Resize(num_buckets);
446 }
447 }
448
449 // To distance that inserted elements were probed. Used for measuring how good hash functions
450 // are.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected