slice

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 1 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func At added in v0.21.5

func At[T any](slice []T, index int) T

At returns a bounds-safe value from a slice. If the index is out of bounds for the slice, then `At` returns the zero value for that type.

func AtOK added in v0.22.0

func AtOK[T any](slice []T, index int) (T, bool)

AtOK returns a bounds-safe value from a slice. If the index is out of bounds for the slice, then `At` returns the zero value for that type.

func Contains added in v0.2.0

func Contains[T comparable](slice []T, value T) bool

Contains scans a slice for a matching value, and returns TRUE if the value is found.

func ContainsAll added in v0.2.0

func ContainsAll[T comparable](slice []T, values ...T) bool

ContainsAll returns TRUE if the slice contains ALL of the provided values

func ContainsAny added in v0.14.0

func ContainsAny[T comparable](slice []T, values ...T) bool

ContainsAny returns TRUE if the slice contains ANY of the provided values

func Equal added in v0.5.1

func Equal[T comparable](value1 []T, value2 []T) bool

Equal returns true if the two slices are identical, having the same items in the same order, with no alterations.

func Filter

func Filter[T any](original []T, keep func(T) bool) []T

func Find added in v0.23.0

func Find[T any](slice []T, f func(T) bool) (T, bool)

Find returns the first element in the slice that satisfies the provided function.

func First added in v0.11.0

func First[T any](original []T, keep func(T) bool) T

func Map

func Map[T1 any, T2 any](source []T1, delta func(T1) T2) []T2

func NonZero added in v0.19.0

func NonZero[T comparable](original []T) []T

NonZero filters out all zero values from a slice

func Reverse added in v0.19.0

func Reverse[T any](x []T) []T

func Split added in v0.23.1

func Split[T any](slice []T) (T, []T)

func Unique added in v0.19.0

func Unique[T comparable](original []T) []T

Unique returns a new slice with all duplicate values removed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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