08-30-2007 12:30 PM
08-30-2007 12:32 PM - edited 08-30-2007 12:32 PM
Message Edited by jdunham on 08-30-2007 12:33 PM
08-30-2007 01:07 PM - edited 08-30-2007 01:07 PM
Message Edited by altenbach on 08-30-2007 11:15 AM
08-30-2007 02:59 PM - edited 08-30-2007 02:59 PM
Message Edited by jdunham on 08-30-2007 03:01 PM
08-30-2007 03:13 PM
As far as I know, arrays must occupy contiguous memory locations. So if you have an array with one million points and delete element #2, elements #3 and above need all to be moved down by one slot. Even if you don't allocate a new array for the result, all higher elements must be moved for each deletion operation so if you delete 100000 elements using "delete from array" in a loop, the last element in the array needs to be moved down 100000 different times. That's a lot of work! In my original code, each element is only moved exactly once.
@jdunham wrote:
I would love to see a benchmark, because I would think it is not necessary for LabVIEW to copy the array just to delete an element.
08-30-2007 03:31 PM - edited 08-30-2007 03:31 PM
Yes, but it's really, really fast. Just think of how fast LV can transpose a huge 2D array (it's fast).
@altenbach wrote:As far as I know, arrays must occupy contiguous memory locations. So if you have an array with one million points and delete element #2, elements #3 and above need all to be moved down by one slot.
I would agree that as you get to a large deletion list, my solution may lose its advantage. But your method still runs a bunch of LabVIEW nodes for each element of your huge array, that is guaranteed to be somewhat slow, since you are taxing the LabVIEW scheduler. My other solution (the one with the array of booleans) has the same problem, but for non-huge applications it is both fast and simple to code.Even if you don't allocate a new array for the result, all higher elements must be moved for each deletion operation so if you delete 100000 elements using "delete from array" in a loop, the last element in the array needs to be moved down 100000 different times. That's a lot of work! In my original code, each element is only moved exactly once.
Message Edited by jdunham on 08-30-2007 03:33 PM
Message Edited by jdunham on 08-30-2007 03:34 PM
Message Edited by jdunham on 08-30-2007 03:35 PM
08-30-2007 05:13 PM
08-30-2007 05:19 PM - edited 08-30-2007 05:19 PM
Message Edited by Jarrod S. on 08-30-2007 05:19 PM
08-30-2007 05:27 PM
I'm interested in the compare of Jarods new way and Christian old way.
I would guess a tie if Christian did not win.
Ben
08-30-2007 05:32 PM