MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / find

Method find

libCacheSim/dataStructure/sparsepp/spp.h:3057–3081  ·  view source on GitHub ↗

I hate to duplicate find() like that, but it is significantly faster to not have the intermediate pair ------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3055 // significantly faster to not have the intermediate pair
3056 // ------------------------------------------------------------------
3057 iterator find(const key_type& key)
3058 {
3059 size_type num_probes = 0; // how many times we've probed
3060 const size_type bucket_count_minus_one = bucket_count() - 1;
3061 size_type bucknum = hash(key) & bucket_count_minus_one;
3062
3063 while (1) // probe until something happens
3064 {
3065 typename Table::GrpPos grp_pos(table, bucknum);
3066
3067 if (!grp_pos.test_strict())
3068 return end(); // bucket is empty
3069 if (grp_pos.test())
3070 {
3071 reference ref(grp_pos.unsafe_get());
3072
3073 if (equals(key, get_key(ref)))
3074 return grp_pos.get_iter(ref);
3075 }
3076 ++num_probes; // we're doing another probe
3077 bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one;
3078 assert(num_probes < bucket_count()
3079 && "Hashtable is full: an error in key_equal<> or hash<>");
3080 }
3081 }
3082
3083 // Wish I could avoid the duplicate find() const and non-const.
3084 // ------------------------------------------------------------

Callers 6

operator==Method · 0.45
findMethod · 0.45
containsMethod · 0.45
sparse_hash_mapClass · 0.45
findMethod · 0.45
containsMethod · 0.45

Calls 7

hashClass · 0.85
endFunction · 0.85
assertFunction · 0.85
test_strictMethod · 0.45
testMethod · 0.45
unsafe_getMethod · 0.45
get_iterMethod · 0.45

Tested by

no test coverage detected