Function
Static Public Summary | ||
public |
Heap(compare: *, data: *) |
|
public |
Builds a heap in O(n) operations. |
|
public |
heappop(heap: *): * |
|
public |
heappush(heap: *, item: *) |
|
public |
heappushpop(heap: *, item: *): * |
|
public |
heapreplace(heap: *, item: *): * |
|
public |
keeporder(compare: *) |
|
public |
* merge(compare: *, iterables: ...*) |
|
public |
Computes which child is the smallest according to a comparison function. |
|
public |
nlargest(compare: *, n: *, iterable: *): * |
|
public |
nsmallest(compare: *, n: *, iterable: *): * |
|
public |
Sifts down a node. |
|
public |
Sifts up a node. |
Static Public
public Heap(compare: *, data: *) source
import Heap from '@data-structure/heapq/src/core/Heap.js'
Params:
Name | Type | Attribute | Description |
compare | * | ||
data | * |
public heapify(compare: function, x: array): * source
import heapify from '@data-structure/heapq/src/heapify.js'
Builds a heap in O(n) operations.
Params:
Name | Type | Attribute | Description |
compare | function | the comparison function |
|
x | array | the array where the heap is stored |
Return:
* |
public heappop(heap: *): * source
import heappop from '@data-structure/heapq/src/heappop.js'
Params:
Name | Type | Attribute | Description |
heap | * |
Return:
* |
public heappush(heap: *, item: *) source
import heappush from '@data-structure/heapq/src/heappush.js'
Params:
Name | Type | Attribute | Description |
heap | * | ||
item | * |
public heappushpop(heap: *, item: *): * source
import heappushpop from '@data-structure/heapq/src/heappushpop.js'
Params:
Name | Type | Attribute | Description |
heap | * | ||
item | * |
Return:
* |
public heapreplace(heap: *, item: *): * source
import heapreplace from '@data-structure/heapq/src/heapreplace.js'
Params:
Name | Type | Attribute | Description |
heap | * | ||
item | * |
Return:
* |
public keeporder(compare: *) source
import keeporder from '@data-structure/heapq/src/core/keeporder.js'
Params:
Name | Type | Attribute | Description |
compare | * |
public * merge(compare: *, iterables: ...*) source
import merge from '@data-structure/heapq/src/merge.js'
Params:
Name | Type | Attribute | Description |
compare | * | ||
iterables | ...* |
public nextchild(compare: function, a: array, i: number, j: number): number source
import nextchild from '@data-structure/heapq/src/core/nextchild.js'
Computes which child is the smallest according to a comparison function.
Hypothesis : i < j i.e. there should be at least one child
public nlargest(compare: *, n: *, iterable: *): * source
import nlargest from '@data-structure/heapq/src/nlargest.js'
Params:
Name | Type | Attribute | Description |
compare | * | ||
n | * | ||
iterable | * |
Return:
* |
public nsmallest(compare: *, n: *, iterable: *): * source
import nsmallest from '@data-structure/heapq/src/nsmallest.js'
Params:
Name | Type | Attribute | Description |
compare | * | ||
n | * | ||
iterable | * |
Return:
* |
public siftdown(compare: function, a: array, i: number, j: number, k: number): * source
import siftdown from '@data-structure/heapq/src/core/siftdown.js'
Sifts down a node.
Return:
* |