diff --git a/apiCount.include.md b/apiCount.include.md index 5034df85..35ff3ab8 100644 --- a/apiCount.include.md +++ b/apiCount.include.md @@ -1,28 +1,28 @@ -**API count: 847** +**API count: 863** ### Per Target Framework | Target | APIs | | -- | -- | -| `net461` | 802 | -| `net462` | 802 | -| `net47` | 801 | -| `net471` | 801 | -| `net472` | 797 | -| `net48` | 797 | -| `net481` | 797 | -| `netstandard2.0` | 800 | -| `netstandard2.1` | 637 | -| `netcoreapp2.0` | 723 | -| `netcoreapp2.1` | 649 | -| `netcoreapp2.2` | 649 | -| `netcoreapp3.0` | 596 | -| `netcoreapp3.1` | 595 | -| `net5.0` | 473 | -| `net6.0` | 392 | -| `net7.0` | 279 | +| `net461` | 816 | +| `net462` | 816 | +| `net47` | 815 | +| `net471` | 815 | +| `net472` | 811 | +| `net48` | 811 | +| `net481` | 811 | +| `netstandard2.0` | 814 | +| `netstandard2.1` | 647 | +| `netcoreapp2.0` | 737 | +| `netcoreapp2.1` | 659 | +| `netcoreapp2.2` | 659 | +| `netcoreapp3.0` | 606 | +| `netcoreapp3.1` | 605 | +| `net5.0` | 483 | +| `net6.0` | 402 | +| `net7.0` | 285 | | `net8.0` | 181 | | `net9.0` | 121 | | `net10.0` | 75 | | `net11.0` | 57 | -| `uap10.0` | 789 | +| `uap10.0` | 803 | diff --git a/api_list.include.md b/api_list.include.md index 8c9a11af..837c0811 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -741,6 +741,14 @@ * `bool EndsWith(T) where T : IEquatable?` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.endswith?view=net-11.0#system-memoryextensions-endswith-1(system-readonlyspan((-0))-0)) * `int IndexOf(T, IEqualityComparer?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexof?view=net-11.0#system-memoryextensions-indexof-1(system-readonlyspan((-0))-0-system-collections-generic-iequalitycomparer((-0)))) * `int IndexOfAny(ReadOnlySpan, IEqualityComparer?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.countany?view=net-11.0#system-memoryextensions-countany-1(system-readonlyspan((-0))-system-buffers-searchvalues((-0)))) + * `int IndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) + * `int IndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0-0)) + * `int IndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0)) + * `int IndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0)) + * `int LastIndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) + * `int LastIndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0-0)) + * `int LastIndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0)) + * `int LastIndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0)) * `SpanSplitEnumerator Split(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-11.0#system-memoryextensions-split-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) * `SpanSplitEnumerator Split(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-11.0#system-memoryextensions-split-1(system-readonlyspan((-0))-0)) * `SpanSplitEnumerator SplitAny(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.splitany?view=net-11.0#system-memoryextensions-splitany-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) @@ -871,6 +879,14 @@ * `bool ContainsAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyexcept?view=net-11.0#system-memoryextensions-containsanyexcept-1(system-span((-0))-0)) * `bool ContainsAnyExceptInRange(T, T) where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyexceptinrange?view=net-11.0#system-memoryextensions-containsanyexceptinrange-1(system-span((-0))-0-0)) * `bool ContainsAnyInRange(T, T) where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyinrange?view=net-11.0#system-memoryextensions-containsanyinrange-1(system-span((-0))-0-0)) + * `int IndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-system-readonlyspan((-0)))) + * `int IndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0-0)) + * `int IndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0)) + * `int IndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0)) + * `int LastIndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-system-readonlyspan((-0)))) + * `int LastIndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0-0)) + * `int LastIndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0)) + * `int LastIndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0)) * `void Sort(Comparison)` * `void Sort() where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.sort?view=net-11.0#system-memoryextensions-sort-1(system-span((-0)))) diff --git a/assemblySize.include.md b/assemblySize.include.md index 1d445e2a..3500aaa6 100644 --- a/assemblySize.include.md +++ b/assemblySize.include.md @@ -2,23 +2,23 @@ | | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------| -| netstandard2.0 | 8.0KB | 259.5KB | +251.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netstandard2.1 | 8.5KB | 212.5KB | +204.0KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | -| net461 | 8.5KB | 268.0KB | +259.5KB | +9.0KB | +6.0KB | +8.5KB | +13.5KB | -| net462 | 7.0KB | 266.5KB | +259.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net47 | 7.0KB | 266.5KB | +259.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net471 | 8.5KB | 266.5KB | +258.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net472 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net48 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net481 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netcoreapp2.0 | 9.0KB | 241.0KB | +232.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netcoreapp2.1 | 9.0KB | 221.5KB | +212.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp2.2 | 9.0KB | 221.5KB | +212.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp3.0 | 9.5KB | 212.5KB | +203.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp3.1 | 9.5KB | 210.5KB | +201.0KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | -| net5.0 | 9.5KB | 173.5KB | +164.0KB | +9.0KB | +6.0KB | +9.0KB | +14.0KB | -| net6.0 | 10.0KB | 128.5KB | +118.5KB | +10.0KB | +6.5KB | +512bytes | +3.5KB | -| net7.0 | 10.0KB | 98.5KB | +88.5KB | +9.5KB | +5.5KB | +512bytes | +3.5KB | +| netstandard2.0 | 8.0KB | 262.0KB | +254.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netstandard2.1 | 8.5KB | 214.5KB | +206.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| net461 | 8.5KB | 270.0KB | +261.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net462 | 7.0KB | 269.0KB | +262.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net47 | 7.0KB | 269.0KB | +262.0KB | +9.0KB | +6.0KB | +8.5KB | +13.5KB | +| net471 | 8.5KB | 269.0KB | +260.5KB | +9.0KB | +6.0KB | +9.0KB | +13.5KB | +| net472 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net48 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net481 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netcoreapp2.0 | 9.0KB | 243.5KB | +234.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netcoreapp2.1 | 9.0KB | 223.5KB | +214.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| netcoreapp2.2 | 9.0KB | 223.5KB | +214.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| netcoreapp3.0 | 9.5KB | 214.0KB | +204.5KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | +| netcoreapp3.1 | 9.5KB | 212.5KB | +203.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| net5.0 | 9.5KB | 175.0KB | +165.5KB | +9.0KB | +6.5KB | +9.5KB | +14.0KB | +| net6.0 | 10.0KB | 130.5KB | +120.5KB | +9.5KB | +6.5KB | +512bytes | +3.0KB | +| net7.0 | 10.0KB | 100.0KB | +90.0KB | +9.0KB | +5.5KB | +512bytes | +3.5KB | | net8.0 | 9.5KB | 80.0KB | +70.5KB | +8.5KB | | +512bytes | +3.5KB | | net9.0 | 9.5KB | 45.0KB | +35.5KB | +9.0KB | | +1.0KB | +3.5KB | | net10.0 | 10.0KB | 23.5KB | +13.5KB | +9.0KB | | +512bytes | +3.5KB | @@ -29,23 +29,23 @@ | | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------| -| netstandard2.0 | 8.0KB | 384.4KB | +376.4KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netstandard2.1 | 8.5KB | 312.2KB | +303.7KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | -| net461 | 8.5KB | 393.3KB | +384.8KB | +16.7KB | +7.7KB | +13.4KB | +18.9KB | -| net462 | 7.0KB | 391.8KB | +384.8KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net47 | 7.0KB | 391.6KB | +384.6KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net471 | 8.5KB | 391.6KB | +383.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net472 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net48 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net481 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netcoreapp2.0 | 9.0KB | 355.7KB | +346.7KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netcoreapp2.1 | 9.0KB | 325.4KB | +316.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp2.2 | 9.0KB | 325.4KB | +316.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp3.0 | 9.5KB | 307.2KB | +297.7KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp3.1 | 9.5KB | 305.2KB | +295.7KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | -| net5.0 | 9.5KB | 250.9KB | +241.4KB | +16.7KB | +7.7KB | +13.9KB | +19.4KB | -| net6.0 | 10.0KB | 189.4KB | +179.4KB | +17.7KB | +8.2KB | +1.1KB | +4.2KB | -| net7.0 | 10.0KB | 142.4KB | +132.4KB | +17.1KB | +6.9KB | +1.1KB | +4.2KB | +| netstandard2.0 | 8.0KB | 387.9KB | +379.9KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netstandard2.1 | 8.5KB | 315.0KB | +306.5KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| net461 | 8.5KB | 396.4KB | +387.9KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net462 | 7.0KB | 395.4KB | +388.4KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net47 | 7.0KB | 395.1KB | +388.1KB | +16.7KB | +7.7KB | +13.4KB | +18.9KB | +| net471 | 8.5KB | 395.1KB | +386.6KB | +16.7KB | +7.7KB | +13.9KB | +18.9KB | +| net472 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net48 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net481 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netcoreapp2.0 | 9.0KB | 359.3KB | +350.3KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netcoreapp2.1 | 9.0KB | 328.2KB | +319.2KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| netcoreapp2.2 | 9.0KB | 328.2KB | +319.2KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| netcoreapp3.0 | 9.5KB | 309.6KB | +300.1KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | +| netcoreapp3.1 | 9.5KB | 308.1KB | +298.6KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| net5.0 | 9.5KB | 253.2KB | +243.8KB | +16.7KB | +8.2KB | +14.4KB | +19.4KB | +| net6.0 | 10.0KB | 192.2KB | +182.2KB | +17.2KB | +8.2KB | +1.1KB | +3.7KB | +| net7.0 | 10.0KB | 144.7KB | +134.7KB | +16.6KB | +6.9KB | +1.1KB | +4.2KB | | net8.0 | 9.5KB | 114.0KB | +104.5KB | +16.0KB | +299bytes | +1.1KB | +4.2KB | | net9.0 | 9.5KB | 65.0KB | +55.5KB | +16.5KB | | +1.6KB | +4.2KB | | net10.0 | 10.0KB | 35.7KB | +25.7KB | +16.5KB | | +1.1KB | +4.2KB | diff --git a/readme.md b/readme.md index 52d1e25c..c125948d 100644 --- a/readme.md +++ b/readme.md @@ -13,34 +13,34 @@ The package targets `netstandard2.0` and is designed to support the following ru * `uap10` -**API count: 847** +**API count: 863** ### Per Target Framework | Target | APIs | | -- | -- | -| `net461` | 802 | -| `net462` | 802 | -| `net47` | 801 | -| `net471` | 801 | -| `net472` | 797 | -| `net48` | 797 | -| `net481` | 797 | -| `netstandard2.0` | 800 | -| `netstandard2.1` | 637 | -| `netcoreapp2.0` | 723 | -| `netcoreapp2.1` | 649 | -| `netcoreapp2.2` | 649 | -| `netcoreapp3.0` | 596 | -| `netcoreapp3.1` | 595 | -| `net5.0` | 473 | -| `net6.0` | 392 | -| `net7.0` | 279 | +| `net461` | 816 | +| `net462` | 816 | +| `net47` | 815 | +| `net471` | 815 | +| `net472` | 811 | +| `net48` | 811 | +| `net481` | 811 | +| `netstandard2.0` | 814 | +| `netstandard2.1` | 647 | +| `netcoreapp2.0` | 737 | +| `netcoreapp2.1` | 659 | +| `netcoreapp2.2` | 659 | +| `netcoreapp3.0` | 606 | +| `netcoreapp3.1` | 605 | +| `net5.0` | 483 | +| `net6.0` | 402 | +| `net7.0` | 285 | | `net8.0` | 181 | | `net9.0` | 121 | | `net10.0` | 75 | | `net11.0` | 57 | -| `uap10.0` | 789 | +| `uap10.0` | 803 | @@ -96,23 +96,23 @@ This project uses features from the current stable SDK and C# language. As such | | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------| -| netstandard2.0 | 8.0KB | 259.5KB | +251.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netstandard2.1 | 8.5KB | 212.5KB | +204.0KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | -| net461 | 8.5KB | 268.0KB | +259.5KB | +9.0KB | +6.0KB | +8.5KB | +13.5KB | -| net462 | 7.0KB | 266.5KB | +259.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net47 | 7.0KB | 266.5KB | +259.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net471 | 8.5KB | 266.5KB | +258.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net472 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net48 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| net481 | 8.5KB | 265.0KB | +256.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netcoreapp2.0 | 9.0KB | 241.0KB | +232.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | -| netcoreapp2.1 | 9.0KB | 221.5KB | +212.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp2.2 | 9.0KB | 221.5KB | +212.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp3.0 | 9.5KB | 212.5KB | +203.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | -| netcoreapp3.1 | 9.5KB | 210.5KB | +201.0KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | -| net5.0 | 9.5KB | 173.5KB | +164.0KB | +9.0KB | +6.0KB | +9.0KB | +14.0KB | -| net6.0 | 10.0KB | 128.5KB | +118.5KB | +10.0KB | +6.5KB | +512bytes | +3.5KB | -| net7.0 | 10.0KB | 98.5KB | +88.5KB | +9.5KB | +5.5KB | +512bytes | +3.5KB | +| netstandard2.0 | 8.0KB | 262.0KB | +254.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netstandard2.1 | 8.5KB | 214.5KB | +206.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| net461 | 8.5KB | 270.0KB | +261.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net462 | 7.0KB | 269.0KB | +262.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net47 | 7.0KB | 269.0KB | +262.0KB | +9.0KB | +6.0KB | +8.5KB | +13.5KB | +| net471 | 8.5KB | 269.0KB | +260.5KB | +9.0KB | +6.0KB | +9.0KB | +13.5KB | +| net472 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net48 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| net481 | 8.5KB | 267.5KB | +259.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netcoreapp2.0 | 9.0KB | 243.5KB | +234.5KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB | +| netcoreapp2.1 | 9.0KB | 223.5KB | +214.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| netcoreapp2.2 | 9.0KB | 223.5KB | +214.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| netcoreapp3.0 | 9.5KB | 214.0KB | +204.5KB | +9.5KB | +6.5KB | +9.5KB | +14.0KB | +| netcoreapp3.1 | 9.5KB | 212.5KB | +203.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB | +| net5.0 | 9.5KB | 175.0KB | +165.5KB | +9.0KB | +6.5KB | +9.5KB | +14.0KB | +| net6.0 | 10.0KB | 130.5KB | +120.5KB | +9.5KB | +6.5KB | +512bytes | +3.0KB | +| net7.0 | 10.0KB | 100.0KB | +90.0KB | +9.0KB | +5.5KB | +512bytes | +3.5KB | | net8.0 | 9.5KB | 80.0KB | +70.5KB | +8.5KB | | +512bytes | +3.5KB | | net9.0 | 9.5KB | 45.0KB | +35.5KB | +9.0KB | | +1.0KB | +3.5KB | | net10.0 | 10.0KB | 23.5KB | +13.5KB | +9.0KB | | +512bytes | +3.5KB | @@ -123,23 +123,23 @@ This project uses features from the current stable SDK and C# language. As such | | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------| -| netstandard2.0 | 8.0KB | 384.4KB | +376.4KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netstandard2.1 | 8.5KB | 312.2KB | +303.7KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | -| net461 | 8.5KB | 393.3KB | +384.8KB | +16.7KB | +7.7KB | +13.4KB | +18.9KB | -| net462 | 7.0KB | 391.8KB | +384.8KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net47 | 7.0KB | 391.6KB | +384.6KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net471 | 8.5KB | 391.6KB | +383.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net472 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net48 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| net481 | 8.5KB | 389.0KB | +380.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netcoreapp2.0 | 9.0KB | 355.7KB | +346.7KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | -| netcoreapp2.1 | 9.0KB | 325.4KB | +316.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp2.2 | 9.0KB | 325.4KB | +316.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp3.0 | 9.5KB | 307.2KB | +297.7KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | -| netcoreapp3.1 | 9.5KB | 305.2KB | +295.7KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | -| net5.0 | 9.5KB | 250.9KB | +241.4KB | +16.7KB | +7.7KB | +13.9KB | +19.4KB | -| net6.0 | 10.0KB | 189.4KB | +179.4KB | +17.7KB | +8.2KB | +1.1KB | +4.2KB | -| net7.0 | 10.0KB | 142.4KB | +132.4KB | +17.1KB | +6.9KB | +1.1KB | +4.2KB | +| netstandard2.0 | 8.0KB | 387.9KB | +379.9KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netstandard2.1 | 8.5KB | 315.0KB | +306.5KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| net461 | 8.5KB | 396.4KB | +387.9KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net462 | 7.0KB | 395.4KB | +388.4KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net47 | 7.0KB | 395.1KB | +388.1KB | +16.7KB | +7.7KB | +13.4KB | +18.9KB | +| net471 | 8.5KB | 395.1KB | +386.6KB | +16.7KB | +7.7KB | +13.9KB | +18.9KB | +| net472 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net48 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| net481 | 8.5KB | 392.6KB | +384.1KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netcoreapp2.0 | 9.0KB | 359.3KB | +350.3KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB | +| netcoreapp2.1 | 9.0KB | 328.2KB | +319.2KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| netcoreapp2.2 | 9.0KB | 328.2KB | +319.2KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| netcoreapp3.0 | 9.5KB | 309.6KB | +300.1KB | +17.2KB | +8.2KB | +14.4KB | +19.4KB | +| netcoreapp3.1 | 9.5KB | 308.1KB | +298.6KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB | +| net5.0 | 9.5KB | 253.2KB | +243.8KB | +16.7KB | +8.2KB | +14.4KB | +19.4KB | +| net6.0 | 10.0KB | 192.2KB | +182.2KB | +17.2KB | +8.2KB | +1.1KB | +3.7KB | +| net7.0 | 10.0KB | 144.7KB | +134.7KB | +16.6KB | +6.9KB | +1.1KB | +4.2KB | | net8.0 | 9.5KB | 114.0KB | +104.5KB | +16.0KB | +299bytes | +1.1KB | +4.2KB | | net9.0 | 9.5KB | 65.0KB | +55.5KB | +16.5KB | | +1.6KB | +4.2KB | | net10.0 | 10.0KB | 35.7KB | +25.7KB | +16.5KB | | +1.1KB | +4.2KB | @@ -1272,6 +1272,14 @@ The class `Polyfill` includes the following extension methods: * `bool EndsWith(T) where T : IEquatable?` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.endswith?view=net-11.0#system-memoryextensions-endswith-1(system-readonlyspan((-0))-0)) * `int IndexOf(T, IEqualityComparer?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexof?view=net-11.0#system-memoryextensions-indexof-1(system-readonlyspan((-0))-0-system-collections-generic-iequalitycomparer((-0)))) * `int IndexOfAny(ReadOnlySpan, IEqualityComparer?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.countany?view=net-11.0#system-memoryextensions-countany-1(system-readonlyspan((-0))-system-buffers-searchvalues((-0)))) + * `int IndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) + * `int IndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0-0)) + * `int IndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0)) + * `int IndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0)) + * `int LastIndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) + * `int LastIndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0-0)) + * `int LastIndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0)) + * `int LastIndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0)) * `SpanSplitEnumerator Split(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-11.0#system-memoryextensions-split-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) * `SpanSplitEnumerator Split(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-11.0#system-memoryextensions-split-1(system-readonlyspan((-0))-0)) * `SpanSplitEnumerator SplitAny(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.splitany?view=net-11.0#system-memoryextensions-splitany-1(system-readonlyspan((-0))-system-readonlyspan((-0)))) @@ -1402,6 +1410,14 @@ The class `Polyfill` includes the following extension methods: * `bool ContainsAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyexcept?view=net-11.0#system-memoryextensions-containsanyexcept-1(system-span((-0))-0)) * `bool ContainsAnyExceptInRange(T, T) where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyexceptinrange?view=net-11.0#system-memoryextensions-containsanyexceptinrange-1(system-span((-0))-0-0)) * `bool ContainsAnyInRange(T, T) where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.containsanyinrange?view=net-11.0#system-memoryextensions-containsanyinrange-1(system-span((-0))-0-0)) + * `int IndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-system-readonlyspan((-0)))) + * `int IndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0-0)) + * `int IndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0)) + * `int IndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0)) + * `int LastIndexOfAnyExcept(ReadOnlySpan) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-system-readonlyspan((-0)))) + * `int LastIndexOfAnyExcept(T, T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0-0)) + * `int LastIndexOfAnyExcept(T, T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0)) + * `int LastIndexOfAnyExcept(T) where T : IEquatable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0)) * `void Sort(Comparison)` * `void Sort() where T : IComparable` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.sort?view=net-11.0#system-memoryextensions-sort-1(system-span((-0)))) diff --git a/src/Consume/Consume.cs b/src/Consume/Consume.cs index a205a776..33f00486 100644 --- a/src/Consume/Consume.cs +++ b/src/Consume/Consume.cs @@ -1043,6 +1043,14 @@ void ReadOnlySpan_Methods() result = readOnlySpan.StartsWith('a'); result = readOnlySpan.EndsWith('a'); result = readOnlySpan.StartsWith("value", StringComparison.Ordinal); + _ = readOnlySpan.IndexOfAnyExcept('a'); + _ = readOnlySpan.IndexOfAnyExcept('a', 'b'); + _ = readOnlySpan.IndexOfAnyExcept('a', 'b', 'c'); + _ = readOnlySpan.IndexOfAnyExcept("ab".AsSpan()); + _ = readOnlySpan.LastIndexOfAnyExcept('a'); + _ = readOnlySpan.LastIndexOfAnyExcept('a', 'b'); + _ = readOnlySpan.LastIndexOfAnyExcept('a', 'b', 'c'); + _ = readOnlySpan.LastIndexOfAnyExcept("ab".AsSpan()); #if FeatureValueTuple var split = readOnlySpan.Split('a'); split = readOnlySpan.Split("a".AsSpan()); @@ -1139,6 +1147,15 @@ void Span_Methods() var numbers = new Span(array); numbers.Sort(); + + _ = span.IndexOfAnyExcept('a'); + _ = span.IndexOfAnyExcept('a', 'b'); + _ = span.IndexOfAnyExcept('a', 'b', 'c'); + _ = span.IndexOfAnyExcept("ab".AsSpan()); + _ = span.LastIndexOfAnyExcept('a'); + _ = span.LastIndexOfAnyExcept('a', 'b'); + _ = span.LastIndexOfAnyExcept('a', 'b', 'c'); + _ = span.LastIndexOfAnyExcept("ab".AsSpan()); } #endif diff --git a/src/Polyfill/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Polyfill/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..a4d9779b --- /dev/null +++ b/src/Polyfill/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,100 @@ +#if FeatureMemory && !NET7_0_OR_GREATER + +namespace Polyfills; + +using System; + +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0) + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + + return -1; + } + + /// Searches for the first index of any value other than or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0) + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + + return -1; + } + + /// Searches for the first index of any value other than , , or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-0-0-0) + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + + return -1; + } + + /// Searches for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0))) + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + + return -1; + } + + /// Searches for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0) + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + + /// Searches for the first index of any value other than or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0) + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + + /// Searches for the first index of any value other than , , or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-0-0-0) + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + + /// Searches for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.indexofanyexcept?view=net-11.0#system-memoryextensions-indexofanyexcept-1(system-span((-0))-system-readonlyspan((-0))) + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} + +#endif diff --git a/src/Polyfill/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Polyfill/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..0e0f8d9e --- /dev/null +++ b/src/Polyfill/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,100 @@ +#if FeatureMemory && !NET7_0_OR_GREATER + +namespace Polyfills; + +using System; + +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0) + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + + return -1; + } + + /// Searches from the end for the first index of any value other than or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0) + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + + return -1; + } + + /// Searches from the end for the first index of any value other than , , or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-0-0-0) + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + + return -1; + } + + /// Searches from the end for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-readonlyspan((-0))-system-readonlyspan((-0))) + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + + return -1; + } + + /// Searches from the end for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0) + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + + /// Searches from the end for the first index of any value other than or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0) + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + + /// Searches from the end for the first index of any value other than , , or . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-0-0-0) + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + + /// Searches from the end for the first index of any value other than the specified . + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.lastindexofanyexcept?view=net-11.0#system-memoryextensions-lastindexofanyexcept-1(system-span((-0))-system-readonlyspan((-0))) + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} + +#endif diff --git a/src/Split/net461/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net461/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net461/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net461/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net461/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net461/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net462/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net462/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net462/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net462/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net462/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net462/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net47/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net47/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net47/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net47/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net47/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net47/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net471/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net471/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net471/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net471/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net471/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net471/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net472/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net472/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net472/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net472/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net472/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net472/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net48/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net48/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net48/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net48/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net48/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net48/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net481/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net481/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net481/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net481/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net481/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net481/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net5.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net5.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net5.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net5.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net5.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net5.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net6.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/net6.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/net6.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/net6.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/net6.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/net6.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netcoreapp2.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netcoreapp2.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netcoreapp2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netcoreapp2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.1/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netcoreapp2.1/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netcoreapp2.1/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netcoreapp2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netcoreapp2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.2/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netcoreapp2.2/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netcoreapp2.2/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp2.2/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netcoreapp2.2/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netcoreapp2.2/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp3.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netcoreapp3.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netcoreapp3.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp3.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netcoreapp3.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netcoreapp3.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp3.1/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netcoreapp3.1/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netcoreapp3.1/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netcoreapp3.1/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netcoreapp3.1/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netcoreapp3.1/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netstandard2.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netstandard2.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netstandard2.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netstandard2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netstandard2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netstandard2.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netstandard2.1/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/netstandard2.1/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/netstandard2.1/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/netstandard2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/netstandard2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/netstandard2.1/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/uap10.0/Polyfill_Memory_IndexOfAnyExcept.cs b/src/Split/uap10.0/Polyfill_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..d49c931b --- /dev/null +++ b/src/Split/uap10.0/Polyfill_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = 0; i < span.Length; i++) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches for the first index of any value other than or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches for the first index of any value other than , , or . + public static int IndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches for the first index of any value other than the specified . + public static int IndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + IndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Split/uap10.0/Polyfill_Memory_LastIndexOfAnyExcept.cs b/src/Split/uap10.0/Polyfill_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..591af601 --- /dev/null +++ b/src/Split/uap10.0/Polyfill_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable +#if FeatureMemory +namespace Polyfills; +using System; +static partial class Polyfill +{ + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!span[i].Equals(value)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, T value0, T value1, T value2) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + var item = span[i]; + if (!item.Equals(value0) && !item.Equals(value1) && !item.Equals(value2)) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this ReadOnlySpan span, ReadOnlySpan values) + where T : IEquatable + { + for (var i = span.Length - 1; i >= 0; i--) + { + if (!values.Contains(span[i])) + { + return i; + } + } + return -1; + } + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, T value) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value); + /// Searches from the end for the first index of any value other than or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1); + /// Searches from the end for the first index of any value other than , , or . + public static int LastIndexOfAnyExcept(this Span span, T value0, T value1, T value2) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, value0, value1, value2); + /// Searches from the end for the first index of any value other than the specified . + public static int LastIndexOfAnyExcept(this Span span, ReadOnlySpan values) + where T : IEquatable => + LastIndexOfAnyExcept((ReadOnlySpan)span, values); +} +#endif diff --git a/src/Tests/PolyfillTests_Memory_IndexOfAnyExcept.cs b/src/Tests/PolyfillTests_Memory_IndexOfAnyExcept.cs new file mode 100644 index 00000000..f577e3de --- /dev/null +++ b/src/Tests/PolyfillTests_Memory_IndexOfAnyExcept.cs @@ -0,0 +1,92 @@ +partial class PolyfillTests +{ + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_SingleValue_Found() + { + var span = new ReadOnlySpan(new[] { 1, 1, 2, 1 }); + var result = span.IndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(2); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_SingleValue_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 1, 1 }); + var result = span.IndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_SingleValue_Empty() + { + var span = new ReadOnlySpan(new int[0]); + var result = span.IndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_TwoValues_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 2, 1, 2 }); + var result = span.IndexOfAnyExcept(1, 2); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_TwoValues_Found() + { + var span = new ReadOnlySpan(new[] { 1, 2, 3, 2 }); + var result = span.IndexOfAnyExcept(1, 2); + await Assert.That(result).IsEqualTo(2); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_ThreeValues_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 2, 3, 2, 1, 3 }); + var result = span.IndexOfAnyExcept(1, 2, 3); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_ThreeValues_Found() + { + var span = new ReadOnlySpan(new[] { 1, 2, 3, 4 }); + var result = span.IndexOfAnyExcept(1, 2, 3); + await Assert.That(result).IsEqualTo(3); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_ReadOnlySpanValues_AllExcluded() + { + var span = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var values = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var result = span.IndexOfAnyExcept(values); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_IndexOfAnyExcept_ReadOnlySpanValues_PartialExcluded() + { + var span = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var values = new ReadOnlySpan(new[] { 'a', 'b' }); + var result = span.IndexOfAnyExcept(values); + await Assert.That(result).IsEqualTo(2); + } + + [Test] + public async Task Span_IndexOfAnyExcept_SingleValue_Found() + { + var span = new Span(new[] { 1, 1, 2, 1 }); + var result = span.IndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(2); + } + + [Test] + public async Task Span_IndexOfAnyExcept_SingleValue_NotFound() + { + var span = new Span(new[] { 1, 1, 1 }); + var result = span.IndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } +} diff --git a/src/Tests/PolyfillTests_Memory_LastIndexOfAnyExcept.cs b/src/Tests/PolyfillTests_Memory_LastIndexOfAnyExcept.cs new file mode 100644 index 00000000..2f79747d --- /dev/null +++ b/src/Tests/PolyfillTests_Memory_LastIndexOfAnyExcept.cs @@ -0,0 +1,92 @@ +partial class PolyfillTests +{ + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_SingleValue_Found() + { + var span = new ReadOnlySpan(new[] { 1, 2, 1, 1 }); + var result = span.LastIndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_SingleValue_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 1, 1 }); + var result = span.LastIndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_SingleValue_Empty() + { + var span = new ReadOnlySpan(new int[0]); + var result = span.LastIndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_TwoValues_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 2, 1, 2 }); + var result = span.LastIndexOfAnyExcept(1, 2); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_TwoValues_Found() + { + var span = new ReadOnlySpan(new[] { 1, 3, 2, 1 }); + var result = span.LastIndexOfAnyExcept(1, 2); + await Assert.That(result).IsEqualTo(1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_ThreeValues_NotFound() + { + var span = new ReadOnlySpan(new[] { 1, 2, 3, 2, 1, 3 }); + var result = span.LastIndexOfAnyExcept(1, 2, 3); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_ThreeValues_Found() + { + var span = new ReadOnlySpan(new[] { 4, 1, 2, 3 }); + var result = span.LastIndexOfAnyExcept(1, 2, 3); + await Assert.That(result).IsEqualTo(0); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_ReadOnlySpanValues_AllExcluded() + { + var span = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var values = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var result = span.LastIndexOfAnyExcept(values); + await Assert.That(result).IsEqualTo(-1); + } + + [Test] + public async Task ReadOnlySpan_LastIndexOfAnyExcept_ReadOnlySpanValues_PartialExcluded() + { + var span = new ReadOnlySpan(new[] { 'a', 'b', 'c' }); + var values = new ReadOnlySpan(new[] { 'b', 'c' }); + var result = span.LastIndexOfAnyExcept(values); + await Assert.That(result).IsEqualTo(0); + } + + [Test] + public async Task Span_LastIndexOfAnyExcept_SingleValue_Found() + { + var span = new Span(new[] { 1, 2, 1, 1 }); + var result = span.LastIndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(1); + } + + [Test] + public async Task Span_LastIndexOfAnyExcept_SingleValue_NotFound() + { + var span = new Span(new[] { 1, 1, 1 }); + var result = span.LastIndexOfAnyExcept(1); + await Assert.That(result).IsEqualTo(-1); + } +}