structs.Heap Extends
Class for a Heap datastructure.

Inheritance

Constructor

goog.structs.Heap(opt_heap)

Parameters

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

Instance Methods

Public Protected Private
clear()
Removes all elements from the heap.
code »
clone() !goog.structs.Heap
Clones a heap and returns a new heap
Returns: !goog.structs.Heap  A new goog.structs.Heap with the same key-value pairs.
code »
containsKey(key) boolean
Whether the heap contains the given key.
Arguments:
key : K
The key to check for.
Returns: boolean  Whether the heap contains the key.
code »
containsValue(val) boolean
Whether the heap contains the given value.
Arguments:
val : V
The value to check for.
Returns: boolean  Whether the heap contains the value.
code »
getCount() number
The number of key-value pairs in the map
Returns: number  The number of pairs.
code »
getKeys() !Array.<K>
Gets the keys of the heap.
Returns: !Array.<K>  The keys in the heap.
code »
getLeftChildIndex_(index) number
Gets the index of the left child of the node at the given index.
Arguments:
index : number
The index of the node to get the left child for.
Returns: number  The index of the left child.
code »
getParentIndex_(index) number
Gets the index of the parent of the node at the given index.
Arguments:
index : number
The index of the node to get the parent for.
Returns: number  The index of the parent.
code »
getRightChildIndex_(index) number
Gets the index of the right child of the node at the given index.
Arguments:
index : number
The index of the node to get the right child for.
Returns: number  The index of the right child.
code »
getValues() !Array.<V>
Gets the values of the heap.
Returns: !Array.<V>  The values in the heap.
code »
insert(keyvalue)
Insert the given value into the heap with the given key.
Arguments:
key : K
The key.
value : V
The value.
code »
insertAll(heap)
Adds multiple key-value pairs from another goog.structs.Heap or Object
Arguments:
heap : goog.structs.Heap | Object
Object containing the data to add.
code »
isEmpty() boolean
Returns true if this heap contains no elements.
Returns: boolean  Whether this heap contains no elements.
code »
moveDown_(index)
Moves the node at the given index down to its proper place in the heap.
Arguments:
index : number
The index of the node to move down.
code »
moveUp_(index)
Moves the node at the given index up to its proper place in the heap.
Arguments:
index : number
The index of the node to move up.
code »
peek() V
Retrieves but does not remove the root value of this heap.
Returns: V  The value at the root of the heap. Returns undefined if the heap is empty.
code »
peekKey() V
Retrieves but does not remove the key of the root node of this heap.
Returns: V  The key at the root of the heap. Returns undefined if the heap is empty.
code »
remove() V
Retrieves and removes the root value of this heap.
Returns: V  The value removed from the root of the heap. Returns undefined if the heap is empty.
code »

Instance Properties

nodes_ :
The nodes of the heap.
Code »

Package structs

Package Reference