Documentation
¶
Index ¶
- type Element
- type PriorityQueue
- func (queue *PriorityQueue) At(index int) *Element
- func (queue PriorityQueue) IsEmpty() bool
- func (queue PriorityQueue) Len() int
- func (queue *PriorityQueue) Peek() *Element
- func (queue *PriorityQueue) Pop() *Element
- func (queue *PriorityQueue) PopLowest() *Element
- func (queue *PriorityQueue) Push(element *Element)
- func (queue *PriorityQueue) Remove(index int) *Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { Value interface{} Priority int // contains filtered or unexported fields }
Element - struct used to represent an item in the prioriry queue
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue - wrapper over the heap implementation
func NewPriorityQueue ¶
func NewPriorityQueue() PriorityQueue
NewPriorityQueue - creates a new priority queue and initializes the heap
func (*PriorityQueue) At ¶
func (queue *PriorityQueue) At(index int) *Element
At - get the element at the specified index from the heap
func (PriorityQueue) IsEmpty ¶
func (queue PriorityQueue) IsEmpty() bool
IsEmpty - returns true if the heap has no elements, false otherwise
func (PriorityQueue) Len ¶
func (queue PriorityQueue) Len() int
Len - return the number of elements in the heap
func (*PriorityQueue) Peek ¶
func (queue *PriorityQueue) Peek() *Element
Peek - returns the element with the highest priority from the heap
func (*PriorityQueue) Pop ¶
func (queue *PriorityQueue) Pop() *Element
Pop - removes and returns the element with the highest priority from the heap
func (*PriorityQueue) PopLowest ¶
func (queue *PriorityQueue) PopLowest() *Element
PopLowest - removes and returns the element with the lowest priority from the heap
func (*PriorityQueue) Push ¶
func (queue *PriorityQueue) Push(element *Element)
Push - add a new element in the right position in the heap according to its priority
func (*PriorityQueue) Remove ¶
func (queue *PriorityQueue) Remove(index int) *Element
Remove - removes and returns the element at position index from the heap