POV-Ray : Newsgroups : povray.beta-test : I have a hunch some of you may like this... : Re: I have a hunch some of you may like this... Server Time
20 Apr 2024 02:53:01 EDT (-0400)
  Re: I have a hunch some of you may like this...  
From: clipka
Date: 17 Sep 2016 19:15:47
Message: <57ddcea3$1@news.povray.org>
Am 17.09.2016 um 22:41 schrieb clipka:

> I love it when a plan comes together.

Oh, and while I'm at it:

    #declare MyFnord = array { "Element 0", "Element 1" };

    #declare MyFnord[2] = "Element 2";
    #declare MyFnord[3] = "Element 3";
    #declare MyFnord[42] = "Uqbar";

https://github.com/POV-Ray/povray/releases/tag/v3.7.1-x.dictionary.8791118


Sorry, one-dimensional only. Also, it's not designed as a sparse array,
nor a stack, nor a double-ended queue, nor whatever. Just a plain stupid
array that behaves as if it had no upper limit.

Also, there are a few caveats:

- An index larger than the current capacity of the array will /always/
adjust its capacity, even when just testing whether the element has been
set:

    #ifndef (MyFnord[9999999999])
    // Whoops! MyFnord has now grabbed enough memory to
    // accomodate 10000000000 entries.

- The array is a bit greedy, and may grab as much as twice the necessary
size, in order to avoid having to constantly adjust its capacity.

- There is currently no way to shrink the array (aside from copying it
into a new array and throwing away the old one entirely).

- There is currently no way to test whether an array is of the new
dynamic flavour or a plain old one-dimensional fixed-size array.

- I'm still looking for some neat syntax to access the element right
beyond the current size, i.e. some shorthand for:

    MyFnord[dimension_size(MyFnord,0)]


Post a reply to this message

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