POV-Ray : Newsgroups : povray.general : Linked Arrays : Re: Linked Arrays Server Time
29 Jul 2024 14:26:42 EDT (-0400)
  Re: Linked Arrays  
From: Leroy Whetstone
Date: 4 May 2011 10:47:39
Message: <4DC166B4.4000603@joplin.com>
Le_Forgeron wrote:
> Le 03/05/2011 23:00, Warp a écrit :
> 
>>Leroy Whetstone <lrw### [at] joplincom> wrote:
>>
>>
>>>Warp wrote:
>>>
>>>>  The standard arrays.inc already provides a Sort_Array() macro.
>>>>
>>>>http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc
>>>>
>>>
>>>True, but it does one array! It doesn't move associated arrays with it. 
>>>My idea is you have a group of arrays linked so if you sort using one of 
>>>them all the others are also move around. The Sort_Array() macro could 
>>>be modified to do so. You would have to rewrite it for every time the 
>>>number of arrays you have changed.
>>
>>  You don't need to rewrite it. You simply implement your own comparison
>>and swapping macros (Sort_Compare() and Sort_Swap_Data()) to perform those
>>operations.
>>
> 
> Why sorting the other arrays if you can use explicit indirection instead ?
> 
> Let's A[] be the array to be sorted, and B[], C[], D[]... the associated
> data.
> 
> You can of course re-order/swap items in A, and then swap also B, C, ...
> 
> Or you can leave A as it is, and compute an ordering array XOX[] of integer.
> 
> So that accessing the first element is no more A[0], B[0],... but
> A[XOX[0]], B[XOX[0]]
> 
> The best data are the data that do not move. The order is in the eye of
> the user.
> 
True I've use that before when dealing with a very large data set.


Post a reply to this message

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