slices

package
v0.9.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[S ~[]E, E any](s S) S

Clone returns a copy of the slice. The elements are copied using assignment, so this is a shallow clone. TODO(rfindley): use go1.19 slices.Clone.

func Concat

func Concat[S ~[]E, E any](slices ...S) S

Concat returns a new slice concatenating the passed in slices. TODO(rfindley): use go1.22 slices.Concat.

func Contains

func Contains[S ~[]E, E comparable](slice S, x E) bool

Contains reports whether x is present in slice. TODO(adonovan): use go1.19 slices.Contains.

func ContainsFunc

func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool

ContainsFunc reports whether at least one element e of s satisfies f(e). TODO(adonovan): use go1.19 slices.ContainsFunc.

func Grow

func Grow[S ~[]E, E any](s S, n int) S

Grow increases the slice's capacity, if necessary, to guarantee space for another n elements. After Grow(n), at least n elements can be appended to the slice without another allocation. If n is negative or too large to allocate the memory, Grow panics. TODO(rfindley): use go1.19 slices.Grow.

func IndexFunc

func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int

IndexFunc returns the first index i satisfying f(s[i]), or -1 if none do. TODO(adonovan): use go1.19 slices.IndexFunc.

func Remove

func Remove[T comparable](slice []T, elem T) []T

Remove removes all values equal to elem from slice.

The closest equivalent in the standard slices package is:

DeleteFunc(func(x T) bool { return x == elem })

Types

This section is empty.

Jump to

Keyboard shortcuts

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