sortutil

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0, NCSA Imports: 1 Imported by: 4

Documentation

Overview

Package sortutil implements utilities for sorting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort added in v0.0.18

func Sort(l Lesser, a []interface{})

Sort uses l to sort the given slice.

Types

type ByLesser

type ByLesser struct {
	Lesser Lesser
	Slice  []interface{}
}

ByLesser implements the heap.Interface using a Lesser over a slice.

func (*ByLesser) Clear

func (s *ByLesser) Clear()

Clear removes all elements from the underlying slice.

func (ByLesser) Len

func (s ByLesser) Len() int

Len implements part of the sort.Interface

func (ByLesser) Less

func (s ByLesser) Less(i, j int) bool

Less implements part of the sort.Interface

func (ByLesser) Peek

func (s ByLesser) Peek() interface{}

Peek returns the least element in the heap. nil is returned if the heap is empty.

func (*ByLesser) Pop

func (s *ByLesser) Pop() interface{}

Pop implements part of the heap.Interface

func (*ByLesser) Push

func (s *ByLesser) Push(v interface{})

Push implements part of the heap.Interface

func (ByLesser) Swap

func (s ByLesser) Swap(i, j int)

Swap implements part of the sort.Interface

type Lesser

type Lesser interface {
	// Less returns true if a < b.
	Less(a, b interface{}) bool
}

Lesser is an interface to a comparison function.

type LesserFunc

type LesserFunc func(a, b interface{}) bool

LesserFunc implements the Lesser interface using a function.

func (LesserFunc) Less

func (f LesserFunc) Less(a, b interface{}) bool

Less implements the Lesser interface.

Jump to

Keyboard shortcuts

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