开发者

List Contains() with PLinq?

开发者 https://www.devze.com 2023-02-09 15:24 出处:网络
let\'s say I have a big List List<long> longList = new Lis开发者_如何学Got<long>(10000000)

let's say I have a big List

List<long> longList = new Lis开发者_如何学Got<long>(10000000)

And I want to do the following query:

bool found = longList.Contains(4345235234524245124L);

Is there a way to use PLinq for that to let each thread search just a little part of the list?

I know that using a Dictionary or a HashMap would be better in this case. It is just something I want to know regarding PLinq and this example was very handy.


Yup, using

bool found = longList.AsParallel().Contains(4345235234524245124L);

should indeed parallelize it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号