Class SpanExtensions
Extension methods for
Inheritance
Namespace: X10D.Collections
Assembly: X10D.dll
Syntax
public static class SpanExtensions : object
Methods
| Improve this Doc View SourceAsReadOnly<T>(Span<T>)
Returns a read-only
Declaration
public static ReadOnlySpan<T> AsReadOnly<T>(this in Span<T> source)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | source | The source span. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | A |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Count<T>(ReadOnlySpan<T>, T)
Returns the number of times that a specified element appears in a read-only span of elements of the same type.
Declaration
public static int Count<T>(this in ReadOnlySpan<T> source, T element)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | source | The source to search. |
T | element | The element to count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of times that |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Count<T>(Span<T>, T)
Returns the number of times that a specified element appears in a span of elements of the same type.
Declaration
public static int Count<T>(this in Span<T> source, T element)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
Span<T> | source | The source to search. |
T | element | The element to count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of times that |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Replace<T>(Span<T>, T, T)
Replaces all occurrences of a specified element in a span of elements with another specified element.
Declaration
public static void Replace<T>(this Span<T> haystack, T needle, T replacement)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | haystack | The source span. |
T | needle | The element to replace. |
T | replacement | The replacement element. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Split<T>(ReadOnlySpan<T>, T)
Splits a span of elements into sub-spans based on a delimiting element.
Declaration
public static SpanSplitEnumerator<T> Split<T>(this in ReadOnlySpan<T> source, T delimiter)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | source | The span to split. |
T | delimiter | The delimiting element. |
Returns
Type | Description |
---|---|
SpanSplitEnumerator<T> | An enumerator which wraps |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Split<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Splits a span of elements into sub-spans based on a span of delimiting elements.
Declaration
public static SpanSplitEnumerator<T> Split<T>(this in ReadOnlySpan<T> source, in ReadOnlySpan<T> delimiter)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | source | The span to split. |
ReadOnlySpan<T> | delimiter | The span of delimiting elements. |
Returns
Type | Description |
---|---|
SpanSplitEnumerator<T> | An enumerator which wraps |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Split<T>(Span<T>, T)
Splits a span of elements into sub-spans based on a delimiting element.
Declaration
public static SpanSplitEnumerator<T> Split<T>(this in Span<T> source, T delimiter)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
Span<T> | source | The span to split. |
T | delimiter | The delimiting element. |
Returns
Type | Description |
---|---|
SpanSplitEnumerator<T> | An enumerator which wraps |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |
Split<T>(Span<T>, ReadOnlySpan<T>)
Splits a span of elements into sub-spans based on a span of delimiting elements.
Declaration
public static SpanSplitEnumerator<T> Split<T>(this in Span<T> source, in ReadOnlySpan<T> delimiter)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
Span<T> | source | The span to split. |
ReadOnlySpan<T> | delimiter | The span of delimiting elements. |
Returns
Type | Description |
---|---|
SpanSplitEnumerator<T> | An enumerator which wraps |
Type Parameters
Name | Description |
---|---|
T | The type of elements in |