queue

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue[T any](compare func(T, T) int) (*PriorityQueue[T], error)

NewPriorityQueue 创建一个新的优先级队列 compare: 用于定义元素之间的优先级比较规则的函数,返回值为 -1、0、1,表示小于、等于、大于 返回值: - *PriorityQueue: 新创建的优先级队列实例指针 - error: 如果 compare 为 nil,则返回错误

func (*PriorityQueue[T]) Delete

func (_self *PriorityQueue[T]) Delete(data *T) bool

func (*PriorityQueue[T]) Destroy

func (_self *PriorityQueue[T]) Destroy()

func (*PriorityQueue[T]) IsEmpty

func (_self *PriorityQueue[T]) IsEmpty() bool

IsEmpty 检查队列是否为空 返回值: - bool: 如果队列为空,则返回 true;否则返回 false

func (*PriorityQueue[T]) Pop

func (_self *PriorityQueue[T]) Pop() (data *T, ok bool)

Pop 删除并返回队列中的最高优先级元素 返回值: - error: 如果队列为空,则返回错误

func (*PriorityQueue[T]) Push

func (_self *PriorityQueue[T]) Push(data *T)

Push 向队列中插入元素 data: 元素的数据信息

func (*PriorityQueue[T]) Size

func (_self *PriorityQueue[T]) Size() int

Jump to

Keyboard shortcuts

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