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

Method erase

libCacheSim/dataStructure/sparsepp/spp.h:3311–3340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3309 }
3310
3311 size_type erase(const key_type& key)
3312 {
3313 size_type num_probes = 0; // how many times we've probed
3314 const size_type bucket_count_minus_one = bucket_count() - 1;
3315 size_type bucknum = hash(key) & bucket_count_minus_one;
3316
3317 while (1) // probe until something happens
3318 {
3319 typename Table::GrpPos grp_pos(table, bucknum);
3320
3321 if (!grp_pos.test_strict())
3322 return 0; // bucket is empty, we deleted nothing
3323 if (grp_pos.test())
3324 {
3325 reference ref(grp_pos.unsafe_get());
3326
3327 if (equals(key, get_key(ref)))
3328 {
3329 grp_pos.erase(table);
3330 ++num_deleted;
3331 settings.set_consider_shrink(true); // will think about shrink after next insert
3332 return 1; // because we deleted one thing
3333 }
3334 }
3335 ++num_probes; // we're doing another probe
3336 bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one;
3337 assert(num_probes < bucket_count()
3338 && "Hashtable is full: an error in key_equal<> or hash<>");
3339 }
3340 }
3341
3342 const_iterator erase(const_iterator pos)
3343 {

Callers

nothing calls this directly

Calls 9

hashClass · 0.85
assertFunction · 0.85
cendFunction · 0.85
set_consider_shrinkMethod · 0.80
test_strictMethod · 0.45
testMethod · 0.45
unsafe_getMethod · 0.45
eraseMethod · 0.45
num_nonemptyMethod · 0.45

Tested by

no test coverage detected