KeepUpToN
Filters a collection keeping up to n
occurences of each value.
- Use
IEnumerable.Distinct()
in combination withIEnumerable.ToDictionary()
to create a dictionary with an initial count of0
for each distinct value indata
. - Use
IEnumerable.Where()
to filter out occurences after then
th one for each element, using the previously created dictionary.