Help us shape the future of Go! Take the 2026 Go Developer Survey

prque

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

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(setIndex SetIndexCallback) *Prque

New creates a new priority queue.

func (*Prque) Empty

func (p *Prque) Empty() bool

Checks whether the priority queue is empty.

func (*Prque) Peek added in v0.16.1

func (p *Prque) Peek() (interface{}, int64)

Peek returns the value with the greates priority but does not pop it off.

func (*Prque) Pop

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

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 int64)

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

func (*Prque) Remove

func (p *Prque) Remove(i int) interface{}

Remove removes the element with the given index.

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.

type SetIndexCallback added in v0.16.1

type SetIndexCallback func(a interface{}, i int)

SetIndexCallback is called when the element is moved to a new index. Providing SetIndexCallback is optional, it is needed only if the application needs to delete elements other than the top one.

Jump to

Keyboard shortcuts

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