Documentation ¶
Index ¶
- type PriorityQueue
- func (p *PriorityQueue) Insert(v interface{}, priority float64) (duplicate bool)
- func (p *PriorityQueue) Len() int
- func (p *PriorityQueue) Peek() (interface{}, bool)
- func (p *PriorityQueue) Pop() interface{}
- func (p *PriorityQueue) Remove(x interface{})
- func (p *PriorityQueue) UpdatePriority(x interface{}, newPriority 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 (*PriorityQueue) Insert ¶
func (p *PriorityQueue) Insert(v interface{}, priority float64) (duplicate bool)
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) Peek ¶
func (p *PriorityQueue) Peek() (interface{}, bool)
Peek returns the item that is on top of the heap but does not remove. In case of an empty queue, false is returned.
func (*PriorityQueue) Pop ¶
func (p *PriorityQueue) Pop() interface{}
Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, nil is returned.
func (*PriorityQueue) Remove ¶
func (p *PriorityQueue) Remove(x interface{})
Remove removes the element.
func (*PriorityQueue) UpdatePriority ¶
func (p *PriorityQueue) UpdatePriority(x interface{}, newPriority float64)
UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.
Click to show internal directories.
Click to hide internal directories.