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

Method TotalProbeDistance

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

To distance that inserted elements were probed. Used for measuring how good hash functions are.

Source from the content-addressed store, hash-verified

449 // To distance that inserted elements were probed. Used for measuring how good hash functions
450 // are.
451 size_t TotalProbeDistance() const {
452 size_t total = 0;
453 for (size_t i = 0; i < NumBuckets(); ++i) {
454 const T& element = ElementForIndex(i);
455 if (!emptyfn_.IsEmpty(element)) {
456 size_t ideal_location = IndexForHash(hashfn_(element));
457 if (ideal_location > i) {
458 total += i + NumBuckets() - ideal_location;
459 } else {
460 total += i - ideal_location;
461 }
462 }
463 }
464 return total;
465 }
466
467 // Calculate the current load factor and return it.
468 double CalculateLoadFactor() const {

Callers

nothing calls this directly

Calls 1

IsEmptyMethod · 0.45

Tested by

no test coverage detected