Documentation ¶
Overview ¶
Package slice provides generic functions for slice types
Index ¶
- Variables
- func Clone[T any, TS ~[]T](elements TS) []T
- func Delete[T any, TS ~[]T](index int, elements TS) []T
- func Filter[T any, TS ~[]T](elements TS, filter c.Predicate[T]) []T
- func Flatt[From, To any, FS ~[]From](elements FS, by c.Flatter[From, To]) []To
- func For[T any, TS ~[]T](elements TS, walker func(T) error) error
- func ForEach[T any, TS ~[]T](elements TS, walker func(T))
- func ForEachRef[T any, TS ~[]*T](references TS, walker func(T))
- func Get[T any, TS ~[]T](elements TS, index int) (T, bool)
- func Group[T any, K comparable, TS ~[]T](elements TS, by c.Converter[T, K]) map[K][]T
- func Of[T any](elements ...T) []T
- func Range[T constraints.Integer](from T, to T) []T
- func Reduce[T any, TS ~[]T](elements TS, by op.Binary[T]) T
- func Reverse[T any, TS ~[]T](elements TS) []T
- func Sort[T any, TS ~[]T](elements TS, less func(e1, e2 T) bool) []T
- func SortByOrdered[T any, o constraints.Ordered, TS ~[]T](elements TS, by c.Converter[T, o]) []T
- func ToString[T any, TS ~[]T](elements TS) string
- func ToStringRefs[T any, TS ~[]*T](references TS) string
- func ToStringRefsf[T any, TS ~[]*T](references TS, elementFormat, nilValue, delimeter string) string
- func ToStringf[T any, TS ~[]T](elements TS, elementFormat, delimeter string) string
- func Track[T any, TS ~[]T](elements TS, tracker func(int, T) error) error
- func TrackEach[T any, TS ~[]T](elements TS, tracker func(int, T))
Constants ¶
This section is empty.
Variables ¶
var ErrBreak = it.ErrBreak
ErrBreak is the 'break' statement of the For, Track methods
Functions ¶
func Clone ¶ added in v0.0.2
func Clone[T any, TS ~[]T](elements TS) []T
Clone makes new slice instance with copied elements.
func ForEach ¶
func ForEach[T any, TS ~[]T](elements TS, walker func(T))
ForEach applies walker to elements without error checking.
func ForEachRef ¶
func ForEachRef[T any, TS ~[]*T](references TS, walker func(T))
ForEachRef applies walker to references without error checking
func Get ¶
Get returns an element from elements by index, otherwise, if the provided index is ouf of the elements, returns zero T and false in the second result
func Group ¶
func Group[T any, K comparable, TS ~[]T](elements TS, by c.Converter[T, K]) map[K][]T
Group converts the slice into a map with keys computeable by a Converter.
func Range ¶
func Range[T constraints.Integer](from T, to T) []T
Range generates a sclice of integers in the range defined by from and to inclusive.
func SortByOrdered ¶
func SortByOrdered[T any, o constraints.Ordered, TS ~[]T](elements TS, by c.Converter[T, o]) []T
SortByOrdered sorts elements in place by converting them to Ordered values and applying the operator <
func ToStringRefs ¶
ToStringRefs converts references to the default string representation
func ToStringRefsf ¶
func ToStringRefsf[T any, TS ~[]*T](references TS, elementFormat, nilValue, delimeter string) string
ToStringRefsf converts references to a string representation defined by a delimiter and a nil value representation
func ToStringf ¶
ToStringf converts elements to a string representation defined by a custom element format and a delimiter
Types ¶
This section is empty.