Table of Contents

Interface ISegmentOwner<T>

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

Owner of an ArraySegment<T> that controls the lifetime of its underlying memory. Implementors decide the acquisition and release strategy (pool return, GC collection, or no-op) while callers use a single consistent API.

public interface ISegmentOwner<T> : IDisposable

Type Parameters

T
Inherited Members

Remarks

Three built-in implementations cover the most common ownership strategies:

Properties

this[int]

Gets or sets element i relative to Offset inside Array.

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.

ArraySegment<T> Segment { get; }

Property Value

ArraySegment<T>

Methods

TrySetSegment(int, int)

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

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.