+ 1

Parallel or filtered list

I have list of custom object. For this example I made a class Person. I am most interested in the Girls-list, and I need to do calculations in  this is list (not coded yet). Sometimes I need to print out all Persons, Boys and Girls. I tend to go for parallel list, since I am most interested in the result in  that list. But the filtered list looks quite neat as well. Would there be a performance issue ? Is parallel list faster that filtered list ? (This example is just for explanation. IRL the boys list is not a list of  boys and the girls list is not a list of girls)  https://code.sololearn.com/cRvLqMMr9GIK/?ref=app

5th Aug 2019, 8:31 PM
sneeze
sneeze - avatar
1 Odpowiedź
+ 4
Good day! One fact that you'll need to keep in mind when using LINQ is its nature of lazy evaluation. That means, the result is not available yet until its values is required. Therefore the next challenge would be determining how frequent you'll need to access each parallel list as you may need to iterate the list more than once with LINQ for each grouping. Otherwise, how about using LINQ GroupBy function? 😉
6th Aug 2019, 12:17 AM
Zephyr Koo
Zephyr Koo - avatar