pqueue

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: GPL-3.0 Imports: 6 Imported by: 1

README

pqueue

GoDoc

A collection of concurrency-safe priority queue implementations.

[!NOTE] This package is under development, and I plan to add more implementations in the future.

Implementations

Currently, this package provides the following queues:

  • Pairing
  • Skew

Documentation

Overview

Package pqueue provides concurrency-safe priority queue implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConcurrencySafetyError = errors.New("concurrency-safety error: one or more queues share the same underlying" +
		"ID. ensure that all queues are being created via their designated constructors")
)

Functions

This section is empty.

Types

type Pairing

type Pairing[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

Pairing is a concurrency-safe min-priority queue built on a pairing heap.

func NewPairing

func NewPairing[K cmp.Ordered, V any]() *Pairing[K, V]

func (*Pairing[K, V]) Clear

func (p *Pairing[K, V]) Clear()

func (*Pairing[K, V]) Meld

func (p *Pairing[K, V]) Meld(other *Pairing[K, V])

Meld merges another Pairing queue into this one and clears it.

func (*Pairing[K, V]) Peek

func (p *Pairing[K, V]) Peek() V

func (*Pairing[K, V]) Pop

func (p *Pairing[K, V]) Pop() (v V, ok bool)

func (*Pairing[K, V]) Push

func (p *Pairing[K, V]) Push(v V, priority K)

func (*Pairing[K, V]) Size

func (p *Pairing[K, V]) Size() int

type Skew

type Skew[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

Skew is a concurrency-safe min-priority queue built on a skew heap.

func NewSkew

func NewSkew[K cmp.Ordered, V any]() *Skew[K, V]

func (*Skew[K, V]) Clear

func (s *Skew[K, V]) Clear()

func (*Skew[K, V]) Meld

func (s *Skew[K, V]) Meld(other *Skew[K, V])

Meld merges another Skew queue into this one and clears it.

func (*Skew[K, V]) Peek

func (s *Skew[K, V]) Peek() V

func (*Skew[K, V]) Pop

func (s *Skew[K, V]) Pop() (v V, ok bool)

func (*Skew[K, V]) Push

func (s *Skew[K, V]) Push(v V, priority K)

func (*Skew[K, V]) Size

func (s *Skew[K, V]) Size() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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