@flemist/pairing-heap
v1.0.0
Published
Fastest pairing heap (priority queue) implementation on JavaScript
Downloads
458
Maintainers
Readme
Fastest pairing heap (priority queue) implementation on JavaScript
Usage
import {PairingHeap, PairingNode} from "./PairingHeap";
const pairingHeap = new PairingHeap({
lessThanFunc: (o1, o2) => o1 < o2 // optional
})
let node: PairingNode<number>
node = pairingHeap.add(5)
pairingHeap.add(9)
pairingHeap.add(3)
pairingHeap.add(7)
pairingHeap.getMin() // 3
pairingHeap.deleteMin() // 3
pairingHeap.delete(node)
pairingHeap.deleteMin() // 7
pairingHeap.size() // 1
pairingHeap.isEmpty() // false
pairingHeap.clear()
pairingHeap.deleteMin() // undefined