Search Results for

    Show / Hide Table of Contents

    Class CircularBuffer<T>

    Creates new structure array like, with fast front and back insertion.

    Every overflow of this buffer removes last item form other side of insertion

    Inheritance
    System.Object
    CircularBuffer<T>
    Implements
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    Namespace: FlaxEngine.Collections
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    public class CircularBuffer<T> : Object, IEnumerable<T>, IEnumerable
    Type Parameters
    T

    Type of items inserted into buffer

    Remarks

    This collection is NOT thread-safe.

    Constructors

    CircularBuffer(IEnumerable<T>, Int32, Int32)

    Creates new instance of object with given capacity, copies given array as a framework

    Declaration
    public CircularBuffer(IEnumerable<T> buffer, int frontItem = 0, int backItem = 0)
    Parameters
    System.Collections.Generic.IEnumerable<T> buffer

    Buffer to insert into

    System.Int32 frontItem

    First index of an item in provided buffer

    System.Int32 backItem

    Last index on an item in provided buffer

    CircularBuffer(Int32)

    Creates new instance of object with given capacity

    Declaration
    public CircularBuffer(int capacity)
    Parameters
    System.Int32 capacity

    Capacity of internal structure

    CircularBuffer(Int32, T[], Int32)

    Creates new instance of object with given capacity and adds array of items to internal buffer

    Declaration
    public CircularBuffer(int capacity, T[] items, int arrayIndex = 0)
    Parameters
    System.Int32 capacity

    Capacity of internal structure

    T[] items

    Items to input

    System.Int32 arrayIndex

    Index of items to input at in internal buffer

    Properties

    Capacity

    Current capacity of internal buffer

    Declaration
    public int Capacity { get; set; }
    Property Value
    System.Int32

    Count

    Amount of items currently in buffer

    Declaration
    public int Count { get; }
    Property Value
    System.Int32

    IsEmpty

    Returns true if there are no items in structure, or false if there are

    Declaration
    public bool IsEmpty { get; }
    Property Value
    System.Boolean

    IsFull

    Returns true if buffer is filled with whole of its capacity with items

    Declaration
    public bool IsFull { get; }
    Property Value
    System.Boolean

    Item[Int32]

    Gets or sets item from list at given index. All items are in order of input regardless of overflow that may occur

    Declaration
    public T this[int index] { get; set; }
    Parameters
    System.Int32 index

    Index to item required

    Property Value
    T

    Methods

    add_OnItemAdded(CircularBuffer<T>.ItemAddedEventHandler)

    Declaration
    public void add_OnItemAdded(CircularBuffer<T>.ItemAddedEventHandler value)
    Parameters
    CircularBuffer.ItemAddedEventHandler<> value

    add_OnItemOverflown(CircularBuffer<T>.ItemOverflownEventHandler)

    Declaration
    public void add_OnItemOverflown(CircularBuffer<T>.ItemOverflownEventHandler value)
    Parameters
    CircularBuffer.ItemOverflownEventHandler<> value

    add_OnItemRemoved(CircularBuffer<T>.ItemRemovedEventHandler)

    Declaration
    public void add_OnItemRemoved(CircularBuffer<T>.ItemRemovedEventHandler value)
    Parameters
    CircularBuffer.ItemRemovedEventHandler<> value

    Back()

    Gets bottom first element form collection

    Declaration
    public T Back()
    Returns
    T

    Clear()

    Clears buffer and remains capacity

    Declaration
    public void Clear()

    Clear(Int32)

    Clears buffer and changes its capacity.

    Declaration
    public void Clear(int newCapacity)
    Parameters
    System.Int32 newCapacity

    The new capacity of the buffer.

    CopyTo(T[], Int32)

    CopyTo copies a collection into an Array, starting at a particular index into the array.

    Declaration
    public void CopyTo(T[] array, int arrayIndex)
    Parameters
    T[] array

    System.Int32 arrayIndex

    Front()

    Gets top first element form collection

    Declaration
    public T Front()
    Returns
    T

    GetEnumerator()

    Returns an enumerator that iterates through the collection.

    Declaration
    public IEnumerator<T> GetEnumerator()
    Returns
    System.Collections.Generic.IEnumerator<T>

    A System.Collections.Generic.IEnumerator<> that can be used to iterate through the collection.

    PopBack()

    Removes first item from the back of the buffer

    Declaration
    public T PopBack()
    Returns
    T

    PopFront()

    Removes first item from the front of the buffer

    Declaration
    public T PopFront()
    Returns
    T

    PushBack(T)

    Adds item to the back of the buffer

    Declaration
    public void PushBack(T item)
    Parameters
    T item

    Item to add

    PushFront(T)

    Adds item to the front of the buffer

    Declaration
    public void PushFront(T item)
    Parameters
    T item

    Item to add

    remove_OnItemAdded(CircularBuffer<T>.ItemAddedEventHandler)

    Declaration
    public void remove_OnItemAdded(CircularBuffer<T>.ItemAddedEventHandler value)
    Parameters
    CircularBuffer.ItemAddedEventHandler<> value

    remove_OnItemOverflown(CircularBuffer<T>.ItemOverflownEventHandler)

    Declaration
    public void remove_OnItemOverflown(CircularBuffer<T>.ItemOverflownEventHandler value)
    Parameters
    CircularBuffer.ItemOverflownEventHandler<> value

    remove_OnItemRemoved(CircularBuffer<T>.ItemRemovedEventHandler)

    Declaration
    public void remove_OnItemRemoved(CircularBuffer<T>.ItemRemovedEventHandler value)
    Parameters
    CircularBuffer.ItemRemovedEventHandler<> value

    ToArray()

    Copies the buffer contents to an array, according to the logical contents of the buffer (i.e. independent of the internal order/contents)

    Declaration
    public T[] ToArray()
    Returns
    T[]

    A new array with a copy of the buffer contents.

    Events

    OnItemAdded

    Executes an action when item is added

    Declaration
    public event CircularBuffer<T>.ItemAddedEventHandler OnItemAdded
    Event Type
    CircularBuffer.ItemAddedEventHandler<>

    OnItemOverflown

    Executes an action when item is removed because of overflow in buffer

    Declaration
    public event CircularBuffer<T>.ItemOverflownEventHandler OnItemOverflown
    Event Type
    CircularBuffer.ItemOverflownEventHandler<>

    OnItemRemoved

    Executes an action when item is removed

    Declaration
    public event CircularBuffer<T>.ItemRemovedEventHandler OnItemRemoved
    Event Type
    CircularBuffer.ItemRemovedEventHandler<>

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat