Search Results for

    Show / Hide Table of Contents

    Class RingBuffer<T>

    A circular buffer collection.

    Inheritance
    System.Object
    RingBuffer<T>
    Namespace: DisCatSharp
    Assembly: DisCatSharp.dll
    Syntax
    public class RingBuffer<T> : ICollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T

    Type of elements within this ring buffer.

    Constructors

    | Improve this Doc View Source

    RingBuffer(IEnumerable<T>)

    Creates a new ring buffer, filled with specified elements.

    Declaration
    public RingBuffer(IEnumerable<T> elements)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> elements

    Elements to fill the buffer with.

    Exceptions
    Type Condition
    System.ArgumentException
    System.ArgumentOutOfRangeException
    | Improve this Doc View Source

    RingBuffer(IEnumerable<T>, Int32)

    Creates a new ring buffer, filled with specified elements, and starting at specified index.

    Declaration
    public RingBuffer(IEnumerable<T> elements, int index)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> elements

    Elements to fill the buffer with.

    System.Int32 index

    Starting element index.

    Exceptions
    Type Condition
    System.ArgumentException
    System.ArgumentOutOfRangeException
    | Improve this Doc View Source

    RingBuffer(Int32)

    Creates a new ring buffer with specified size.

    Declaration
    public RingBuffer(int size)
    Parameters
    Type Name Description
    System.Int32 size

    Size of the buffer to create.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    Properties

    | Improve this Doc View Source

    Capacity

    Gets the capacity of this ring buffer.

    Declaration
    public int Capacity { get; protected set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Count

    Gets the number of items in this ring buffer.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    CurrentIndex

    Gets the current index of the buffer items.

    Declaration
    public int CurrentIndex { get; protected set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    InternalBuffer

    Gets or sets the internal collection of items.

    Declaration
    protected T[] InternalBuffer { get; set; }
    Property Value
    Type Description
    T[]
    | Improve this Doc View Source

    IsReadOnly

    Gets whether this ring buffer is read-only.

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    Add(T)

    Inserts an item into this ring buffer.

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

    Item to insert.

    | Improve this Doc View Source

    Clear()

    Clears this ring buffer and resets the current item index.

    Declaration
    public void Clear()
    | Improve this Doc View Source

    Contains(T)

    Checks whether given item is present in the buffer. This method is not implemented. Use Contains(Func<T, Boolean>) instead.

    Declaration
    public bool Contains(T item)
    Parameters
    Type Name Description
    T item

    Item to check for.

    Returns
    Type Description
    System.Boolean

    Whether the buffer contains the item.

    Exceptions
    Type Condition
    System.NotImplementedException
    | Improve this Doc View Source

    Contains(Func<T, Boolean>)

    Checks whether given item is present in the buffer using given predicate to find it.

    Declaration
    public bool Contains(Func<T, bool> predicate)
    Parameters
    Type Name Description
    System.Func<T, System.Boolean> predicate

    Predicate used to check for the item.

    Returns
    Type Description
    System.Boolean

    Whether the buffer contains the item.

    | Improve this Doc View Source

    CopyTo(T[], Int32)

    Copies this ring buffer to target array, attempting to maintain the order of items within.

    Declaration
    public void CopyTo(T[] array, int index)
    Parameters
    Type Name Description
    T[] array

    Target array.

    System.Int32 index

    Index starting at which to copy the items to.

    | Improve this Doc View Source

    GetEnumerator()

    Returns an enumerator for this ring buffer.

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

    Enumerator for this ring buffer.

    | Improve this Doc View Source

    Remove(T)

    Removes an item from the buffer. This method is not implemented. Use Remove(Func<T, Boolean>) instead.

    Declaration
    public bool Remove(T item)
    Parameters
    Type Name Description
    T item

    Item to remove.

    Returns
    Type Description
    System.Boolean

    Whether an item was removed or not.

    | Improve this Doc View Source

    Remove(Func<T, Boolean>)

    Removes an item from the buffer using given predicate to find it.

    Declaration
    public bool Remove(Func<T, bool> predicate)
    Parameters
    Type Name Description
    System.Func<T, System.Boolean> predicate

    Predicate used to find the item.

    Returns
    Type Description
    System.Boolean

    Whether an item was removed or not.

    | Improve this Doc View Source

    TryGet(Func<T, Boolean>, out T)

    Gets first item from the buffer that matches the predicate.

    Declaration
    public bool TryGet(Func<T, bool> predicate, out T item)
    Parameters
    Type Name Description
    System.Func<T, System.Boolean> predicate

    Predicate used to find the item.

    T item

    Item that matches the predicate, or default value for the type of the items in this ring buffer, if one is not found.

    Returns
    Type Description
    System.Boolean

    Whether an item that matches the predicate was found or not.

    Extension Methods

    ReflectionUtilities.ToDictionary<T>(T)
    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems