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
spanExSpan<T>The span in which the elements should be replaced.
oldValueTThe value to be replaced with
newValue.newValueTThe value to replace all occurrences of
oldValue.
Type Parameters
TThe 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
spanExSpan<T>The span in which the elements should be replaced.
oldValueTThe value to be replaced with
newValue.newValueTThe value to replace all occurrences of
oldValue.comparerIEqualityComparer<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
TThe 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
sourceReadOnlyExSpan<T>The span to copy.
destinationExSpan<T>The span into which the copied and replaced values should be written.
oldValueTThe value to be replaced with
newValue.newValueTThe value to replace all occurrences of
oldValue.
Type Parameters
TThe type of the elements in the spans.
Exceptions
- ArgumentException
The
destinationExSpan was shorter than thesourcespan.- ArgumentException
The
sourceanddestinationwere 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
sourceReadOnlyExSpan<T>The span to copy.
destinationExSpan<T>The span into which the copied and replaced values should be written.
oldValueTThe value to be replaced with
newValue.newValueTThe value to replace all occurrences of
oldValue.comparerIEqualityComparer<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
TThe type of the elements in the spans.
Exceptions
- ArgumentException
The
destinationExSpan was shorter than thesourcespan.- ArgumentException
The
sourceanddestinationwere overlapping but not referring to the same starting location.