Documentation
¶
Overview ¶
Package utils provides common utility functions.
Provided functionalities: - sorting - comparators
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicComparator ¶ added in v0.3.0
func BasicComparator[T constraints.Ordered](a, b T) int
func Max ¶ added in v0.16.0
func Max[T constraints.Ordered](a T, b T) T
func Min ¶ added in v0.16.0
func Min[T constraints.Ordered](a T, b T) T
func Sort ¶
func Sort[T any](values []T, comparator Comparator[T])
Sort sorts values (in-place) with respect to the given comparator.
Uses Go's sort (hybrid of quicksort for large and then insertion sort for smaller slices).
func TimeComparator ¶
TimeComparator provides a basic comparison on time.Time.
Types ¶
type Comparator ¶
Comparator will make type assertion (see IntComparator for example), which will panic if a or b are not of the asserted type.
Should return a number:
negative , if a < b zero , if a == b positive , if a > b
Click to show internal directories.
Click to hide internal directories.