sortutil

package
v0.0.67 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 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 []any)

Sort uses l to sort the given slice.

Types

type ByLesser

type ByLesser struct {
	Lesser Lesser
	Slice  []any
}

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() any

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

func (*ByLesser) Pop

func (s *ByLesser) Pop() any

Pop implements part of the heap.Interface

func (*ByLesser) Push

func (s *ByLesser) Push(v any)

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 any) bool
}

Lesser is an interface to a comparison function.

type LesserFunc

type LesserFunc func(a, b any) bool

LesserFunc implements the Lesser interface using a function.

func (LesserFunc) Less

func (f LesserFunc) Less(a, b any) bool

Less implements the Lesser interface.

Jump to

Keyboard shortcuts

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