How to satisfy the Iterator trait bound in order to use Rayon here?

后端 未结 1 1944
傲寒
傲寒 2021-01-25 08:37

I\'m attempting to parallelise the Ramer–Douglas-Peucker line simplification algorithm by using Rayon\'s par_iter instead of iter:

exte         


        
相关标签:
1条回答
  • 2021-01-25 09:00

    Rayon's parallel iterators implement ParallelIterator, not Iterator. In particular, this means you cannot just put a par_iter() in a for-loop header and expect it to suddenly be parallel. for is sequential.

    Since your original code isn't written in terms of iterator functions, but rather as for loops, you can't parallelize it simply with the switch to par_iter(), but have to actually redesign the code.

    In particular, the failing part of the code seems to be implementing the max_by_key function.

    0 讨论(0)
提交回复
热议问题