@utilityjs/min-heap
v1.0.1
Published
An implementation of MinHeap data structure.
Downloads
1
Maintainers
Readme
An implementation of MinHeap data structure.
npm i @utilityjs/min-heap | yarn add @utilityjs/min-heap
MinHeap(compareFunction?)
class MinHeap<T> {
constructor(compareFunction?: CompareFunction<T>);
pairIsInCorrectOrder(firstItem: T | null, secondItem: T | null): boolean;
getLeftChildIndex(parentIndex: number): number;
getRightChildIndex(parentIndex: number): number;
getParentIndex(childIndex: number): number;
hasParent(childIndex: number): boolean;
hasLeftChild(parentIndex: number): boolean;
hasRightChild(parentIndex: number): boolean;
getLeftChild(parentIndex: number): T | null;
getRightChild(parentIndex: number): T | null;
getParent(childIndex: number): T | null;
isEmpty(): boolean;
toString(): string;
peek(): T | null;
poll(): T | null;
add(item: T): void;
remove(item: T): void;
find(item: T): number[];
swap(index1: number, index2: number): void;
heapifyDown(startIndex?: number): void;
heapifyUp(startIndex?: number): void;
}