docs.unity3d.com
    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
    Syntax
    public class CircularBuffer<T> : IReadOnlyList<T>
    Type Parameters
    Name Description
    T

    The type of data stored in the buffer.

    Constructors

    CircularBuffer(Int32)

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

    Declaration
    public CircularBuffer(int capacity)
    Parameters
    Type Name Description
    Int32 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
    Int32

    Count

    Gets the number of elements in the collection.

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

    Item[Int32]

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 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(Int32)

    Sets the Capacity of the circular buffer.

    Declaration
    public void SetCapacity(int capacity)
    Parameters
    Type Name Description
    Int32 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.

    In This Article
    • Constructors
      • CircularBuffer(Int32)
    • Properties
      • Capacity
      • Count
      • Item[Int32]
    • Methods
      • Add(T)
      • Back()
      • Clear()
      • Front()
      • GetEnumerator()
      • PopBack()
      • PopFront()
      • PushBack(T)
      • PushFront(T)
      • SetCapacity(Int32)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023