File tree Expand file tree Collapse file tree 1 file changed +0
-22
lines changed
Expand file tree Collapse file tree 1 file changed +0
-22
lines changed Original file line number Diff line number Diff line change @@ -16,28 +16,6 @@ public static ReadOnlySpan<T> AsReadOnly<T>(this in Span<T> source)
1616 return source ;
1717 }
1818
19- #if ! NET8_0_OR_GREATER
20- /// <summary>
21- /// Replaces all occurrences of a specified element in a span of elements with another specified element.
22- /// </summary>
23- /// <param name="haystack">The source span.</param>
24- /// <param name="needle">The element to replace.</param>
25- /// <param name="replacement">The replacement element.</param>
26- /// <typeparam name="T">The type of elements in <paramref name="haystack" />.</typeparam>
27- public static void Replace < T > ( this Span < T > haystack , T needle , T replacement ) where T : struct
28- {
29- var comparer = EqualityComparer < T > . Default ;
30-
31- for ( var index = 0 ; index < haystack . Length ; index ++ )
32- {
33- if ( comparer . Equals ( haystack [ index ] , needle ) )
34- {
35- haystack [ index ] = replacement ;
36- }
37- }
38- }
39- #endif
40-
4119#if ! NET9_0_OR_GREATER
4220 /// <summary>
4321 /// Splits a span of elements into sub-spans based on a delimiting element.
You can’t perform that action at this time.
0 commit comments