MCPcopy Create free account
hub / github.com/NetSys/bess / EmplaceEntry

Method EmplaceEntry

core/utils/cuckoo_map.h:392–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390 // Return the pointer to the entry if success. Otherwise return nullptr.
391 template <typename... Args>
392 Entry* EmplaceEntry(HashResult primary, HashResult secondary, const K& key,
393 const H& hasher, Args&&... args) {
394 HashResult primary_bucket_index, secondary_bucket_index;
395 Entry* entry = nullptr;
396 again:
397 primary_bucket_index = primary & bucket_mask_;
398 if ((entry = EmplaceInBucket(primary_bucket_index, key, hasher,
399 std::forward<Args>(args)...)) != nullptr) {
400 return entry;
401 }
402
403 secondary_bucket_index = secondary & bucket_mask_;
404 if ((entry = EmplaceInBucket(secondary_bucket_index, key, hasher,
405 std::forward<Args>(args)...)) != nullptr) {
406 return entry;
407 }
408
409 if (MakeSpace(primary_bucket_index, 0, hasher) >= 0) {
410 goto again;
411 }
412
413 if (MakeSpace(secondary_bucket_index, 0, hasher) >= 0) {
414 goto again;
415 }
416
417 return nullptr;
418 }
419
420 // Return an empty slot index in the bucket
421 int FindEmptySlot(const Bucket& bucket) const {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected