The goog.structs.Heap Class

goog.structs.Heap(opt_heap)

Class for a Heap datastructure.

opt_heap {goog.structs.Heap|Object=}
Optional goog.structs.Heap or Object to initialize heap with.

.clear()

Removes all elements from the heap.

.clone()

Clones a heap and returns a new heap

returns {goog.structs.Heap}
A new goog.structs.Heap with the same key-value pairs.

.containsKey(key)

Whether the heap contains the given key.

key {Object}
The key to check for.
returns {boolean}
Whether the heap contains the key.

.containsValue(val)

Whether the heap contains the given value.

val {Object}
The value to check for.
returns {boolean}
Whether the heap contains the value.

.getCount()

The number of key-value pairs in the map

returns {number}
The number of pairs.

.getKeys()

Gets the keys of the heap.

returns {Array}
The keys in the heap.

.getValues()

Gets the values of the heap.

returns {Array}
The values in the heap.

.insert(key, value)

Insert the given value into the heap with the given key.

key {*}
The key.
value {*}
The value.

.insertAll(heap)

Adds multiple key-value pairs from another goog.structs.Heap or Object

heap {goog.structs.Heap|Object}
Object containing the data to add.

.isEmpty()

Returns true if this heap contains no elements.

returns {boolean}
Whether this heap contains no elements.

.peek()

Retrieves but does not remove the root value of this heap.

returns {*}
The value at the root of the heap. Returns undefined if the heap is empty.

.peekKey()

Retrieves but does not remove the key of the root node of this heap.

returns {*}
The key at the root of the heap. Returns undefined if the heap is empty.

.remove()

Retrieves and removes the root value of this heap.

returns {*}
The value removed from the root of the heap. Returns undefined if the heap is empty.