generalheap

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0, BSD-2-Clause Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparable

type Comparable[T any] interface {
	CompareTo(other T) int
}

type Heap

type Heap[Key Comparable[Key], Value any] []*HeapElement[Key, Value]

Heap defines a heap based on times.

func (Heap[K, V]) Len

func (h Heap[K, V]) Len() int

Len is the number of elements in the collection.

func (Heap[K, V]) Less

func (h Heap[K, V]) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*Heap[K, V]) Pop

func (h *Heap[K, V]) Pop() interface{}

Pop removes and returns the last element of the heap.

func (*Heap[K, V]) Push

func (h *Heap[K, V]) Push(x interface{})

Push adds x as the last element to the heap.

func (Heap[K, V]) Swap

func (h Heap[K, V]) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type HeapElement

type HeapElement[K Comparable[K], V any] struct {
	// Value represents the value of the queued element.
	Value V
	// Key represents the time of the element to be used as a key.
	Key K
	// contains filtered or unexported fields
}

func (HeapElement[K, V]) Index

func (h HeapElement[K, V]) Index() int

Jump to

Keyboard shortcuts

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