sets

package
v2.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[S ~map[T]struct{}, T comparable](s S, pred func(v T) bool) bool

All returns true if pred returns true for every element of the input sequence.

func Any

func Any[S ~map[T]struct{}, T comparable](s S, pred func(v T) bool) bool

Any returns true if pred returns true for any element of the input sequence.

func Collect

func Collect[T comparable](it iter.Seq[T]) fx.Set[T]

Collect collects the values in the input sequence into a set.

func Contains added in v2.0.10

func Contains[S ~map[T]struct{}, T comparable](s S, t T) bool

Contains returns true if the input sequence contains t.

func FMap

func FMap[S ~map[T]struct{}, T comparable, U any](s S, fn func(v T) (U, bool)) iter.Seq[U]

FMap returns a sequence of values computed by invoking fn on each element of the input sequence and returning only mapped values for with fn returns true.

func FMapUnpack added in v2.0.10

func FMapUnpack[S ~map[T]struct{}, T comparable, U any, V any](s S, fn func(v T) (U, V, bool)) iter.Seq2[U, V]

FMapUnpack returns a sequence of values computed by invoking fn on each element of the input sequence and returning only mapped values for with fn returns true.

func Filter

func Filter[S ~map[T]struct{}, T comparable](s S, fn func(v T) bool) iter.Seq[T]

Filter returns a sequence of values computed by invoking fn on each element of the input sequence and returning only those elements for with fn returns true.

func First added in v2.0.10

func First[S ~map[T]struct{}, T comparable](s S) (T, bool)

First returns the first element of it, if any elements exist.

func IntersectAll added in v2.0.10

func IntersectAll[T ~map[E]struct{}, E comparable](sets ...T) fx.Set[E]

IntersectAll returns a new set that is the intersection of the input sets.

func IntersectMany added in v2.0.10

func IntersectMany[T ~map[E]struct{}, E comparable](sets iter.Seq[T]) fx.Set[E]

IntersectMany returns a new set that is the intersection of the input sets.

func Intersection

func Intersection[T ~map[E]struct{}, U ~map[E]struct{}, E comparable](s1 T, s2 U) fx.Set[E]

Intersection returns a new set that is the intersection of the input sets.

func Last added in v2.0.10

func Last[S ~map[T]struct{}, T comparable](s S) (T, bool)

Last returns the last element of it, if any elements exist.

func Map

func Map[S ~map[T]struct{}, T comparable, U any](s S, fn func(v T) U) iter.Seq[U]

Map invokes fn on each value in the input sequence and returns the results.

func MapUnpack added in v2.0.10

func MapUnpack[S ~map[T]struct{}, T comparable, U any, V any](s S, fn func(v T) (U, V)) iter.Seq2[U, V]

MapUnpack invokes fn on each value in the input sequence and returns the results.

func OfType

func OfType[U any, S ~map[T]struct{}, T comparable](s S) iter.Seq[U]

OfType returns a sequence composed of all elements in the input sequence that are of type U.

func Reduce

func Reduce[S ~map[T]struct{}, T comparable, U any](s S, init U, fn func(acc U, v T) U) U

Reduce calls fn on each element of the input sequence, passing in the current value of the accumulator with each invocation and updating the accumulator to the result of fn after each invocation.

func Skip added in v2.0.10

func Skip[S ~map[T]struct{}, T comparable](s S, n int) iter.Seq[T]

Skip returns an iterator that skips n values from its source.

func Take

func Take[S ~map[T]struct{}, T comparable](s S, n int) iter.Seq[T]

Take returns an iterator that takes at most n values from its source.

func TryCollect

func TryCollect[T comparable](it iter.Seq2[T, error]) (fx.Set[T], error)

TryCollect attempts to collect the values in the input sequence into a set. If any pair in the input contains a non-nil error, TryCollect halts and returns the values collected up to that point (excluding the value returned with the error) and the error.

func Union

func Union[T ~map[E]struct{}, U ~map[E]struct{}, E comparable](s1 T, s2 U) fx.Set[E]

Union returns a new set that is the union of the input sets.

func UnionAll added in v2.0.10

func UnionAll[T ~map[E]struct{}, E comparable](sets ...T) fx.Set[E]

UnionAll returns a new set that is the union of the input sets.

func UnionMany added in v2.0.10

func UnionMany[T ~map[E]struct{}, E comparable](sets iter.Seq[T]) fx.Set[E]

UnionMany returns a new set that is the union of the input sets.

func Values

func Values[T ~map[E]struct{}, E comparable](s T) iter.Seq[E]

Values returns a sequence of each value in the input set. The ordering of elements is undefined.

Types

This section is empty.

Jump to

Keyboard shortcuts

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