2024-01-23 10:01:53 -07:00
|
|
|
### Iterators
|
|
|
|
|
2024-05-17 18:05:08 -06:00
|
|
|
The new [iter] package provides the basic definitions for working with
|
|
|
|
user-defined iterators.
|
2024-03-01 18:40:50 -07:00
|
|
|
|
2024-05-17 18:05:08 -06:00
|
|
|
The [slices] package adds several functions that work with iterators:
|
2024-03-01 18:40:50 -07:00
|
|
|
- [All](/pkg/slices#All) returns an iterator over slice indexes and values.
|
|
|
|
- [Values](/pkg/slices#Values) returns an iterator over slice elements.
|
|
|
|
- [Backward](/pkg/slices#Backward) returns an iterator that loops over
|
|
|
|
a slice backward.
|
|
|
|
- [Collect](/pkg/slices#Collect) collects values from an iterator into
|
|
|
|
a new slice.
|
|
|
|
- [AppendSeq](/pkg/slices#AppendSeq) appends values from an iterator to
|
|
|
|
an existing slice.
|
|
|
|
- [Sorted](/pkg/slices#Sorted) collects values from an iterator into a
|
|
|
|
new slice, and then sorts the slice.
|
|
|
|
- [SortedFunc](/pkg/slices#SortedFunc) is like `Sorted` but with a
|
|
|
|
comparison function.
|
|
|
|
- [SortedStableFunc](/pkg/slices#SortedStableFunc) is like `SortFunc`
|
|
|
|
but uses a stable sort algorithm.
|
2024-02-09 08:34:58 -07:00
|
|
|
- [Chunk](/pkg/slices#Chunk) returns an iterator over consecutive
|
|
|
|
sub-slices of up to n elements of a slice.
|
2024-05-20 03:04:15 -06:00
|
|
|
|
2024-05-17 18:05:08 -06:00
|
|
|
The [maps] package adds several functions that work with iterators:
|
2024-05-20 03:04:15 -06:00
|
|
|
- [All](/pkg/maps#All) returns an iterator over key-value pairs from m.
|
|
|
|
- [Keys](/pkg/maps#Keys) returns an iterator over keys in m.
|
|
|
|
- [Values](/pkg/maps#Values) returns an iterator over values in m.
|
|
|
|
- [Insert](/pkg/maps#Insert) adds the key-value pairs from seq to m.
|
|
|
|
- [Collect](/pkg/maps#Collect) collects key-value pairs from seq into a new map and returns it.
|