public class CircularBuffer<T> : ICollection<T>, IEnumerable<T>, ICollection, IEnumerable
{
private int capacity;
volatile private int size;
volatile private int head;//头,指示读数据位置
volatile private int tail;//尾,指示写数据位置
volatile private T[] buffer;//内部数据
[NonSerialized()]
private object _syncRoot = new object();
public CircularBuffer(int capacity)
: this(capacity, false)
{
}
public CircularBuffer(int capacity, bool allowOverflow)
{
if (capacity < 0)
throw new ArgumentException("Capacity set to " + capacity, "capacity");
this.capacity = capacity;
size = 0;
head = 0;
tail = 0;
buffer = new T[capacity];
AllowOverflow = allowOverflow;
} public class CircularBuffer<T> : ICollec