阅读背景:

c#环形缓冲区

来源:互联网 

    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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: