[dmd-concurrency] How to use parallel foreach to process a part of array?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Oct 29 06:41:49 PDT 2013
Slice it.
foreach(i, ref el; parallel(data[10..$-10]))
-Steve
On Oct 29, 2013, at 3:49 AM, Ilya Sazonov <poxvuibr at gmail.com> wrote:
> Suppose I have the following piece of code
>
> import std.parallelism;
>
> void main() {
> int[] data = new int[1000_000_00];
>
> foreach(i, ref el; parallel(data)) {
> if (i > 10 && i < 1000_000_00 - 10)
> data[i] = data[i-10] + data[i+10];
> }
> }
>
> That's right, I want to process all the elements of the array, except for first 10 and last 10.
> Is there a way to do that without if statement?
>
> I mean something like foreach starting from element with index 10 and ending with lendth - 10
>
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
More information about the dmd-concurrency
mailing list