13
src/Managing.Core/FixedSizedQueue/FixedSizeQueue.cs
Normal file
13
src/Managing.Core/FixedSizedQueue/FixedSizeQueue.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Managing.Core.FixedSizedQueue;
|
||||
|
||||
public class FixedSizeQueue<T> : Queue<T>
|
||||
{
|
||||
private readonly int _maxSize;
|
||||
public FixedSizeQueue(int maxSize) => _maxSize = maxSize;
|
||||
|
||||
public new void Enqueue(T item)
|
||||
{
|
||||
while (Count >= _maxSize) Dequeue();
|
||||
base.Enqueue(item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user