POV-Ray : Newsgroups : povray.programming : Growing arrays : Re: Growing arrays Server Time
28 Jul 2024 14:25:10 EDT (-0400)
  Re: Growing arrays  
From: Disnel
Date: 29 Sep 2000 12:21:58
Message: <39D4C1A5.42EA2BED@itam.cas.cz>
Warp wrote:
> 
> Disnel <dis### [at] itamcascz> wrote:
> : If we assume, that array can only grow, thinkgs become simplier.
> 
>   Actually it's the opposite: If we assume that an array can only shrink
> (ie. get smaller) then the answer is very trivial (unless you really want
> to _free_ that non-used memory as well).
>   If it has to be possible to grow the array, some specialized algorithm
> has to be implemented. You can't make the array bigger every time the
> user wants to make it one item bigger because it would be extremely slow
> (specially with big arrays) but you have to reserve space for more than
> one item at a time. When the array gets full you have to reserve a bigger
> array and copy the old one there (and then free the old one). This copying
> is the heaviest operation in the dynamic array and shouldn't be done
> too often.

Sure. But if we assume, that access to array is perormed only via
some control functions (methods of array object in OO), we can
work with pieces of array with fixed size organised to some sort
of tree.

> 
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.