slicei

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accumulate

func Accumulate[A any](scope incr.Scope, from incr.Incr[A], fn func([]A, A) []A) incr.Incr[[]A]

Accumulate returns an incremental that accepts new values from an input incremental and returns an array of those values based on the result of a function.

You can use this function to sort the values, filter the values, or to simply append.

func AccumulateSorted

func AccumulateSorted[A any](scope incr.Scope, from incr.Incr[A], f SortFunc[A]) incr.Incr[[]A]

AccumulateSorted returns a new incremental that continually sorts new values into an output array using an online insertion sort.

func Asc

func Asc[A ~int | ~uint | ~float64 | ~string](testValue, newValue A) int

Asc returns a sorted comparer for sortable values in ascending order.

func Desc

func Desc[A ~int | ~uint | ~float64 | ~string](testValue, newValue A) int

Desc returns a sorted comparer for sortable values in descending order.

func Filter

func Filter[A any](g incr.Scope, input incr.Incr[[]A], pred func(A) bool) incr.Incr[[]A]

Filter takes an input incremental and applies a predicate to it.

func First

func First[A any](scope incr.Scope, input incr.Incr[[]A]) incr.Incr[A]

First returns the first element from an incremental that is typed as an array.

func Last

func Last[A any](scope incr.Scope, input incr.Incr[[]A]) incr.Incr[A]

Last returns the last element from an incremental that is typed as an array.

func Sort

func Sort[A any](scope incr.Scope, input incr.Incr[[]A], fn SortFunc[A]) incr.Incr[[]A]

Sort sorts a given input incremental according to the sort func.

func TakeFirst

func TakeFirst[A any](scope incr.Scope, input incr.Incr[[]A], count int) incr.Incr[[]A]

TakeFirst returns the first count elements from an incremental that is typed as an array.

func TakeFirstSearch

func TakeFirstSearch[A any](scope incr.Scope, input incr.Incr[[]A], fn func(A) bool) incr.Incr[[]A]

TakeFirstSearch returns the elements before a point determined by a search function.

The requirement for the input incremental is that it should already be sorted.

The function should return true for elements you would like to skip, and the first element that returns false is the one that will mark the end of the list.

An example sort function might be:

func(v int) bool {
	return v >= 5
}

For a list of `[]int{0,1,2,3,4,5,6,7,8,9}` this will return `[]int{0,1,2,3,4}`.

func TakeLast

func TakeLast[A any](scope incr.Scope, input incr.Incr[[]A], count int) incr.Incr[[]A]

Last returns the last count elements from an incremental that is typed as an array.

func TakeLastSearch

func TakeLastSearch[A any](scope incr.Scope, input incr.Incr[[]A], fn func(A) bool) incr.Incr[[]A]

TakeLastSearch returns the elements after a point determined by a search function.

The requirement for the input incremental is that it should already be sorted.

The function should return true for elements you would like to skip, and the first element that returns false is the one that will mark the beginning of the list.

An example sort function might be:

func(v int) bool {
	return v > 5
}

For a list of `[]int{0,1,2,3,4,5,6,7,8,9}` this will return `[]int{6,7,8,9}`.

Types

type SortFunc

type SortFunc[A any] func(a, b A) int

SortFunc is a function that can be used to sort slices.

Jump to

Keyboard shortcuts

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