Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOutOfCapacity = errors.New("priorityQueue exceeding capacity limit ") ErrEmptyQueue = errors.New("priorityQueue has no elements") )
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[T any] struct { // contains filtered or unexported fields }
func NewPriorityQueue ¶
func NewPriorityQueue[T any](capacity int, compare containerx.Comparator[T]) *PriorityQueue[T]
NewPriorityQueue 创建优先队列 capacity <= 0 时,为无界队列,否则为有界队列
func (*PriorityQueue[T]) Dequeue ¶
func (p *PriorityQueue[T]) Dequeue() (T, error)
func (*PriorityQueue[T]) Enqueue ¶
func (p *PriorityQueue[T]) Enqueue(t T) error
func (*PriorityQueue[T]) IsBoundless ¶
func (p *PriorityQueue[T]) IsBoundless() bool
func (*PriorityQueue[T]) Len ¶
func (p *PriorityQueue[T]) Len() int
func (*PriorityQueue[T]) Peek ¶
func (p *PriorityQueue[T]) Peek() (T, error)
Click to show internal directories.
Click to hide internal directories.