slicetools

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backward added in v0.0.16

func Backward[E any](s []E) func(func(int, E) bool)

Backward iterates over a slice in reverse order.

func Batch added in v0.0.22

func Batch[T any](ctx context.Context, elems []T, size int, fn func(context.Context, []T) error) error

Batch applies fn to successive chunks of at most "size" elements. A size of 0 (or negative) processes all the elements in one chunk. Stops at the first error and returns it.

func Chunks

func Chunks[T any](items []T, chunkSize int) [][]T

Chunks splits a slice into chunks of the given size.

func Concat added in v0.0.5

func Concat[T any](slices ...[]T) []T

Concat concatenates multiple slices and returns the result.

func Deduplicate added in v0.0.8

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

Deduplicate filters a slice of any comparable type, removing duplicate elements in place. Keeps the order of the original slice. The original slice can't be used after calling this function because it's likely to have a different length.

func UniqueCopy added in v0.0.8

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

UniqueCopy filters a slice of any comparable type, returning a slice of unique elements. Keeps the order of the original slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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