hi, i am foreign with java, and processing but i know just enough to “get around”
now, i have a lattice/2d array, and I would like to assign a dictionary to each one
ex:
int myArray = new int[2][2];
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2 y++){
myArray[y] = new IntDict();
}
}
i would then like to be able to access each one via,
myArray[1][2].get(“prev_hue”,255)
so simply put it, i would like to store more then one value in each cell, or locatio in the array.
I don’t know if you have seen the reference for the Processing language? It also has intDict.
(And here’s a page with tutorials, just in case).
Testing this a bit for myself just now, it might not be as straight-forward as you hope. I suspect you have to put the IntDict in a class, which you then can make an object array out of (I might be wrong, not a Java / Processing expert either).
that was helpful, how ever would you mind trying to reword it for someone who has been working with python for most of thier life? I guess i was spoiled when it comes to data structures…
// https://Discourse.Processing.org/t/int-array-and-int-dict/23879/5
// GoToLoop (2020/Sep/16)
final IntDict[][] matrixDict = new IntDict[2][2];
for (final IntDict[] rowDict : matrixDict)
for (int len = rowDict.length, i = 0; i < len; ++i)
rowDict[i] = new IntDict();
final IntDict dict_0_1 = matrixDict[0][1];
dict_0_1.set("prev_hue", 255);
dict_0_1.set("curr_hue", -1);
dict_0_1.print();
final int prev_hue = dict_0_1.get("prev_hue");
println(prev_hue);
final int curr_hue = dict_0_1.get("curr_hue");
println(curr_hue);
exit();