Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.8.3
type Option[T comparable] func(*PriorityQueue[T])
Option customize the PriorityQueue
func WithCompare ¶ added in v0.8.3
func WithCompare[T comparable](cmp comparator.Comparable[T]) Option[T]
WithCompare customize comparator.Comparable
func WithItems ¶ added in v0.8.3
func WithItems[T comparable](items ...T) Option[T]
WithItems customize initialize items
func WithMaxHeap ¶ added in v0.8.3
func WithMaxHeap[T comparable]() Option[T]
WithMaxHeap customize max heap
type PriorityQueue ¶
type PriorityQueue[T comparable] struct { // contains filtered or unexported fields }
PriorityQueue represents an unbounded priority queue based on a priority heap. It implements heap.Interface.
func NewPriorityQueue ¶
func NewPriorityQueue[T cmp.Ordered](opts ...Option[T]) *PriorityQueue[T]
NewPriorityQueue initializes and returns a priority Queue, default min heap.
func NewPriorityQueueWith ¶ added in v0.3.1
func NewPriorityQueueWith[T comparable](cmp comparator.Comparable[T], opts ...Option[T]) *PriorityQueue[T]
NewPriorityQueueWith initializes and returns a priority Queue, default min heap.
func (*PriorityQueue[T]) Clear ¶
func (pq *PriorityQueue[T]) Clear()
Clear removes all the elements from this priority queue.
func (*PriorityQueue[T]) IsEmpty ¶
func (pq *PriorityQueue[T]) IsEmpty() bool
IsEmpty returns true if this list contains no elements.
func (*PriorityQueue[T]) Len ¶
func (pq *PriorityQueue[T]) Len() int
Len returns the length of this priority queue.
func (*PriorityQueue[T]) Peek ¶
func (pq *PriorityQueue[T]) Peek() (val T, exist bool)
Peek retrieves, but does not remove, the head of this queue, or return nil if this queue is empty.
func (*PriorityQueue[T]) Pop ¶ added in v0.3.0
func (pq *PriorityQueue[T]) Pop() (val T, exist bool)
Pop retrieves and removes the head of the this queue, or return nil if this queue is empty.
func (*PriorityQueue[T]) Push ¶ added in v0.3.0
func (pq *PriorityQueue[T]) Push(item T)
Push inserts the specified element into this priority queue.