Parallel foreach iteration with Associative Arrays
Kirill
kirill.saidov at mail.com
Sat Apr 17 02:20:32 UTC 2021
On Saturday, 17 April 2021 at 02:14:50 UTC, Paul Backus wrote:
> `parallel` requires a range [1], and an associative array is
> not a range. To get a range of an AA's keys and values, you can
> use the method `.byKeyValue`:
>
> foreach (pair; parallel(example.byKeyValue)) {
> writeln(pair.key, ": ", pair.value);
> }
>
> If you're confused about what a "range" is, the short answer is
> that it's kind of like an iterator. For the long answer, check
> out Andrei Alexandrescu's article "On Iteration" [2], or the
> "Ranges" chapter of Ali Çehreli's "Programming in D" [3].
>
> [1]
> https://phobos.dpldocs.info/std.parallelism.TaskPool.parallel.2.html
> [2] https://www.informit.com/articles/printerfriendly/1407357
> [3] http://ddili.org/ders/d.en/ranges.html
That worked! Thanks you!
More information about the Digitalmars-d-learn
mailing list