Documentation ¶
Overview ¶
Package depriorityqueue provides interface and implementations for double-ended priority queue abstract data type
Index ¶
- type DEPriorityQueue
- type NaiveDEPriorityQueue
- func (q *NaiveDEPriorityQueue[T]) ExtractMax() (T, bool)
- func (q *NaiveDEPriorityQueue[T]) ExtractMin() (T, bool)
- func (q *NaiveDEPriorityQueue[T]) Insert(i T)
- func (q *NaiveDEPriorityQueue[T]) PeekMax() (T, bool)
- func (q *NaiveDEPriorityQueue[T]) PeekMin() (T, bool)
- func (q *NaiveDEPriorityQueue[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DEPriorityQueue ¶
type NaiveDEPriorityQueue ¶
NaiveDEPriorityQueue is a naive implementation of a double-ended priority queue.
func NewNaiveDEPriorityQueue ¶
func NewNaiveDEPriorityQueue[T cmp.Ordered]() *NaiveDEPriorityQueue[T]
NewNaiveDEPriorityQueue instantiates a NaiveDEPriorityQueue and returns a pointer to it.
func (*NaiveDEPriorityQueue[T]) ExtractMax ¶
func (q *NaiveDEPriorityQueue[T]) ExtractMax() (T, bool)
ExtractMax removes the highest-priority item and returns it. A Boolean is also returned that is false if the queue was empty.
func (*NaiveDEPriorityQueue[T]) ExtractMin ¶
func (q *NaiveDEPriorityQueue[T]) ExtractMin() (T, bool)
ExtractMin removes the lowest-priority item and returns it. A Boolean is also returned that is false if the queue was empty.
func (*NaiveDEPriorityQueue[T]) Insert ¶
func (q *NaiveDEPriorityQueue[T]) Insert(i T)
Insert inserts an element into the queue.
func (*NaiveDEPriorityQueue[T]) PeekMax ¶
func (q *NaiveDEPriorityQueue[T]) PeekMax() (T, bool)
PeekMax returns the highest-priority item but, unlike ExtractMax, does not remove it. A Boolean is also returned that is false if the queue was empty.
func (*NaiveDEPriorityQueue[T]) PeekMin ¶
func (q *NaiveDEPriorityQueue[T]) PeekMin() (T, bool)
PeekMin returns the lowest-prioity item but, unlike ExtractMin, does not remove it. A Boolean is also returned that is false if the queue was empty.
func (*NaiveDEPriorityQueue[T]) Size ¶
func (q *NaiveDEPriorityQueue[T]) Size() int
Size returns the number of items in the queue.