Class EmptySequence<T>
- Namespace
- CryptoHives.Foundation.Memory.Buffers
- Assembly
- CryptoHives.Foundation.Memory.dll
An ISequenceOwner<T> that represents an empty, zero-allocation sequence backed by Empty. Follows the null-object pattern to avoid null checks in consumers.
public sealed class EmptySequence<T> : ISequenceOwner<T>, IDisposable
Type Parameters
T
- Inheritance
-
EmptySequence<T>
- Implements
- Inherited Members
Remarks
This is what a producer hands back when there is nothing to own, so callers can always write
using over the result of a detach without a null test.
Properties
Instance
Gets the shared empty sequence singleton. No allocation is ever needed.
public static ISequenceOwner<T> Instance { get; }
Property Value
IsEmpty
Gets whether the owner holds no elements.
public bool IsEmpty { get; }
Property Value
Length
Gets the total number of elements in Sequence.
public long Length { get; }
Property Value
Sequence
Gets the sequence spanning the owned buffers.
public ReadOnlySequence<T> Sequence { get; }
Property Value
Remarks
Valid until this owner is disposed.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
A no-op. The singleton owns nothing, so disposing it — including repeatedly, and from several callers — has no effect.