algorithm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search[T cmp.Ordered](values []T, target T) int

Search searches for target in a sorted array of values and return the smallest index i which satisfies values[i] >= target.

func SearchFunc

func SearchFunc[T any](values []T, target T, less LessFunc[T]) int

SearchFunc searches for target in a sorted array of values using less and return the smallest index i which satisfies !less(values[i], target).

func Sort

func Sort[T cmp.Ordered](values []T)

Sort sorts an array of values from ordered types like int, float, etc....

func SortFunc

func SortFunc[T any](values []T, less LessFunc[T])

SortFunc sorts an array using less.

Types

type LessFunc

type LessFunc[T any] func(x, y T) bool

LessFunc is a function that returns whether x < y or not.

Jump to

Keyboard shortcuts

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