priority_queue

package
v0.0.0-...-54421ad Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

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

PriorityQueue represents the queue

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

New initializes an empty priority queue.

func (*PriorityQueue) Insert

func (p *PriorityQueue) Insert(v interface{}, time_stamp int64, price float64)

Insert inserts a new element into the queue. No action is performed on duplicate elements.

func (*PriorityQueue) Len

func (p *PriorityQueue) Len() int

Len returns the number of elements in the queue.

func (*PriorityQueue) Pop

func (p *PriorityQueue) Pop() (interface{}, error)

Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.

func (*PriorityQueue) Remove

func (p *PriorityQueue) Remove(value interface{}) (interface{}, error)

remove 删除一个元素

func (*PriorityQueue) UpdatePriority

func (p *PriorityQueue) UpdatePriority(x interface{}, time_stamp int64, price float64)

UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.

type RPriorityQueue

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

RPriorityQueue represents the queue

func NewRPriorityQueue

func NewRPriorityQueue() RPriorityQueue

New initializes an empty priority queue.

func (*RPriorityQueue) Insert

func (p *RPriorityQueue) Insert(v interface{}, time_stamp int64, price float64)

Insert inserts a new element into the queue. No action is performed on duplicate elements.

func (*RPriorityQueue) Len

func (p *RPriorityQueue) Len() int

Len returns the number of elements in the queue.

func (*RPriorityQueue) Pop

func (p *RPriorityQueue) Pop() (interface{}, error)

Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.

func (*RPriorityQueue) Remove

func (p *RPriorityQueue) Remove(value interface{}) (interface{}, error)

remove 删除一个元素

func (*RPriorityQueue) UpdatePriority

func (p *RPriorityQueue) UpdatePriority(x interface{}, time_stamp int64, price float64)

UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.

Jump to

Keyboard shortcuts

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