Heap instance constructor.
Optional comparison function, defaults to Heap.minComparator
Optional comparison function, defaults to Heap.minComparator
Alias of __type
peek
Alias of __type
add
Alias of __type
pop
Alias of __type
clear
Length of the heap. Aliases: size.
size
setLimit
Set length limit of the heap. Same as using setLimit.
Limit, defaults to 0 (no limit). Negative, Infinity, or NaN values set the limit to 0.
If the heap is longer than the limit, the needed amount of leafs are removed.
setLimit
Adds an array of elements to the heap. Similar as: push(element, element, ...).
Elements to be added
true
Returns the comparison function.
Returns true if this queue contains the specified element.
Element to be found
Optional comparison function, receives (element, needle)
Get the index of the first occurrence of the element in the heap (using the comparator).
Element to be found
Optional comparison function, receives (element, needle)
Index or -1 if not found
Get the indexes of the every occurrence of the element in the heap (using the comparator).
Element to be found
Optional comparison function, receives (element, needle)
Array of indexes or empty array if not found
Get the leafs of the tree (no children nodes). See also: getChildrenOf and bottom.
Extract the top node (root). Aliases: poll.
Extracted top node, undefined if empty
Remove the first occurrence of an element from the heap.
Optional
o: TElement to be found
Optional equality function, receives (element, needle)
True if the heap was modified
Set length limit of the heap. Same as assigning to limit but returns NaN if the value was invalid.
Limit. Negative, Infinity, or NaN values set the limit to 0.
The limit or NaN if the value was negative, or NaN.
limit
Static
defaultStatic
getStatic
getStatic
getStatic
heapbottomReturn the n
least valuable elements of a heap-like Array
Array, should be an array-heap
Max number of elements
Optional
compare: Comparator<N>Optional compare function
Elements
Static
heapifyConverts an array into an array-heap, in place
Array to be modified
Optional
compare: Comparator<N>Optional compare function
For convenience, it returns a Heap instance
Static
heappopExtract the peek of an array-heap
Array to be modified, should be a heap
Optional
compare: Comparator<N>Optional compare function
Returns the extracted peek
Static
heappushPushes a item into an array-heap
Array to be modified, should be a heap
Item to push
Optional
compare: Comparator<N>Optional compare function
Static
heappushpopPush followed by pop, faster
Array to be modified, should be a heap
Item to push
Optional
compare: Comparator<N>Optional compare function
Returns the extracted peek
Static
heapreplaceReplace peek with item
Array to be modified, should be a heap
Item as replacement
Optional
compare: Comparator<N>Optional compare function
Returns the extracted peek
Static
heaptopReturn the n
most valuable elements of a heap-like Array
Array, should be an array-heap
Max number of elements
Optional
compare: Comparator<N>Optional compare function
Elements
Static
maxStatic
maxStatic
minStatic
minStatic
nlargestReturn the n
most valuable elements of an iterable
Max number of elements
Optional
compare: Comparator<N>Optional compare function
Elements
Static
nsmallestReturn the n
least valuable elements of an iterable
Max number of elements
Optional
compare: Comparator<N>Optional compare function
Elements
Static
printPrints a heap.
Heap to be printed
Generated using TypeDoc
Heap