Search Results for

    Show / Hide Table of Contents

    Class RingBuffer<T>

    A circular buffer collection.

    Inheritance
    Object
    RingBuffer<T>
    Implements
    System.Collections.ICollection<T>
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: KSharpPlus
    Assembly: KSharpPlus.dll
    Syntax
    public class RingBuffer<T>
    Type Parameters
    Name Description
    T

    Type of elements within this ring buffer.

    Constructors

    | Improve this Doc View Source

    RingBuffer(Int32)

    Creates a new ring buffer with specified size.

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

    Size of the buffer to create.

    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
    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
    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
    Int32
    | Improve this Doc View Source

    IsReadOnly

    Gets whether this ring buffer is read-only.

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    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
    Boolean

    Whether the buffer contains the item.

    | 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
    Func<T, Boolean> predicate

    Predicate used to check for the item.

    Returns
    Type Description
    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.

    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.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
    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
    Func<T, Boolean> predicate

    Predicate used to find the item.

    Returns
    Type Description
    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
    Func<T, 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
    Boolean

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

    Explicit Interface Implementations

    | Improve this Doc View Source

    IEnumerable.GetEnumerator()

    Returns an enumerator for this ring buffer.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    Enumerator for this ring buffer.

    Implements

    System.Collections.ICollection<>
    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2023 KSharpPlus Contributors