Closed hungarian-notation closed 4 years ago
The documentation gives an example alternative compare function for as:
const { BinaryHeap } = require('structurae'); class MaxHeap extends BinaryHeap {} MaxHeap.compare = (a, b) => b - a;
This example will not compile in a typescript project, as BinaryHeap.compare has the signature:
static compare(a: any, b: any): boolean;
It appears that the implementation does indeed expect a boolean result from compare, and as such the documentation should probably be something like:
const { BinaryHeap } = require('structurae'); class MaxHeap extends BinaryHeap {} MaxHeap.compare = (a, b) => a > b;
Yes, indeed BineryHeap#compare returns a boolean. Thanks!
BineryHeap#compare
The documentation gives an example alternative compare function for as:
This example will not compile in a typescript project, as BinaryHeap.compare has the signature:
It appears that the implementation does indeed expect a boolean result from compare, and as such the documentation should probably be something like: