collect

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[I ~[]T, T any](input I, condition func(t T) bool) (output []T)

All collects all items from input that satisfy the condition Empty or nil input returns nil output

func First

func First[I ~[]T, T any](input I, condition func(t T) bool) *T

First collects the first item from input that satisfies the condition Empty or nil input returns nil output

func From

func From[I ~[]T, T, R any](input I, mapper func(t T) R) (output []R)

From translates a slice into another using a mapper func (T) => (R). Empty or nil input returns nil output

func FromMap

func FromMap[M ~map[K1]V1, K1, K2 comparable, V1, V2 any](input M, mapper func(K1, V1) (K2, V2, bool)) (output map[K2]V2)

FromMap translates a map into another using a mapper func (k1, v2) => (k2, v2, include). Empty or nil input returns nil output

func In

func In[E comparable](values ...E) (condition func(item E) bool)

In returns a new condition that is true as one of the values matches

func Last

func Last[I ~[]T, T any](input I, condition func(t T) bool) *T

Last collects the last item from input that satisfies the condition Empty or nil input returns nil output

func Not

func Not[T any, C func(t T) bool](condition C) C

Not inverts the meaning of condition

func With

func With[C ~func(t T) bool, T any](conditions ...C) (condition C)

With returns a new condition that is true when all conditions match

Types

This section is empty.

Jump to

Keyboard shortcuts

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