algorithms

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accumulate

func Accumulate[T constraints.Ordered](data []T, from, to int) T

Accumulate returns the sum of data[from:to]. @param data the slice to accumulate partially @param from the starting index (inclusive) @param to the ending index (exclusive) @return the sum of the subrange

func ForEach

func ForEach[T any](data []T, fn func(T))

ForEach applies a function to each element in the slice. @param data the slice to iterate @param fn the function to apply

func GetMax

func GetMax[T constraints.Ordered](data []T, from, to int) (T, int)

GetMax returns the maximum value and its index (absolute) in data[from:to]. @param data the slice to search partially @param from the starting index (inclusive) @param to the ending index (exclusive) @return maximum value and its absolute index in data

func GetMin

func GetMin[T constraints.Ordered](data []T, from, to int) (T, int)

GetMin returns the minimum value and its index (absolute) in data[from:to]. @param data the slice to search partially @param from the starting index (inclusive) @param to the ending index (exclusive) @return minimum value and its absolute index in data

func IsSorted

func IsSorted[T constraints.Ordered](data []T, from, to int) bool

IsSorted checks if data[from:to] is sorted in ascending order. @param data the slice to check partially @param from the starting index (inclusive) @param to the ending index (exclusive) @return true if sorted, false otherwise

func Reverse

func Reverse[T any](data []T, from, to int)

Reverse reverses the elements in the given slice in-place. @param data the slice to reverse @param from the start index (inclusive) @param to the end index (exclusive)

func Sort

func Sort[T constraints.Ordered](data []T, from, to int)

Sort sorts data[from:to] in-place using default comparison. @param data the slice to partially sort @param from the starting index (inclusive) @param to the ending index (exclusive)

func SortComp

func SortComp[T any](data []T, from, to int, less func(a, b T) bool)

SortComp sorts the elements in data[from:to] using the provided comparison function. @param data the slice to partially sort @param from the starting index (inclusive) @param to the ending index (exclusive) @param less the comparison function

Types

This section is empty.

Jump to

Keyboard shortcuts

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