Documentation ¶
Index ¶
- func Count[T comparable](collection []T) (count int)
- func CountBy[T any](collection []T, predicate func(item T) bool) (count int)
- func Each[T any](collection []T, iteratee func(item T, index int))
- func Filter[V any](collection []V, predicate func(item V, index int) bool) []V
- func GroupBy[T any, U comparable](collection []T, iteratee func(item T) U) map[U][]T
- func Keys[K comparable, V any](in map[K]V) []K
- func Map[T any, R any](collection []T, iteratee func(item T, index int) R) []R
- func Max[T constraints.Ordered](collection []T) T
- func Merge[K comparable, V any](maps ...map[K]V) map[K]V
- func Min[T constraints.Ordered](collection []T) T
- func Reverse[T any](collection []T) []T
- func Shuffle[T any](collection []T) []T
- func Split[T any](collection []T, size int) [][]T
- func Sum[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
- func Unique[T comparable](collection []T) []T
- func Values[K comparable, V any](in map[K]V) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count[T comparable](collection []T) (count int)
Count counts the number of elements in the collection.
func Filter ¶
Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for.
func GroupBy ¶
func GroupBy[T any, U comparable](collection []T, iteratee func(item T) U) map[U][]T
GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee.
func Max ¶
func Max[T constraints.Ordered](collection []T) T
Max searches the maximum value of a collection.
func Merge ¶
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
Merge merges multiple maps from left to right.
func Min ¶
func Min[T constraints.Ordered](collection []T) T
Min search the minimum value of a collection.
func Reverse ¶
func Reverse[T any](collection []T) []T
Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
func Shuffle ¶
func Shuffle[T any](collection []T) []T
Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm.
func Split ¶
Split returns an array of elements split into groups the length of size. If array can't be split evenly,
func Sum ¶
func Sum[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
Sum sums the values in a collection. If collection is empty 0 is returned.
func Unique ¶
func Unique[T comparable](collection []T) []T
Unique returns a duplicate-free version of an array, in which only the first occurrence of each element is kept.
func Values ¶
func Values[K comparable, V any](in map[K]V) []V
Values creates an array of the map values.
Types ¶
This section is empty.