I need to make a buffer of number arrays so that I can save pixel data arrays and use them later in sequence
I wanted to create a 2d array and to be able to pop things off the end and then push a new one onto the start. Or (as here) rotate the last to the first and then be able to replace it with a new array. I'm not sure about memory management issues here as I keep getting ArrayStoreException errors when adding(splicing) to the start of the 2d array.
Is there a better way to do this?
This is my bare bones test. I will be doing it with much larger arrays.
int[] sa1 = {1,1,1};
int[] sa2 = {2,2,2};
int[] sa3 = {3,3,3};
int[][] frameArray ={sa1,sa2,sa3};
void setup()
{
rotateArray(frameArray);
println();
rotateArray(frameArray);
println();
rotateArray(frameArray);
println();
}
void rotateArray(int[][] arr){
println("rotateArray");
print2DArray(arr);
int[] end = new int[arr[0].length];
arrayCopy(arr[arr.length-1],end);
arr=(int[][]) shorten(arr);
print2DArray(arr);
arr= (int[][]) splice(arr,end,1); //ArrayStoreException ERROR HERE