Documentation
¶
Overview ¶
Package priorityqueue provides a generic priority queue implementation based on array heap that is safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[T any] struct { // contains filtered or unexported fields }
PriorityQueue is a generic priority queue with a configurable comparision function (comparator).
func New ¶
func New[T any](comparator comparator.Comparator[T]) *PriorityQueue[T]
New creates a new PriorityQueue with the specified comparator.
func (*PriorityQueue[T]) Empty ¶
func (pq *PriorityQueue[T]) Empty() bool
Empty reports whether the priority queue is empty.
func (*PriorityQueue[T]) Len ¶
func (pq *PriorityQueue[T]) Len() int
Len returns the number of elements in the priority queue.
func (*PriorityQueue[T]) Pop ¶
func (pq *PriorityQueue[T]) Pop() (T, bool)
Pop returns the element with the maximal priority in the queue, and removes it from the queue. If the queue is empty, it returns the zero value of the element type and false.
func (*PriorityQueue[T]) Push ¶
func (pq *PriorityQueue[T]) Push(v T)
Push adds an element to the priority queue.
func (*PriorityQueue[T]) Top ¶
func (pq *PriorityQueue[T]) Top() (T, bool)
Top returns the element with the maximal priority in the queue. If the queue is empty, it returns the zero value of the element type and false.