The map iterator implementation was only handling buckets in the
Element unions. This meant that if the length of HAMT is sufficiently
large, such that Elements could contain a link to a node, the map
iterator would panic.
To avoid this, load the Element link when it is encountered and
populate the iterator steps appropriately so that the entire map is
traversed.
Add tests that assert the map iterator functions as expected: traverses
the entire map, and returns each key exactly once.
Avoid panicing by letting Done proceed and retrospectively return
errors via Next as stated in MapIterator.Done interface
documentation.
The map iterator implementation was only handling buckets in the
Element
unions. This meant that if the length of HAMT is sufficiently large, such thatElement
s could contain a link to a node, the map iterator would panic.To avoid this, load the
Element
link when it is encountered and populate the iterator steps appropriately so that the entire map is traversed.Add tests that assert the map iterator functions as expected: traverses the entire map, and returns each key exactly once.
Avoid
panic
ing by lettingDone
proceed and retrospectively return errors viaNext
as stated inMapIterator.Done
interface documentation.