RingBuffer [Src] [A: A]

A ring buffer.

class ref RingBuffer[A: A]

Constructors

create [Src]

new ref create(
  len: USize val)
: RingBuffer[A] ref^

Parameters

Returns


Public Functions

head [Src]

The first read that will succeed. If nothing has been written to the ring, this will raise an error.

fun box head()
: USize val ?

Returns


size [Src]

The number of elements that have been added to the ring.

fun box size()
: USize val

Returns


space [Src]

The available space in the ring.

fun box space()
: USize val

Returns


apply [Src]

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.

fun box apply(
  i: USize val)
: this->A ?

Parameters

Returns

  • this->A ?

push [Src]

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.

fun ref push(
  value: A)
: Bool val

Parameters

  • value: A

Returns


clear [Src]

Clear the queue.

fun ref clear()
: None val

Returns