queue

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

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]) Cap

func (p *PriorityQueue[T]) Cap() int

Cap 无界队列返回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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL