Using JavaScript I would like to offset the elements in a typed array so that if the original array had values of 0 to 99, the new array would start at 10 and go to 99 leaving 10 empty elements for new data. So if the original array can be viewed as a 10 x 10 grid, I would like to move all data up one row and then enter new data in the bottom row.
I know this can be done using a loop but this method would be too slow for my project which has a much larger array (990 x 1920). I've tried ArrayBuffers and got nowhere.
The problem with the following test method (using subarray) is that although data1 size is specified as 100 it appears to reduce down to the subarray size when applied. I can then find no way to add further data at the end.
function initialize() {
data = new Uint32Array(100);
data1 = new Uint32Array(100);
for (var i = 0; i < data.length; i++) {
data[i] = i;
}
data1 = data.subarray(10);
console.log(data1);
}
Is there any way other than a loop to offset data in a typed array and add data at the end.
OK, I found a solution at Typed Arrays in Gecko 2: Float32Array concatenation and expansion using Set().