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

Method Del

hashmap.go:104–121  ·  view source on GitHub ↗

Del deletes the key from the map and returns whether the key was deleted.

(key Key)

Source from the content-addressed store, hash-verified

102
103// Del deletes the key from the map and returns whether the key was deleted.
104func (m *Map[Key, Value]) Del(key Key) bool {
105 hash := m.hasher(key)
106 store := m.store.Load()
107 element := store.item(hash)
108
109 for ; element != nil; element = element.Next() {
110 if element.keyHash == hash && element.key == key {
111 m.deleteElement(element)
112 m.linkedList.Delete(element)
113 return true
114 }
115
116 if element.keyHash > hash {
117 return false
118 }
119 }
120 return false
121}
122
123// Insert sets the value under the specified key to the map if it does not exist yet.
124// If a resizing operation is happening concurrently while calling Insert, the item might show up in the map

Callers 2

TestDeleteFunction · 0.80
TestHashMap_parallelFunction · 0.80

Calls 4

deleteElementMethod · 0.95
itemMethod · 0.80
NextMethod · 0.80
DeleteMethod · 0.80

Tested by 2

TestDeleteFunction · 0.64
TestHashMap_parallelFunction · 0.64