Documentation ¶
Index ¶
- type PriorityQueue
- func (p *PriorityQueue[Element, Priority]) IsEmpty() bool
- func (p *PriorityQueue[Element, Priority]) Peek() (element Element, exists bool)
- func (p *PriorityQueue[Element, Priority]) Pop() (element Element, exists bool)
- func (p *PriorityQueue[Element, Priority]) PopAll() []Element
- func (p *PriorityQueue[Element, Priority]) PopUntil(priority Priority) []Element
- func (p *PriorityQueue[Element, Priority]) Push(element Element, priority Priority) (remove func())
- func (p *PriorityQueue[Element, Priority]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[Element any, Priority generalheap.Comparable[Priority]] struct { // contains filtered or unexported fields }
PriorityQueue is a priority queue that sorts elements by a priority value.
func New ¶
func New[Element any, Priority generalheap.Comparable[Priority]]() *PriorityQueue[Element, Priority]
New creates a new PriorityQueue.
func (*PriorityQueue[Element, Priority]) IsEmpty ¶
func (p *PriorityQueue[Element, Priority]) IsEmpty() bool
IsEmpty returns true if the queue is empty.
func (*PriorityQueue[Element, Priority]) Peek ¶
func (p *PriorityQueue[Element, Priority]) Peek() (element Element, exists bool)
Peek returns the element with the highest priority without removing it.
func (*PriorityQueue[Element, Priority]) Pop ¶
func (p *PriorityQueue[Element, Priority]) Pop() (element Element, exists bool)
Pop removes the element with the highest priority from the queue.
func (*PriorityQueue[Element, Priority]) PopAll ¶
func (p *PriorityQueue[Element, Priority]) PopAll() []Element
PopAll removes all elements from the queue.
func (*PriorityQueue[Element, Priority]) PopUntil ¶
func (p *PriorityQueue[Element, Priority]) PopUntil(priority Priority) []Element
PopUntil removes all elements with a priority lower than the given priority from the queue.
func (*PriorityQueue[Element, Priority]) Push ¶
func (p *PriorityQueue[Element, Priority]) Push(element Element, priority Priority) (remove func())
Push adds an element to the queue with the given priority.
func (*PriorityQueue[Element, Priority]) Size ¶
func (p *PriorityQueue[Element, Priority]) Size() int
Size returns the number of elements in the queue.
Click to show internal directories.
Click to hide internal directories.