public RingBuffer(int size, InitializeElementDelegate initializer) { if (size < 1) { throw new ArgumentOutOfRangeException("size"); } this.buffer = new T[size]; for (int x = 0; x < this.buffer.Length && initializer != null; x++) { this.buffer[x] = initializer.Invoke(); } }
public RingBuffer <T> Resize(int newSize, InitializeElementDelegate initializer) { if (newSize < 1) { throw new ArgumentOutOfRangeException("newSize"); } lock (this.ringLock) { Array.Resize <T>(ref this.buffer, newSize); if (this.currentIndex > this.buffer.Length - 1) { this.currentIndex = this.buffer.Length - 1; } for (int x = 0; x < this.buffer.Length && initializer != null; x++) { this.buffer[x] = initializer.Invoke(); } return(this); } }