Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[T any, P comparable] struct { // contains filtered or unexported fields }
PriorityQueue will pop items with the highest or lowest priority depending on compare.
func NewPriorityQueue ¶
func NewPriorityQueue[T any, P comparable](compare func(a, b P) bool) *PriorityQueue[T, P]
NewPriorityQueue creates a heap that is sorted by priority.
func (*PriorityQueue[T, P]) Clear ¶
func (h *PriorityQueue[T, P]) Clear()
Clear removes all items from the queue.
func (*PriorityQueue[T, P]) Empty ¶
func (h *PriorityQueue[T, P]) Empty() bool
Empty returns true if the queue is empty.
func (*PriorityQueue[T, P]) Len ¶
func (h *PriorityQueue[T, P]) Len() int
Len returns the number of items in the queue.
func (*PriorityQueue[T, P]) Pop ¶
func (h *PriorityQueue[T, P]) Pop() T
Pop removes the item with the highest or lowest priority depending on compare.
func (*PriorityQueue[T, P]) Push ¶
func (h *PriorityQueue[T, P]) Push(v T, priority P)
Push adds an item to the queue with the given priority.
Click to show internal directories.
Click to hide internal directories.