queue

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: AGPL-3.0 Imports: 2 Imported by: 4

Documentation

Overview

Package queue implements a priority queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Value    interface{}
	Priority uint64
}

Entry is a PriorityQueue entry.

type PriorityQueue

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

PriorityQueue is a priority queue instance.

func New

func New() *PriorityQueue

New creates a new PriorityQueue.

func (*PriorityQueue) DequeueIndex added in v0.0.7

func (q *PriorityQueue) DequeueIndex(index int) *Entry

DequeueIndex removes the specified entry from the queue.

func (*PriorityQueue) DequeueRandom

func (q *PriorityQueue) DequeueRandom(r *rand.Rand) *Entry

DequeueRandom removes a random entry from the queue.

func (*PriorityQueue) Enqueue

func (q *PriorityQueue) Enqueue(priority uint64, value interface{})

Enqueue inserts the provided value, into the queue with the specified priority.

func (*PriorityQueue) FilterOnce added in v0.0.7

func (q *PriorityQueue) FilterOnce(filter func(value interface{}) bool)

FilterOnce removes the first item from the queue who's value is passed to the filter function and returns true.

func (*PriorityQueue) Len

func (q *PriorityQueue) Len() int

Len returns the current length of the priority queue.

func (PriorityQueue) Less added in v0.0.7

func (q PriorityQueue) Less(i, j int) bool

Less implements sort.Interface Less method

func (*PriorityQueue) Peek

func (q *PriorityQueue) Peek() *Entry

Peek returns the 0th entry (lowest priority) if any, leaving the PriorityQueue unaltered. Callers MUST NOT alter the Priority of the returned entry.

func (*PriorityQueue) PeekIndex added in v0.0.7

func (q *PriorityQueue) PeekIndex(i int) *Entry

PeekIndex peeks at the specified index.

func (*PriorityQueue) Pop

func (q *PriorityQueue) Pop() interface{}

Pop removes and returns the 0th entry (lowest priority) if any.

func (*PriorityQueue) Push added in v0.0.7

func (q *PriorityQueue) Push(x interface{})

Push implements heap.Interface Push method

func (*PriorityQueue) Remove added in v0.0.7

func (q *PriorityQueue) Remove(index int) interface{}

Remove removes and returns element from the heap with given index

func (*PriorityQueue) RemovePriority added in v0.0.7

func (q *PriorityQueue) RemovePriority(priority uint64) interface{}

RemovePriority removes and returns element from the heap with given priority or nil

func (PriorityQueue) Swap added in v0.0.7

func (q PriorityQueue) Swap(i, j int)

Swap implements sort.Interface Swap method

Jump to

Keyboard shortcuts

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