go-ethereum: github.com/axiomzen/go-ethereum/common/prque Index | Files

package prque

import "github.com/axiomzen/go-ethereum/common/prque"

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

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.


Package Files

prque.go sstack.go

type Prque Uses

type Prque struct {
    // contains filtered or unexported fields

Priority queue data structure.

func New Uses

func New(setIndex SetIndexCallback) *Prque

New creates a new priority queue.

func (*Prque) Empty Uses

func (p *Prque) Empty() bool

Checks whether the priority queue is empty.

func (*Prque) Peek Uses

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

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

func (*Prque) Pop Uses

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 Uses

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

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

func (*Prque) Push Uses

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

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

func (*Prque) Remove Uses

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

Remove removes the element with the given index.

func (*Prque) Reset Uses

func (p *Prque) Reset()

Clears the contents of the priority queue.

func (*Prque) Size Uses

func (p *Prque) Size() int

Returns the number of element in the priority queue.

type SetIndexCallback Uses

type SetIndexCallback func(data interface{}, index 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.

Package prque imports 1 packages (graph). Updated 2019-07-06. Refresh now. Tools for package owners.