ReadOnlySpan<T> Yapı
Tanım
İsteğe bağlı rastgele bellek bölgesinin türü güvenli ve bellek açısından güvenli bir salt okuma gösterimi sağlar.Provides a type-safe and memory-safe read-only representation of a contiguous region of arbitrary memory.
generic <typename T>
public value class ReadOnlySpan
public struct ReadOnlySpan<T>
type ReadOnlySpan<'T> = struct
Public Structure ReadOnlySpan(Of T)
Tür Parametreleri
- T
İçindeki öğelerin türü ReadOnlySpan<T> .The type of items in the ReadOnlySpan<T>.
- Devralma
Açıklamalar
ReadOnlySpan<T> , yığına ayrılan ve yönetilen yığına hiçbir şekilde atlabilen bir başvuru struct .ReadOnlySpan<T> is a ref struct that is allocated on the stack and can never escape to the managed heap. Ref struct türlerinin, yönetilen yığına yükseltilmemesini sağlamak için çeşitli kısıtlamalar vardır. Bunlar, kutulanabilir, Lambda ifadelerinde yakalanamaz, tür değişkenlerine atanır, Object dynamic değişkenlere atanır ve herhangi bir arabirim türü uygulayamaz.Ref struct types have a number of restrictions to ensure that they cannot be promoted to the managed heap, including that they can't be boxed, captured in lambda expressions, assigned to variables of type Object, assigned to dynamic variables, and they cannot implement any interface type.
Bir ReadOnlySpan<T> örnek genellikle dizi öğelerine veya bir dizinin kısmına başvurmak için kullanılır.A ReadOnlySpan<T> instance is often used to reference the elements of an array or a portion of an array. Ancak, bir dizinin aksine, bir ReadOnlySpan<T> örnek yönetilen bellek, yerel bellek veya yığında yönetilen bellek üzerine işaret edebilir.Unlike an array, however, a ReadOnlySpan<T> instance can point to managed memory, native memory, or memory managed on the stack.
Oluşturucular
| ReadOnlySpan<T>(T[]) |
ReadOnlySpan<T>Belirtilen dizinin tamamı üzerinde yeni bir oluşturur.Creates a new ReadOnlySpan<T> over the entirety of a specified array. |
| ReadOnlySpan<T>(T[], Int32, Int32) |
ReadOnlySpan<T>Belirtilen dizinden başlayarak bir dizinin belirtilen sayıda öğesini içeren yeni bir oluşturur.Creates a new ReadOnlySpan<T> that includes a specified number of elements of an array starting at a specified index. |
| ReadOnlySpan<T>(Void*, Int32) |
ReadOnlySpan<T> |
Özellikler
| Empty |
Boş değer döndürür ReadOnlySpan<T> .Returns an empty ReadOnlySpan<T>. |
| IsEmpty |
Geçerli salt okuma yayılımının boş olduğunu gösteren bir değer döndürür.Returns a value that indicates the current read-only span is empty. |
| Item[Int32] |
Belirtilen sıfır tabanlı dizindeki salt okunurdur, bir öğeyi alır.Gets an item from the read-only span at the specified zero-based index. |
| Length |
Salt okuma yayılma alanındaki öğelerin sayısı.The number of items in the read-only span. |
Yöntemler
| CopyTo(Span<T>) |
Bunun içeriğini ReadOnlySpan<T> bir hedefe kopyalar Span<T> .Copies the contents of this ReadOnlySpan<T> into a destination Span<T>. |
| Equals(Object) |
Kullanımdan kalktı.
Desteklenmez.Not supported. Bir oluşturur NotSupportedException .Throws a NotSupportedException. |
| GetEnumerator() |
Bunun için bir Numaralandırıcı döndürür ReadOnlySpan<T> .Returns an enumerator for this ReadOnlySpan<T>. |
| GetHashCode() |
Kullanımdan kalktı.
Desteklenmez.Not supported. Bir oluşturur NotSupportedException .Throws a NotSupportedException. |
| GetPinnableReference() |
Sabitleme için kullanılabilecek ve sabit bir ifadede yayılımın kullanımını desteklemek için gerekli olan T türünde bir nesneye salt okuma başvurusu.A read-only reference to an object of type T that can be used for pinning, and is required to support the use of span within a fixed statement. |
| Slice(Int32) |
Belirtilen dizinde başlayan geçerli salt okunurdur, bir dilimi bir dilimde oluşturur.Forms a slice out of the current read-only span that begins at a specified index. |
| Slice(Int32, Int32) |
Belirtilen bir dizin için belirtilen bir dizinden başlayarak geçerli salt okunurdur.Forms a slice out of the current read-only span starting at a specified index for a specified length. |
| ToArray() |
Bu salt okunurdur bu yayılımın içeriğini yeni bir diziye kopyalar.Copies the contents of this read-only span into a new array. |
| ToString() |
Bu öğesinin dize gösterimini döndürür ReadOnlySpan<T> .Returns the string representation of this ReadOnlySpan<T>. |
| TryCopyTo(Span<T>) |
Bunun içeriğini öğesine kopyalamayı dener ReadOnlySpan<T> Span<T> ve işlemin başarılı olup olmadığını göstermek için bir değer döndürür.Attempts to copy the contents of this ReadOnlySpan<T> into a Span<T> and returns a value to indicate whether or not the operation succeeded. |
İşleçler
| Equality(ReadOnlySpan<T>, ReadOnlySpan<T>) |
İki örneğinin eşit olup olmadığını gösteren bir değer döndürür ReadOnlySpan<T> .Returns a value that indicates whether two ReadOnlySpan<T> instances are equal. |
| Implicit(ArraySegment<T> to ReadOnlySpan<T>) |
' A örtülü dönüşümünü tanımlar ArraySegment<T> ReadOnlySpan<T> .Defines an implicit conversion of an ArraySegment<T> to a ReadOnlySpan<T>. |
| Implicit(T[] to ReadOnlySpan<T>) |
Bir dizinin örtük bir şekilde dönüştürülmesini tanımlar ReadOnlySpan<T> .Defines an implicit conversion of an array to a ReadOnlySpan<T>. |
| Inequality(ReadOnlySpan<T>, ReadOnlySpan<T>) |
İki örnek eşit olup olmadığını gösteren bir değer döndürür ReadOnlySpan<T> .Returns a value that indicates whether two ReadOnlySpan<T> instances are not equal. |
Uzantı Metotları
| BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>) |
ReadOnlySpan<T>Belirtilen genel arabirimi kullanarak bir değer için bir bütün sıralanmasını arar IComparable<T> .Searches an entire sorted ReadOnlySpan<T> for a value using the specified IComparable<T> generic interface. |
| BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer) |
Belirtilen ReadOnlySpan<T> genel türü kullanarak belirtilen bir değer için bir bütün olarak bir sıralama arar |
| BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable) |
ReadOnlySpan<T>Belirtilen genel türü kullanarak bir değer için tüm sıralanmış bir değeri arar |
| Contains<T>(ReadOnlySpan<T>, T) |
Belirtilen değerin salt okunurdur bir yayılma alanında bulunup bulunmadığını gösterir.Indicates whether a specified value is found in a read-only span. Değerler IEquatable {T} kullanılarak karşılaştırılır. Eşittir (T).Values are compared using IEquatable{T}.Equals(T). |
| EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Belirtilen dizinin salt okunurdur bir yayılma alanının sonunda görünüp görünmeyeceğini belirler.Determines whether the specified sequence appears at the end of a read-only span. |
| IndexOf<T>(ReadOnlySpan<T>, T) |
Belirtilen değeri arar ve ilk oluşumunun dizinini döndürür.Searches for the specified value and returns the index of its first occurrence. Değerler IEquatable {T} kullanılarak karşılaştırılır. Eşittir (T).Values are compared using IEquatable{T}.Equals(T). |
| IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Belirtilen diziyi arar ve ilk oluşumunun dizinini döndürür.Searches for the specified sequence and returns the index of its first occurrence. Değerler IEquatable {T} kullanılarak karşılaştırılır. Eşittir (T).Values are compared using IEquatable{T}.Equals(T). |
| IndexOfAny<T>(ReadOnlySpan<T>, T, T) |
Mantıksal OR işleciyle IndexOf 'un birkaç kez çağrılmasına benzer şekilde, belirtilen değerlerin her birinin ilk dizinini arar.Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. |
| IndexOfAny<T>(ReadOnlySpan<T>, T, T, T) |
Mantıksal OR işleciyle IndexOf 'un birkaç kez çağrılmasına benzer şekilde, belirtilen değerlerin her birinin ilk dizinini arar.Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. |
| IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Mantıksal OR işleciyle IndexOf 'un birkaç kez çağrılmasına benzer şekilde, belirtilen değerlerin her birinin ilk dizinini arar.Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. |
| LastIndexOf<T>(ReadOnlySpan<T>, T) |
Belirtilen değeri arar ve en son oluşumun dizinini döndürür.Searches for the specified value and returns the index of its last occurrence. Değerler IEquatable {T} kullanılarak karşılaştırılır. Eşittir (T).Values are compared using IEquatable{T}.Equals(T). |
| LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Belirtilen diziyi arar ve en son oluşumun dizinini döndürür.Searches for the specified sequence and returns the index of its last occurrence. Değerler IEquatable {T} kullanılarak karşılaştırılır. Eşittir (T).Values are compared using IEquatable{T}.Equals(T). |
| LastIndexOfAny<T>(ReadOnlySpan<T>, T, T) |
, Bir mantıksal OR işleciyle LastIndexOf 'ı birkaç kez çağırmaya benzer şekilde, belirtilen değerlerden herhangi birinin son dizinini arar.Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. |
| LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T) |
, Bir mantıksal OR işleciyle LastIndexOf 'ı birkaç kez çağırmaya benzer şekilde, belirtilen değerlerden herhangi birinin son dizinini arar.Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. |
| LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
, Bir mantıksal OR işleciyle LastIndexOf 'ı birkaç kez çağırmaya benzer şekilde, belirtilen değerlerden herhangi birinin son dizinini arar.Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. |
| Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Bellekte iki salt okunan sıranın çakışıp örtüşmeyeceğini belirler.Determines whether two read-only sequences overlap in memory. |
| Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32) |
İki salt okuma dizisinin bellekte çakışıp örtüşmediğini belirler ve öğe sapmasını verir.Determines whether two read-only sequences overlap in memory and outputs the element offset. |
| SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
, IComparable {T} kullanarak öğelerini karşılaştırarak, iki salt okuma sırasının göreli sırasını belirler. CompareTo (T).Determines the relative order of two read-only sequences by comparing their elements using IComparable{T}.CompareTo(T). |
| SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
IEquatable {T} kullanılarak öğeleri karşılaştırarak iki salt okuma dizisinin eşit olup olmadığını belirler. Eşittir (T).Determines whether two read-only sequences are equal by comparing the elements using IEquatable{T}.Equals(T). |
| StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Belirtilen bir dizinin salt bir salt okunurdur alanının başlangıcında görünüp görünmeyeceğini belirler.Determines whether a specified sequence appears at the start of a read-only span. |
| Trim<T>(ReadOnlySpan<T>, T) |
Belirtilen öğenin tüm öndeki ve sondaki tekrarlamalarını salt okunurdur.Removes all leading and trailing occurrences of a specified element from a read-only span. |
| Trim<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Salt okunurdur ve salt okunurdur bir yayılımda belirtilen öğelerin kümesinin tüm öndeki ve sondaki oluşumlarını kaldırır.Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only span. |
| TrimEnd<T>(ReadOnlySpan<T>, T) |
Belirtilen öğenin tüm sondaki tekrarlamalarını salt okunurdur.Removes all trailing occurrences of a specified element from a read-only span. |
| TrimEnd<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Salt okunurdur bir yayılma alanından bir salt okunurdur belirtilen bir öğe kümesinin tüm sondaki oluşumlarını kaldırır.Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only span. |
| TrimStart<T>(ReadOnlySpan<T>, T) |
Belirli bir öğenin tüm önde gelen oluşumlarını yayılım öğesinden kaldırır.Removes all leading occurrences of a specified element from the span. |
| TrimStart<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Yayılımın salt okunurdur bir yayılma alanında belirtilen öğelerin kümesinin tüm önde gelen oluşumlarını kaldırır.Removes all leading occurrences of a set of elements specified in a read-only span from the span. |