mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 15:59:20 +03:00
swap based on dataIndex not raw hash map index
This commit is contained in:
parent
8a30615a20
commit
ac2380f6c8
@ -326,8 +326,9 @@ remove = \@Dict { metadata, dataIndices, data, size }, key ->
|
||||
when findIndexHelper metadata dataIndices data h2Key key probe 0 is
|
||||
Ok index ->
|
||||
last = List.len data - 1
|
||||
dataIndex = listGetUnsafe dataIndices index
|
||||
|
||||
if index == last then
|
||||
if dataIndex == last then
|
||||
@Dict {
|
||||
metadata: List.set metadata index deletedSlot,
|
||||
dataIndices,
|
||||
@ -731,6 +732,15 @@ expect
|
||||
|> remove 3
|
||||
keys dict == [2]
|
||||
|
||||
expect
|
||||
list =
|
||||
fromList [(T 1u8 1u8), (T 2u8 2u8), (T 3 3)]
|
||||
|> remove 1
|
||||
|> insert 0 0
|
||||
|> remove 3
|
||||
|> keys
|
||||
list == [0, 2]
|
||||
|
||||
# Reach capacity, no rehash.
|
||||
expect
|
||||
val =
|
||||
|
Loading…
Reference in New Issue
Block a user