package
1.0.26
Repository: https://github.com/askasoft/pango.git
Documentation: pkg.go.dev

# README

Compare

Various helper functions used by Collection package.

Comparator

Some data structures (e.g. TreeMap, TreeSet) require a comparator function to automatically keep their elements sorted upon insertion. This comparator is necessary during the initalization.

Comparator is defined as:

// Should return a int:
//   negative : if a < b
//   zero     : if a == b
//   positive : if a > b

Comparator signature:

type Compare[T any] func(a, b T) int

All common comparators for builtin types are included in the package:

func CompareString(a, b string) int
func CompareInt(a, b int) int
func CompareInt8(a, b int8) int
func CompareInt16(a, b int16) int
func CompareInt32(a, b int32) int
func CompareInt64(a, b int64) int
func CompareUInt(a, b uint) int
func CompareUInt8(a, b uint8) int
func CompareUInt16(a, b uint16) int
func CompareUInt32(a, b uint32) int
func CompareUInt64(a, b uint64) int
func CompareFloat32(a, b float32) int
func CompareFloat64(a, b float64) int
func CompareByte(a, b byte) int
func CompareRune(a, b rune) int

Less

Some data structures require a less compare function to sort it's elements (e.g. ArrayList.Sort()).

Less comparator is defined as:

// Should return a bool:
//    true : if a < b
//    false: if a >= b

Comparator signature:

type Less[T any] func(a, b T) bool

All common comparators for builtin types are included in the package:

func LessString(a, b string) bool
func LessByte(a, b byte) bool
func LessRune(a, b rune) bool
func LessInt(a, b int) bool
func LessInt8(a, b int8) bool
func LessInt16(a, b int16) bool
func LessInt32(a, b int32) bool
func LessInt64(a, b int64) bool
func LessUint(a, b uint) bool
func LessUint8(a, b uint8) bool
func LessUint16(a, b uint16) bool
func LessUint32(a, b uint32) bool
func LessUint64(a, b uint64) bool
func LessFloat32(a, b float32) bool
func LessFloat64(a, b float64) bool

# Functions

CompareByte provides a basic comparison on byte.
CompareFloat32 provides a basic comparison on float32.
CompareFloat64 provides a basic comparison on float64.
CompareInt provides a basic comparison on int.
CompareInt16 provides a basic comparison on int16.
CompareInt32 provides a basic comparison on int32.
CompareInt64 provides a basic comparison on int64.
CompareInt8 provides a basic comparison on int8.
CompareRune provides a basic comparison on rune.
CompareString provides a basic comparison on string.
CompareStringFold provides a basic case-insensitive comparison on string.
CompareUInt provides a basic comparison on uint.
CompareUInt16 provides a basic comparison on uint16.
CompareUInt32 provides a basic comparison on uint32.
CompareUInt64 provides a basic comparison on uint64.
CompareUInt8 provides a basic comparison on uint8.
LessByte byte less function.
LessFloat32 float32 less function.
LessFloat64 float64 less function.
LessInt int less function.
LessInt16 int16 less function.
LessInt32 int32 less function.
LessInt64 int64 less function.
LessInt8 int8 less function.
LessRune rune less function.
LessString string less function.
LessStringFold string case-insensitive less function.
LessUint uint less function.
LessUint16 uint16 less function.
LessUint32 uint32 less function.
LessUint64 uint64 less function.
LessUint8 uint8 less function.