priority_queue

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package priority_queue provides ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

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

A PriorityQueue is a container adaptor that provides constant time lookup of the largest (by default) element, at the expense of logarithmic insertion and extraction. A user-provided comparator can be supplied to change the ordering, e.g. using utility.Greater[T] would cause the smallest element to appear as the Top().

func NewPriorityQueue

func NewPriorityQueue[T constraints.Ordered]() *PriorityQueue[T]

NewPriorityQueue constructs the PriorityQueue.

func NewPriorityQueueWithComparator

func NewPriorityQueueWithComparator[T any](comparator utility.Compare[T]) *PriorityQueue[T]

NewPriorityQueueWithComparator constructs the PriorityQueue. A utility.Compare type providing a strict weak ordering.

func (*PriorityQueue[T]) Empty

func (h *PriorityQueue[T]) Empty() bool

Empty checks if the PriorityQueue has no elements Complexity - constant.

func (*PriorityQueue[T]) Pop

func (h *PriorityQueue[T]) Pop() T

Pop removes the top element from the PriorityQueue Complexity - logarithmic number of comparisons.

func (*PriorityQueue[T]) Push

func (h *PriorityQueue[T]) Push(value T)

Push pushes the given element value to the PriorityQueue. Complexity - logarithmic number of comparisons.

func (*PriorityQueue[T]) Size

func (h *PriorityQueue[T]) Size() int

Size returns the number of elements in the PriorityQueue. Complexity - constant.

func (*PriorityQueue[T]) Top

func (h *PriorityQueue[T]) Top() T

Top returns reference to the top element in the PriorityQueue. Complexity - constant.

Jump to

Keyboard shortcuts

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