Home

# Class goog.structs.Heap

Class for a Heap datastructure.

Instance Method Summary
| `clear()` Removes all elements from the heap.
| `clone() ⇒ ?goog.structs.Heap` Clones a heap and returns a new heap
| `containsKey(?Object key) ⇒ boolean` Whether the heap contains the given key.
| `containsValue(?Object val) ⇒ boolean` Whether the heap contains the given value.
| `getCount() ⇒ number` The number of key-value pairs in the map
| `getKeys() ⇒ ?Array` Gets the keys of the heap.
| `getLeftChildIndex_(number index) ⇒ number` Gets the index of the left child of the node at the given index.
| `getParentIndex_(number index) ⇒ number` Gets the index of the parent of the node at the given index.
| `getRightChildIndex_(number index) ⇒ number` Gets the index of the right child of the node at the given index.
| `getValues() ⇒ ?Array` Gets the values of the heap.
| `insert(<Any Type> key, <Any Type> value)` Insert the given value into the heap with the given key.
| `insertAll((Object|goog.structs.Heap|null) heap)` Adds multiple key-value pairs from another goog.structs.Heap or Object
| `isEmpty() ⇒ boolean` Returns true if this heap contains no elements.
| `moveDown_(number index)` Moves the node at the given index down to its proper place in the heap.
| `moveUp_(number index)` Moves the node at the given index up to its proper place in the heap.
| `peek() ⇒ <Any Type>` Retrieves but does not remove the root value of this heap.
| `peekKey() ⇒ <Any Type>` Retrieves but does not remove the key of the root node of this heap.
| `remove() ⇒ <Any Type>` Retrieves and removes the root value of this heap.