sliceutil

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any added in v0.2.0

func Any[T any](ts []T) (T, bool)

Any returns an arbitrary element of the slice. If the slice is not empty, the second return value is true. Otherwise, Any returns the zero value of the slice's element type and false.

func Contains added in v0.3.5

func Contains[T comparable](ts []T, t T) bool

Contains returns true if the slice contains the given element.

func ContainsAll added in v0.3.5

func ContainsAll[T comparable](ts []T, ts2 []T) bool

ContainsAll returns true if the slice contains all elements of the given slice.

func Equal added in v0.4.0

func Equal[T comparable](s1 []T, s2 []T) bool

Equal returns true if the two slices are equal.

func Filter added in v0.2.0

func Filter[T any](ts []T, f func(i int, t T) bool) []T

func Generate

func Generate[T any](n int, f func(i int) T) []T

func Repeat

func Repeat[T any](value T, n int) []T

Repeat returns a slice with value repeated n times.

func Transform added in v0.2.0

func Transform[T, R any](ts []T, f func(i int, t T) R) []R

Types

This section is empty.

Jump to

Keyboard shortcuts

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