Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmpty = errors.New("queue is empty")
ErrEmpty is returned for queues with no items
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[T any] struct { // contains filtered or unexported fields }
func NewPriorityQueue ¶
func NewPriorityQueue[T any](comp func(this, that *T) bool) *PriorityQueue[T]
NewPriorityQueue initializes internal data structure and returns new PriorityQueue accepting a comparator function comp function decides ordering in queue, Sort `this` before `that` if True.
func (*PriorityQueue[T]) Pop ¶
func (pq *PriorityQueue[T]) Pop() (*T, error)
Pop pops the highest priority item from queue The complexity is O(log n) where n = h.Len().
func (*PriorityQueue[T]) Push ¶
func (pq *PriorityQueue[T]) Push(x *T)
Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Len().
Click to show internal directories.
Click to hide internal directories.