[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

resizing an array of structures (uugh)



Hi all,

I have an ascii file containing a few thousand lines with each individual
dataset comprising 10 lines of floats, ints, strings, etc.  It seems
logical to read this in as an array of structures as each dataset contains
the same information, just different numbers.  

My problem is that I don't know what the dimension of the array should be
before I start.  Initially I just defined a large array and counted the
number of datasets for subsequent processing.  However, as time progresses
and this code gets more use, I have to say that I really hate all the
excess array elements... I figured there would be an easy way to resize
the array of structures, but the best I can come up with is a double for
loop that is rather slow.

; loop over the number of array elements
for i, n_elements(array) do begin
   ; loop over the number of tags
   for j, n_tags(structure) do begin
     resized_array[i].(j) = array[i].(j)
   endfor
endfor

Is there a *faster* or more elegant way to do this?  Does IDL have a
*fast* resize command that can handle any type of array to simply adjust
the number of elements in the array without rebinning, or otherwise
changing the numbers?

Cheers,
Randall