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:
- PooledSegment<T> — rents from ArrayPool<T> and returns on dispose.
- AllocatedSegment<T> — wraps a GC-managed array; only the segment wrapper is cleared on dispose.
- EmptySegment<T> — a zero-allocation null-object sentinel.
Properties
this[int]
T this[int i] { get; set; }
Parameters
iintZero-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
offsetintThe new zero-based offset into the underlying array.
lengthintThe number of elements to expose starting at
offset.