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

Home » Public Forums » archive » Re: Dynamically resizing arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Dynamically resizing arrays [message #42408] Mon, 07 February 2005 09:01 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
Rick Towler wrote:
> Adding data row by row like this can be a little inefficient as you are
> forcing IDL to allocate RAM for every iteration. I have found it to be
> a bit quicker to grow the array in chunks appropriate for your application.

[snip]

> ; grow array if needed - adding 100 rows at a time
> if (nrows eq totrows - 1) then begin
> array_init = [[array_init],[INTARR(100,100)]]
> totrows = totrows + 100
> endif

One other common solution is to multiply your current number of rows by
2 rather than adding a constant. If your array grows past the initial
mark you've set, this exponential algorithm will require fewer array
resize operations than the linear algorithm, and hence improve
efficiency. The one caveat is that if your array grows really large,
doubling the array might use up way too much memory. There are benefits
from both approaches -- it just depends on the nature of your data and
how large you think it may grow.

-Mike
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: 3D heart
Next Topic: Blurred display of images in PDFs created from EPS on Mac OS X

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

Current Time: Wed Oct 08 18:29:19 PDT 2025

Total time taken to generate the page: 0.00188 seconds