simple implementation of binary heap in js for fun
npm install b-heapwindow.BinayHeap) inline hot-link using tag:
Server side (import as ES6/CommonJS/AMD* module)
install via npm: npm install --save b-heap
or via yarn: yarn add b-heap
---
- isEmpty
- size
- peek
- push
- pop
- contains
- remove
[check if the heap is empty]
Returns Boolean [is empty or not]
[count the number of elements in current heap]
Returns \[Number] [size of the heap]
[top element of current heap]
Returns \[Object] [top element]
[push element into heap]
Parameters
- e \[Object] [element]
[remove top element from heap]
Returns \[Object] [removed element]
[check if contains target element]
Parameters
- e \[Object] [target element]
Returns \[Boolean] [contains or not]
[remove target element from heap]
Parameters
- e \[Object] [target element]
Returns \[Boolean] [removed or not]