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 IntComparator ¶
func IntComparator(a, b interface{}) int
IntComparator provides a basic comparison on ints
func Sort ¶
func Sort(values []interface{}, comparator Comparator)
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 StringComparator ¶
func StringComparator(a, b interface{}) int
StringComparator provides a fast comparison on strings
Types ¶
type Comparator ¶
type Comparator func(a, b interface{}) int
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.