utils

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: BSD-2-Clause, ISC Imports: 4 Imported by: 0

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 ByteComparator added in v1.6.0

func ByteComparator(a, b interface{}) int

ByteComparator provides a basic comparison on byte

func Float32Comparator added in v1.6.0

func Float32Comparator(a, b interface{}) int

Float32Comparator provides a basic comparison on float32

func Float64Comparator added in v1.6.0

func Float64Comparator(a, b interface{}) int

Float64Comparator provides a basic comparison on float64

func Int16Comparator added in v1.6.0

func Int16Comparator(a, b interface{}) int

Int16Comparator provides a basic comparison on int16

func Int32Comparator added in v1.6.0

func Int32Comparator(a, b interface{}) int

Int32Comparator provides a basic comparison on int32

func Int64Comparator added in v1.6.0

func Int64Comparator(a, b interface{}) int

Int64Comparator provides a basic comparison on int64

func Int8Comparator added in v1.6.0

func Int8Comparator(a, b interface{}) int

Int8Comparator provides a basic comparison on int8

func IntComparator

func IntComparator(a, b interface{}) int

IntComparator provides a basic comparison on int

func RuneComparator added in v1.6.0

func RuneComparator(a, b interface{}) int

RuneComparator provides a basic comparison on rune

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

func TimeComparator added in v1.7.0

func TimeComparator(a, b interface{}) int

TimeComparator provides a basic comparison on time.Time

func ToString added in v1.9.0

func ToString(value interface{}) string

ToString converts a value to string.

func UInt16Comparator added in v1.6.0

func UInt16Comparator(a, b interface{}) int

UInt16Comparator provides a basic comparison on uint16

func UInt32Comparator added in v1.6.0

func UInt32Comparator(a, b interface{}) int

UInt32Comparator provides a basic comparison on uint32

func UInt64Comparator added in v1.6.0

func UInt64Comparator(a, b interface{}) int

UInt64Comparator provides a basic comparison on uint64

func UInt8Comparator added in v1.6.0

func UInt8Comparator(a, b interface{}) int

UInt8Comparator provides a basic comparison on uint8

func UIntComparator added in v1.6.0

func UIntComparator(a, b interface{}) int

UIntComparator provides a basic comparison on uint

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

Jump to

Keyboard shortcuts

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