MCPcopy
hub / github.com/cornelk/hashmap / Get

Method Get

hashmap.go:47–60  ·  view source on GitHub ↗

Get retrieves an element from the map under given hash key.

(key Key)

Source from the content-addressed store, hash-verified

45
46// Get retrieves an element from the map under given hash key.
47func (m *Map[Key, Value]) Get(key Key) (Value, bool) {
48 hash := m.hasher(key)
49
50 for element := m.store.Load().item(hash); element != nil; element = element.Next() {
51 if element.keyHash == hash && element.key == key {
52 return element.Value(), true
53 }
54
55 if element.keyHash > hash {
56 return *new(Value), false
57 }
58 }
59 return *new(Value), false
60}
61
62// GetOrInsert returns the existing value for the key if present.
63// Otherwise, it stores and returns the given value.

Callers 15

TestHashCollisionFunction · 0.80
TestAliasTypeSupportFunction · 0.80
TestSetStringFunction · 0.80
TestSetUint8Function · 0.80
TestSetInt16Function · 0.80
TestSetFloat32Function · 0.80
TestSetFloat64Function · 0.80
TestSetInt64Function · 0.80
TestInsertFunction · 0.80
TestGetNonExistingItemFunction · 0.80
TestResizeFunction · 0.80
TestHashMap_parallelFunction · 0.80

Calls 3

itemMethod · 0.80
NextMethod · 0.80
ValueMethod · 0.80

Tested by 15

TestHashCollisionFunction · 0.64
TestAliasTypeSupportFunction · 0.64
TestSetStringFunction · 0.64
TestSetUint8Function · 0.64
TestSetInt16Function · 0.64
TestSetFloat32Function · 0.64
TestSetFloat64Function · 0.64
TestSetInt64Function · 0.64
TestInsertFunction · 0.64
TestGetNonExistingItemFunction · 0.64
TestResizeFunction · 0.64
TestHashMap_parallelFunction · 0.64