Documentation
¶
Index ¶
- func All[T any](vs []T, f func(T) bool) bool
- func Any[T comparable](vs []T, f func(T) bool) bool
- func Chunk[T any](slice []T, size int) (chunks [][]T)
- func Contains[T comparable](vs []T, t T) bool
- func ContainsAnyKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
- func ContainsAnyValues[M ~map[K]V, K comparable, V comparable](m M, vs []V) bool
- func ContainsKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
- func ContainsNoneKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
- func ContainsNoneValues[M ~map[K]V, K, V comparable](m M, vs []V) bool
- func ContainsValues[M ~map[K]V, K, V comparable](m M, vs []V) bool
- func Copy[M ~map[K]V, K comparable, V any](dst M, src M)
- func Dedup[T comparable](in []T) (out []T)
- func Equals[T comparable](s1 []T, s2 []T) bool
- func Filter[T any](vs []T, f func(T) bool) []T
- func First[T any](vs []T, f func(T) bool) *T
- func Include(vs []string, t string) bool
- func Index(vs []string, t string) int
- func IndexOf[T comparable](vs []T, t T) int
- func Intersect[T comparable](slice1, slice2 []T) []T
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func Last[T any](vs []T, f func(T) bool) *T
- func Map[I, R any](vs []I, f func(I) R) []R
- func MapI[T any](vs []T, f func(T) interface{}) []interface{}
- func Values[M ~map[K]V, K comparable, V any](m M) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
func Any[T comparable](vs []T, f func(T) bool) bool
Any returns true if one of the element in the slice satisfies the predicate f
func Chunk ¶ added in v0.1.8
Chunk splits a slice into chunks of the given size. The last chunk may be smaller than the given size. Reference: https://github.com/golang/go/wiki/SliceTricks#batching-with-minimal-allocation
func Contains ¶ added in v0.1.5
func Contains[T comparable](vs []T, t T) bool
Contains returns true if the target element t is in the slice.
func ContainsAnyKeys ¶ added in v0.1.7
func ContainsAnyKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
ContainsAnyKeys checks whether any item in the slice is in the map
func ContainsAnyValues ¶ added in v0.1.7
func ContainsAnyValues[M ~map[K]V, K comparable, V comparable](m M, vs []V) bool
ContainsAnyValues checks whether any item in the slice is in the map values
func ContainsKeys ¶ added in v0.1.7
func ContainsKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
ContainsKeys checks whether all items in the slice are in the map
func ContainsNoneKeys ¶ added in v0.1.7
func ContainsNoneKeys[M ~map[K]V, K comparable, V any](m M, ks []K) bool
ContainsNoneKeys checks whether none of the items in the slice is in the map
func ContainsNoneValues ¶ added in v0.1.7
func ContainsNoneValues[M ~map[K]V, K, V comparable](m M, vs []V) bool
ContainsNoneValues checks whether none of the items in the slice is in the map values
func ContainsValues ¶ added in v0.1.7
func ContainsValues[M ~map[K]V, K, V comparable](m M, vs []V) bool
ContainsValues checks whether all items in the slice are in the map values
func Copy ¶ added in v0.1.10
func Copy[M ~map[K]V, K comparable, V any](dst M, src M)
Copy copies the key-value pairs. When key is already in the dst map, it will be overwritten.
func Dedup ¶ added in v0.1.4
func Dedup[T comparable](in []T) (out []T)
Dedup returns the input slice after removing duplicated items
func Equals ¶ added in v0.1.7
func Equals[T comparable](s1 []T, s2 []T) bool
Equals checks whether 2 slices are equal
func First ¶ added in v0.1.13
First returns the first element of the slice matching the predicate f, or nil if no match is found
func IndexOf ¶ added in v0.1.5
func IndexOf[T comparable](vs []T, t T) int
IndexOf returns the first index of the target element t, or -1 if no match is found
func Intersect ¶ added in v0.1.12
func Intersect[T comparable](slice1, slice2 []T) []T
Intersect returns a new slice containing elements that exist in both input slices.
func Keys ¶ added in v0.1.7
func Keys[M ~map[K]V, K comparable, V any](m M) []K
Keys returns the keys of the map
func Last ¶ added in v0.1.13
Last returns the last element matching the predicate f, or nil if no match is found
func Map ¶
func Map[I, R any](vs []I, f func(I) R) []R
Map returns a new slice containing the results of applying the function f to each element in the original slice
func MapI ¶ added in v0.1.1
func MapI[T any](vs []T, f func(T) interface{}) []interface{}
MapI returns a new slice containing the results of applying the function f to each element in the original slice FIXME: will deprecate this function in the future
func Values ¶ added in v0.1.7
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns all values in the map
Types ¶
This section is empty.