keeping track of ranges in an array

This commit is contained in:
Baipyrus 2024-05-23 21:28:04 +02:00
parent 12ab608b58
commit 702296eb79

View File

@ -35,6 +35,26 @@
interv = setInterval(animate, 1000 / FPS);
});
class ArrRef {
/**
* @param {number} start
* @param {number} end
*/
constructor(start, end) {
this.start = start;
this.end = end;
this.length = end - start;
}
/**
* @param {number} index
* @returns {number}
*/
at(index) {
return data[this.start + index];
}
}
/** Render a single frame of the sorting algorithm at a time on the canvas. */
function animate() {
// Clear canvas with black background