Help us shape the future of Go! Take the 2026 Go Developer Survey

collection

package module
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](vs []T, f func(T) bool) bool

All returns true if all the elements in the slice satisfy the predicate f

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

func Chunk[T any](slice []T, size int) (chunks [][]T)

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 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 Filter

func Filter[T any](vs []T, f func(T) bool) []T

Filter returns a new slice containing all in the slice that satisfy the predicate f

func Include

func Include(vs []string, t string) bool

Include returns true if the target string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string t, or -1 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 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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL