@utilityjs/max-heap
v1.0.1
Published
An implementation of MaxHeap data structure.
Downloads
1
Maintainers
Readme
An implementation of MaxHeap data structure.
npm i @utilityjs/max-heap | yarn add @utilityjs/max-heap
MaxHeap(compareFunction?)
class MaxHeap<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;
}