gi2opt

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package gi2opt provides a set of generic iterator combinators over pairs of values iter.Seq adapted for optpair.Pair.

Index

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

func Max[V1, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

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

func MaxByLeft[V1 cmp.Ordered, V2 any](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

MaxByLeft returns the pair with the maximum left value or optpair.None if it is empty.

func MaxByRight

func MaxByRight[V1 any, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

MaxByRight returns the pair with the maximum right value or optpair.None if it is empty.

func Min

func Min[V1, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

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

func MinByLeft[V1 cmp.Ordered, V2 any](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

MinByLeft returns the pair with the minimum left value or optpair.None if pairs is empty.

func MinByRight

func MinByRight[V1 any, V2 cmp.Ordered](pairs iter.Seq2[V1, V2]) optpair.Pair[V1, V2]

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.

Jump to

Keyboard shortcuts

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