prque

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: GPL-3.0, BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package prque implements a priority queue data structure supporting arbitrary value types and float priorities.

The reasoning behind using floats for the priorities vs. ints or interfaces was larger flexibility without sacrificing too much performance or code complexity.

If you would like to use a min-priority queue, simply negate the priorities.

Internally the queue is based on the standard heap package working on a sortable version of the block based stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prque

type Prque struct {
	// contains filtered or unexported fields
}

Priority queue data structure.

func New

func New() *Prque

Creates a new priority queue.

func (*Prque) Empty

func (p *Prque) Empty() bool

Checks whether the priority queue is empty.

func (*Prque) Pop

func (p *Prque) Pop() (interface{}, float32)

Pops the value with the greates priority off the stack and returns it. Currently no shrinking is done.

func (*Prque) PopItem

func (p *Prque) PopItem() interface{}

Pops only the item from the queue, dropping the associated priority value.

func (*Prque) Push

func (p *Prque) Push(data interface{}, priority float32)

Pushes a value with a given priority into the queue, expanding if necessary.

func (*Prque) Reset

func (p *Prque) Reset()

Clears the contents of the priority queue.

func (*Prque) Size

func (p *Prque) Size() int

Returns the number of element in the priority queue.

Jump to

Keyboard shortcuts

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