c# - Efficient way to group all equal objects defined by IEqualityComparer -


i have big list of objects of type order. furthermore, have defined iequalitycomparer<order> , goal efficiently create list of lists (or groupings) every sublist contains objects equal each other. mathematically, have equivalence relation (iequalitycomparer) , want have list of equivalence classes. thought using hashset<order>, dictionary<> or lookup<> dont seem perfect case. ideas?

i think shluod job:

var uniqueitems = yourrawlist.distinct(yourcomparer); var result = uniqueitems.select(i => new list<order>(yourrawlist.where(o =>yourcomparer.equals(i, o)))); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -