slice

package
v0.0.0-...-c049333 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T comparable](slice []T, matches func(elem T) bool) bool

All returns true if all items in slice are matched by matches func;

func Any

func Any[T comparable](slice []T, matches func(elem T) bool) bool

Any returns true if at least one item in slice is matched by matches func.

func Chunk

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

func Compact

func Compact[T comparable](slice []T) []T

Compact removes all empty/zero values from slice.

func Contains

func Contains[T comparable](slice []T, value T) bool

Contains returns true if value exists in slice.

func ContainsAll

func ContainsAll[T comparable](slice []T, values ...T) bool

ContainsAll returns true if all values exist in slice.

func ContainsAny

func ContainsAny[T comparable](slice []T, values ...T) bool

Contains returns true if any values exist in slice.

func Distinct

func Distinct[T comparable](slice []T, normalizeMapKey func(T) T) []T

Distinct returns a list of unique items in slice. It uses a map to determine uniqueness and the normalizeMapKey func to normalize the key for comparison.

func Filter

func Filter[T comparable](slice []T, matches func(elem T) bool) []T

Filter returns a list of items in slice that are matched by matches func.

func First

func First[T comparable](slice []T, matches func(elem T) bool) T

First returns the first item in slice that is matched by matches func.

func ForEach

func ForEach[T any](slice []T, f func(elem T, index int))

ForEach calls func f with every item in slice

func IndexOf

func IndexOf[T comparable](slice []T, matches func(elem T) bool) int

IndexOf returns the index of the first item in slice that is matched by matches func.

func Insert

func Insert[T any](slice []T, item T, i int) []T

func Last

func Last[T comparable](slice []T, matches func(elem T) bool) T

Last returns the last item in slice that is matched by matches func.

func LastIndexOf

func LastIndexOf[T comparable](slice []T, matches func(elem T) bool) int

LastIndexOf returns the index of the last item in slice that is matched by matches func.

func Map

func Map[T comparable](slice []T, mapper func(elem T) T) []T

func Max

func Max[T constraints.Ordered](slice []T) T

Max returns the largest item in slice.

func Min

func Min[T constraints.Ordered](slice []T) T

Min returns the smallest item in slice. Min returns the smallest item in slice.

func Prepend

func Prepend[T any](slice []T, item T) []T

func Reduce

func Reduce[T comparable, TResult any](slice []T, seed TResult, reducer func(acc TResult, elem T, index int) TResult) TResult

func Reverse

func Reverse[T any](slice []T) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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