Documentation
¶
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 represents the queue
func New ¶
func New[T any](ops ...PriorityQueueOption) PriorityQueue[T]
New initializes an empty priority queue.
func (*PriorityQueue[T]) Insert ¶
func (p *PriorityQueue[T]) Insert(v T, priority float64)
Insert inserts a new element into the queue. No action is performed on duplicate elements.
func (*PriorityQueue[T]) Len ¶
func (p *PriorityQueue[T]) Len() int
Len returns the number of elements in the queue.
func (*PriorityQueue[T]) Pop ¶
func (p *PriorityQueue[T]) Pop() (T, error)
Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.
func (*PriorityQueue[T]) UpdatePriority ¶
func (p *PriorityQueue[T]) UpdatePriority(x T, newPriority float64)
UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.
type PriorityQueueOption ¶
type PriorityQueueOption func(*option)
func MaxHeap ¶
func MaxHeap() PriorityQueueOption
Click to show internal directories.
Click to hide internal directories.