queue

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item[T any] struct {
	Value    T
	Priority int
	// contains filtered or unexported fields
}

Item is a single item in the priority queue

type PriorityQueue

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

PriorityQueue implements a thread-safe generic priority queue

func NewPriorityQueue

func NewPriorityQueue[T any]() *PriorityQueue[T]

NewPriorityQueue creates a new priority queue

func (*PriorityQueue[T]) Dequeue

func (pq *PriorityQueue[T]) Dequeue() (T, bool)

Dequeue removes and returns the highest priority item from the queue

func (*PriorityQueue[T]) DequeueAll

func (pq *PriorityQueue[T]) DequeueAll() []T

func (*PriorityQueue[T]) Enqueue

func (pq *PriorityQueue[T]) Enqueue(value T, priority int)

Enqueue adds a value to the priority queue with the given priority

func (*PriorityQueue[T]) Len

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

Len returns the length of the priority queue

Jump to

Keyboard shortcuts

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