mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
31 lines
630 B
C#
31 lines
630 B
C#
namespace Wabbajack.Common.CSP
|
|
{
|
|
public class FixedSizeBuffer<T> : IBuffer<T>
|
|
{
|
|
private int _size;
|
|
private RingBuffer<T> _buffer;
|
|
|
|
public FixedSizeBuffer(int size)
|
|
{
|
|
_size = size;
|
|
_buffer = new RingBuffer<T>(size);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
|
|
public bool IsFull => _buffer.Length >= _size;
|
|
public bool IsEmpty => _buffer.IsEmpty;
|
|
public T Remove()
|
|
{
|
|
return _buffer.Pop();
|
|
}
|
|
|
|
public void Add(T itm)
|
|
{
|
|
_buffer.UnboundedUnshift(itm);
|
|
}
|
|
}
|
|
}
|