pqueue

package
v0.0.0-...-e52ff56 Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: MIT Imports: 1 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 {
	Value    interface{} // 元素值
	Priority int64       // 优先级
	Index    int         // 保存自身的索引值
}

type PriorityQueue

type PriorityQueue []*Item

func New

func New(capacity int) PriorityQueue

创建容量为capacity的切片

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

返回切片的长度

func (PriorityQueue) Less

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

比较索引i,j元素优先级大小()

func (*PriorityQueue) PeekAndShift

func (pq *PriorityQueue) PeekAndShift(max int64) (*Item, int64)

最小元素的优先级大于max才返回Item

func (*PriorityQueue) Pop

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

弹出最小值

func (*PriorityQueue) Push

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

添加x

func (PriorityQueue) Swap

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

交换索引i,j元素

Jump to

Keyboard shortcuts

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