MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / find

Method find

include/reactphysics3d/containers/Set.h:540–565  ·  view source on GitHub ↗

Try to find an item of the set given a key. The method returns an iterator to the found item or an iterator pointing to the end if not found

Source from the content-addressed store, hash-verified

538 /// The method returns an iterator to the found item or
539 /// an iterator pointing to the end if not found
540 Iterator find(const V& value) const {
541
542 uint64 bucket;
543 uint64 entry = INVALID_INDEX;
544
545 if (mHashSize > 0) {
546
547 const size_t hashCode = Hash()(value);
548 const size_t divider = mHashSize - 1;
549 bucket = static_cast<uint64>(hashCode & divider);
550 auto keyEqual = KeyEqual();
551
552 for (uint64 i = mBuckets[bucket]; i != INVALID_INDEX; i = mNextEntries[i]) {
553 if (Hash()(mEntries[i]) == hashCode && keyEqual(mEntries[i], value)) {
554 entry = i;
555 break;
556 }
557 }
558 }
559
560 if (entry == INVALID_INDEX) {
561 return end();
562 }
563
564 return Iterator(this, bucket, entry);
565 }
566
567 /// Overloaded equality operator
568 bool operator==(const Set<V>& set) const {

Callers

nothing calls this directly

Calls 1

IteratorClass · 0.70

Tested by

no test coverage detected