RingBuffer[A: A]¶
A ring buffer.
Constructors¶
create¶
Create a ring buffer with a fixed size. The size will be rounded up to the next power of 2.
Parameters¶
- len: USize val
Returns¶
- RingBuffer[A] ref^
Public Functions¶
head¶
The first read that will succeed. If nothing has been written to the ring, this will raise an error.
Returns¶
- USize val ?
size¶
The number of elements that have been added to the ring.
Returns¶
- USize val
space¶
The available space in the ring.
Returns¶
- USize val
apply¶
Get the i-th element from the ring. If the i-th element has not yet been added or is no longer available, this will raise an error.
Parameters¶
- i: USize val
Returns¶
- this->A ?
push¶
Add an element to the ring. If the ring is full, this will drop the oldest element in the ring. Returns true if an element was dropped.
Parameters¶
- value: A
Returns¶
- Bool val
clear¶
Clear the queue.
Returns¶
- None val