pqueue

package module
Version: v0.0.0-...-bd25904 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pqueue provides an implementation of priority queue derived from the work done by Robert Sedgewick and Kevin Wayne as part of Algorithms, 4th Edition.

http://algs4.cs.princeton.edu/code/

Copyright (C) 2000–2016 Robert Sedgewick and Kevin Wayne Copyright (C) 2017 Kasper Kronborg Isager

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Order

type Order int

Order describes the ordering of a priority queue.

const (
	// Ascending ordering; smallest key at the head.
	Ascending Order = iota
	// Descending ordering; largest key at the head.
	Descending
)

type PriorityQueue

type PriorityQueue interface {
	// Size gets the current number of keys within the priority queue.
	Size() int

	// Push adds a key with a priority to the priority queue.
	Push(key int, priority float32)

	// Pop removes and returns the head of the priority queue.
	Pop() (int, error)

	// Peek returns the head of the priority queue.
	Peek() (int, error)

	// Priority returns the priority of a key in the priority queue.
	Priority(key int) (float32, error)

	// Update changes the priority of a key in the priority queue.
	Update(key int, priority float32) error

	// Remove removes a key from the priority queue.
	Remove(key int) error
}

PriorityQueue describes a priority queue data structure used for ordering a set of keys according to their priority.

func New

func New(order Order) PriorityQueue

New constructs and initialises a new priority queue.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL