Documentation
¶
Index ¶
- Variables
- func All[S ~[]E, E any](s S, f Predicate[E]) bool
- func Any[S ~[]E, E any](s S, f Predicate[E]) bool
- func AppendSeqWithError[S ~[]E, E any](s S, seq iter.Seq2[E, error]) (S, error)
- func AppendUnique[S ~[]E, E comparable](s S, vs ...E) S
- func AppliedToEach[S ~[]E, E any, T any](s S, f func(E) T) iter.Seq[T]
- func ApplyToAll[S ~[]E1, E1, E2 any](s S, f func(E1) E2) []E2
- func ApplyToAllWithError[S ~[]E1, E1, E2 any](s S, f func(E1) (E2, error)) ([]E2, error)
- func BackwardValues[Slice ~[]E, E any](s Slice) iter.Seq[E]
- func CollectWithError[E any](seq iter.Seq2[E, error]) ([]E, error)
- func Filter[S ~[]E, E any](s S, f Predicate[E]) S
- func IndexOf[S ~[]any, E comparable](s S, v E) int
- func Range[T signed](start, stop, step T) []T
- func RemoveAll[S ~[]E, E comparable](s S, vs ...E) S
- func Reverse[S ~[]E, E any](s S) S
- func Strings[S ~[]E, E Stringable](s S) []string
- func Values[S ~[]*E, E any](s S) []E
- type FinderOptions
- type FinderOptionsFunc
- type Predicate
- type Stringable
Constants ¶
This section is empty.
Variables ¶
var WithReturnFirstMatch = func(o *FinderOptions) { o.returnFirstMatch = true }
WithReturnFirstMatch is a finder option to enable paginated operations to short circuit after the first filter match
This option should only be used when only a single match will ever be returned from the specified filter.
Functions ¶
func AppendSeqWithError ¶
AppendSeqWithError appends the values from seq to the slice and returns the extended slice. The first non-nil error in seq is returned. If seq is empty, the result preserves the nilness of s.
func AppendUnique ¶
func AppendUnique[S ~[]E, E comparable](s S, vs ...E) S
AppendUnique appends unique (not already in the slice) values to a slice.
func AppliedToEach ¶
AppliedToEach returns an iterator that yields the slice elements transformed by the function `f`.
func ApplyToAll ¶
func ApplyToAll[S ~[]E1, E1, E2 any](s S, f func(E1) E2) []E2
ApplyToAll returns a new slice containing the results of applying the function `f` to each element of the original slice `s`.
func ApplyToAllWithError ¶
func BackwardValues ¶
BackwardValues returns an iterator that yields the slice elements in reverse order. It is a values-only equivalent of `slices.Backward`.
func CollectWithError ¶
CollectWithError collects values from seq into a new slice and returns it. The first non-nil error in seq is returned. If seq is empty, the result is nil.
func Filter ¶
Filter returns a new slice containing all values that return `true` for the filter function `f`.
func IndexOf ¶
func IndexOf[S ~[]any, E comparable](s S, v E) int
IndexOf returns the index of the first occurrence of `v` in `s`, or -1 if not present. This function is similar to the `Index` function in the Go standard `slices` package, the difference being that `s` is a slice of `any` and a runtime type check is made.
func Range ¶
func Range[T signed](start, stop, step T) []T
Range returns a slice of integers from `start` to `stop` (exclusive) using the specified `step`.
func RemoveAll ¶
func RemoveAll[S ~[]E, E comparable](s S, vs ...E) S
RemoveAll removes all occurrences of the specified value `r` from a slice `s`.
func Strings ¶
func Strings[S ~[]E, E Stringable](s S) []string
Types ¶
type FinderOptions ¶
type FinderOptions struct {
// contains filtered or unexported fields
}
func NewFinderOptions ¶
func NewFinderOptions(optFns []FinderOptionsFunc) *FinderOptions
func (*FinderOptions) ReturnFirstMatch ¶
func (o *FinderOptions) ReturnFirstMatch() bool
type FinderOptionsFunc ¶
type FinderOptionsFunc func(*FinderOptions)
type Predicate ¶
Predicate represents a predicate (boolean-valued function) of one argument.
func PredicateAnd ¶
PredicateAnd returns a Predicate that evaluates to true if all of the specified predicates evaluate to true.
func PredicateEquals ¶
func PredicateEquals[T comparable](v T) Predicate[T]
PredicateEquals returns a Predicate that evaluates to true if the predicate's argument equals `v`.
func PredicateOr ¶
PredicateOr returns a Predicate that evaluates to true if any of the specified predicates evaluate to true.
func PredicateTrue ¶
PredicateTrue returns a Predicate that always evaluates to true.