mirror of https://github.com/golang/go.git
1.4 KiB
1.4 KiB
Iterators
The new [iter] package provides the basic definitions for working with user-defined iterators.
The [slices] package adds several functions that work with iterators:
- All returns an iterator over slice indexes and values.
- Values returns an iterator over slice elements.
- Backward returns an iterator that loops over a slice backward.
- Collect collects values from an iterator into a new slice.
- AppendSeq appends values from an iterator to an existing slice.
- Sorted collects values from an iterator into a new slice, and then sorts the slice.
- SortedFunc is like
Sortedbut with a comparison function. - SortedStableFunc is like
SortFuncbut uses a stable sort algorithm. - Chunk returns an iterator over consecutive sub-slices of up to n elements of a slice.
The [maps] package adds several functions that work with iterators: