Documentation
¶
Overview ¶
Package gi2opt provides a set of generic iterator combinators over pairs of values iter.Seq adapted for optpair.Pair.
Index ¶
- func FilterMap[V1, V2, R1, R2 any, F func(V1, V2) optpair.Pair[R1, R2]](pairs iter.Seq2[V1, V2], f F) iter.Seq2[R1, R2]
- func FilterMapWith[V1, V2, R1, R2 any, F func(V1, V2) optpair.Pair[R1, R2]](f F) func(pairs iter.Seq2[V1, V2]) iter.Seq2[R1, R2]
- func Find[V1, V2 any, P constraints.Predicate2[V1, V2]](values iter.Seq2[V1, V2], predicate P) optpair.Pair[V1, V2]
- func FindWith[V1, V2 any, P constraints.Predicate2[V1, V2]](predicate P) func(iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func Max[V1, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func MaxBy[V1, V2 any, K cmp.Ordered, F ~func(V1, V2) K](pairs iter.Seq2[V1, V2], key F) optpair.Pair[V1, V2]
- func MaxByLeft[V1 cmp.Ordered, V2 any](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func MaxByRight[V1 any, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func Min[V1, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func MinBy[V1, V2 any, K cmp.Ordered, F ~func(V1, V2) K](pairs iter.Seq2[V1, V2], key F) optpair.Pair[V1, V2]
- func MinByLeft[V1 cmp.Ordered, V2 any](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func MinByRight[V1 any, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
- func Reduce[V1, V2 any, F ~func(V1, V2, V1, V2) (V1, V2)](values iter.Seq2[V1, V2], accumulate F) optpair.Pair[V1, V2]
- func ReduceWith[V1, V2 any, F ~func(V1, V2, V1, V2) (V1, V2)](accumulate F) func(iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMap ¶
func FilterMap[V1, V2, R1, R2 any, F func(V1, V2) optpair.Pair[R1, R2]](pairs iter.Seq2[V1, V2], f F) iter.Seq2[R1, R2]
FilterMap returns an iterator that yields the results of applying f to each pair of values. If f returns empty optional pair, it is skipped.
func FilterMapWith ¶
func FilterMapWith[V1, V2, R1, R2 any, F func(V1, V2) optpair.Pair[R1, R2]](f F) func(pairs iter.Seq2[V1, V2]) iter.Seq2[R1, R2]
FilterMapWith returns a function that transforms an iterator sequence over pairs to an iterator sequence over pairs. It uses the provided filter-map function to transform and filter pairs. If f returns empty optional pair, it is skipped.
func Find ¶
func Find[V1, V2 any, P constraints.Predicate2[V1, V2]](values iter.Seq2[V1, V2], predicate P) optpair.Pair[V1, V2]
Find returns the first pair among the pairs matching the predicate.
func FindWith ¶
func FindWith[V1, V2 any, P constraints.Predicate2[V1, V2]](predicate P) func(iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
FindWith returns a function that finds the first pair among the pairs matching the predicate.
func Max ¶
Max returns the maximum pair of the given pair sequence or optpair.None if it is empty.
func MaxBy ¶
func MaxBy[V1, V2 any, K cmp.Ordered, F ~func(V1, V2) K](pairs iter.Seq2[V1, V2], key F) optpair.Pair[V1, V2]
MaxBy returns the maximum pair of the given pair sequence or optpair.None if it is empty. It uses the provided key function for comparison.
func MaxByLeft ¶
MaxByLeft returns the pair with the maximum left value or optpair.None if it is empty.
func MaxByRight ¶
MaxByRight returns the pair with the maximum right value or optpair.None if it is empty.
func Min ¶
Min returns minimum pair of the given pair or optpair.None if pairs is empty.
func MinBy ¶
func MinBy[V1, V2 any, K cmp.Ordered, F ~func(V1, V2) K](pairs iter.Seq2[V1, V2], key F) optpair.Pair[V1, V2]
MinBy returns minimum pair of the given pair or optpair.None if pairs is empty. It uses provided key function for comparison.
func MinByLeft ¶
MinByLeft returns the pair with the minimum left value or optpair.None if pairs is empty.
func MinByRight ¶
MinByRight returns the pair with the minimum right value or optpair.None if pairs is empty.
func Reduce ¶
func Reduce[V1, V2 any, F ~func(V1, V2, V1, V2) (V1, V2)](values iter.Seq2[V1, V2], accumulate F) optpair.Pair[V1, V2]
Reduce reduces the values to a value which is the accumulated result of running accumulate function on each element where each successive invocation is supplied the return value of the previous one.
Reduce returns [optval.None] if the sequence is empty.
func ReduceWith ¶
func ReduceWith[V1, V2 any, F ~func(V1, V2, V1, V2) (V1, V2)](accumulate F) func(iter.Seq2[V1, V2]) optpair.Pair[V1, V2]
ReduceWith returns a function that reduces the values to a value which is the accumulated result of running accumulate function on each element where each successive invocation is supplied the return value of the previous one.
Types ¶
This section is empty.