Documentation ¶
Overview ¶
Package slice provides generic functions to work with slices. Ideally this package will be replaced by a properly written and tested third-party package.
Index ¶
- func AppendAllMissing[S ~[]C, C comparable](existing *S, additional S)
- func Contains[C comparable](list []C, value C) bool
- func FindAll[C comparable](list []C, element C) []int
- func FirstElementOr[C comparable](list []C, alternative C) C
- func Hoist[S ~[]C, C comparable](list *S, needle C)
- func Remove[S ~[]C, C comparable](list *S, value C)
- func RemoveAt[S ~[]C, C comparable](list *S, index int)
- func TruncateLast[S ~[]C, C comparable](list *S)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendAllMissing ¶
func AppendAllMissing[S ~[]C, C comparable](existing *S, additional S)
AppendAllMissing appends all elements of `additional` that aren't contained in `existing` to `existing`.
func Contains ¶
func Contains[C comparable](list []C, value C) bool
Contains returns whether the given slice contains the given element.
func FindAll ¶
func FindAll[C comparable](list []C, element C) []int
FindAll provides the indexes of all occurrences of the given element in the given list.
func FirstElementOr ¶
func FirstElementOr[C comparable](list []C, alternative C) C
FirstElementOr provides the first element of the given list or the given alternative if the list is empty.
func Hoist ¶
func Hoist[S ~[]C, C comparable](list *S, needle C)
Hoist moves the given element in the given slice to the first position.
func Remove ¶
func Remove[S ~[]C, C comparable](list *S, value C)
Remove removes the given element from the given slice.
func RemoveAt ¶
func RemoveAt[S ~[]C, C comparable](list *S, index int)
RemoveAt removes the element at the given position from the given list.
func TruncateLast ¶
func TruncateLast[S ~[]C, C comparable](list *S)
TruncateLast removes the last element from the given list.
Types ¶
This section is empty.