prioqueue

package
v3.0.0-rc75 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prioqueue implements a priority queue using a heap-based implementation.

Items are ordered according to the Interface.Before method. The queue is a min-heap: items for which Before returns true come first. This means lower priority values (as defined by the Before implementation) are popped before higher values.

The heap keeps no arrival order between items Before does not order: of equal items, the last pushed may pop first. The daemon/runner breaks the ties with an arrival rank, for its items of equal priority to run in the order they were queued:

func (t Item) Before(other prioqueue.Interface) bool {
    o := other.(Item)
    if t.priority != o.priority {
        return t.priority < o.priority
    }
    return t.seq < o.seq
}

Then an item of priority 1 pops before an item of priority 2, and of two items of priority 2, the one queued first pops first.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Before(Interface) bool
}

type Queue

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

func New

func New() *Queue

func (*Queue) Len

func (pq *Queue) Len() int

func (*Queue) Pop

func (pq *Queue) Pop() Interface

func (*Queue) Push

func (pq *Queue) Push(something Interface)

Jump to

Keyboard shortcuts

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