* Removes a key-value pair from the map * * @param key - The key to remove * @returns True if the key was found and removed, false otherwise
(key: TKey)
| 123 | * @returns True if the key was found and removed, false otherwise |
| 124 | */ |
| 125 | delete(key: TKey): boolean { |
| 126 | if (this.map.has(key)) { |
| 127 | const oldValue = this.map.get(key) |
| 128 | const index = this.indexOf(key, oldValue!) |
| 129 | this.sortedKeys.splice(index, 1) |
| 130 | return this.map.delete(key) |
| 131 | } |
| 132 | |
| 133 | return false |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Checks if a key exists in the map |