Skip to content

Add Iterators (Go 1.23) #1

Description

@AndrewWPhillips

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions