Documentation ¶
Index ¶
- type PrioQueue
- func (q *PrioQueue[T, P]) ChangePriority(item T, newPriority P)
- func (q *PrioQueue[T, P]) ChangeValue(toChange T, newValue T)
- func (q *PrioQueue[T, P]) Dequeue() T
- func (q *PrioQueue[T, P]) GetPriority(item T) (P, error)
- func (q *PrioQueue[T, P]) Insert(item T, priority P)
- func (q *PrioQueue[T, P]) IsEmpty() bool
- func (q *PrioQueue[T, P]) Peek() T
- func (q *PrioQueue[T, P]) Remove(priority P) T
- func (q *PrioQueue[T, P]) Size() int
- func (q *PrioQueue[T, P]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrioQueue ¶
type PrioQueue[T comparable, P cmp.Ordered] struct { // contains filtered or unexported fields }
PrioQueue Priority queue implemented with a heap. Lowest number -> highest priority. Admits duplicates for both priorities and items
func NewPrioQueue ¶
func NewPrioQueue[T comparable, P cmp.Ordered]() PrioQueue[T, P]
func (*PrioQueue[T, P]) ChangePriority ¶
func (q *PrioQueue[T, P]) ChangePriority(item T, newPriority P)
ChangePriority If the item is not found is added to the priority list
func (*PrioQueue[T, P]) ChangeValue ¶
func (q *PrioQueue[T, P]) ChangeValue(toChange T, newValue T)
ChangeValue Changes the value of an element of the queue. Does nothing if the element is not found
func (*PrioQueue[T, P]) Dequeue ¶
func (q *PrioQueue[T, P]) Dequeue() T
Dequeue Removes and returns the item with the highest priority
func (*PrioQueue[T, P]) GetPriority ¶
GetPriority Returns the priority of the specified item. If there are duplicates returns one of them with no guarantees about which item is retrieved
Click to show internal directories.
Click to hide internal directories.