Documentation ¶
Index ¶
- type PriorityQueue
- func (p *PriorityQueue) Insert(v interface{}, time_stamp int64, price float64)
- func (p *PriorityQueue) Len() int
- func (p *PriorityQueue) Pop() (interface{}, error)
- func (p *PriorityQueue) Remove(value interface{}) (interface{}, error)
- func (p *PriorityQueue) UpdatePriority(x interface{}, time_stamp int64, price float64)
- type RPriorityQueue
- func (p *RPriorityQueue) Insert(v interface{}, time_stamp int64, price float64)
- func (p *RPriorityQueue) Len() int
- func (p *RPriorityQueue) Pop() (interface{}, error)
- func (p *RPriorityQueue) Remove(value interface{}) (interface{}, error)
- func (p *RPriorityQueue) UpdatePriority(x interface{}, time_stamp int64, price float64)
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.