Documentation
¶
Index ¶
- func AddUnique[T comparable](slice []T, elem T) []T
- func Average[T Number](slice []T) T
- func Concat[T any](s ...[]T) []T
- func Contains[T comparable](slice []T, elem T) bool
- func ContainsPredicate[T comparable](slice []T, predicate func(elem T) bool) bool
- func Difference[T comparable](slice1, slice2 []T) []T
- func Filter[T any](slice []T, filter func(T) bool) []T
- func Intersection[T comparable](arrays ...[]T) []T
- func IsSliceConsecutive[T constraints.Integer](slice []T) (int, bool)
- func IsSubset[T comparable](subset, superset []T) bool
- func Map[T, V any](slice []T, filter func(T) V) []V
- func Max[T constraints.Ordered](s []T) (m T)
- func Median[T Number](slice []T) T
- func Min[T constraints.Ordered](s []T) (m T)
- func Percentile[T Number](slice []T, rank float64, reverse bool) T
- func Remove[T comparable](slice []T, elem T) ([]T, bool)
- func Slice[T any](v ...T) []T
- func SortStable[T constraints.Ordered](slice []T)
- func SplitGenericSliceIntoChunks[T any](arr []T, chunkSize int) [][]T
- func Stability[T Number](slice []T, compare T) float64
- func Union[T comparable](arrays ...[]T) []T
- func UnionByFunc[T ComparableByFunc](arrays ...[]T) []T
- func UnorderedEqual[T comparable](slices ...[]T) bool
- func Variance[T Number](slice []T, mean T) T
- type ComparableByFunc
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUnique ¶
func AddUnique[T comparable](slice []T, elem T) []T
func Contains ¶
func Contains[T comparable](slice []T, elem T) bool
func ContainsPredicate ¶
func ContainsPredicate[T comparable](slice []T, predicate func(elem T) bool) bool
func Difference ¶
func Difference[T comparable](slice1, slice2 []T) []T
func Intersection ¶
func Intersection[T comparable](arrays ...[]T) []T
func IsSliceConsecutive ¶
func IsSliceConsecutive[T constraints.Integer](slice []T) (int, bool)
This function is used to check if the slice is consecutive. It returns the index of the first non-consecutive element or 0 if all elements are consecutive.
func IsSubset ¶
func IsSubset[T comparable](subset, superset []T) bool
func Max ¶
func Max[T constraints.Ordered](s []T) (m T)
func Min ¶
func Min[T constraints.Ordered](s []T) (m T)
func Percentile ¶
Percentile returns the value at the given rank in the slice. If reverse is true, the slice is sorted in descending order. If reverse is false, the slice is sorted in ascending order.
func Remove ¶
func Remove[T comparable](slice []T, elem T) ([]T, bool)
Remove removes the first instance (if exists) of elem from the slice, and returns the new slice and indication if removal took place.
func SortStable ¶
func SortStable[T constraints.Ordered](slice []T)
func SplitGenericSliceIntoChunks ¶
splitSliceGeneric splits a slice into smaller slices of at most chunkSize length. for example len(arr) == 1400 and chunk size 500 will return [500, 500, 400]
func Stability ¶
the bigger it is the more unstable the values in slice from the given argument "compare"
func Union ¶
func Union[T comparable](arrays ...[]T) []T
func UnionByFunc ¶
func UnionByFunc[T ComparableByFunc](arrays ...[]T) []T
func UnorderedEqual ¶
func UnorderedEqual[T comparable](slices ...[]T) bool
Types ¶
type ComparableByFunc ¶
type ComparableByFunc interface {
Differentiator() string
}
type Number ¶
type Number interface { constraints.Float | constraints.Integer }