Documentation
¶
Overview ¶
Package iterutils provides functional utilities for working with Go 1.23+ iterators (iter.Seq and iter.Seq2), enabling lazy evaluation and efficient data processing.
See README.md for details.
Index ¶
- func All[V any](seq iter.Seq[V], f func(V) bool) bool
- func All2[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) bool
- func Any[V any](seq iter.Seq[V], f func(V) bool) bool
- func Any2[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) bool
- func Concat[V any](seqs ...iter.Seq[V]) iter.Seq[V]
- func Concat2[K, V any](seqs ...iter.Seq2[K, V]) iter.Seq2[K, V]
- func Contains[In comparable](seq iter.Seq[In], v In) bool
- func Contains2[K comparable, V comparable](seq iter.Seq2[K, V], k K, v V) bool
- func ContainsFunc[In any](seq iter.Seq[In], v In, f func(In, In) bool) bool
- func ContainsFunc2[K any, V any](seq iter.Seq2[K, V], k K, v V, f func(K, V, K, V) bool) bool
- func Empty[V any]() iter.Seq[V]
- func Empty2[K, V any]() iter.Seq2[K, V]
- func Equal[V comparable](x, y iter.Seq[V]) bool
- func Equal2[K, V comparable](x, y iter.Seq2[K, V]) bool
- func EqualFunc[V1, V2 any](x iter.Seq[V1], y iter.Seq[V2], f func(V1, V2) bool) bool
- func EqualFunc2[K1, V1, K2, V2 any](x iter.Seq2[K1, V1], y iter.Seq2[K2, V2], f func(K1, V1, K2, V2) bool) bool
- func Filter[V any](seq iter.Seq[V], f func(V) bool) iter.Seq[V]
- func Filter2[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) iter.Seq2[K, V]
- func Flatten[V any](seq iter.Seq[iter.Seq[V]]) iter.Seq[V]
- func Flatten2[K, V any](seq iter.Seq[iter.Seq2[K, V]]) iter.Seq2[K, V]
- func Map[In, Out any](seq iter.Seq[In], f func(In) Out) iter.Seq[Out]
- func Map2[KIn, KOut, VIn, VOut any](seq iter.Seq2[KIn, VIn], f func(KIn, VIn) (KOut, VOut)) iter.Seq2[KOut, VOut]
- func MapKeys2[KIn, KOut, V any](seq iter.Seq2[KIn, V], f func(KIn, V) KOut) iter.Seq2[KOut, V]
- func MapValues2[K, VIn, VOut any](seq iter.Seq2[K, VIn], f func(K, VIn) VOut) iter.Seq2[K, VOut]
- func Reduce[Accum, V any](seq iter.Seq[V], accum Accum, f func(Accum, V) Accum) Accum
- func Reduce2[Accum, K, V any](seq iter.Seq2[K, V], accum Accum, f func(Accum, K, V) Accum) Accum
- func ReduceOrError[Accum, V any](seq iter.Seq[V], accum Accum, f func(Accum, V) (Accum, error)) (Accum, error)
- func ReduceOrError2[Accum, K, V any](seq iter.Seq2[K, V], accum Accum, f func(Accum, K, V) (Accum, error)) (Accum, error)
- func Truncate[V any](seq iter.Seq[V], n int) iter.Seq[V]
- func Truncate2[K, V any](seq iter.Seq2[K, V], n int) iter.Seq2[K, V]
- func Zip[V1, V2 any](x iter.Seq[V1], y iter.Seq[V2]) iter.Seq[Zipped[V1, V2]]
- func Zip2[K1, V1, K2, V2 any](x iter.Seq2[K1, V1], y iter.Seq2[K2, V2]) iter.Seq[Zipped2[K1, V1, K2, V2]]
- func ZipTruncate[V1, V2 any](x iter.Seq[V1], y iter.Seq[V2]) iter.Seq2[V1, V2]
- type Zipped
- type Zipped2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All2 ¶
All2 checks if all key-value pairs in the sequence satisfy the given predicate function.
func Any2 ¶
Any2 checks if any key-value pair in the sequence satisfies the given predicate function.
func Contains ¶
func Contains[In comparable](seq iter.Seq[In], v In) bool
Contains checks if the given value is present in the sequence.
func Contains2 ¶
func Contains2[K comparable, V comparable](seq iter.Seq2[K, V], k K, v V) bool
Contains2 checks if the given key-value pair is present in the sequence.
func ContainsFunc ¶
ConstainsFunc checks if the given value is present in the sequence using a custom equality function.
func ContainsFunc2 ¶
func Equal ¶
func Equal[V comparable](x, y iter.Seq[V]) bool
Equal checks if two sequences of the same value type are equal.
func Equal2 ¶
func Equal2[K, V comparable](x, y iter.Seq2[K, V]) bool
Equal2 checks if two sequences of key-value pairs are equal.
func EqualFunc2 ¶
func EqualFunc2[K1, V1, K2, V2 any](x iter.Seq2[K1, V1], y iter.Seq2[K2, V2], f func(K1, V1, K2, V2) bool) bool
EqualFunc2 checks if two sequences of key-value pairs are equal using a custom equality function.
func Filter2 ¶
Filter2 filters the key-value pairs of the sequence based on the given predicate function.
func Flatten ¶
Flatten flattens a sequence of sequences into a single sequence by yielding all elements from each inner sequence.
func Flatten2 ¶
Flatten2 flattens a sequence of key-value pair sequences into a single key-value pair sequence.
func Map ¶
Map applies the given function to each element of the input sequence and returns a new sequence of the results.
func Map2 ¶
func Map2[KIn, KOut, VIn, VOut any](seq iter.Seq2[KIn, VIn], f func(KIn, VIn) (KOut, VOut)) iter.Seq2[KOut, VOut]
Map2 applies the given function to each key-value pair of the input sequence and returns a new sequence of the results.
func MapKeys2 ¶
MapKeys2 applies the given function to each key of the input key-value pair sequence and returns a new sequence with transformed keys.
func MapValues2 ¶
MapValues2 applies the given function to each value of the input key-value pair sequence and returns a new sequence with transformed values.
func Reduce2 ¶
Reduce2 reduces the sequence of key-value pairs to a single value by applying the given binary function.
func ReduceOrError ¶
func ReduceOrError[Accum, V any](seq iter.Seq[V], accum Accum, f func(Accum, V) (Accum, error)) (Accum, error)
ReduceOrError reduces the sequence to a single value by applying the given binary function that can return an error.
func ReduceOrError2 ¶
func ReduceOrError2[Accum, K, V any](seq iter.Seq2[K, V], accum Accum, f func(Accum, K, V) (Accum, error)) (Accum, error)
ReduceOrError2 reduces the sequence of key-value pairs to a single value by applying the given binary function that can return an error.
Types ¶
type Zipped ¶
type Zipped[V1, V2 any] struct { V1 V1 Ok1 bool // whether V1 is present (if not, it will be false) V2 V2 Ok2 bool // whether V2 is present (if not, it will be false) }
Zipped represents a pair of values from two sequences, along with flags indicating their presence.
type Zipped2 ¶
type Zipped2[K1, V1, K2, V2 any] struct { K1 K1 V1 V1 Ok1 bool // whether K1, V1 are present (if not, they will be false) K2 K2 V2 V2 Ok2 bool // whether K2, V2 are present (if not, they will be false) }
Zipped2 represents a pair of key-value pairs from two sequences, along with flags indicating their presence.