Documentation ¶
Overview ¶
Package priorityqueue describe an prioriry queue implement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMismatchQueue represent the element's queue mismatch current operation queue ErrMismatchQueue = xerrors.Errorf("MismatchQueue") // ErrOutOfIndex represent the element's index out of queue's length ErrOutOfIndex = xerrors.Errorf("OutOfIndex") // ErrMismatchPriority represent the element's priority mismatch ErrMismatchPriority = xerrors.Errorf("MismatchPriority") )
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[T any] struct { // Value for element Value T // contains filtered or unexported fields }
Element for priority queue element
type PriorityQueue ¶
type PriorityQueue[T any] interface { // Add element to the PriorityQueue, it will return the element witch been added Add(v T, priority int64) *Element[T] // Peek return the lowest priority element Peek() *Element[T] // Pop return the lowest priority element and remove it Pop() *Element[T] // Remove will remove the element from the priority queue Remove(v *Element[T]) error // Update the element in the priority queue with the new priority Update(v *Element[T], priority int64) error // Size return the element size of queue Size() int }
PriorityQueue for priority queue trait
func NewPriorityQueue ¶
func NewPriorityQueue[T any](size int) PriorityQueue[T]
NewPriorityQueue construct a PriorityQueue
Click to show internal directories.
Click to hide internal directories.