2022-05-07 16:55:12 +02:00
|
|
|
let lRecorder = new Recorder(
|
|
|
|
d3.select("#left").graphviz(),
|
2022-05-15 17:53:12 +02:00
|
|
|
null,
|
2022-05-07 16:55:12 +02:00
|
|
|
"left"
|
|
|
|
).renderAtOnce();
|
|
|
|
let rRecorder = new Recorder(
|
|
|
|
d3.select("#right").graphviz(),
|
2022-05-15 17:53:12 +02:00
|
|
|
null,
|
2022-05-07 16:55:12 +02:00
|
|
|
"right"
|
|
|
|
).renderAtOnce();
|
|
|
|
|
|
|
|
let left = new AVLTree();
|
|
|
|
let right = new WAVLTree();
|
|
|
|
|
|
|
|
left.recorder = lRecorder;
|
|
|
|
right.recorder = rRecorder;
|
|
|
|
|
|
|
|
function insertCallback() {
|
|
|
|
let number = document.getElementById("insertInput").value;
|
|
|
|
if (number === "") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = parseInt(number);
|
|
|
|
|
|
|
|
left.insert(value);
|
|
|
|
right.insert(value);
|
|
|
|
|
|
|
|
document.getElementById("insertInput").value = "";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteCallback() {
|
|
|
|
let number = document.getElementById("deleteInput").value;
|
|
|
|
if (number === "") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = parseInt(number);
|
|
|
|
|
|
|
|
left.delete(value);
|
|
|
|
right.delete(value);
|
|
|
|
|
|
|
|
document.getElementById("deleteInput").value = "";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function render() {
|
|
|
|
await Promise.all([
|
|
|
|
new Promise(() => lRecorder.render()),
|
|
|
|
new Promise(() => rRecorder.render()),
|
|
|
|
]);
|
|
|
|
// lRecorder.render();
|
|
|
|
// rRecorder.render();
|
|
|
|
setTimeout(render);
|
|
|
|
}
|
|
|
|
render();
|