Documentation ¶
Overview ¶
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.
Index ¶
- type Prque
- func (p *Prque) Empty() bool
- func (p *Prque) Peek() (interface{}, int64)
- func (p *Prque) Pop() (interface{}, int64)
- func (p *Prque) PopItem() interface{}
- func (p *Prque) Push(data interface{}, priority int64)
- func (p *Prque) Remove(i int) interface{}
- func (p *Prque) Reset()
- func (p *Prque) Size() int
- type SetIndexCallback
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 (*Prque) Pop ¶
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.
type SetIndexCallback ¶
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.