pq

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 2 Imported by: 0

README

codecov

Small library for personal projects that need to use some sort of priority queue. Includes an implementation of a priority channel.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelMessage

type ChannelMessage[T any] struct {
	Payload  T
	Priority int
}

type Comparator

type Comparator[T any] = func(a, b T) int

type PriorityChannel

type PriorityChannel[T any] struct {
	// contains filtered or unexported fields
}

func NewPriorityChannel

func NewPriorityChannel[T any]() *PriorityChannel[T]

func (*PriorityChannel[T]) Pop

func (pc *PriorityChannel[T]) Pop(ctx context.Context) (T, int, bool, error)

func (*PriorityChannel[T]) PopBlocking added in v0.1.3

func (pc *PriorityChannel[T]) PopBlocking(ctx context.Context) (T, int, error)

PopBlocking blocks until queue isn't empty or context is canceled.

func (*PriorityChannel[T]) Push

func (pc *PriorityChannel[T]) Push(item T, priority int)

func (*PriorityChannel[T]) TryImmediatePop

func (pc *PriorityChannel[T]) TryImmediatePop() (T, int, bool)

type PriorityQueue

type PriorityQueue[C Comparator[T], T any] struct {
	// contains filtered or unexported fields
}

func NewPriorityQueue

func NewPriorityQueue[C Comparator[T], T any](cmp C) *PriorityQueue[C, T]

func (*PriorityQueue[C, T]) Len added in v0.1.3

func (pq *PriorityQueue[C, T]) Len() int

func (*PriorityQueue[C, T]) Peek

func (pq *PriorityQueue[C, T]) Peek() (T, bool)

func (*PriorityQueue[C, T]) Pop

func (pq *PriorityQueue[C, T]) Pop() (T, bool)

func (*PriorityQueue[C, T]) Push

func (pq *PriorityQueue[C, T]) Push(item T)

Jump to

Keyboard shortcuts

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