Table of Contents

Class SpanExtensions

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll
public static class SpanExtensions
Inheritance
SpanExtensions
Inherited Members

Methods

Concat(ReadOnlySpan<char>, char, ReadOnlySpan<char>)

Concat 2 spans without allocating extra memory.

public static string Concat(this ReadOnlySpan<char> span, char combine, ReadOnlySpan<char> span2)

Parameters

span ReadOnlySpan<char>
combine char
span2 ReadOnlySpan<char>

Returns

string

Concat(ReadOnlySpan<char>, char, ReadOnlySpan<char>, ReadOnlySpan<char>)

Concat 3 spans without allocating extra memory.

public static string Concat(this ReadOnlySpan<char> span, char span2, ReadOnlySpan<char> span3, ReadOnlySpan<char> span4)

Parameters

span ReadOnlySpan<char>
span2 char
span3 ReadOnlySpan<char>
span4 ReadOnlySpan<char>

Returns

string

Concat(ReadOnlySpan<char>, ReadOnlySpan<char>)

Concat 2 spans without allocating extra memory.

public static string Concat(this ReadOnlySpan<char> span, ReadOnlySpan<char> span2)

Parameters

span ReadOnlySpan<char>
span2 ReadOnlySpan<char>

Returns

string

Concat(ReadOnlySpan<char>, ReadOnlySpan<char>, ReadOnlySpan<char>)

Concat 3 spans without allocating extra memory.

public static string Concat(this ReadOnlySpan<char> span, ReadOnlySpan<char> span2, ReadOnlySpan<char> span3)

Parameters

span ReadOnlySpan<char>
span2 ReadOnlySpan<char>
span3 ReadOnlySpan<char>

Returns

string

Concat(ReadOnlySpan<char>, string)

Concat a span and string without allocating extra memory.

public static string Concat(this ReadOnlySpan<char> span, string str)

Parameters

span ReadOnlySpan<char>
str string

Returns

string

Count<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Counts the number of occurences of value in span.

public static int Count<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

Parameters

span ReadOnlySpan<T>
value ReadOnlySpan<T>

Returns

int

Type Parameters

T

Count<T>(ReadOnlySpan<T>, T)

Counts the number of occurences of value in span.

public static int Count<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>

Parameters

span ReadOnlySpan<T>
value T

Returns

int

Type Parameters

T

IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, int)

Gets the index of an object in a span with an offset.

public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value, int startIndex) where T : IEquatable<T>

Parameters

span ReadOnlySpan<T>
value ReadOnlySpan<T>
startIndex int

Returns

int

Type Parameters

T

IndexOf<T>(ReadOnlySpan<T>, T, int)

Gets the index of an object in a span with an offset.

public static int IndexOf<T>(this ReadOnlySpan<T> span, T value, int startIndex) where T : IEquatable<T>

Parameters

span ReadOnlySpan<T>
value T
startIndex int

Returns

int

Type Parameters

T

Split(ReadOnlySpan<char>, Span<Range>, char, bool, bool, StringSplitOptions)

Span implementation of Split(char, StringSplitOptions). (this exists but only in .net 8+)

public static int Split(this ReadOnlySpan<char> span, Span<Range> ranges, char separator, bool trimOuter = false, bool trimEachEntry = false, StringSplitOptions options = StringSplitOptions.None)

Parameters

span ReadOnlySpan<char>
ranges Span<Range>
separator char
trimOuter bool

Trim white-space off the input string before splitting.

trimEachEntry bool

Trim white-space off each split entry.

options StringSplitOptions

Returns

int

Remarks

Will return as many ranges as ranges can fit. To get a maximum, use span.Count(separator) + 1.