POV-Ray : Newsgroups : povray.programming : Growing arrays : Re: Growing arrays Server Time
28 Jul 2024 14:33:40 EDT (-0400)
  Re: Growing arrays  
From: Disnel
Date: 6 Oct 2000 05:17:51
Message: <39DD99B1.EF79067D@hlavacek-partner.cz>
Warp wrote:
> 
> Disnel <dis### [at] itamcascz> wrote:
> : 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.
> 
>   But then indexing the array will be slower. Depending on the size of each
> block and the number of blocks it may be very slow.
>   That's why it's not a list, anyways.

Lets use hexadecimal numbers for indexing and chunks of array with
length
of 16. First 16 objects added to array are in one starting chunk and
indexing is direct. When we try to add 17th object then new chunk
is created with reference to starting chunk at the begin. The first
16 objects has indexes 00-0FH which mean zero position in the first
chunk and 0-FH position in subchunk. Then we can have 256 objects
indexed in two passes. Three passes indexes 4096 objects, four
65536 objects and so on. Sure, it is slower than direct indexing
of one big array, but is can grow without memory reallocation ;-).

> 
> --
> 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.