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

collection

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 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 comparable](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 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 Dedup added in v0.1.4

func Dedup[T comparable](in []T) (out []T)

Dedup returns the input slice after removing duplicated items

func Equal added in v0.1.3

func Equal[T comparable](s1 []T, s2 []T) bool

Equal checks whether 2 slices have the same items

func Filter

func Filter[T comparable](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 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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