Table of Contents

Method IndexOf

Namespace
Zyl.ExSpans
Assembly
ExSpans.dll

IndexOf<T>(ExSpan<T>, T)

Searches for the specified value and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ExSpan<T> span, T value) where T : IEquatable<T>?

Parameters

span ExSpan<T>

The span to search.

value T

The value to search for.

Returns

nint

Type Parameters

T

IndexOf<T>(ExSpan<T>, ReadOnlyExSpan<T>)

Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ExSpan<T> span, ReadOnlyExSpan<T> value) where T : IEquatable<T>?

Parameters

span ExSpan<T>

The span to search.

value ReadOnlyExSpan<T>

The sequence to search for.

Returns

nint

Type Parameters

T

IndexOf<T>(ReadOnlyExSpan<T>, T)

Searches for the specified value and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ReadOnlyExSpan<T> span, T value) where T : IEquatable<T>?

Parameters

span ReadOnlyExSpan<T>

The span to search.

value T

The value to search for.

Returns

nint

Type Parameters

T

IndexOf<T>(ReadOnlyExSpan<T>, T, IEqualityComparer<T>?)

Searches for the specified value and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ReadOnlyExSpan<T> span, T value, IEqualityComparer<T>? comparer = null)

Parameters

span ReadOnlyExSpan<T>

The span to search.

value T

The value to search for.

comparer IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing elements, or null to use the default IEqualityComparer<T> for the type of an element.

Returns

nint

Type Parameters

T

IndexOf<T>(ReadOnlyExSpan<T>, ReadOnlyExSpan<T>)

Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ReadOnlyExSpan<T> span, ReadOnlyExSpan<T> value) where T : IEquatable<T>?

Parameters

span ReadOnlyExSpan<T>

The span to search.

value ReadOnlyExSpan<T>

The sequence to search for.

Returns

nint

Type Parameters

T

IndexOf<T>(ReadOnlyExSpan<T>, ReadOnlyExSpan<T>, IEqualityComparer<T>?)

Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable{T}.Equals(T).

public static nint IndexOf<T>(this ReadOnlyExSpan<T> span, ReadOnlyExSpan<T> value, IEqualityComparer<T>? comparer = null)

Parameters

span ReadOnlyExSpan<T>

The span to search.

value ReadOnlyExSpan<T>

The sequence to search for.

comparer IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing elements, or null to use the default IEqualityComparer<T> for the type of an element.

Returns

nint

Type Parameters

T

IndexOf(ReadOnlyExSpan<char>, ReadOnlyExSpan<char>, StringComparison)

Reports the zero-based index of the first occurrence of the specified value in the current span.

public static nint IndexOf(this ReadOnlyExSpan<char> span, ReadOnlyExSpan<char> value, StringComparison comparisonType)

Parameters

span ReadOnlyExSpan<char>

The source span.

value ReadOnlyExSpan<char>

The value to seek within the source span.

comparisonType StringComparison

One of the enumeration values that determines how the span and value are compared.

Returns

nint

Exceptions

ExSpanTooLongException

Throws an exception if the length is out of the range of Int32.