queue

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfCapacity = errors.New("ekit: 超出最大容量限制")
	ErrEmptyQueue    = errors.New("ekit: 队列为空")
)

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue[T any] struct {
	// contains filtered or unexported fields
}

PriorityQueue 是一个基于小顶堆的优先队列 当capacity <= 0时,为无界队列,切片容量会动态扩缩容 当capacity > 0 时,为有界队列,初始化后就固定容量,不会扩缩容

func NewPriorityQueue

func NewPriorityQueue[T any](capacity int, compare ekit.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