prque

package
v2.11.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 3 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, V cmp.Ordered] struct {
	// The value associated with the item
	Value T

	// The priority of the item
	Priority V
}

Item represents an item from the priority queue.

type PriorityQueue

type PriorityQueue[T any, V cmp.Ordered] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PriorityQueue is a priority queue implementation based container/heap.

func New

func New[T any, V cmp.Ordered]() *PriorityQueue[T, V]

New creates a new priority queue, containing items of type T with priority V.

func (*PriorityQueue[T, V]) Get added in v2.11.0

func (pq *PriorityQueue[T, V]) Get() (T, V)

Get returns the next item from the priority queue

func (*PriorityQueue[T, V]) IsEmpty added in v2.11.0

func (pq *PriorityQueue[T, V]) IsEmpty() bool

IsEmpty returns a boolean indicating whether the priority queue is empty or not.

func (*PriorityQueue[T, V]) Len

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

Len implements sort.Interface.

func (*PriorityQueue[T, V]) Less added in v2.11.0

func (pq *PriorityQueue[T, V]) Less(i, j int) bool

Less implements sort.Interface.

func (*PriorityQueue[T, V]) Peek added in v2.11.0

func (pq *PriorityQueue[T, V]) Peek() (T, V)

Peek returns the next time from the priority queue without dequeing it.

func (*PriorityQueue[T, V]) Pop

func (pq *PriorityQueue[T, V]) Pop() any

Pop implements heap.Interface.

func (*PriorityQueue[T, V]) Push

func (pq *PriorityQueue[T, V]) Push(x any)

Push implements heap.Interface.

func (*PriorityQueue[T, V]) Put added in v2.11.0

func (pq *PriorityQueue[T, V]) Put(value T, priority V)

Put adds a value with the given priority to the priority queue.

func (*PriorityQueue[T, V]) Swap added in v2.11.0

func (pq *PriorityQueue[T, V]) Swap(i, j int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

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