POV-Ray : Newsgroups : povray.general : dynamic memory possible? : Re: dynamic memory possible? Server Time
31 Jul 2024 10:22:06 EDT (-0400)
  Re: dynamic memory possible?  
From: Jim Charter
Date: 4 Jun 2007 13:02:25
Message: <466445a1$1@news.povray.org>
Warp wrote:
> Jim Charter <jrc### [at] msncom> wrote:
> 
>>In arrays.inc there is a macro to resize an array.  So you can define 
>>you array initially to take the first item then resize it with each 
>>sucessful read from your file.
> 
> 
>   This is not a good solution, especially if the amount of items is large.
> 
>   The resizing is done by creating a second array of the new size and
> then copying the elements of the first array into the second. If you do
> this for all n elements in the input you'll end up doing n resizes and
> n+(n-1)+(n-2)+...+1 copy operations, which grows proportional to the
> square of n. (For example if the input had 1000 elements it would end up
> making 500500 copy operations. That's half million.)
> 
<shrug> I know ... but that's his call. And even a slow old 1 gh machine 
can still polish off a half a million copies pretty fast can't it? Also 
the coding is awkward with the array index, the loop control and the 
array dimension to resize to, being offset.  Personally I would probably 
print the array declaration into an include file, externally in a 
program such as Python.  But we really don't know what his purposes are.


Post a reply to this message

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