I would start by expanding your dimensions for indexing:
provided that you have a set of indices (from your first example, valid values ββare from 2 to 14):
i1 = 2 i2 = 3 i3 = 5 i4 = 6 i5 = 7
and created your array using
short array[] = new short[13 * 13 * 13 * 13 * 13]; ...
then access to each element becomes
array[(i1 - 2) * 13 * 13 * 13 * 13 + (i2 - 2) * 13 * 13 * 13 + (i3 - 2) * 13 * 13 + (i4 - 2) * 13 + (i5 - 2)]
This array will consume much less memory, since you do not need to create an additional layer of objects for each dimension, and you can easily save all the contents in a file and load it into one list.
It will also move faster around this array, because you will do 1/5 of the array search.
Also, pulling the number of elements in each dimension will save significant memory.
To clear your code, this array must be hidden inside the object using the get and set method, which takes five indexes.
source share