package utils
Import Path
github.com/emirpasic/gods/utils (on go.dev)
Dependency Relation
imports 4 packages, and imported by 4 packages
Involved Source Files
comparator.go
sort.go
Package utils provides common utility functions.
Provided functionalities:
- sorting
- comparators
Package-Level Type Names (total 2, in which 1 are exported)
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
func Sort(values []interface{}, comparator Comparator)
func github.com/emirpasic/gods/containers.GetSortedValues(container containers.Container, comparator Comparator) []interface{}
func github.com/emirpasic/gods/lists.List.Sort(comparator Comparator)
func github.com/emirpasic/gods/lists/arraylist.(*List).Sort(comparator Comparator)
func github.com/emirpasic/gods/trees/binaryheap.NewWith(comparator Comparator) *binaryheap.Heap
Package-Level Functions (total 18, all are exported)
ByteComparator provides a basic comparison on byte
Float32Comparator provides a basic comparison on float32
Float64Comparator provides a basic comparison on float64
Int16Comparator provides a basic comparison on int16
Int32Comparator provides a basic comparison on int32
Int64Comparator provides a basic comparison on int64
Int8Comparator provides a basic comparison on int8
IntComparator provides a basic comparison on int
RuneComparator provides a basic comparison on rune
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).
StringComparator provides a fast comparison on strings
TimeComparator provides a basic comparison on time.Time
ToString converts a value to string.
UInt16Comparator provides a basic comparison on uint16
UInt32Comparator provides a basic comparison on uint32
UInt64Comparator provides a basic comparison on uint64
UInt8Comparator provides a basic comparison on uint8
UIntComparator provides a basic comparison on uint
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |