queue

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

bill 2018.1.8 优先级队列[同级别先进先出]权重值越大越优先

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircularLinked

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

func (*CircularLinked) Dump

func (q *CircularLinked) Dump()

func (*CircularLinked) Front

func (q *CircularLinked) Front() *list.Element

读取第一个元素后,把它移到队列尾

func (*CircularLinked) Len

func (q *CircularLinked) Len() int

func (*CircularLinked) Pop

func (q *CircularLinked) Pop() interface{}

func (*CircularLinked) Push

func (q *CircularLinked) Push(v interface{})

func (*CircularLinked) Remove

func (q *CircularLinked) Remove(iter *list.Element)

移除元素

type Item

type Item struct {
	Data       interface{} //数据
	Priority   int32       //优先级
	AddTime    time.Time   //插入队列的时间
	Expiration int64       //过期时间值 以秒为单位
}

type PriorityQueue

type PriorityQueue struct {
	Data        *list.List
	PriorityMap map[int32]*pqmap
}

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

func (*PriorityQueue) Clear added in v1.1.3

func (pq *PriorityQueue) Clear()

清除队列

func (*PriorityQueue) Dump

func (pq *PriorityQueue) Dump()

func (*PriorityQueue) Expirations

func (pq *PriorityQueue) Expirations(expriCallback func(item *Item))

检测超时任务

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() *Item

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(v *Item)

Jump to

Keyboard shortcuts

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