Documentation
¶
Index ¶
- func Accumulate[T constraints.Ordered](data []T, from, to int) T
- func ForEach[T any](data []T, fn func(T))
- func GetMax[T constraints.Ordered](data []T, from, to int) (T, int)
- func GetMin[T constraints.Ordered](data []T, from, to int) (T, int)
- func IsSorted[T constraints.Ordered](data []T, from, to int) bool
- func Reverse[T any](data []T, from, to int)
- func Sort[T constraints.Ordered](data []T, from, to int)
- func SortComp[T any](data []T, from, to int, less func(a, b T) bool)
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 ¶
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)
Types ¶
This section is empty.