queue

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 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 {
	// contains filtered or unexported fields
}

An Item is something we manage in a priority queue.

func NewItem

func NewItem(value interface{}, priority time.Time) *Item

NewItem wraps a value in a Queue Item

func (*Item) Index

func (i *Item) Index() int

Index of the item

func (*Item) Priority

func (i *Item) Priority() time.Time

Priority of the item

func (*Item) Value

func (i *Item) Value() interface{}

Value pointed to by the item

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) AtIdx

func (pq PriorityQueue) AtIdx(i int) *Item

AtIdx gets item at given index

func (PriorityQueue) Cap

func (pq PriorityQueue) Cap() int

Cap returns the current capacity of the underlying array of the Priority Queue

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len returns the current length of the underlying array of the PriorityQueue

func (PriorityQueue) Less

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

Less defines item ordering. Priority is defined by trigger time in the future

func (*PriorityQueue) Pop

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

Pop the item with the closest trigger time (priority)

func (*PriorityQueue) Push

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

Push an item to this PriorityQueue

func (PriorityQueue) Swap

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

Jump to

Keyboard shortcuts

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