docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CircularBuffer<T>

    A queue-like data structure that allows read-only access to all values in the queue.

    Inheritance
    object
    CircularBuffer<T>
    TimedDataBuffer<T>
    Namespace: Unity.LiveCapture
    Assembly: Unity.LiveCapture.dll
    Syntax
    public class CircularBuffer<T>
    Type Parameters
    Name Description
    T

    The type of data stored in the buffer.

    Constructors

    CircularBuffer(int)

    Constructs a new CircularBuffer<T> instance with a given size.

    Declaration
    public CircularBuffer(int capacity)
    Parameters
    Type Name Description
    int capacity

    The maximum number of elements which can be stored in the collection.

    Properties

    Capacity

    Gets the maximum number of elements which can be stored in the collection.

    Declaration
    public int Capacity { get; }
    Property Value
    Type Description
    int

    Count

    Gets the number of elements in the collection.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int

    this[int]

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type Description
    T

    Methods

    Add(T)

    Alias for PushBack(T) to support initializer syntax.

    Declaration
    public void Add(T value)
    Parameters
    Type Name Description
    T value

    The element to add.

    Back()

    Get the element at the back of the buffer.

    Declaration
    public T Back()
    Returns
    Type Description
    T

    The element at the back of the buffer.

    Clear()

    Removes all items in the collection.

    Declaration
    public void Clear()

    Front()

    Get the element at the front of the buffer.

    Declaration
    public T Front()
    Returns
    Type Description
    T

    The element at the front of the buffer.

    GetEnumerator()

    Declaration
    public IEnumerator<T> GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    PopBack()

    Removes an element from the back of the buffer.

    Declaration
    public T PopBack()
    Returns
    Type Description
    T

    The removed element.

    PopFront()

    Removes an element from the front of the buffer.

    Declaration
    public T PopFront()
    Returns
    Type Description
    T

    The removed element.

    PushBack(T)

    Adds an element to the buffer at the back. If the buffer is full, the front element will be discarded.

    Declaration
    public void PushBack(T value)
    Parameters
    Type Name Description
    T value

    The element to add.

    PushFront(T)

    Adds an element to the buffer at the front. If the buffer is full, the back element will be discarded.

    Declaration
    public void PushFront(T value)
    Parameters
    Type Name Description
    T value

    SetCapacity(int)

    Sets the Capacity of the circular buffer.

    Declaration
    public void SetCapacity(int capacity)
    Parameters
    Type Name Description
    int capacity

    The desired capacity of the collection.

    Remarks

    If the new size is smaller than the current Count, elements will be truncated from the front.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if the capacity is not greater than zero.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)