Closed BryonLewis closed 3 years ago
This naturally breaks anything related to search, so delete()
produces a rather unexpected behavior.
const tree = new IntervalTree();
atree.insert([0, 0], 0);
atree.insert([0, 0], 1);
atree.search([0, 0])
// [ [ 0, 0 ], 1 ]
atree.remove([0, 0], 1);
atree.search([0, 0])
// [ 1 ]
Hello @subdavis, @BryonLewis ,
Issue fixed in release v1.0.12.
Now Interval Tree supports storing falsy values like 0, null, NaN, false, except of undefined
Please check this release.
Best regards, Alex
Not a big deal because you provide the ability to insert your own function. The default outputMapperFn tests for truthy on the value. So if you store a value of '0' or other falsey values you will get back an array of keys that intersect the range. https://github.com/alexbol99/flatten-interval-tree/blob/master/src/classes/intervalTree.js#L126
search(interval, outputMapperFn = (value, key) => value ? value : key.output()) {
Wondering if this should test forvalue !== undefined ? value : key.output()
? If the user is storing numbers that happen to have '0', intentional 'null' values or 'false' in the interval tree this will allow them to get the result if it exists without overriding the outputMapperFn.