Quickly retrieve the subset of properties used in a huge collection in C#
Posted
by ccornet
on Stack Overflow
See other posts from Stack Overflow
or by ccornet
Published on 2010-04-29T14:34:08Z
Indexed on
2010/04/29
14:37 UTC
Read the original article
Hit count: 303
I have a huge Collection (which I can cast as an enumerable using OfType<>()) of objects. Each of these objects has a Category
property, which is drawn from a list somewhere else in the application. This Collection can reach sizes of hundreds of items, but it is possible that only, say, 6/30 of the possible Categories are actually used. What is the fastest method to find these 6 Categories? The size of the huge Collection discourages me from just iterating across the entire thing and returning all unique values, so is there a faster method of accomplishing this?
Ideally I'd collect the categories into a List.
© Stack Overflow or respective owner