07-27-2011 03:23 PM
Hello, simple question which I saw somewhere on the net but can seem to relocate it.
So I have a loop that inserts an element into a large 3D array every iteration of the loop. Unfortunately, because the loop stops based of a unpreditable variable I do not know how many times this loop will run. As a result I do not know how large my 3D array needs to be. As of now I initialize a 3D array that is bigger than needed and insert elements in. The problem is how do I delete the unused or extra elements within the array that were not needed.
Thanks,
Taylor S. Amarel
07-27-2011 03:31 PM
ummmm the "delete from array" primative on the array palatte would be one way to try
07-27-2011 03:33 PM
Use "Array subset" to get the valid portion.
07-27-2011 04:19 PM
Reshape array is also commonly used for this purpose.
07-27-2011 04:30 PM
@nathand wrote:
Reshape array is also commonly used for this purpose.
For higher dimension arrays (3D in this case), this will only work if the elements are arranged in the correct order. This is not guaranteed per se, but can always be arranged if programmed correctly.
07-27-2011 08:59 PM
If you are preallocating an array, then you don't want to insert elements into it. That will just make a big array grow larger.
I hope you meant you were replacing elements of that preallocated array.