Documentation
¶
Overview ¶
Package slices contains a utility functions to work with slices.
Index ¶
- func Clip[S ~[]E, E any](s S) Sdeprecated
- func Clone[S ~[]E, E any](s S) Sdeprecated
- func Contains[T any](s []T, fn func(T) bool) booldeprecated
- func Copy[S ~[]V, V any](s S, n int) Sdeprecated
- func Filter[S ~[]T, T any](slc S, fn func(T) bool) Sdeprecated
- func FilterInPlace[S ~[]V, V any](slc S, fn func(V) bool) Sdeprecated
- func FlatMap[T, R any](slc []T, fn func(T) []R) []Rdeprecated
- func Grow[S ~[]E, E any](s S, n int) Sdeprecated
- func IndexFunc[T any](slc []T, fn func(T) bool) intdeprecated
- func Map[T, R any](slc []T, fn func(T) R) []Rdeprecated
- func ToMap[T any, K comparable, V any](slc []T, fn func(T) (K, V)) map[K]Vdeprecated
- func ToSet[T comparable](slc []T) map[T]struct{}deprecated
- func ToSetFunc[T any, K comparable](slc []T, fn func(T) K) map[K]struct{}deprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clip
deprecated
added in
v0.4.5
func Clip[S ~[]E, E any](s S) S
Clip removes unused capacity from the slice, returning s[:len(s):len(s)].
Deprecated: Use slices.Clip instead.
func Clone
deprecated
added in
v0.4.5
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.
Deprecated: Use slices.Clone instead.
func Contains
deprecated
Contains reports whether v is present in s.
Deprecated: Use slices.ContainsFunc instead.
func Copy
deprecated
Copy copies first n elements. If n is greater than the length of the slice, it will copy the whole slice.
Deprecated: Use xslices.CopyN instead.
func Filter
deprecated
Filter returns a slice containing all the elements of s that satisfy fn.
Deprecated: Use xslices.Filter instead.
func FilterInPlace
deprecated
FilterInPlace filters the slice in place.
Deprecated: Use xslices.FilterInPlace instead.
func FlatMap
deprecated
func FlatMap[T, R any](slc []T, fn func(T) []R) []R
FlatMap applies the function fn to each element of the slice and returns a new slice with the results. It flattens the result of fn into the result slice.
Deprecated: Use xslices.FlatMap instead.
func Grow
deprecated
added in
v0.4.5
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.
Deprecated: Use slices.Grow instead.
func IndexFunc
deprecated
IndexFunc returns the first index satisfying fn(slc[i]), or -1 if none do.
Deprecated: Use slices.IndexFunc instead.
func Map
deprecated
func Map[T, R any](slc []T, fn func(T) R) []R
Map applies the function fn to each element of the slice and returns a new slice with the results.
Deprecated: Use xslices.Map instead.
func ToMap
deprecated
func ToMap[T any, K comparable, V any](slc []T, fn func(T) (K, V)) map[K]V
ToMap converts a slice to a map.
Deprecated: Use xslices.ToMap instead.
func ToSet
deprecated
func ToSet[T comparable](slc []T) map[T]struct{}
ToSet converts a slice to a set.
Deprecated: Use xslices.ToSet instead.
func ToSetFunc
deprecated
func ToSetFunc[T any, K comparable](slc []T, fn func(T) K) map[K]struct{}
ToSetFunc converts a slice to a set using the function fn.
Deprecated: Use xslices.ToSetFunc instead.
Types ¶
This section is empty.