[DGD] Re: Extremely large nested structures

balduin at uni-paderborn.de balduin at uni-paderborn.de
Thu Jul 2 14:54:57 CEST 1998


> Evening everyone,
> 
> I've been looking at using octrees to implement a 3D mechanism.  What this
> means is that I'll need some sort of large nested structure with 8
> elements, within each element may be another 8 elements.
> 
> So... would it be idiotic to have bookkeeping objects that contain one
> octree with a depth of roughly 11+?  Note that octrees can and will be
> sparse so it wouldn't always take up 1024*1024*1024 elements.  Is this bad
> for the driver?  Affects on swapping?  I'm hoping arrays are shared within
> an object so can pass the array around within without any adverse
> affects...
try mixed ...
You can then have recursive arrays where each value is either a new
array or a 0 to indicate an empty array. Of course you can use ({})
as true empty array also, but i expect this to be more costly in terms of
memory.
mixed arrays are kept via pointers internally.
If array's aren't mappings are. 

Something like
({ 1,
  ({1,0,4,({1,3,5,0,0,0,({}),0}),0,0,0,4}),
   5,
   0,
  ({}),
   3,
  ({1,2,3,4,5,6,7,8}),
  0
})

would be a valid entry for a variable of type mixed. Interpretation as
an octree of course is up to you. Assignment between two mixed variables
is possible, but notice that you are working with pointers. So

mixed a,b;

a=({1,2,3,4});
b=a;
b[2]=0;

will result in ({1,2,0,4}) for both a and b ! You can do a true
copy by "abusing" the + operator. (perhaps there are more possibilities)

a=({1,2,3,4});
b=({})+a;
b[2]=({1,2,3,4});

will result in 
a=({1,2,3,4})
b=({1,2,({1,2,3,4}),5})

but of course you will now need memory for both arrays a and b.
Notice, that assignment of an array to each element of the mixed is possible.
Each element of mixed is a mixed...

With this you will have few problems to design sparse recursive datastructures,
but i don't know exactly about the memory needed by each value in an mixed,
since type information has to be stored i guess.

A last thing

a=({1,2,3,4,5});
a[2]=a;
is possible, but you will run into great problems when trying to travers
such a datastructure.

> 
> Alternatively... I could set up an object version of the same structure.
> Each node = one object....
Dont do this, you automatically will need all variables from the auto-object
for each of theese node objects (and you will have many objects). But Memory 
is cheap theese days ...

Ludger Merkens
(balduin at uni-paderborn.de)
[ grumbel at xyllomer : telnet 131.234.10.45 3000 ]



List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list