fix: prevent duplicate keys by reusing tombstones in map probe sequence
Previously, when inserting a key that already existed in the map but was located after a tombstone in the probe sequence, the insertion would stop at the first tombstone and add the key there, resulting in duplicate entries for the same key. This fix introduces a `findEntry` function that tracks the first encountered tombstone during probing and reuses it for insertion only when the key is not found elsewhere in the sequence.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Regression test for #373.
|
||||
var map = {}
|
||||
map[2] = "two"
|
||||
map[0] = "zero"
|
||||
map.remove(2)
|
||||
map[0] = "zero again"
|
||||
map.remove(0)
|
||||
|
||||
System.print(map.containsKey(0)) // expect: false
|
||||
Reference in New Issue
Block a user