Documentation
¶
Index ¶
- func All[T any](arr []T, check func(elem T) bool) bool
- func Compare[T comparable](arr1, arr2 []T) bool
- func CompareWith[T any](arr1, arr2 []T, cmp func(elem1, elem2 T) bool) bool
- func Filter[T any](arr []T, filter func(elem T) bool) []T
- func FindElem[T comparable](arr []T, elem T) (int, bool)
- func FindElemRef[T comparable](arr []T, elem T) (*T, bool)
- func FindMatch[T any](arr []T, match func(T) bool) (int, bool)
- func FindMatchRef[T any](arr []T, match func(T) bool) (*T, bool)
- func ForEach[T any](arr []T, action func(elem T) (breaking Break))
- func ForEachReverse[T any](arr []T, action func(elem T) (breaking Break))
- func Map[T1, T2 any](arr []T1, action func(elem T1) T2) []T2
- func MapRef[T1, T2 any](arr []T1, action func(elem *T1) T2) []T2
- func Reduce[T any](arr []T, reduce func(reduced, elem T) T) T
- func ReduceAs[T1, T2 any](arr []T1, reduce func(reduced T2, elem T1) T2) T2
- func Reversed[T any](arr []T) []T
- type Break
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶ added in v0.0.12
func Compare[T comparable](arr1, arr2 []T) bool
Compare two array with operator == on their element array of different size are not equal
func CompareWith ¶ added in v0.0.12
Compare two array with cmp function on their element array of different size are not equal
func Filter ¶ added in v0.0.10
Filter will generate a new slice containing only element that match the filter function (a match mean the function returns true)
func FindElem ¶ added in v0.0.11
func FindElem[T comparable](arr []T, elem T) (int, bool)
FindElem will return the index to the first element from 'arr' where 'arr[i] == elem' (with 'i' the index) it also returns a boolean set to true if the element is found and false otherwise If the element is not found the index is set to 0
func FindElemRef ¶ added in v0.0.11
func FindElemRef[T comparable](arr []T, elem T) (*T, bool)
FindElemRef will return a reference to the first element from 'arr' equal to 'elem' (using '==') along with a boolean that indicate if the element is found if the element is not found the boolean is false and the pointer is nil
func FindMatch ¶ added in v0.0.11
FindMatch do the same thing than FindMatchRef except it return the index instead of a reference it return 0 if the element is not found
func FindMatchRef ¶ added in v0.0.11
FindMatchRef will return the reference of the first element from 'arr' where 'match' is true it also returns a boolean that indicate wether the element is found or not if the element is not found, the pointer is nil
func ForEachReverse ¶ added in v0.0.10
ForEachReverse apply action like a for-range loop on a slice, in reversed order
func Map ¶ added in v0.0.10
func Map[T1, T2 any](arr []T1, action func(elem T1) T2) []T2
Map allows to generate a new slice from value of an existing one. If you need to get references of the existing slice use MapRef
func MapRef ¶ added in v0.0.10
func MapRef[T1, T2 any](arr []T1, action func(elem *T1) T2) []T2
MapRef allows to generate a new slice from reference's value of an existing one. If you don't need reference use Map
func Reduce ¶ added in v0.0.11
func Reduce[T any](arr []T, reduce func(reduced, elem T) T) T
Reduce like ReduceAs except the result type is the same as the array type.