heap

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package heap provides a generic heap implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap[K cmp.Ordered, T comparable] struct {
	// contains filtered or unexported fields
}

Heap is a generic heap implementation.

func NewHeap

func NewHeap[K cmp.Ordered, T comparable]() *Heap[K, T]

NewHeap creates a new heap.

func (*Heap[K, T]) Len

func (h *Heap[K, T]) Len() int

Len returns the number of items in the queue.

func (*Heap[K, T]) Peek

func (h *Heap[K, T]) Peek() (k K, v T, ok bool)

Peek returns the next item in the queue without removing it.

func (*Heap[K, T]) Pop

func (h *Heap[K, T]) Pop() (k K, v T, ok bool)

Pop removes an item from the queue.

func (*Heap[K, T]) Push

func (h *Heap[K, T]) Push(key K, data T)

Push adds an item to the queue.

func (*Heap[K, T]) Remove

func (h *Heap[K, T]) Remove(data T) bool

Remove removes an item from the queue.

Jump to

Keyboard shortcuts

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