Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

Commit d8ae7e9

Browse files
committed
data-structures: clarify HAMT.Set with an existing key
That is, we should modify an existing key-value pair, instead of inserting a new pair and ending up with duplicate keys.
1 parent 5b8f87f commit d8ae7e9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

data-structures/hashmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Notes:
168168
2. If `(depth x bitWidth) / 8` is less than the number of bytes in the hash, repeat with the child node identified in step **3**.
169169
2. If the `dataIndex` element of `data` contains a bucket (array) and the bucket's size is less than `bucketSize`:
170170
1. Mutate the current node (create a copy).
171-
2. Insert the `key` / `value` pair into the new bucket at a position sorted by `key` such that all entries in the bucket are ordered respective to their `key`s. This helps ensure canonical form.
171+
2. If `key` is already present in the new bucket, change its corresponding `value` to the new one. Otherwise, insert the `key` / `value` pair at a position sorted by `key` such that all entries in the bucket are ordered respective to their `key`s. This helps ensure canonical form.
172172
3. Proceed to create new CIDs for the current block and each parent as per step **6.c**. until we have a new root block and its CID.
173173
3. If the `dataIndex` element of `data` contains a bucket (array) and the bucket's size is `bucketSize`:
174174
1. Create a new empty node

0 commit comments

Comments
 (0)