Changeset View
Changeset View
Standalone View
Standalone View
src/cuckoocache.h
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | public: | ||||
* @param erase | * @param erase | ||||
* | * | ||||
* @post if erase is true and the element is found, then the garbage collect | * @post if erase is true and the element is found, then the garbage collect | ||||
* flag is set | * flag is set | ||||
* @returns true if the element is found, false otherwise | * @returns true if the element is found, false otherwise | ||||
*/ | */ | ||||
inline bool contains(const Element &e, const bool erase) const { | inline bool contains(const Element &e, const bool erase) const { | ||||
std::array<uint32_t, 8> locs = compute_hashes(e); | std::array<uint32_t, 8> locs = compute_hashes(e); | ||||
for (uint32_t loc : locs) | for (uint32_t loc : locs) { | ||||
if (table[loc] == e) { | if (table[loc] == e) { | ||||
if (erase) allow_erase(loc); | if (erase) { | ||||
allow_erase(loc); | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
} | |||||
return false; | return false; | ||||
} | } | ||||
}; | }; | ||||
} // namespace CuckooCache | } // namespace CuckooCache | ||||
#endif | #endif |