queue

package
v0.0.0-...-b952f1b Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	// contains filtered or unexported fields
}

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

NewPriorityQueue 初始化 PriorityQueue 实例

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

Len 获取堆中元素数量

func (*PriorityQueue) Less

func (pq *PriorityQueue) Less(i, j int) bool

Less 比较两个元素的优先级大小

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop 弹出堆顶元素

func (*PriorityQueue) PopItem

func (pq *PriorityQueue) PopItem() interface{}

PopItem 从 PriorityQueue 中取出元素

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push 添加元素到堆中

func (*PriorityQueue) PushItem

func (pq *PriorityQueue) PushItem(value interface{}, priority int)

PushItem 向 PriorityQueue 实例中添加元素

func (*PriorityQueue) Swap

func (pq *PriorityQueue) Swap(i, j int)

Swap 交换两个元素的位置

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(item *Item, value interface{}, priority int)

Update 更新堆中元素的优先级

type Queue

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

func GetDefaultQueue

func GetDefaultQueue[T any](size int) *Queue[T]

func (*Queue[T]) Count

func (q *Queue[T]) Count() int

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() (T, bool)

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(item T)

func (*Queue[T]) Front

func (q *Queue[T]) Front() T

Jump to

Keyboard shortcuts

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