Home Manual Reference Source

Function

Static Public Summary
public

Heap(compare: *, data: *)

public

heapify(compare: function, x: array): *

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

nextchild(compare: function, a: array, i: number, j: number): number

Computes which child is the smallest according to a comparison function.

public

nlargest(compare: *, n: *, iterable: *): *

public

nsmallest(compare: *, n: *, iterable: *): *

public

siftdown(compare: function, a: array, i: number, j: number, k: number): *

Sifts down a node.

public

siftup(compare: function, a: array, i: number, j: number, k: number): *

Sifts up a node.

Static Public

public Heap(compare: *, data: *) source

Params:

NameTypeAttributeDescription
compare *
data *

public heapify(compare: function, x: array): * source

Builds a heap in O(n) operations.

Params:

NameTypeAttributeDescription
compare function

the comparison function

x array

the array where the heap is stored

Return:

*

public heappop(heap: *): * source

Params:

NameTypeAttributeDescription
heap *

Return:

*

public heappush(heap: *, item: *) source

Params:

NameTypeAttributeDescription
heap *
item *

public heappushpop(heap: *, item: *): * source

Params:

NameTypeAttributeDescription
heap *
item *

Return:

*

public heapreplace(heap: *, item: *): * source

Params:

NameTypeAttributeDescription
heap *
item *

Return:

*

public keeporder(compare: *) source

Params:

NameTypeAttributeDescription
compare *

public * merge(compare: *, iterables: ...*) source

Params:

NameTypeAttributeDescription
compare *
iterables ...*

public nextchild(compare: function, a: array, i: number, j: number): number source

Computes which child is the smallest according to a comparison function.

Hypothesis : i < j i.e. there should be at least one child

Params:

NameTypeAttributeDescription
compare function

the comparison function

a array

the array where the heap is stored

i number

is the first child

j number

1 is the last leaf

Return:

number

public nlargest(compare: *, n: *, iterable: *): * source

Params:

NameTypeAttributeDescription
compare *
n *
iterable *

Return:

*

public nsmallest(compare: *, n: *, iterable: *): * source

Params:

NameTypeAttributeDescription
compare *
n *
iterable *

Return:

*

public siftdown(compare: function, a: array, i: number, j: number, k: number): * source

Sifts down a node.

Params:

NameTypeAttributeDescription
compare function

the comparison function

a array

the array where the heap is stored

i number

is the root element

j number

1 is the last leaf

k number

is the target node

Return:

*

public siftup(compare: function, a: array, i: number, j: number, k: number): * source

Sifts up a node.

Params:

NameTypeAttributeDescription
compare function

the comparison function

a array

the array where the heap is stored

i number

is the root element

j number

1 is the last leaf

k number

is the target node

Return:

*