Documentation
¶
Index ¶
- func ArrayEquals[T comparable](a []T, b []T) bool
- func CopyWithin[T any](slice []T, target int, start int, end int) []T
- func DefaultCompare[T constraints.Ordered](a, b T) bool
- func DefaultCompareC[T utils.Comparable[T]](a, b T) bool
- func Every[T any](slice []T, callback func(T) bool) bool
- func Fill[T any](slice []T, value T, start int, end int) []T
- func Filter[T any](slice []T, callback func(T) bool) []T
- func Find[T any](slice []T, callback func(T) bool) T
- func FindIndex[T any](slice []T, callback func(T) bool) int
- func ForEach[T any](slice []T, callback func(T))
- func Includes[T comparable](slice []T, value T) bool
- func Join[T any](slice []T, separator string) string
- func Map[T any, U any](slice []T, callback func(T) U) []U
- func Reduce[T any, U any](slice []T, callback func(U, T) U, initial U) U
- func Reverse[T any](slice []T) []T
- func Shift[T any](slice []T) []T
- func Some[T any](slice []T, callback func(T) bool) bool
- func Sort[T any](slice []T, compareFn func(T, T) bool) []T
- func Unshift[T any](slice []T, elems ...T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayEquals ¶
func ArrayEquals[T comparable](a []T, b []T) bool
ArrayEquals returns true if 'a' and 'b' are equal.
func CopyWithin ¶
CopyWithin copies slice[start:end] to slice[target:target+(start-end)]
func DefaultCompare ¶
func DefaultCompare[T constraints.Ordered](a, b T) bool
Default compare function for Sort[T] with Ordered type constraint.
func DefaultCompareC ¶
func DefaultCompareC[T utils.Comparable[T]](a, b T) bool
Default compare function for Sort[T] with Comparable type constraint.
Comparable type constraint is a custom constraint that checks the type to contain a Compare() method.
func Every ¶
Every returns true if all elements in the 'slice' satisfies the test implemented by the 'callback' function.
func FindIndex ¶
Find returns first element index in 'slice' that satisfies the given 'callback' function.
func ForEach ¶
func ForEach[T any](slice []T, callback func(T))
ForEach runs 'callback' function for each element in the 'slice'.
func Includes ¶
func Includes[T comparable](slice []T, value T) bool
Includes returns true if the 'slice' includes the given 'value', otherwise false.
func Reduce ¶
Reduce runs a function for each element in 'slice', and reduces it into a single value, using the given 'callback' function and 'initial' value.
func Shift ¶
func Shift[T any](slice []T) []T
Shift removes the first element from the 'slice' and returns it.
func Some ¶
Some returns true if some of the element(s) in the 'slice' satisfy the given 'callback' function, otherwise false.
Types ¶
This section is empty.