Michael,
The only way you are going to be able to do this is by looping through
each item and then determining if it should be removed:
public static int RemoveAllFromSortedList<TKey, TValue>(SortedList<TKey,
TValuesortedList,
Predicate<KeyValuePair<TKey, TValue>match)
{
// The number of items removed.
int itemsRemoved = 0;
// Cycle through each of the values in the sorted list.
foreach (KeyValuePair<TKey, TValuepair in sortedList)
{
// If the predicate returns true, then remove the item.
if (match(pair))
{
// Remove the item.
sortedList.Remove(pair.Key);
// Increment the number of items removed.
itemsRemoved++;
}
}
// Return the items removed.
return itemsRemoved;
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Michael Nesslinger" <Mi****************@gmx.dewrote in message
news:46********@news.kullen.rwth-aachen.de...
Hello,
i am looking for an easy way to do a "RemoveAll(Predicate<Tmatch)" for a
SortedList like it is possible for a List.
My first question is:
Why is the Method not available for the SortedList.
And my second one:
How can it be done the best (fastest) way for a SortedList
Thanks for any ideas
Michael Neßlinger