seq

package
v1.11.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](seq iter.Seq[T], fn func(T) bool) iter.Seq[T]

Filter is a function the yields only values for which the predicate returns `true`.

func Flatten

func Flatten[T any](seqs ...iter.Seq[T]) iter.Seq[T]

Flatten is a function that merges a set of provided `iter.Seq[T]` values into a single `iter.Seq[T]` value. The values of each input are yielded in the order yielded by each `iter.Seq[T]`, in the order provided to the function.

func Sequence

func Sequence[T any](items ...T) iter.Seq[T]

Sequence is a function that turns its input into an `iter.Seq[T]` that yields values in the order that they were provided to the function.

func Transform

func Transform[T any, U any](seq iter.Seq[T], fn func(T) U) iter.Seq[U]

Transform is a function that maps the values yielded by the input `seq` to values produced by the input function `fn`, and returns an `iter.Seq` that yields those new values.

Types

type SeqReader added in v1.11.3

type SeqReader[T any] struct {
	// contains filtered or unexported fields
}

SeqReader is a struct that provides functionality for reading from an iter.Seq value.

SeqReader is provided as a way to read chunks of values from an iter.Seq without needing to allocate a new slice for each chunk.

func NewSeqReader added in v1.11.3

func NewSeqReader[T any](seq iter.Seq[T]) *SeqReader[T]

NewSeqReader is a function that constructs a new SeqReader that wraps the given iter.Seq value.

func (*SeqReader[T]) Close added in v1.11.3

func (r *SeqReader[T]) Close() error

Close is a function that indicates that the caller will not continue to read from the iter.Seq. A call to Read after calling Close is considered a programming error.

func (*SeqReader[T]) Read added in v1.11.3

func (r *SeqReader[T]) Read(buf []T) int

Read is a function that fills the given buffer with elements from the internal iter.Seq value. A count of total items read into the buffer is returned. The count returned will be less than the size of the buffer when fewer items remain in the internal iter.Seq value. In this case, the sequence is complete and subsequent calls to Read will return a count of 0.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL