Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List Contains() with PLinq?

let's say I have a big List

List<long> longList = new List<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.

like image 766
Chris Avatar asked Feb 07 '11 14:02

Chris


1 Answers

Yup, using

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

should indeed parallelize it.

like image 88
Jon Skeet Avatar answered Oct 11 '22 01:10

Jon Skeet