Clearing Multidimensional arrays
Posted on 2008-11-10
I m hoping somebody can tell me which is the quickest way (in app performance) to clear multi dimensional arrays?
These arrays have up to 10 dimensions and each dimension has approx 8 indexes. The obvious way to clear (by clear i mean set to default value, in this case 0 because the arrays are doubles) is to run a few nested loops but doing this adds far too much time to the app. i also tried setting the object hold the arrays equal to a another object reference that had just been instantiated but this actually added even more time.
My final idea is to use an arraylist as the first dimension of the array andcalling .clear() on this. however this would require alot of rewriting of code so i havent tried it yet.