On Wed, 9 Sep 2009, Arjan van Staalduijnen wrote:
> I have various loops were I'm performing operations like:
[...]
Jonas has already remarked on the use of -=.
> I guess this results in quite a bit of back-and-forth copying of data in
> memory. Since I'm attempting to process the data in a destructive manner
> anyway, I'm searching for an operation like Array.shift(update_values,
> 5000) which could return the (max) 5000 elements I'd be looking for, and
> modify the update_values in the same step. Looking through Array and ADT
> I am not finding such a feature. Am I overlooking something?
You might want to consider using an iterator, but your approach below is
probably better in this specific case.
> (I could possibly rewrite the code to accomplish a similar but faster,
> non-destructive effect
>
> foreach (update_values / 5000, array updates)
Note: You probably want to divide with 5000.0 here, unless you have an
even multiple of 5000 elements in update_values.
> Regards,
>
> Arjan
--
Henrik Grubbström <grubba[at]roxen.com>
Roxen Internet Software AB
|