Import std.collections.ring_buffer
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.
Examples
Local recent = RingBuffer<Int>(3)
recent.AddAll([1, 2, 3, 4])
Expect(recent.ToArray() == [2, 3, 4])
Expect(recent.IsFull)
Expect(recent.First() == 2 && recent.Last() == 4)std/collections/ring_buffer.fb, line 21
-
An empty RingBuffer that holds up to
capacityvalues, which must be 1 or more. -
How many values it holds.
-
How many values it holds at most.
-
Whether the next Add drops the oldest value.
-
Adds the
valueas the newest, dropping the oldest when the RingBuffer is full. -
Adds each of the
valuesin turn, so the last Capacity of them stay. -
Takes the oldest value off and gives it. Panics when the RingBuffer is empty.
-
Takes the newest value off and gives it. Panics when the RingBuffer is empty.
-
Takes the oldest value off and gives it, or Null when the RingBuffer is empty.
-
Takes the newest value off and gives it, or Null when the RingBuffer is empty.
-
The oldest value, which stays. Panics when the RingBuffer is empty.
-
The newest value, which stays. Panics when the RingBuffer is empty.
-
The oldest value, or Null when the RingBuffer is empty.
-
The newest value, or Null when the RingBuffer is empty.
-
The value at index, counting from the oldest, which is 0. Panics unless index is from 0 to Count minus 1.
-
Gives the value at index, counting from the oldest, a new value.
-
Whether it holds
value. -
Takes every value out.
-
The values, oldest first, in a new array.
-
A new RingBuffer with the same values and Capacity.
-
The values, oldest first. Adding or removing a value while going over them panics.
Report an issue with this page or with FutureBlitz on GitHub.