Method Replace
Replace<T>(ExSpan<T>, T, T)
Replaces all occurrences of oldValue
with newValue
.
public static void Replace<T>(this ExSpan<T> span, T oldValue, T newValue) where T : IEquatable<T>?
Parameters
span
ExSpan<T>The span in which the elements should be replaced.
oldValue
TThe value to be replaced with
newValue
.newValue
TThe value to replace all occurrences of
oldValue
.
Type Parameters
T
The type of the elements in the span.
Replace<T>(ExSpan<T>, T, T, IEqualityComparer<T>?)
Replaces all occurrences of oldValue
with newValue
.
public static void Replace<T>(this ExSpan<T> span, T oldValue, T newValue, IEqualityComparer<T>? comparer = null)
Parameters
span
ExSpan<T>The span in which the elements should be replaced.
oldValue
TThe value to be replaced with
newValue
.newValue
TThe value to replace all occurrences of
oldValue
.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.
Type Parameters
T
The type of the elements in the span.
Replace<T>(ReadOnlyExSpan<T>, ExSpan<T>, T, T)
Copies source
to destination
, replacing all occurrences of oldValue
with newValue
.
public static void Replace<T>(this ReadOnlyExSpan<T> source, ExSpan<T> destination, T oldValue, T newValue) where T : IEquatable<T>?
Parameters
source
ReadOnlyExSpan<T>The span to copy.
destination
ExSpan<T>The span into which the copied and replaced values should be written.
oldValue
TThe value to be replaced with
newValue
.newValue
TThe value to replace all occurrences of
oldValue
.
Type Parameters
T
The type of the elements in the spans.
Exceptions
- ArgumentException
The
destination
ExSpan was shorter than thesource
span.- ArgumentException
The
source
anddestination
were overlapping but not referring to the same starting location.
Replace<T>(ReadOnlyExSpan<T>, ExSpan<T>, T, T, IEqualityComparer<T>?)
Copies source
to destination
, replacing all occurrences of oldValue
with newValue
.
public static void Replace<T>(this ReadOnlyExSpan<T> source, ExSpan<T> destination, T oldValue, T newValue, IEqualityComparer<T>? comparer = null)
Parameters
source
ReadOnlyExSpan<T>The span to copy.
destination
ExSpan<T>The span into which the copied and replaced values should be written.
oldValue
TThe value to be replaced with
newValue
.newValue
TThe value to replace all occurrences of
oldValue
.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.
Type Parameters
T
The type of the elements in the spans.
Exceptions
- ArgumentException
The
destination
ExSpan was shorter than thesource
span.- ArgumentException
The
source
anddestination
were overlapping but not referring to the same starting location.