heaps

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryHeap

type BinaryHeap[T any] struct {
	// contains filtered or unexported fields
}

func NewBinaryHeap

func NewBinaryHeap[T any](capacity int, compare containers.Compare[T]) *BinaryHeap[T]

func (*BinaryHeap[T]) Clear

func (heap *BinaryHeap[T]) Clear()

func (*BinaryHeap[T]) Fix

func (heap *BinaryHeap[T]) Fix(i int, k T)

func (*BinaryHeap[T]) Iterator

func (heap *BinaryHeap[T]) Iterator() containers.IndexIterator[T]

func (*BinaryHeap[T]) Merge

func (heap *BinaryHeap[T]) Merge(h Heap[T])

func (*BinaryHeap[T]) Peek

func (heap *BinaryHeap[T]) Peek() (_ T, _ bool)

func (*BinaryHeap[T]) Pop

func (heap *BinaryHeap[T]) Pop() (_ T, _ bool)

func (*BinaryHeap[T]) Push

func (heap *BinaryHeap[T]) Push(es ...T)

func (*BinaryHeap[T]) Remove

func (heap *BinaryHeap[T]) Remove(i int)

func (*BinaryHeap[T]) Size

func (heap *BinaryHeap[T]) Size() int

func (*BinaryHeap[T]) String

func (heap *BinaryHeap[T]) String() string

func (*BinaryHeap[T]) Values

func (heap *BinaryHeap[T]) Values() []T

type Heap

type Heap[T any] interface {
	// Push pushes an element into queue
	Push(e ...T)
	// Peek returns an element on the head of queue
	Peek() (T, bool)
	// Pop returns an element on the head of queue, then pop it from queue
	Pop() (T, bool)
	// Fix replace the element at the given index to k, returns if k equal to the element or re-heapify
	Fix(i int, k T)
	// Remove removes an element at the give index from heap
	Remove(i int)
	// Merge merges another heap into this one
	Merge(heap Heap[T])

	containers.IndexIterable[T]

	containers.Container[T]
}

Heap is the base interface of all heap implementations

Jump to

Keyboard shortcuts

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