sliceext

package
v5.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0, MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](slice []T, fn func(v T) bool) []T

Filter filters out the elements specified by the function.

This shuffles and returns the retained values of the slice.

func Map

func Map[T, U any](slice []T, init U, fn func(accum U, v T) U) U

Map maps a slice of []T -> []U using the map function.

func Reduce

func Reduce[T any](slice []T, fn func(accum T, current T) T) optionext.Option[T]

Reduce reduces the elements to a single one, by repeatedly applying a reducing function.

func Retain

func Retain[T any](slice []T, fn func(v T) bool) []T

Retain retains only the elements specified by the function.

This shuffles and returns the retained values of the slice.

func Reverse added in v5.16.0

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

Reverse reverses the slice contents.

func Sort

func Sort[T any](slice []T, less func(i T, j T) bool)

Sort sorts the sliceWrapper x given the provided less function.

The sort is not guaranteed to be stable: equal elements may be reversed from their original order.

For a stable sort, use SortStable.

func SortStable

func SortStable[T any](slice []T, less func(i T, j T) bool)

SortStable sorts the sliceWrapper x using the provided less function, keeping equal elements in their original order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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