A ring buffer is a circular buffer. A new element is inserted at a position called the ring head which points to the oldest element in the ring, an insert overwrites the oldest element. After inserting, the head is moved to point to the next element which is now the oldest element.
Elements in the ring are indexed relative to the head. RingArray head is
designated as the index 0 of the ring buffer, it points to the oldest or the
first element in the buffer. Higher positive indices point to the newer
elements in the buffer. Index -1 points to the newest or the last element
in the buffer. Higher negative indices point to older elements.
The ring is of fixed size and cannot be expanded or reduced after creation. Creation of zero sized rings is not allowed.
This module provides an unboxed implementation of ring buffers for best performance.