Del deletes the key from the map and returns whether the key was deleted.
(key Key)
| 102 | |
| 103 | // Del deletes the key from the map and returns whether the key was deleted. |
| 104 | func (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 |