Skip to content
FutureBlitz

    Install

    Import std.collections.ring_buffer

    std.collections.ring_buffer

    RingBuffer<T>: the last values added, up to its Capacity, oldest first. Adding to a full one drops the oldest, which makes it a history, or a window over what came last. Its values are in a fixed array of slots, from Head on, round to the start.

    std/collections/ring_buffer.fb

    Types

    RingBuffer class

    @DebugElements Public Class RingBuffer<T> Implements Iterable<T>, Cloneable

    A queue of up to its Capacity, where a value added to a full one takes the place of the oldest.

    std/collections/ring_buffer.fb, line 9

    • @PanicsAtCaller Public New(capacity: Int) constructor #

      An empty RingBuffer that holds up to capacity values, which must be 1 or more.

    • Public Property Count: Int property #

      How many values it holds.

    • Public Property Capacity: Int property #

      How many values it holds at most.

    • Public Property IsFull: Bool property #

      Whether the next Add drops the oldest value.

    • Public Method Add(value: T) method #

      Adds the value as the newest, dropping the oldest when the RingBuffer is full.

    • Public Method AddAll(values: Iterable<T>) method #

      Adds each of the values in turn, so the last Capacity of them stay.

    • @PanicsAtCaller Public Method RemoveFirst(): T method #

      Takes the oldest value off and gives it. Panics when the RingBuffer is empty.

    • @PanicsAtCaller Public Method RemoveLast(): T method #

      Takes the newest value off and gives it. Panics when the RingBuffer is empty.

    • Public Method TryRemoveFirst(): T? method #

      Takes the oldest value off and gives it, or Null when the RingBuffer is empty.

    • Public Method TryRemoveLast(): T? method #

      Takes the newest value off and gives it, or Null when the RingBuffer is empty.

    • @PanicsAtCaller Public Method First(): T method #

      The oldest value, which stays. Panics when the RingBuffer is empty.

    • @PanicsAtCaller Public Method Last(): T method #

      The newest value, which stays. Panics when the RingBuffer is empty.

    • Public Method TryFirst(): T? method #

      The oldest value, or Null when the RingBuffer is empty.

    • Public Method TryLast(): T? method #

      The newest value, or Null when the RingBuffer is empty.

    • @PanicsAtCaller Operator [](index: Int): T operator #

      The value at index, counting from the oldest, which is 0. Panics unless index is from 0 to Count minus 1.

    • @PanicsAtCaller Operator []=(index: Int, value: T) operator #

      Gives the value at index, counting from the oldest, a new value.

    • Public Method Contains(value: T): Bool method #

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

    • Public Method ToArray(): T[] method #

      The values, oldest first, in a new array.

    • Public Method Clone(): RingBuffer<T> method #

      A new RingBuffer with the same values and Capacity.

    • Public Method Iterate(): RingBufferIterator<T> method #

      The values, oldest first. Adding or removing a value while going over them panics.

    RingBufferIterator struct

    Public Struct RingBufferIterator<T> Implements Iterator<T>

    The values of a RingBuffer, oldest first, which For ... In goes over.

    std/collections/ring_buffer.fb, line 193

    Extends

    RingBuffer extend

    Extend RingBuffer<T> Implements Printable

    No doc comment.

    std/collections/ring_buffer.fb, line 211

    Report an issue with this page or with FutureBlitz on GitHub.