comparator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareTime added in v0.3.1

func CompareTime(v1, v2 time.Time) int

Types

type Comparable

type Comparable[T any] func(T, T) int

Comparable method CompareTo(Comparable) should return a negative number when v1 < v2, a positive number when v1 > v2 and zero when v1 == v2.

type Container

type Container[T any] struct {
	Items   []T           // container data
	Desc    bool          // asc or desc, default asc.
	Compare Comparable[T] // cmp.Compare or custom comparison
}

func (Container[T]) Len

func (c Container[T]) Len() int

Len implement heap.Interface.

func (Container[T]) Less

func (c Container[T]) Less(i, j int) bool

Less implement heap.Interface.

func (*Container[T]) Pop

func (c *Container[T]) Pop() T

Pop implement heap.Interface.

func (*Container[T]) Push

func (c *Container[T]) Push(x T)

Push implement heap.Interface.

func (Container[T]) Swap

func (c Container[T]) Swap(i, j int)

Swap implement heap.Interface.

Jump to

Keyboard shortcuts

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