Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HashMap: allow valueIterable to be iterated more than once #27

Merged
merged 1 commit into from
Jan 22, 2019
Merged

Conversation

wuzzeb
Copy link
Contributor

@wuzzeb wuzzeb commented Jan 21, 2019

Iterators are stateful and can't be reused. Therefore, the iterator protocol
makes Iterable's contain a zero-argument function which creates a new iterator,
and re-calls this zero-argument function to create a new iterator every time
an iteration starts.

hamt.values() returns an iterator which is stateful, so it must be wrapped in
a zero-argument function to become an Iterable.

Iterators are stateful and can't be reused.  Therefore, the iterator protocol
makes Iterable's contain a zero-argument function which creates a new iterator,
and re-calls this zero-argument function to create a new iterator every time
an iteration starts.

hamt.values() returns an iterator which is stateful, so it must be wrapped in
a zero-argument function to become an Iterable<T>.
@emmanueltouzery emmanueltouzery merged commit addc21f into emmanueltouzery:master Jan 22, 2019
@emmanueltouzery
Copy link
Owner

Thank you for the pull request! It looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants