Table of Contents

Struct ReadOnlyExSpan<T>

Namespace
Zyl.ExSpans
Assembly
ExSpans.Core.dll

Provides a type-safe and memory-safe read-only representation of a contiguous region of arbitrary memory. It can be regarded as the ReadOnlySpan<T> of nint index range (提供任意内存连续区域的类型安全且内存安全的只读表示形式. 它可以被视为 nint 索引范围的 ReadOnlySpan<T>).

public readonly ref struct ReadOnlyExSpan<T> : IReadOnlyExSpanBase<T>, IExLength

Type Parameters

T

The element type (元素的类型).

Implements
Inherited Members
Extension Methods

Constructors

ReadOnlyExSpan(void*, nint)

Creates a new ReadOnlyExSpan<T> over the target unmanaged buffer (在目标非托管缓冲区上创建新 ReadOnlyExSpan<T>).

ReadOnlyExSpan(ref readonly T)

Creates a new ReadOnlyExSpan<T> of length 1 around the specified reference (在指定的引用周围创建长度为 1 的新 ReadOnlyExSpan<T>).

ReadOnlyExSpan(T[]?)

Creates a new ReadOnlyExSpan<T> over the entirety of the target array (在整个指定数组中创建新的 ReadOnlyExSpan<T>).

ReadOnlyExSpan(T[]?, nint, nint)

Creates a new ReadOnlyExSpan<T> over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive) (创建一个新的 ReadOnlyExSpan<T>,其中包含从指定索引开始的数组的指定数量的元素).

Properties

Empty

Returns a 0-length read-only Ex span whose base is the null pointer (返回一个值,该值指示当前只读扩展跨度为空).

IsEmpty

Gets a value indicating whether this ReadOnlyExSpan<T> is empty (返回一个值,该值指示当前只读扩展跨度为空).

this[nint]

Returns the specified element of the read-only Ex span (从只读扩展跨度中返回指定项).

Length

The number of items in the read-only Ex span (只读扩展跨度中的项数).

Methods

CastUp<TDerived>(ReadOnlyExSpan<TDerived>)

Casts a read-only ExSpan of TDerived to a read-only ExSpan of T.

CopyTo(ExSpan<T>)

Copies the contents of this read-only span into destination span. If the source and destinations overlap, this method behaves as if the original values in a temporary location before the destination is overwritten (将此只读跨度的内容复制到目标跨度. 如果源和目标重叠, 则此方法的行为就像覆盖目标之前临时位置中的原始值一样).

GetEnumerator()

Gets an enumerator for this span (返回此跨度的枚举器).

LastSlice(nint)

Forms a slice out of the given read-only Ex span, last beginning at 'TSize' (从尾部指定索引处的只读扩展跨度形成切片).

LastSlice(nint, nint)

Forms a slice out of the given read-only Ex span, last beginning at 'end', of given length (从尾部指定长度的指定索引处开始的当前只读扩展跨度形成切片)

Slice(nint)

Forms a slice out of the given read-only Ex span, beginning at 'start' (从指定索引处开始的只读扩展跨度形成切片).

Slice(nint, nint)

Forms a slice out of the given read-only Ex span, beginning at 'start', of given length (从指定长度的指定索引处开始的当前只读扩展跨度形成切片)

ToArray()

Copies the contents of this span into a new array. The maxLength parameter uses the value of ArrayMaxLengthSafe (将此范围的内容复制到新建数组中. maxLength 参数使用 ArrayMaxLengthSafe 的值).

ToArray(int)

Copies the contents of this span into a new array. It has a maxLength parameters (将此跨度的内容复制到新建数组中. 它具有 maxLength 参数).

ToString()

Returns the string representation of this ReadOnlyExSpan<T> (返回此 ReadOnlyExSpan<T> 的字符串表示形式).

TryCopyTo(ExSpan<T>)

Try copies the contents of this read-only span into destination span. If the source and destinations overlap, this method behaves as if the original values in a temporary location before the destination is overwritten (尝试将此只读跨度的内容复制到目标跨度. 如果源和目标重叠, 则此方法的行为就像覆盖目标之前临时位置中的原始值一样).

Operators

operator ==(ReadOnlyExSpan<T>, ReadOnlyExSpan<T>)

Returns a value that indicates whether two ReadOnlySpan<T> instances are equal (返回一个值,该值指示两个 ReadOnlySpan<T> 实例是否相等).

explicit operator ReadOnlySpan<T>(ReadOnlyExSpan<T>)

Defines an explicit conversion of a ReadOnlyExSpan<T> to a ReadOnlySpan<T>. The length will saturating limited to the maximum length it supports (定义 ReadOnlyExSpan<T>ReadOnlySpan<T> 的显式转换. 长度会饱和限制为它所支持的最大长度).

implicit operator ReadOnlyExSpan<T>(ArraySegment<T>)

Defines an implicit conversion of a ArraySegment<T> to a ReadOnlyExSpan<T> (定义 ArraySegment<T>ReadOnlyExSpan<T> 的隐式转换)

implicit operator ReadOnlyExSpan<T>(ReadOnlySpan<T>)

Defines an implicit conversion of a ReadOnlySpan<T> to a ReadOnlyExSpan<T> (定义 ReadOnlySpan<T>ReadOnlyExSpan<T> 的隐式转换).

implicit operator ReadOnlyExSpan<T>(T[]?)

Defines an implicit conversion of an array to a ReadOnlyExSpan<T> (定义数组到 ReadOnlyExSpan<T> 的隐式转换)

operator !=(ReadOnlyExSpan<T>, ReadOnlyExSpan<T>)

Returns a value that indicates whether two ReadOnlyExSpan<T> instances are not equal (返回一个值,该值指示两个 ReadOnlyExSpan<T> 实例是否不相等).