Struct QueueSlimMemory<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Represents a view of a QueueSlim<T> instance's circular buffer.
public readonly struct QueueSlimMemory<T>
Type Parameters
T
Element type.
- Inherited Members
- Extension Methods
Properties
Empty
Empty QueueSlim<T> view.
public static QueueSlimMemory<T> Empty { get; }
Property Value
First
First range of elements in queue's circular buffer.
public ReadOnlyMemory<T> First { get; }
Property Value
this[int]
Gets a reference to an element at the given index.
public ref T this[int index] { get; }
Parameters
index
intThe zero-based index of the element reference to get.
Property Value
- T
Exceptions
- ArgumentOutOfRangeException
When
index
is out of bounds.
Length
Gets the number of elements in this view.
public int Length { get; }
Property Value
Second
Second range of elements in queue's circular buffer.
public ReadOnlyMemory<T> Second { get; }
Property Value
Methods
CopyTo(Span<T>)
Copies the contents of this view into the buffer
.
public void CopyTo(Span<T> buffer)
Parameters
buffer
Span<T>The span to copy elements into.
Exceptions
- ArgumentException
When
buffer
is too short.
From(ReadOnlyMemory<T>)
Creates a new QueueSlimMemory<T> instance from the provided region of memory.
[Pure]
public static QueueSlimMemory<T> From(ReadOnlyMemory<T> items)
Parameters
items
ReadOnlyMemory<T>Source range of elements.
Returns
- QueueSlimMemory<T>
New QueueSlimMemory<T> instance.
GetEnumerator()
Creates a new QueueSlimMemory<T>.Enumerator instance for this view.
[Pure]
public QueueSlimMemory<T>.Enumerator GetEnumerator()
Returns
- QueueSlimMemory<T>.Enumerator
New QueueSlimMemory<T>.Enumerator instance.
Slice(int)
Forms a slice out of this view, beginning at a specified position and continuing to its end.
[Pure]
public QueueSlimMemory<T> Slice(int startIndex)
Parameters
startIndex
intThe index at which to begin this slice.
Returns
- QueueSlimMemory<T>
New QueueSlimMemory<T> instance.
Exceptions
- ArgumentOutOfRangeException
When
startIndex
is out of bounds.
Slice(int, int)
Forms a slice out of this view, starting at startIndex
position for length
elements.
[Pure]
public QueueSlimMemory<T> Slice(int startIndex, int length)
Parameters
Returns
- QueueSlimMemory<T>
New QueueSlimMemory<T> instance.
Exceptions
- ArgumentOutOfRangeException
When
startIndex
orlength
are out of bounds.