Documentation
¶
Overview ¶
Package slices provides helpful functions for slices
Index ¶
- func Chunk[T any](slice []T, size int) [][]T
- func Contains[T comparable](slice []T, value T) bool
- func ContainsCount[T comparable](slice []T, value T) int
- func EqualsIgnoreOrder[ComparableSlice ~[]Type, Type comparable](s1 ComparableSlice, s2 ComparableSlice) bool
- func IndexOf[T comparable](slice []T, value T) int
- func IndexOfAll[T comparable](slice []T, value T) []int
- func Reverse[T any](slice []T)
- func Unique[T comparable](slice []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
Chunk returns a slice of slices of size Each of size specified - last may be smaller Panics when size <= 0
func Contains ¶
func Contains[T comparable](slice []T, value T) bool
Contains returns true if value is found Empty slice always returns false
func ContainsCount ¶
func ContainsCount[T comparable](slice []T, value T) int
ContainsCount gives back the count of value findings
func EqualsIgnoreOrder ¶
func EqualsIgnoreOrder[ComparableSlice ~[]Type, Type comparable](s1 ComparableSlice, s2 ComparableSlice) bool
EqualsIgnoreOrder compares two splices ignoring the order of elements It returns true if both slices contain the same elements (and same frequency of same elements), regardless of order
func IndexOf ¶
func IndexOf[T comparable](slice []T, value T) int
IndexOf returns index of first match. Similar to strings.Index Empty slice / no finding returns -1
func IndexOfAll ¶
func IndexOfAll[T comparable](slice []T, value T) []int
IndexOfAll returns all positions of value findings
func Unique ¶
func Unique[T comparable](slice []T) []T
Unique returns a new slice containing only the unique values from slice (deduplication)
Types ¶
This section is empty.