sort

package
v0.0.0-...-90c9d3a Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2010 License: BSD-3-Clause, GooglePatentClause Imports: 0 Imported by: 0

Documentation

Overview

The sort package provides primitives for sorting arrays and user-defined collections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FloatsAreSorted

func FloatsAreSorted(a []float) bool

FloatsAreSorted tests whether an array of floats is sorted in increasing order.

func IntsAreSorted

func IntsAreSorted(a []int) bool

IntsAreSorted tests whether an array of ints is sorted in increasing order.

func IsSorted

func IsSorted(data Interface) bool

func Sort

func Sort(data Interface)

func SortFloats

func SortFloats(a []float)

SortFloats sorts an array of floats in increasing order.

func SortInts

func SortInts(a []int)

SortInts sorts an array of ints in increasing order.

func SortStrings

func SortStrings(a []string)

SortStrings sorts an array of strings in increasing order.

func StringsAreSorted

func StringsAreSorted(a []string) bool

StringsAreSorted tests whether an array of strings is sorted in increasing order.

Types

type FloatArray

type FloatArray []float

FloatArray attaches the methods of Interface to []float, sorting in increasing order.

func (FloatArray) Len

func (p FloatArray) Len() int

func (FloatArray) Less

func (p FloatArray) Less(i, j int) bool

func (FloatArray) Sort

func (p FloatArray) Sort()

Sort is a convenience method.

func (FloatArray) Swap

func (p FloatArray) Swap(i, j int)

type IntArray

type IntArray []int

IntArray attaches the methods of Interface to []int, sorting in increasing order.

func (IntArray) Len

func (p IntArray) Len() int

func (IntArray) Less

func (p IntArray) Less(i, j int) bool

func (IntArray) Sort

func (p IntArray) Sort()

Sort is a convenience method.

func (IntArray) Swap

func (p IntArray) Swap(i, j int)

type Interface

type Interface interface {
	// Len is the number of elements in the collection.
	Len() int
	// Less returns whether the element with index i should sort
	// before the element with index j.
	Less(i, j int) bool
	// Swap swaps the elements with indexes i and j.
	Swap(i, j int)
}

A type, typically a collection, that satisfies sort.Interface can be sorted by the routines in this package. The methods require that the elements of the collection be enumerated by an integer index.

type StringArray

type StringArray []string

StringArray attaches the methods of Interface to []string, sorting in increasing order.

func (StringArray) Len

func (p StringArray) Len() int

func (StringArray) Less

func (p StringArray) Less(i, j int) bool

func (StringArray) Sort

func (p StringArray) Sort()

Sort is a convenience method.

func (StringArray) Swap

func (p StringArray) Swap(i, j int)

Jump to

Keyboard shortcuts

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