Open jpbmdev opened 3 months ago
// Using specialized getters const StaticIntervalTree = require("mnemonist/static-interval-tree");
const figures = [ { name: "John II of Cyprus", birth: 1418, death: 1458 }, { name: "Helena Palaiologina", birth: 1428, death: 1458 }, { name: "Ashikaga Yoshikatsu", birth: 1434, death: 1443 }, ];
const tree = StaticIntervalTree.from(figures, [(f) => f.birth, (f) => f.death]);
const result = tree.intervalsOverlappingInterval([1420, 1430]); //Expected [ { name: "Helena Palaiologina", birth: 1428, death: 1458 }, { name: "John II of Cyprus", birth: 1418, death: 1458 } ] result [ ]
console.log(result);
// Using specialized getters
const figures2 = [ [1418, 1458], [1428, 1458], [1434, 1443], ];
const tree2 = StaticIntervalTree.from(figures2);
const result2 = tree2.intervalsOverlappingInterval([1420, 1430]);
console.log(result2); //Expected [ [ 1428, 1458 ], [ 1418, 1458 ] ] result [ [ 1428, 1458 ], [ 1418, 1458 ] ]
// Using specialized getters const StaticIntervalTree = require("mnemonist/static-interval-tree");
const figures = [ { name: "John II of Cyprus", birth: 1418, death: 1458 }, { name: "Helena Palaiologina", birth: 1428, death: 1458 }, { name: "Ashikaga Yoshikatsu", birth: 1434, death: 1443 }, ];
const tree = StaticIntervalTree.from(figures, [(f) => f.birth, (f) => f.death]);
const result = tree.intervalsOverlappingInterval([1420, 1430]); //Expected [ { name: "Helena Palaiologina", birth: 1428, death: 1458 }, { name: "John II of Cyprus", birth: 1418, death: 1458 } ] result [ ]
console.log(result);
// Using specialized getters
const figures2 = [ [1418, 1458], [1428, 1458], [1434, 1443], ];
const tree2 = StaticIntervalTree.from(figures2);
const result2 = tree2.intervalsOverlappingInterval([1420, 1430]);
console.log(result2); //Expected [ [ 1428, 1458 ], [ 1418, 1458 ] ] result [ [ 1428, 1458 ], [ 1418, 1458 ] ]