Instead of remembering the exact pointer we last iterated upon a
break, we remember the index within the linked list and re-iterate
to that index next time we're called. Using a pointer for this
problem would be problematic, probably (alliteration!), because the
linked list could change drastically in the mean time. Elements
could be removed, especially the one we were remembering. adding
checks to make that safe is a lot of hassle and not worth it.
As buckets are supposed to be very small anyway, we just remember
the index and if the list finished before we reach that index, so be
it, we just use the next bucket then.
Foreach support with counter
Instead of remembering the exact pointer we last iterated upon a break, we remember the index within the linked list and re-iterate to that index next time we're called. Using a pointer for this problem would be problematic, probably (alliteration!), because the linked list could change drastically in the mean time. Elements could be removed, especially the one we were remembering. adding checks to make that safe is a lot of hassle and not worth it.
As buckets are supposed to be very small anyway, we just remember the index and if the list finished before we reach that index, so be it, we just use the next bucket then.