wabbajack/Wabbajack.Common.CSP/FixedSizeBuffer.cs

37 lines
747 B
C#
Raw Normal View History

2019-11-09 06:37:05 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
}
}