Search Results for

    Show / Hide Table of Contents

    Interface IMemoryBuffer<T>

    An interface describing the API of resizable memory buffers, such as MemoryBuffer<T> and ContinuousMemoryBuffer<T>.

    Namespace: DisCatSharp.Common.Types
    Assembly: DisCatSharp.Common.dll
    Syntax
    public interface IMemoryBuffer<T> : IDisposable where T : struct
    Type Parameters
    Name Description
    T

    Type of item to hold in the buffer.

    Properties

    | Improve this Doc View Source

    Capacity

    Gets the total capacity of this buffer. The capacity is the number of segments allocated, multiplied by size of individual segment.

    Declaration
    ulong Capacity { get; }
    Property Value
    Type Description
    System.UInt64
    | Improve this Doc View Source

    Count

    Gets the number of items currently written to the buffer. This number is equal to Count divided by size of T.

    Declaration
    ulong Count { get; }
    Property Value
    Type Description
    System.UInt64
    | Improve this Doc View Source

    Length

    Gets the amount of bytes currently written to the buffer. This number is never greater than Capacity.

    Declaration
    ulong Length { get; }
    Property Value
    Type Description
    System.UInt64

    Methods

    | Improve this Doc View Source

    Clear()

    Resets the buffer's pointer to the beginning, allowing for reuse.

    Declaration
    void Clear()
    | Improve this Doc View Source

    CopyTo(Stream)

    Copies all the data from this buffer to a stream.

    Declaration
    void CopyTo(Stream destination)
    Parameters
    Type Name Description
    System.IO.Stream destination

    Stream to copy this buffer's data to.

    | Improve this Doc View Source

    Read(T[], Int32, Int32, UInt64, out Int32)

    Reads data from this buffer to specified destination array. This method will write either as many bytes as specified for the destination array, or however many bytes are available in this buffer, whichever is less.

    Declaration
    bool Read(T[] data, int start, int count, ulong source, out int itemsWritten)
    Parameters
    Type Name Description
    T[] data

    Array to read the data from this buffer into.

    System.Int32 start

    Starting position in the target array to write to.

    System.Int32 count

    Maximum number of bytes to write to target array.

    System.UInt64 source

    Starting position in this buffer to read from.

    System.Int32 itemsWritten

    Number of items written to the destination buffer.

    Returns
    Type Description
    System.Boolean

    Whether more data is available in this buffer.

    | Improve this Doc View Source

    Read(ArraySegment<T>, UInt64, out Int32)

    Reads data from this buffer to specified destination array slice. This method will write either as many bytes as specified in the target slice, or however many bytes are available in this buffer, whichever is less.

    Declaration
    bool Read(ArraySegment<T> data, ulong source, out int itemsWritten)
    Parameters
    Type Name Description
    System.ArraySegment<T> data
    System.UInt64 source
    System.Int32 itemsWritten

    Number of items written to the destination buffer.

    Returns
    Type Description
    System.Boolean

    Whether more data is available in this buffer.

    | Improve this Doc View Source

    Read(Span<T>, UInt64, out Int32)

    Reads data from this buffer to the specified destination buffer. This method will write either as many bytes as there are in the destination buffer, or however many bytes are available in this buffer, whichever is less.

    Declaration
    bool Read(Span<T> destination, ulong source, out int itemsWritten)
    Parameters
    Type Name Description
    System.Span<T> destination

    Buffer to read the data from this buffer into.

    System.UInt64 source

    Starting position in this buffer to read from.

    System.Int32 itemsWritten

    Number of items written to the destination buffer.

    Returns
    Type Description
    System.Boolean

    Whether more data is available in this buffer.

    | Improve this Doc View Source

    ToArray()

    Converts this buffer into a single continuous byte array.

    Declaration
    T[] ToArray()
    Returns
    Type Description
    T[]

    Converted byte array.

    | Improve this Doc View Source

    Write(T[], Int32, Int32)

    Appends data from a supplied array to this buffer, growing it if necessary.

    Declaration
    void Write(T[] data, int start, int count)
    Parameters
    Type Name Description
    T[] data

    Array containing data to write.

    System.Int32 start

    Index from which to start reading the data.

    System.Int32 count

    Number of bytes to read from the source.

    | Improve this Doc View Source

    Write(ArraySegment<T>)

    Appends data from a supplied array slice to this buffer, growing it if necessary.

    Declaration
    void Write(ArraySegment<T> data)
    Parameters
    Type Name Description
    System.ArraySegment<T> data

    Array slice containing data to write.

    | Improve this Doc View Source

    Write(Stream)

    Appends data from a supplied stream to this buffer, growing it if necessary.

    Declaration
    void Write(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream to copy data from.

    | Improve this Doc View Source

    Write(ReadOnlySpan<T>)

    Appends data from a supplied buffer to this buffer, growing it if necessary.

    Declaration
    void Write(ReadOnlySpan<T> data)
    Parameters
    Type Name Description
    System.ReadOnlySpan<T> data

    Buffer containing data to write.

    Extension Methods

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