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

Home » Public Forums » archive » Merits of different ways of 'extending' 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: Merits of different ways of 'extending' arrays [message #85913 is a reply to message #85912] Tue, 17 September 2013 14:47 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 9/17/13 1:34 PM, Yngvar Larsen wrote:
> On Monday, 16 September 2013 15:47:38 UTC+1, suicida...@gmail.com
> wrote:
>
>> Allocating and expanding in fixed "blocks" as suggested before is a
>> way to elegantly handle this problem, however the block size needs
>> to be tuned for every application or you can start to get some big
>> slowdowns.
>
> In the generic case when "big enough" is not known, the best
> algorithm is to double the size of the array every time you hit the
> current capacity. (Or 3x or 1.5x, does not matter as long as the
> growth is exponential in as a function of the number of resizes.)
>
> See
>
> http://en.wikipedia.org/wiki/Dynamic_array
>
>
>

This is what MGcoArrayList does.


https://github.com/mgalloy/mglib/blob/master/src/collection/ mgcoarraylist__define.pro

I used to add capacity in increments of a BLOCK_SIZE property set by the
user, but I think the doubling is the way to go.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL X11 forwarding segmentation fault
Next Topic: defining structure after ascii template

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

Current Time: Fri Oct 10 03:46:04 PDT 2025

Total time taken to generate the page: 1.99398 seconds