Re: Parallel foreach iteration with Associative Arrays

2021-04-16 Thread Kirill via Digitalmars-d-learn
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)) {

Re: Parallel foreach iteration with Associative Arrays

2021-04-16 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 17 April 2021 at 01:57:34 UTC, Kirill wrote: I'd like to iterate over an associative array and output it's key and value using parallel from std.parallelism. But I get an error message: ParallelForeach!(int[string]) error instantiating. My code: auto example = ["apples": 100,

Parallel foreach iteration with Associative Arrays

2021-04-16 Thread Kirill via Digitalmars-d-learn
I'd like to iterate over an associative array and output it's key and value using parallel from std.parallelism. But I get an error message: ParallelForeach!(int[string]) error instantiating. My code: auto example = ["apples": 100, "orange": 250, "banana": 175]; foreach(key, value;