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

Add Iterators (Go 1.23) #1

Open
AndrewWPhillips opened this issue Aug 16, 2024 · 0 comments
Open

Add Iterators (Go 1.23) #1

AndrewWPhillips opened this issue Aug 16, 2024 · 0 comments

Comments

@AndrewWPhillips
Copy link
Owner

This issue is to track adding support for iterators (added to Go 1.23 on 2024/08/14). Currently, a rangeset can return a slice of elements (method Values()) and a slice of ranges (method Spans()). We'd always intended to add some sort of iterators as working with whole slices is cumbersome and inefficient.

Callers of the existing methods would often be much better served by iterators instead of slices. For example, you don't need to get the whole slice before starting to use it, and can terminate at any time. This is particularly relevant to rangesets as they can be easily be used to represent a huge number of elements.

The proposal is to supplement Values() method with two methods called All() and Backwards() which allow iteration over all the elements in the normal and reverse direction. Similarly, we'll add SpansValues() and SpansBackwards().

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

No branches or pull requests

1 participant