Table of Contents

Class EmptySegment<T>

Namespace
CryptoHives.Foundation.Memory.Buffers
Assembly
CryptoHives.Foundation.Memory.dll

An ISegmentOwner<T> that represents an empty, zero-allocation segment backed by Empty<T>(). Follows the null-object pattern to avoid null checks in consumers.

public sealed class EmptySegment<T> : ISegmentOwner<T>, IDisposable

Type Parameters

T
Inheritance
EmptySegment<T>
Implements
Inherited Members

Properties

Instance

Gets the shared empty segment singleton. No allocation is ever needed.

public static ISegmentOwner<T> Instance { get; }

Property Value

ISegmentOwner<T>

this[int]

Gets or sets element i relative to Offset inside Array.

public T this[int i] { get; set; }

Parameters

i int

Zero-based index within the current segment.

Property Value

T

Segment

Gets the current ArraySegment<T> view of the underlying array.

public ArraySegment<T> Segment { get; }

Property Value

ArraySegment<T>

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

TrySetSegment(int, int)

Sets the offset and the length of the ArraySegment<T>.

public bool TrySetSegment(int offset, int length)

Parameters

offset int

The new zero-based offset into the underlying array.

length int

The number of elements to expose starting at offset.

Returns

bool

true if the segment was updated; false if the underlying array is null or too small to satisfy the requested range.