slices

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any[T any](ts []T, predicate func(t T) bool) bool

Any returns true if at least one element satisfies predicate

func Clone added in v0.6.5

func Clone[T any](source []T) []T

func Count

func Count[S any](ss []S, p types.Predicate[S]) int

func DeepClone added in v0.6.5

func DeepClone[T types.Cloneable[T]](source []T) []T

func Filter

func Filter[S any](ss []S, p types.Predicate[S]) []S

func FilterNonNil

func FilterNonNil[T any](ts []*T) []*T

FilterNonNil returns all the elements of array that are non nil

func FilterNot

func FilterNot[S any](ss []S, p types.Predicate[S]) []S

FilterNot removes (filter out) all elements the satisfies predicate

func Find

func Find[S any](ss []S, p types.Predicate[S]) (S, bool)

func FlatMap

func FlatMap[S any, T any](ss []S, m types.Mapper[S, []T]) []T

func Has

func Has[T types.Comparable[T]](ts []T, other T) bool

func Has2

func Has2[T comparable](ts []T, other T) bool

func Index

func Index[S comparable](ss []S, toFind S) int

func Index2

func Index2[S comparable](ss []S, toFind S) (int, bool)

func IndexBy

func IndexBy[S any](ss []S, p types.Predicate[S]) int

func IndexBy2

func IndexBy2[S any](ss []S, p types.Predicate[S]) (int, bool)

func Map

func Map[S any, T any](ss []S, m types.Mapper[S, T]) []T

func MapNonNil

func MapNonNil[S any, T any](ss []S, mapper types.Mapper[S, *T]) []T

MapNonNil apply mapper to all elements of 'ss' and return slice of all non-nil results

func MapWithError added in v0.6.6

func MapWithError[S any, T any](ss []S, m types.MapperWithError[S, T]) ([]T, error)

MapWithError applies mapper to all elements of 'ss' and returns slice of results. If mapper returns error, then it is returned immediately.

func Of

func Of[S any](ss ...S) []S

func Reduce

func Reduce[Value any, Element any](
	initialValue Value,
	elements []Element,
	reducer func(Value, Element) Value,
) Value

func Remove

func Remove[T types.Comparable[T]](ts []T, toRemove T) []T

Remove all occurrences of the given element from the slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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