comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » resizing an array of structures (uugh)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
resizing an array of structures (uugh) [message #25234] Mon, 04 June 2001 04:57 Go to previous message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Object Graphics newbie question
Next Topic: Re: need a quicker way to read ascii file w/a structure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:32:06 PDT 2025

Total time taken to generate the page: 0.00502 seconds