slices

package
v0.3.71-rc-9188597 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Concatenate added in v0.3.63

func Concatenate[S ~[]E, E any](s ...S) S

Concatenate returns a single slice created by concatenating the input slices.

func Filter added in v0.3.63

func Filter[S ~[]E, E any](s S, predicate func(e E) bool) S

func Flatten added in v0.3.50

func Flatten[S ~[]E, E any](s []S) S

Flatten merges a slice of slices into a single slice.

func GroupByFunc added in v0.3.50

func GroupByFunc[S ~[]E, E any, K comparable](s S, keyFunc func(E) K) map[K]S

GroupByFunc groups the elements e_1, ..., e_n of s into separate slices by keyFunc(e).

func MapAndGroupByFuncs added in v0.3.50

func MapAndGroupByFuncs[S ~[]E, E any, K comparable, V any](s S, keyFunc func(E) K, mapFunc func(E) V) map[K][]V

MapAndGroupByFuncs groups the elements e_1, ..., e_n of s into separate slices by keyFunc(e) and then maps those resulting elements by mapFunc(e).

func Partition added in v0.3.50

func Partition[S ~[]E, E any](s S, n int) []S

Partition partitions the elements of s into n non-overlapping slices, such that some slices have len(s)/n+1 items and some len(s)/n items. Ordering is preserved, such that Flatten(Partition(s)) is equal to s.

func PartitionToMaxLen added in v0.3.50

func PartitionToMaxLen[S ~[]E, E any](s S, maxLen int) []S

PartitionToLen partitions the elements of s into non-overlapping slices, such that each such slice contains at most maxLen elements.

func Shuffle added in v0.3.63

func Shuffle[S ~[]E, E any](s ...S)

Shuffle shuffles s.

func Subtract added in v0.3.50

func Subtract[T comparable](list []T, toRemove []T) []T

func Unique added in v0.3.63

func Unique[S ~[]E, E comparable](s S) S

Unique returns a copy of s with duplicate elements removed, keeping only the first occurrence.

Types

This section is empty.

Jump to

Keyboard shortcuts

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