@onesy/heap
v1.0.0
Published
Min/Max Heap
Downloads
67
Maintainers
Readme
Getting started
Add
yarn add @onesy/heap
Use cases
- Priority queues
- Schedulers
- etc.
Use
import { OnesyHeap } from '@onesy/heap';
// Make a new heap instance
// with an optional initial value a variant (min or max)
// a min heap as a default value
const onesyMinHeap = new OnesyHeap();
// Add a onesy node / value
onesyMinHeap.add(4);
// You can also make a heap from array of values
onesyMinHeap.make([4, 44, 54, 14, 31, 37, 24]);
// values
4
/ \
/ \
14 24
/ \ / \
44 31 37 54
// Remove priority min (first) value
onesyMinHeap.remove();
// 4
// values
14
/ \
/ \
31 24
/ \ /
44 54 37
Dev
Install
yarn
Test
yarn test
Prod
Build
yarn build