Documentation ¶
Index ¶
- func Contact[T any](args ...[]T) []T
- func Count[T comparable](s []T, value T) int
- func CountBy[T comparable](s []T, fn func(el T, index int) bool) int
- func Drop[T any](s []T, n int) ([]T, error)
- func Every[T any](s []T, fn func(el T, index int) bool) bool
- func Filter[T any](s []T, filter func(el T, index int) bool) []T
- func Find[T any](s []T, fn func(el T, index int) bool) (T, bool)
- func FindIndex[T any](s []T, fn func(el T, index int) bool) int
- func FindLastIndex[T any](s []T, fn func(el T, index int) bool) int
- func ForEach[T any](s []T, cb func(el T, index int))
- func Includes[T comparable](s []T, el T) bool
- func IndexOf[T comparable](s []T, el T) int
- func Insert[T any](s *[]T, index int, value T) error
- func LastIndexOf[T comparable](s []T, el T) int
- func Map[T, K any](s []T, cb func(el T, index int) K) []K
- func Pop[T any](s *[]T) T
- func Remove[T any](s *[]T, index int) error
- func Reverse[T any](s []T) []T
- func Sample[T any](s []T) T
- func Shift[T any](s *[]T) T
- func Some[T any](s []T, fn func(el T, index int) bool) bool
- func Uniq[T constraints.Ordered | constraints.Complex](s []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contact ¶
func Contact[T any](args ...[]T) []T
Contact Concatenate multiple slices and return a new slice
func Count ¶
func Count[T comparable](s []T, value T) int
Count return the number of elements in the slice that equal to value
func CountBy ¶
func CountBy[T comparable](s []T, fn func(el T, index int) bool) int
CountBy return the number of the elements in the slice that pass the test implemented by the provided the function
func Drop ¶
Drop drops n elements from the beginning(if n greater than zero) or the end(if n less than zero) of the slice
func Every ¶
Every weather all elements in the slice passed the test implemented by the provided function
func Filter ¶
Filter filtered down to just the elements from the given slice that passed the test implemented by the provided function
func Find ¶
Find return the value of the first element of the slice that passed the test function provided
func FindIndex ¶
FindIndex return the index of the first element in the slice that passed the test implemented by the provided function return -1 if no corresponding element is found
func FindLastIndex ¶ added in v1.0.1
FindIndex return the index of the last element in the slice that passed the test implemented by the provided function return -1 if no corresponding element is found
func Includes ¶
func Includes[T comparable](s []T, el T) bool
Includes weather the slice contains a certain element
func IndexOf ¶
func IndexOf[T comparable](s []T, el T) int
IndexOf return the index of the element in the slice, if the element is not in the slice, return -1
func LastIndexOf ¶ added in v1.0.1
func LastIndexOf[T comparable](s []T, el T) int
LastIndexOf return the last index of the element in the slice, if the element is not in the slice, return -1
func Map ¶
Map create a new slice populated with the results of calling the provide function on every element in the calling slice
func Pop ¶
func Pop[T any](s *[]T) T
Pop removes the last element from a slice and return that element, return the removed element. it will change the length of the slice
func Shift ¶
func Shift[T any](s *[]T) T
Shift removes the first element from a slice and return that removed element. This method changes the length of the slice
func Some ¶
Some weather at least one element in the slice passed the test implemented by the provide function
func Uniq ¶
func Uniq[T constraints.Ordered | constraints.Complex](s []T) []T
Uniq remove duplicate elements in the slice
Types ¶
This section is empty.