Heap

tree-like automatic ordering of a set for the purpose of getting the lowest value quickly. This is faster than a normal binary search tree as it actually uses an array

new virtuosity.structures.Heap();


Parameter Type Description

Methods


Methods

size

get the size of the heap

virtuosity.structures.Heap.size();

push

add a value to the heap

virtuosity.structures.Heap.push(val);


Parameter Type Description
val Number vale to add to the heap

print

print the array of the heap

virtuosity.structures.Heap.print();

peek

get the lowest value

virtuosity.structures.Heap.peek();

pop

get and remove the lowest value

virtuosity.structures.Heap.pop();

remove

get and remove a value from a specific index

virtuosity.structures.Heap.remove(i);


Parameter Type Description
i Int index of the value to remove