Documentation ¶
Index ¶
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 Heap ¶
type Heap []*Element
Heap - array of Element pointers that will be transformed in a heap
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
func (PriorityQueue) Len ¶
func (queue PriorityQueue) Len() int
func (*PriorityQueue) Pop ¶
func (queue *PriorityQueue) Pop() *Element
Pop - removes and returns the element with the highest 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
Click to show internal directories.
Click to hide internal directories.