iterate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Done

func Done[V any](yield func(V) bool, done func()) func(V) bool

Done wraps yield and calls done when yield returns false.

func Done2

func Done2[K, V any](yield func(K, V) bool, done func()) func(K, V) bool

Done2 wraps yield and calls done when yield returns false.

func Once

func Once[V comparable](yield func(V) bool) func(V) bool

Once wraps yield to ensure each unique value is only yielded once.

func Once2

func Once2[K any, V comparable](yield func(K, V) bool) func(K, V) bool

Once2 wraps yield to ensure each unique value (but not key) is only yielded once. TODO: necessary?

Types

type Seq

type Seq[V any] func(yield func(V) bool)

Seq is an iterator over sequences of individual values. When called as seq(yield), seq calls yield(v) for each value v in the sequence, stopping early if yield returns false.

TODO: delete this once GOEXPERIMENT=rangefunc lands.

type Seq2

type Seq2[K, V any] func(yield func(K, V) bool)

Seq2 is an iterator over sequences of pairs of values, most commonly key-value pairs. When called as seq(yield), seq calls yield(k, v) for each pair (k, v) in the sequence, stopping early if yield returns false.

TODO: delete this once GOEXPERIMENT=rangefunc lands.

Jump to

Keyboard shortcuts

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