priorityqueue

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: AGPL-3.0 Imports: 5 Imported by: ? 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

This section is empty.

Functions

This section is empty.

Types

type Item

type Item interface {
	Key() string
	Priority() int64
	SetPriority(int64)
	CreationTime() time.Time
	Index() int
	SetIndex(int)
}

Item 是优先队列存储的结构

func NewItem

func NewItem(key string, priority int64, creationTime time.Time) Item

type PriorityQueue

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

PriorityQueue 优先队列

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

func (*PriorityQueue) Add

func (pq *PriorityQueue) Add(item Item)

Add 新增 BaseItem

func (*PriorityQueue) Export

func (pq *PriorityQueue) Export() json.RawMessage

func (*PriorityQueue) Get

func (pq *PriorityQueue) Get(key string) Item

Get 根据 key 获取 BaseItem

func (*PriorityQueue) Import

func (pq *PriorityQueue) Import(rawMsg json.RawMessage) error

func (*PriorityQueue) LeftHasHigherOrder added in v1.0.0

func (pq *PriorityQueue) LeftHasHigherOrder(left, right string) bool

LeftHasHigherOrder judge order of two items. return true if left has higher order.

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

Len 返回队列长度

func (*PriorityQueue) Peek

func (pq *PriorityQueue) Peek() Item

Peek 获取优先级最高的 BaseItem

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() Item

Pop 弹出优先级最高的 BaseItem,并返回

func (*PriorityQueue) Range

func (pq *PriorityQueue) Range(f func(Item) (stopRange bool))

Range range items and apply func to item one by one.

func (*PriorityQueue) Remove

func (pq *PriorityQueue) Remove(key string) Item

Remove 删除 BaseItem

type SnapshotObj

type SnapshotObj struct {
	Key          string    `json:"key"`
	Priority     int64     `json:"priority"`
	CreationTime time.Time `json:"creationTime"`
	Index        int       `json:"index"`
}

Jump to

Keyboard shortcuts

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