Documentation
¶
Index ¶
- func Contains[E comparable](s []E, v E) bool
- func Filter[IN any, F FilterFunc[IN]](in []IN, fun F) []IN
- func First[IN any](in []IN) (IN, bool)
- func FlatMap[IN, OUT any, F FlatMapFunc[IN, OUT]](in []IN, fun F) []OUT
- func Item[T comparable](t T) func(T) bool
- func Last[IN any](in []IN) (IN, bool)
- func Map[IN, OUT any, F MapFunc[IN, OUT]](in []IN, fun F) []OUT
- func OfType[IN, T any](in []IN) []T
- func Reduce[IN, OUT any](in []IN, initializer OUT, fun AccumulatorFunc[IN, OUT]) OUT
- func Remove[IN comparable](in []IN, items ...IN) []IN
- type AccumulatorFunc
- type FilterFunc
- type FlatMapFunc
- type MapFunc
- type Safe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[E comparable](s []E, v E) bool
Contains checks for the existence of v in s.
func Filter ¶
func Filter[IN any, F FilterFunc[IN]](in []IN, fun F) []IN
Filter filters values from a slice using a filter function. Build returns a new slice with only the elements of s for which f returned true.
func FlatMap ¶
func FlatMap[IN, OUT any, F FlatMapFunc[IN, OUT]](in []IN, fun F) []OUT
FlatMap turns a []IN to a []OUT using a mapping function. This function has two type parameters, IN and OUT. This works with slices of any type.
func Item ¶ added in v0.30.39
func Item[T comparable](t T) func(T) bool
Item create a function that check equality to a supplied literal. It requires comparable items.
func Map ¶
Map turns a []IN to a []OUT using a mapping function. This function has two type parameters, IN and OUT. This works with slices of any type.
func OfType ¶
func OfType[IN, T any](in []IN) []T
OfType filters values from a slice satisfying a given type.
func Reduce ¶
func Reduce[IN, OUT any]( in []IN, initializer OUT, fun AccumulatorFunc[IN, OUT], ) OUT
Reduce reduces a []IN to a single value using an accumulator function.
func Remove ¶
func Remove[IN comparable](in []IN, items ...IN) []IN
Remove removes all items from the slice in place.
Types ¶
type AccumulatorFunc ¶
type FlatMapFunc ¶
type Safe ¶ added in v0.30.39
type Safe[T any] struct { // contains filtered or unexported fields }
Safe is a slice wrapper to provide some concurrent operations. It is optimized for reads using the copy-on-write idiom.