Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/easyts/container/mod.ts>Heap

js library written with ts, use select and chan like golang in js.
Latest
class Heap
implements Container<T>
extends Basic<T>
import { Heap } from "https://deno.land/x/easyts@0.1.3/container/mod.ts";

Constructors

new
Heap(opts?: Options<T>, heap?: Array<T>)

Properties

private
readonly
h_: Array<T>

array heap

readonly
capacity: number

returns the capacity of the heap

readonly
heap: Array<T>

Returns an array of underlying storage

readonly
length: number

returns the length of the heap

Methods

clear(callback?: DeleteCallback<T>): void

Empty the data in the container

clone(callback?: CloneCallback<T>): Heap<T>

Create a full copy of the container

fix(i: number)

Fix re-establishes the heap ordering after the element at index i has changed its value.

get(i: number): T

get heap array element

Initialize array to heap

iterator(reverse?: boolean): Iterator<T>

return js iterator

Pop removes and returns the minimum element (according opts.compare cf or <) from the heap.

Pop removes and returns the minimum element (according opts.compare cf or <) from the heap.

push(...vals: Array<T>)

Push pushes the element vals onto the heap.

pushList(vals: Iterable<T>, callback?: CloneCallback<T>)

inserts a copy of another container of heap.

remove(i: number): T

Remove removes and returns the element at index i from the heap.

set(i: number, val: T): void

set heap array element