Memory<T> 構造体
定義
メモリの隣接した領域を表します。Represents a contiguous region of memory.
generic <typename T>
public value class Memory : IEquatable<Memory<T>>
generic <typename T>
public value class Memory
public struct Memory<T> : IEquatable<Memory<T>>
public struct Memory<T>
type Memory<'T> = struct
Public Structure Memory(Of T)
Implements IEquatable(Of Memory(Of T))
Public Structure Memory(Of T)
型パラメーター
- 継承
- 実装
-
IEquatable<Memory<T>>
注釈
と同様 Span<T> に、は Memory<T>
連続したメモリ領域を表します。Like Span<T>, Memory<T>
represents a contiguous region of memory. ただし、とは異なり、 Span<T> Memory<T>
は ref 構造体ではありません。Unlike Span<T>, however, Memory<T>
is not a ref struct. これは、を Memory<T>
マネージヒープに配置できるのに対し、 Span<T> はできないことを意味します。This means that Memory<T>
can be placed on the managed heap, whereas Span<T> cannot. このため、 Memory<T>
構造体にはインスタンスと同じ制限がありません Span<T> 。As a result, the Memory<T>
structure does not have the same restrictions as a Span<T> instance. 特に次の点に違いがあります。In particular:
これは、クラスのフィールドとして使用できます。It can be used as a field in a class.
また、境界を越えて使用することもでき
await
yield
ます。It can be used acrossawait
andyield
boundaries.
に加えて Memory<T>
、を使用して、 System.ReadOnlyMemory<T> 変更不可または読み取り専用のメモリを表すことができます。In addition to Memory<T>
, you can use System.ReadOnlyMemory<T> to represent immutable or read-only memory.
コンストラクター
Memory<T>(T[]) |
指定された配列全体で新しい Memory<T> オブジェクトを作成します。Creates a new Memory<T> object over the entirety of a specified array. |
Memory<T>(T[], Int32, Int32) |
配列の、指定したインデックスから始まる指定した数の要素を含む新しい Memory<T> オブジェクトを作成します。Creates a new Memory<T> object that includes a specified number of elements of an array beginning at a specified index. |
プロパティ
Empty | |
IsEmpty |
現在のインスタンスが空であるかどうかを示します。Indicates whether the current instance is empty. |
Length |
現在のインスタンス内の項目の数を取得します。Gets the number of items in the current instance. |
Span |
現在のインスタンスのスパンを返します。Returns a span from the current instance. |
メソッド
CopyTo(Memory<T>) |
Memory<T> オブジェクトの内容を、コピー先である Memory<T> オブジェクトにコピーします。Copies the contents of a Memory<T> object into a destination Memory<T> object. |
Equals(Memory<T>) |
指定した Memory<T> オブジェクトが現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified Memory<T> object is equal to the current object. |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object. |
GetHashCode() |
このインスタンスのハッシュ コードを返します。Returns the hash code for this instance. |
Pin() |
Memory<T> オブジェクトのハンドルを作成します。Creates a handle for the Memory<T> object. |
Slice(Int32) |
指定したインデックスで始まる現在のメモリからスライスを形成します。Forms a slice out of the current memory that begins at a specified index. |
Slice(Int32, Int32) |
指定したインデックスで始まる現在のメモリから指定した長さでスライスを形成します。Forms a slice out of the current memory starting at a specified index for a specified length. |
ToArray() |
メモリの内容を新しい配列にコピーします。Copies the contents from the memory into a new array. |
ToString() |
この Memory<T> オブジェクトの文字列表現を返します。Returns the string representation of this Memory<T> object. |
TryCopyTo(Memory<T>) |
メモリの内容をコピー先である Memory<T> インスタンスにコピーします。Copies the contents of the memory into a destination Memory<T> instance. |
演算子
Implicit(ArraySegment<T> to Memory<T>) |
ArraySegment<T> オブジェクトから Memory<T> オブジェクトへの暗黙の型変換を定義します。Defines an implicit conversion of an ArraySegment<T> object to a Memory<T> object. |
Implicit(Memory<T> to ReadOnlyMemory<T>) |
Memory<T> オブジェクトから ReadOnlyMemory<T> オブジェクトへの暗黙の型変換を定義します。Defines an implicit conversion of a Memory<T> object to a ReadOnlyMemory<T> object. |
Implicit(T[] to Memory<T>) |
配列から Memory<T> オブジェクトへの暗黙の型変換を定義します。Defines an implicit conversion of an array to a Memory<T> object. |
拡張メソッド
Trim<T>(Memory<T>, T) |
指定された要素が先頭と末尾に現れる箇所をすべて、メモリ領域から削除します。Removes all leading and trailing occurrences of a specified element from a memory region. |
Trim<T>(Memory<T>, ReadOnlySpan<T>) |
読み取り専用スパンで指定された一連の要素が先頭と末尾に現れる箇所をすべて、メモリ領域から削除します。Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a memory region. |
TrimEnd<T>(Memory<T>, T) |
指定された要素が末尾に現れる箇所をすべて、文字メモリ領域から削除します。Removes all trailing occurrences of a specified element from a character memory region. |
TrimEnd<T>(Memory<T>, ReadOnlySpan<T>) |
読み取り専用スパンで指定された一連の要素が末尾に現れる箇所をすべて、メモリ領域から削除します。Removes all trailing occurrences of a set of elements specified in a read-only span from a memory region. |
TrimStart<T>(Memory<T>, T) |
指定された要素が先頭に現れる箇所をすべて、メモリ領域から削除します。Removes all leading occurrences of a specified element from a memory region. |
TrimStart<T>(Memory<T>, ReadOnlySpan<T>) |
読み取り専用スパンで指定された一連の要素が先頭に現れる箇所をすべて、メモリ領域から削除します。Removes all leading occurrences of a set of elements specified in a read-only span from a memory region. |