Added methods RemoveExcept(Ienumberable) and Clear()

This commit is contained in:
glax 2023-04-24 19:37:25 +02:00
parent c705fdb63a
commit d497196f9f

View File

@ -33,4 +33,19 @@ public class RPriorityQueue<TKey, TPriority> where TKey : notnull
Count = queue.Count;
return before - Count;
}
public int RemoveExcept(IEnumerable<TKey> exceptKeys)
{
int before = Count;
queue = queue.IntersectBy(exceptKeys, item => item.Key).ToDictionary(item => item.Key, item => item.Value);
Count = queue.Count;
return before - Count;
}
public int Clear()
{
int before = Count;
queue.Clear();
return before;
}
}