Documentation
¶
Index ¶
- func Clone[T any](in []T) []T
- func Contains[T comparable](values []T, want T) bool
- func ContainsFunc[T any](values []T, match func(T) bool) bool
- func FilterMap[T any, U any](values []T, fn func(T) (U, bool)) []U
- func First[T any](values []T) T
- func IndexBy[T any, K comparable](values []T, key func(T) (K, bool)) map[K]int
- func Limit[T any](values []T, limit int) []T
- func LimitClone[T any](values []T, limit int) []T
- func Map[T any, U any](values []T, fn func(T) U) []U
- func ReverseClone[T any](in []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone[T any](in []T) []T
Clone returns a shallow copy of a slice while preserving nil input as nil.
func Contains ¶
func Contains[T comparable](values []T, want T) bool
Contains reports whether values includes want.
func ContainsFunc ¶
ContainsFunc reports whether any value satisfies match.
func FilterMap ¶
FilterMap returns mapped values for inputs accepted by fn while preserving nil input as nil. A nil fn rejects every value.
func First ¶
func First[T any](values []T) T
First returns the first value from values, or the zero value when values is empty.
func IndexBy ¶
func IndexBy[T any, K comparable](values []T, key func(T) (K, bool)) map[K]int
IndexBy builds an index of the first position for each accepted key in values.
func Limit ¶
Limit returns values truncated to at most limit items. A non-positive limit means no truncation, matching call sites where zero is an unset limit.
func LimitClone ¶
LimitClone returns a shallow copy truncated to at most limit items. A non-positive limit means no truncation.
func Map ¶
Map returns a slice containing fn applied to each value while preserving nil input as nil. A nil fn returns the zero value for each input element.
func ReverseClone ¶
func ReverseClone[T any](in []T) []T
ReverseClone returns a new slice with values from in in reverse order.
Types ¶
This section is empty.