I ran into an issue when using "@flatten-js/interval-tree": "^1.0.6" from NPM.
function setupTreeAndSearch(intervals, searchInterval) {
let tree = new IntervalTree();
for (let i=0; i < intervals.length; i++) {
tree.insert(intervals[i],"val"+i);
}
return tree.search(searchInterval);
}
setupTreeAndSearch(
[[1,1], [1,4], [5,6], [5.5,7], [7,8]],
[5.5, 5.7]
);
// ["val2", "val3"]
// Correct!
setupTreeAndSearch(
[[1,1], [1,4], [5,6], [6,7], [7,8]],
[5.5, 5.7]
);
// []
// Incorrect - expected ["val2"]
The right branch of this.tree_search_interval(...) called from tree.search(...) is excluding the matching (right) branch .
As it is currently running the right conditional is false because, node.not_intersect_right_subtree(...) does not check the left child branch in this line:
let low = this.right.max.low ? this.right.max.low : this.right.item.key.low;
Note: this.right.max is a number, not an object when the line above is run. Perhaps it should be?
I ran into an issue when using
"@flatten-js/interval-tree": "^1.0.6"
from NPM.The right branch of
this.tree_search_interval(...)
called fromtree.search(...)
is excluding the matching (right) branch .As it is currently running the right conditional is
false
because,node.not_intersect_right_subtree(...)
does not check the left child branch in this line:let low = this.right.max.low ? this.right.max.low : this.right.item.key.low;
Note:
this.right.max
is a number, not an object when the line above is run. Perhaps it should be?Thoughts?