Provides extension methods for type Span<T> and ReadOnlySpan<T>.
Namespace: DotNext Assembly: DotNext.dll Syntax Methods | Edit this page View Source Advance<T>(ref ReadOnlySpan<T>)Takes the first element and adjusts the span.
Declarationpublic static ref readonly T Advance<T>(this ref ReadOnlySpan<T> source)
Parameters Type Name Description ReadOnlySpan<T> source
The source span.
Returns Type Description TThe reference to the first element in the span.
Type Parameters Name Description TThe type of elements in the span.
Exceptions | Edit this page View Source Advance<T>(ref ReadOnlySpan<T>, int)Takes the specified number of elements and adjusts the span.
Declarationpublic static ReadOnlySpan<T> Advance<T>(this ref ReadOnlySpan<T> source, int count)
Parameters Type Name Description ReadOnlySpan<T> source
The source span.
int countThe number of elements to take.
Returns Type Description ReadOnlySpan<T>The span containing count
elements.
The type of elements in the span.
Exceptions | Edit this page View Source Advance<T>(ref Span<T>)Takes the first element and adjusts the span.
Declarationpublic static ref T Advance<T>(this ref Span<T> source)
Parameters Type Name Description Span<T> source
The source span.
Returns Type Description TThe reference to the first element in the span.
Type Parameters Name Description TThe type of elements in the span.
Exceptions | Edit this page View Source Advance<T>(ref Span<T>, int)Takes the specified number of elements and adjusts the span.
Declarationpublic static Span<T> Advance<T>(this ref Span<T> source, int count)
Parameters Type Name Description Span<T> source
The source span.
int countThe number of elements to take.
Returns Type Description Span<T>The span containing count
elements.
The type of elements in the span.
Exceptions | Edit this page View Source AsBytes<T>(T*)Converts contiguous memory identified by the specified pointer into Span<T>.
Declaration[CLSCompliant(false)]
public static Span<byte> AsBytes<T>(T* pointer) where T : unmanaged
Parameters Type Name Description T* pointer
The typed pointer.
Returns Type Description Span<byte>The span of contiguous memory.
Type Parameters Name Description TThe type of the pointer.
| Edit this page View Source AsBytes<T>(ref T)Converts contiguous memory identified by the specified pointer into Span<T>.
Declarationpublic static Span<byte> AsBytes<T>(ref T value) where T : unmanaged
Parameters Type Name Description T value
The managed pointer.
Returns Type Description Span<byte>The span of contiguous memory.
Type Parameters Name Description TThe type of the pointer.
| Edit this page View Source AsReadOnlyBytes<T>(ref readonly T)Converts contiguous memory identified by the specified pointer into ReadOnlySpan<T>.
Declarationpublic static ReadOnlySpan<byte> AsReadOnlyBytes<T>(ref readonly T value) where T : unmanaged
Parameters Type Name Description T value
The managed pointer.
Returns Type Parameters Name Description TThe type of the pointer.
| Edit this page View Source BitwiseCompare<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)Compares content of the two memory blocks identified by the given spans.
Declarationpublic static int BitwiseCompare<T>(this ReadOnlySpan<T> x, ReadOnlySpan<T> y) where T : unmanaged
Parameters Type Name Description ReadOnlySpan<T> x
The first memory span to compare.
ReadOnlySpan<T> yThe second array to compare.
Returns Type Description intComparison result.
Type Parameters Name Description TThe type of elements in the span.
| Edit this page View Source BitwiseEquals<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)Determines whether two memory blocks identified by the given spans contain the same set of elements.
Declarationpublic static bool BitwiseEquals<T>(this ReadOnlySpan<T> x, ReadOnlySpan<T> y) where T : unmanaged
Parameters Type Name Description ReadOnlySpan<T> x
The first memory span to compare.
ReadOnlySpan<T> yThe second memory span to compare.
Returns Type Description booltrue, if both memory blocks are equal; otherwise, false.
Type Parameters Name Description TThe type of elements in the span.
| Edit this page View Source CheckMask<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)Determines whether the specified value satisfies the given mask.
Declarationpublic static bool CheckMask<T>(this ReadOnlySpan<T> value, ReadOnlySpan<T> mask) where T : unmanaged
Parameters Returns Type Description bool
true if value & mask == mask
; otherwise, false.
The type of the values.
| Edit this page View Source Concat(ReadOnlySpan<string?>, MemoryAllocator<char>?)Concatenates multiple strings.
Declarationpublic static MemoryOwner<char> Concat(ReadOnlySpan<string?> values, MemoryAllocator<char>? allocator = null)
Parameters Returns Type Description MemoryOwner<char>
A buffer containing characters from the concatenated strings.
Exceptions | Edit this page View Source Concat<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, MemoryAllocator<T>?)Concatenates memory blocks.
Declarationpublic static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second, MemoryAllocator<T>? allocator = null)
Parameters Type Name Description ReadOnlySpan<T> first
The first memory block.
ReadOnlySpan<T> secondThe second memory block.
MemoryAllocator<T> allocatorThe memory allocator used to allocate buffer for the result.
Returns Type Description MemoryOwner<T>The memory block containing elements from the specified two memory blocks.
Type Parameters Name Description TThe type of the elements in the memory.
| Edit this page View Source Concat<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, MemoryAllocator<T>?)Concatenates memory blocks.
Declarationpublic static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second, ReadOnlySpan<T> third, MemoryAllocator<T>? allocator = null)
Parameters Returns Type Description MemoryOwner<T>
The memory block containing elements from the specified two memory blocks.
Type Parameters Name Description TThe type of the elements in the memory.
| Edit this page View Source Contravariance<T, TBase>(ReadOnlySpan<T>)Upcasts the span.
Declarationpublic static ReadOnlySpan<TBase> Contravariance<T, TBase>(this ReadOnlySpan<T> span) where T : class?, TBase where TBase : class?
Parameters Type Name Description ReadOnlySpan<T> span
The span over elements.
Returns Type Description ReadOnlySpan<TBase>The span pointing to the same memory as span
.
The source type.
TBaseThe target type.
| Edit this page View Source CopyTo<T>(ReadOnlySpan<T>, Span<T>, out int)Copies the contents from the source span into a destination span.
Declarationpublic static void CopyTo<T>(this ReadOnlySpan<T> source, Span<T> destination, out int writtenCount)
Parameters Type Name Description ReadOnlySpan<T> source
Source memory.
Span<T> destinationDestination memory.
int writtenCountThe number of copied elements.
Type Parameters Name Description TThe type of the elements in the span.
| Edit this page View Source CopyTo<T>(Span<T>, Span<T>, out int)Copies the contents from the source span into a destination span.
Declarationpublic static void CopyTo<T>(this Span<T> source, Span<T> destination, out int writtenCount)
Parameters Type Name Description Span<T> source
Source memory.
Span<T> destinationDestination memory.
int writtenCountThe number of copied elements.
Type Parameters Name Description TThe type of the elements in the span.
| Edit this page View Source Copy<T>(ReadOnlySpan<T>, MemoryAllocator<T>?)Creates buffered copy of the memory block.
Declarationpublic static MemoryOwner<T> Copy<T>(this ReadOnlySpan<T> span, MemoryAllocator<T>? allocator = null)
Parameters Type Name Description ReadOnlySpan<T> span
The span of elements to be copied to the buffer.
MemoryAllocator<T> allocatorOptional buffer allocator.
Returns Type Description MemoryOwner<T>The copy of the elements from span
.
The type of the elements in the memory.
| Edit this page View Source FirstOrNone<T>(ReadOnlySpan<T>, Predicate<T>?)Returns the first element in a span that satisfies a specified condition.
Declarationpublic static Optional<T> FirstOrNone<T>(this ReadOnlySpan<T> span, Predicate<T>? filter = null)
Parameters Type Name Description ReadOnlySpan<T> span
The source span.
Predicate<T> filterA function to test each element for a condition.
Returns Type Description Optional<T>The first element in the span that matches to the specified filter; or None.
Type Parameters Name Description TThe type of the elements in the span.
| Edit this page View Source ForEach<T>(Span<T>, RefAction<T, int>)Iterates over elements of the span.
Declarationpublic static void ForEach<T>(this Span<T> span, RefAction<T, int> action)
Parameters Type Name Description Span<T> span
The span to iterate.
RefAction<T, int> actionThe action to be applied for each element of the span.
Type Parameters Name Description TThe type of the elements.
| Edit this page View Source ForEach<T, TArg>(Span<T>, delegate*<ref T, TArg, void>, TArg)Iterates over elements of the span.
Declaration[CLSCompliant(false)]
public static void ForEach<T, TArg>(this Span<T> span, delegate*<ref T, TArg, void> action, TArg arg)
Parameters Type Name Description Span<T> span
The span to iterate.
delegate*<ref T, TArg, void> actionThe action to be applied for each element of the span.
TArg argThe argument to be passed to the action.
Type Parameters Name Description TThe type of the elements.
TArgThe type of the argument to be passed to the action.
Exceptions | Edit this page View Source IndexOf<T>(ReadOnlySpan<T>, T, int, delegate*<T, T, bool>)Returns the zero-based index of the first occurrence of the specified value in the Span<T>. The search starts at a specified position.
Declaration[CLSCompliant(false)]
public static int IndexOf<T>(this ReadOnlySpan<T> span, T value, int startIndex, delegate*<T, T, bool> comparer)
Parameters Type Name Description ReadOnlySpan<T> span
The span to search.
T valueThe value to search for.
int startIndexThe search starting position.
delegate*<T, T, bool> comparerThe comparer used to compare the expected value and the actual value from the span.
Returns Type Description intThe zero-based index position of value
from the start of the given span if that value is found, or -1 if it is not.
The of the elements in the span.
| Edit this page View Source IndexOf<T>(ReadOnlySpan<T>, T, int, Func<T, T, bool>)Returns the zero-based index of the first occurrence of the specified value in the Span<T>. The search starts at a specified position.
Declarationpublic static int IndexOf<T>(this ReadOnlySpan<T> span, T value, int startIndex, Func<T, T, bool> comparer)
Parameters Type Name Description ReadOnlySpan<T> span
The span to search.
T valueThe value to search for.
int startIndexThe search starting position.
Func<T, T, bool> comparerThe comparer used to compare the expected value and the actual value from the span.
Returns Type Description intThe zero-based index position of value
from the start of the given span if that value is found, or -1 if it is not.
The of the elements in the span.
| Edit this page View Source Initialize<T>(Span<T>)Initializes each element in the span.
Declarationpublic static void Initialize<T>(this Span<T> span) where T : new()
Parameters Type Name Description Span<T> span
The span of elements.
Type Parameters Name Description TThe type of the element.
| Edit this page View Source IsBitwiseAndNonZero<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)Determines whether the specified value and the given mask produces non-zero bitwise AND.
Declarationpublic static bool IsBitwiseAndNonZero<T>(this ReadOnlySpan<T> value, ReadOnlySpan<T> mask) where T : unmanaged
Parameters Returns Type Description bool
true if value & mask != 0
; otherwise, false.
The type of the values.
| Edit this page View Source Move<T>(Span<T>, Range, Index)Moves the range within the span to the specified index.
Declarationpublic static void Move<T>(this Span<T> span, Range range, Index destinationIndex)
Parameters Type Name Description Span<T> span
The span of elements to modify.
Range rangeThe range of elements within span
to move.
The index of the element before which range
of elements will be placed.
The type of the elements in the span.
Exceptions | Edit this page View Source Sort<T>(Span<T>, delegate*<T?, T?, int>)Sorts the elements.
Declaration[CLSCompliant(false)]
public static void Sort<T>(this Span<T> span, delegate*<T?, T?, int> comparison)
Parameters Type Name Description Span<T> span
The contiguous region of arbitrary memory to sort.
delegate*<T, T, int> comparisonThe comparer used for sorting.
Type Parameters Name Description TThe type of the elements.
| Edit this page View Source Swap<T>(Span<T>, Range, Range)Swaps two ranges within the same span.
Declarationpublic static void Swap<T>(this Span<T> span, Range range1, Range range2)
Parameters Type Name Description Span<T> span
The source span.
Range range1The first range.
Range range2The second range.
Type Parameters Name Description TThe type of the elements in the span.
Exceptions | Edit this page View Source Swap<T>(Span<T>, Span<T>)Swaps contents of the two spans.
Declarationpublic static void Swap<T>(this Span<T> x, Span<T> y)
Parameters Type Name Description Span<T> x
The first span.
Span<T> yThe second span.
Type Parameters Name Description TThe type of the elements in the span.
Exceptions | Edit this page View Source TrimLength<T>(ReadOnlySpan<T>, int)Trims the span to specified length if it exceeds it. If length is less that maxLength
then the original span returned.
public static ReadOnlySpan<T> TrimLength<T>(this ReadOnlySpan<T> span, int maxLength)
Parameters Type Name Description ReadOnlySpan<T> span
A contiguous region of arbitrary memory.
int maxLengthMaximum length.
Returns Type Parameters Name Description TThe type of items in the span.
Exceptions | Edit this page View Source TrimLength<T>(Span<T>, int)Trims the span to specified length if it exceeds it. If length is less that maxLength
then the original span returned.
public static Span<T> TrimLength<T>(this Span<T> span, int maxLength)
Parameters Type Name Description Span<T> span
A contiguous region of arbitrary memory.
int maxLengthMaximum length.
Returns Type Description Span<T>Trimmed span.
Type Parameters Name Description TThe type of items in the span.
Exceptions | Edit this page View Source TrimLength<T>(Span<T>, int, out Span<T>)Trims the span to specified length if it exceeds it. If length is less that maxLength
then the original span returned.
public static Span<T> TrimLength<T>(this Span<T> span, int maxLength, out Span<T> rest)
Parameters Type Name Description Span<T> span
A contiguous region of arbitrary memory.
int maxLengthMaximum length.
Span<T> restThe rest of span
.
Trimmed span.
Type Parameters Name Description TThe type of items in the span.
ExceptionsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4