public class Sandbox.Utility.CircularBuffer<T>
Circular buffer, push pop and index access is always O(1).
Constructors
Showing 2 constructors
No results match this filter.
Methods
Showing 10 methods
public T Back()
Element at the back of the buffer - this[Size - 1].
Returns
The value of the element of type T at the back of the buffer.
public void Clear()
Clears the contents of the array. Size = 0, Capacity is unchanged.
Exceptions
| Exception | Condition |
|---|---|
NotImplementedException |
public T Front()
Element at the front of the buffer - this[0].
Returns
The value of the element of type T at the front of the buffer.
public Sandbox.Utility.CircularBuffer`1.Enumerator<T> GetEnumerator()
Returns a struct-based enumerator that iterates through this buffer without any heap allocation. The compiler's duck-typing for will prefer this overload over the interface methods, so `foreach (var x in buffer)` is zero-alloc.
public void PopBack()
Removes the element at the back of the buffer. Decreasing the Buffer size by 1.
public void PopFront()
Removes the element at the front of the buffer. Decreasing the Buffer size by 1.
public void PushBack(T item)
public void PushFront(T item)
public T[] ToArray()
Copies the buffer contents to an array, according to the logical contents of the buffer (i.e. independent of the internal order/contents)
Returns
A new array with a copy of the buffer contents.
public System.Collections.Generic.IEnumerable`1<System.ArraySegment`1<T>> ToArraySegments()
Get the contents of the buffer as 2 ArraySegments. Respects the logical contents of the buffer, where each segment and items in each segment are ordered according to insertion. Fast: does not copy the array elements. Useful for methods like `Send(IList>)`. Segments may be empty.
Returns
An IList with 2 segments corresponding to the buffer content.
No results match this filter.
Properties
Showing 5 properties
public int Sandbox.Utility.CircularBuffer<T>.Capacity { get; set; }
Maximum capacity of the buffer. Elements pushed into the buffer after maximum capacity is reached (IsFull = true), will remove an element.
public bool Sandbox.Utility.CircularBuffer<T>.IsEmpty { get; set; }
True if has no elements.
public bool Sandbox.Utility.CircularBuffer<T>.IsFull { get; set; }
Boolean indicating if Circular is at full capacity. Adding more elements when the buffer is full will cause elements to be removed from the other end of the buffer.
public T Sandbox.Utility.CircularBuffer<T>.Item { get; set; }
public int Sandbox.Utility.CircularBuffer<T>.Size { get; set; }
Current buffer size (the number of elements that the buffer has).
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox.Utility |
| Type | class |
| Assembly | Sandbox.System |
| Doc ID | T:Sandbox.Utility.CircularBuffer`1 |