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

Method FindIndex

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

Source from the content-addressed store, hash-verified

556 // This value for not found is important so that iterator(this, FindIndex(...)) == end().
557 template <typename K>
558 size_t FindIndex(const K& element, size_t hash) const {
559 // Guard against failing to get an element for a non-existing index.
560 if (UNLIKELY(NumBuckets() == 0)) {
561 return 0;
562 }
563 DCHECK_EQ(hashfn_(element), hash);
564 size_t index = IndexForHash(hash);
565 while (true) {
566 const T& slot = ElementForIndex(index);
567 if (emptyfn_.IsEmpty(slot)) {
568 return NumBuckets();
569 }
570 if (pred_(slot, element)) {
571 return index;
572 }
573 index = NextIndex(index);
574 }
575 }
576
577 bool IsFreeSlot(size_t index) const {
578 return emptyfn_.IsEmpty(ElementForIndex(index));

Callers

nothing calls this directly

Calls 1

IsEmptyMethod · 0.45

Tested by

no test coverage detected