Added methods RemoveExcept(Ienumberable) and Clear()
This commit is contained in:
parent
c705fdb63a
commit
d497196f9f
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user