ReadOnlySequence<T> 结构

定义

表示可读取 T 有序系列的序列。Represents a sequence that can read a sequential series of T.

generic <typename T>
public value class ReadOnlySequence
public struct ReadOnlySequence<T>
type ReadOnlySequence<'T> = struct
Public Structure ReadOnlySequence(Of T)

类型参数

T

只读序列中的元素的类型。The type of the elements in the read-only sequence.

继承
ReadOnlySequence<T>

构造函数

ReadOnlySequence<T>(ReadOnlyMemory<T>)

通过 ReadOnlyMemory<T> 创建 ReadOnlySequence<T> 的实例。Creates an instance of ReadOnlySequence<T> from a ReadOnlyMemory<T>.

ReadOnlySequence<T>(ReadOnlySequenceSegment<T>, Int32, ReadOnlySequenceSegment<T>, Int32)

通过由起始段和结束段表示的已链接内存列表及其中的相应索引创建 ReadOnlySequence<T> 的实例。Creates an instance of a ReadOnlySequence<T> from a linked memory list represented by start and end segments and the corresponding indexes in them.

ReadOnlySequence<T>(T[])

通过 array 创建 ReadOnlySequence<T> 的实例。Creates an instance of ReadOnlySequence<T> from the array.

ReadOnlySequence<T>(T[], Int32, Int32)

通过数组的一部分创建 ReadOnlySequence<T> 的实例。Creates an instance of a ReadOnlySequence<T> from a section of an array.

字段

Empty

返回一个空 ReadOnlySequence<T>Returns an empty ReadOnlySequence<T>.

属性

End

获取 ReadOnlySequence<T> 末尾的位置。Gets the position at the end of the ReadOnlySequence<T>.

First

从第一个段中获取 ReadOnlyMemory<T>Gets the ReadOnlyMemory<T> from the first segment.

FirstSpan

从第一个段中获取 ReadOnlySpan<T>Gets the ReadOnlySpan<T> from the first segment.

IsEmpty

获取一个值,该值指示 ReadOnlySequence<T> 是否为空。Gets a value that indicates whether the ReadOnlySequence<T> is empty.

IsSingleSegment

获取一个值,它指示 ReadOnlySequence<T> 是否包含单个 ReadOnlyMemory<T> 段。Gets a value that indicates whether the ReadOnlySequence<T> contains a single ReadOnlyMemory<T> segment.

Length

获取 ReadOnlySequence<T> 的长度。Gets the length of the ReadOnlySequence<T>.

Start

获取 ReadOnlySequence<T> 的开头的位置。Gets the position to the start of the ReadOnlySequence<T>.

方法

GetEnumerator()

返回在 ReadOnlySequence<T> 上面的枚举数。Returns an enumerator over the ReadOnlySequence<T>.

GetPosition(Int64)

按从序列开头偏移 offset 的量返回一个新的 SequencePositionReturns a new SequencePosition at an offset from the start of the sequence.

GetPosition(Int64, SequencePosition)

origin 位置的指定偏移量开始,返回新的 SequencePositionReturns a new SequencePosition starting at the specified offset from the origin position.

Slice(Int32, Int32)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始且包含 length 个项目。Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(Int32, SequencePosition)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始并在 end 处(不含)结束。Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

Slice(Int64)

根据当前 ReadOnlySequence<T> 形成一个切片,它在所指定的索引处开始并一直到只读序列的末尾。Forms a slice out of the current ReadOnlySequence<T>, beginning at a specified index and continuing to the end of the read-only sequence.

Slice(Int64, Int64)

根据所给定的 ReadOnlySequence<T> 形成一个切片,它在 start 处开始,并包含 length 个项目。Forms a slice out of the given ReadOnlySequence<T>, beginning at start, with length items.

Slice(Int64, SequencePosition)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始并在 end 处(不含)结束。Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

Slice(SequencePosition)

根据当前 ReadOnlySequence<T> 形成一个切片,它在所指定的序列位置处开始并一直到只读序列的末尾。Forms a slice out of the current ReadOnlySequence<T>, beginning at a specified sequence position and continuing to the end of the read-only sequence.

Slice(SequencePosition, Int32)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始且包含 length 个项目。Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(SequencePosition, Int64)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始且包含 length 个项目。Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(SequencePosition, SequencePosition)

根据当前 ReadOnlySequence<T> 形成一个切片,它在 start 处开始并在 end 处(不含)结束。Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

ToString()

返回表示当前序列的字符串。Returns a string that represents the current sequence.

TryGet(SequencePosition, ReadOnlyMemory<T>, Boolean)

尝试检索 position 后面的下一段,并返回一个指示操作是否成功的值。Tries to retrieve the next segment after position and returns a value that indicates whether the operation succeeded.

扩展方法

CopyTo<T>(ReadOnlySequence<T>, Span<T>)

ReadOnlySequence<T> 复制到所指定的 Span<T>Copies the ReadOnlySequence<T> to the specified Span<T>.

PositionOf<T>(ReadOnlySequence<T>, T)

返回 itemReadOnlySequence<T> 中第一次出现的位置。Returns the position of the first occurrence of item in the ReadOnlySequence<T>.

ToArray<T>(ReadOnlySequence<T>)

ReadOnlySequence<T> 转换为数组。Converts the ReadOnlySequence<T> to an array.

适用于