utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2016 License: BSD-2-Clause Imports: 1 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 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

Jump to

Keyboard shortcuts

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