mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 23:48:42 +00:00
Add test function to intervaltree module.
This commit is contained in:
parent
a8c79d192a
commit
ed6417f6db
28
vendor/intervaltree/core.js
vendored
28
vendor/intervaltree/core.js
vendored
@ -323,4 +323,32 @@ goog.scope(function() {
|
|||||||
// Constructors
|
// Constructors
|
||||||
module.interval = makeInterval;
|
module.interval = makeInterval;
|
||||||
module.create = makeTree;
|
module.create = makeTree;
|
||||||
|
|
||||||
|
|
||||||
|
module.test = function() {
|
||||||
|
// const util = require('util');
|
||||||
|
|
||||||
|
console.time("init");
|
||||||
|
const tree = module.create([
|
||||||
|
[1,5], [-5, 10], [4, 9],
|
||||||
|
[10,14], [-10, 1], [9, 22],
|
||||||
|
]);
|
||||||
|
console.timeEnd("init");
|
||||||
|
|
||||||
|
console.dir(tree, { depth: 5});
|
||||||
|
|
||||||
|
const n = 6;
|
||||||
|
console.time("search")
|
||||||
|
console.log("result to", n, "=>", tree.search(n));
|
||||||
|
console.timeEnd("search")
|
||||||
|
|
||||||
|
console.time("remove");
|
||||||
|
// tree.remove([4,9]);
|
||||||
|
tree.remove([9, 22]);
|
||||||
|
tree.remove([-10, 1]);
|
||||||
|
|
||||||
|
console.dir(tree, { depth: 5});
|
||||||
|
console.timeEnd("remove");
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user