keeping track of ranges in an array
This commit is contained in:
parent
12ab608b58
commit
702296eb79
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user