depriorityqueue

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package depriorityqueue provides interface and implementations for double-ended priority queue abstract data type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DEPriorityQueue

type DEPriorityQueue[T cmp.Ordered] interface {
	Size() int
	Insert(T)
	ExtractMax() (T, bool)
	ExtractMin() (T, bool)
	PeekMin() (T, bool)
	PeekMax() (T, bool)
}

type NaiveDEPriorityQueue

type NaiveDEPriorityQueue[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

NaiveDEPriorityQueue is a naive implementation of a double-ended priority queue.

func NewNaiveDEPriorityQueue

func NewNaiveDEPriorityQueue[T cmp.Ordered]() *NaiveDEPriorityQueue[T]

NewNaiveDEPriorityQueue instantiates a NaiveDEPriorityQueue and returns a pointer to it.

func (*NaiveDEPriorityQueue[T]) ExtractMax

func (q *NaiveDEPriorityQueue[T]) ExtractMax() (T, bool)

ExtractMax removes the highest-priority item and returns it. A Boolean is also returned that is false if the queue was empty.

func (*NaiveDEPriorityQueue[T]) ExtractMin

func (q *NaiveDEPriorityQueue[T]) ExtractMin() (T, bool)

ExtractMin removes the lowest-priority item and returns it. A Boolean is also returned that is false if the queue was empty.

func (*NaiveDEPriorityQueue[T]) Insert

func (q *NaiveDEPriorityQueue[T]) Insert(i T)

Insert inserts an element into the queue.

func (*NaiveDEPriorityQueue[T]) PeekMax

func (q *NaiveDEPriorityQueue[T]) PeekMax() (T, bool)

PeekMax returns the highest-priority item but, unlike ExtractMax, does not remove it. A Boolean is also returned that is false if the queue was empty.

func (*NaiveDEPriorityQueue[T]) PeekMin

func (q *NaiveDEPriorityQueue[T]) PeekMin() (T, bool)

PeekMin returns the lowest-prioity item but, unlike ExtractMin, does not remove it. A Boolean is also returned that is false if the queue was empty.

func (*NaiveDEPriorityQueue[T]) Size

func (q *NaiveDEPriorityQueue[T]) Size() int

Size returns the number of items in the queue.

Jump to

Keyboard shortcuts

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