Documentation
¶
Index ¶
- func Concat[T any](slices ...[]T) []T
- func Diff[T comparable](a, b []T) []T
- func Filter[T any](a []T, cb func(a T) bool) []T
- func MakePointers[T any](n int) []*T
- func Map[T, U any](s []T, fn func(e T) U) []U
- func MustIndex[S ~[]E, E comparable](s S, v E) int
- func MustPop[T any](s *[]T) T
- func Pop[T any](s *[]T) (T, bool)
- func Sum[N constraints.Integer | constraints.Float | constraints.Complex](s []N) N
- func Unique[T comparable](a []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Concat ¶ added in v0.3.0
func Concat[T any](slices ...[]T) []T
Concat concatenates multiple slices together into a single slice. The input slices are not modified, order is preserved and the returned slice is exactly sized to hold its elements.
func Diff ¶
func Diff[T comparable](a, b []T) []T
Diff returns `a` with all elements occurring in `b` removed.
func MakePointers ¶ added in v0.15.0
MakePointers creates a slice of pointers and allocates the entries.
All Ts are allocated in a single batch, and won't be garbage collected until the entire batch is no longer referenced.
func Map ¶ added in v0.8.0
func Map[T, U any](s []T, fn func(e T) U) []U
Map returns a new slice with every element from `s` converted by `fn`.
func MustIndex ¶ added in v0.19.0
func MustIndex[S ~[]E, E comparable](s S, v E) int
MustIndex is like slices.Index, but panics instead of returning -1.
func MustPop ¶ added in v0.18.0
func MustPop[T any](s *[]T) T
MustPop returns the last element of a slice, and shrinks the slice by one. MustPop panics if the slice is empty.
func Pop ¶ added in v0.18.0
Pop returns the last element of a slice, and shrinks the slice by one. Pop returns _, false iff the given slice is empty.
func Sum ¶ added in v0.7.0
func Sum[N constraints.Integer | constraints.Float | constraints.Complex](s []N) N
Sum all entries in a slice together.
func Unique ¶
func Unique[T comparable](a []T) []T
Unique returns `a` with all duplicate elements removed. Order is preserved.
Types ¶
This section is empty.