mirror of
https://github.com/golang/go.git
synced 2025-05-09 01:23:01 +00:00
Chunk returns an iterator over consecutive sub-slices of up to n elements of s. Fixes #53987. Change-Id: I508274eca388db39550eb9e4d8abd5ce68d29d8d Reviewed-on: https://go-review.googlesource.com/c/go/+/562935 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
24 lines
1.0 KiB
Markdown
24 lines
1.0 KiB
Markdown
### Iterators
|
|
|
|
The new [`iter` package](/pkg/iter/) provides the basic definitions for
|
|
working with user-defined iterators.
|
|
|
|
The [`slices` package](/pkg/slices/) adds several functions that work
|
|
with iterators:
|
|
- [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.
|
|
- [Chunk](/pkg/slices#Chunk) returns an iterator over consecutive
|
|
sub-slices of up to n elements of a slice.
|