A simple, single file, implementation of a circular buffer in C#.
Switch branches/tags
Nothing to show
Clone or download
joaoportela Fix Back method breaking when capacity and size were diferent.
When doing `Back` there is a corner case where we have to loop back into
the last position of the array. We must use capacity instead of size because
we want the internal buffer, last array index (which has nothing to do with
size if the array is not full).
Closes #2
Latest commit 05310bf May 15, 2018


Simple implementation of a circular buffer in C#.
This is a single file implementation, which means that you only need to copy 
the CircularBuffer.cs file to your project and use it.

What is a circular buffer? 

"A circular buffer, cyclic buffer or ring buffer is a data structure 
that uses a single, fixed-size buffer as if it were connected end-to-end."
This means that you have predefined memory usage. Push and Pop operations 
are always O(1). Index access is also O(1).

More info @ wikipedia: http://en.wikipedia.org/wiki/Circular_buffer

 "THE BEER-WARE LICENSE" (Revision 42):
 Joao Portela wrote this file. As long as you retain this notice you
 can do whatever you want with this stuff. If we meet some day, and you think
 this stuff is worth it, you can buy me a beer in return.
 Joao Portela