Documentation ¶
Index ¶
- func Clone[S ~[]E, E any](s S) S
- func Concat[S ~[]E, E any](slices ...S) S
- func Contains[S ~[]E, E comparable](slice S, x E) bool
- func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool
- func DeleteFunc[S ~[]E, E any](s S, del func(E) bool) S
- func Grow[S ~[]E, E any](s S, n int) S
- func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int
- func Remove[T comparable](slice []T, elem T) []T
- func Reverse[S ~[]E, E any](s S)
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.21 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.21 slices.Contains.
func ContainsFunc ¶
ContainsFunc reports whether at least one element e of s satisfies f(e). TODO(adonovan): use go1.21 slices.ContainsFunc.
func DeleteFunc ¶ added in v0.16.0
DeleteFunc removes any elements from s for which del returns true, returning the modified slice. DeleteFunc zeroes the elements between the new length and the original length. TODO(adonovan): use go1.21 slices.DeleteFunc.
func Grow ¶
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.21 slices.Grow.
func IndexFunc ¶
IndexFunc returns the first index i satisfying f(s[i]), or -1 if none do. TODO(adonovan): use go1.21 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.