Code refactoring, removed unnecessary extensions
このコミットが含まれているのは:
1 親
aac929b9ac
コミット
e66ecd8d99
5ファイル変更
+3
-94
検索条件に一致するファイルはありません
@@ -1,92 +0,0 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Span{T}"/>
|
||||
/// </summary>
|
||||
public static class SpanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Span{T}"/> from a given 2D <typeparamref name="T"/> array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the input array</typeparam>
|
||||
/// <param name="array">The input 2D <typeparamref name="T"/> array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> that maps all the items of the input array</returns>
|
||||
[Pure]
|
||||
public static Span<T> AsSpan<T>(this T[,] array)
|
||||
{
|
||||
ref T r0 = ref array[0, 0];
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref r0, array.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Span{T}"/> from a given 2D <typeparamref name="T"/> array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the input array</typeparam>
|
||||
/// <param name="array">The input 2D <typeparamref name="T"/> array</param>
|
||||
/// <param name="startIndex">The index of the initial row to map from the input array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> that maps the desired items of the input array</returns>
|
||||
[Pure]
|
||||
public static Span<T> AsSpan<T>(this T[,] array, Index startIndex)
|
||||
{
|
||||
int
|
||||
rows = array.GetLength(0),
|
||||
offset = startIndex.GetOffset(rows),
|
||||
interval = rows - offset;
|
||||
ref T r0 = ref array[offset, 0];
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref r0, interval * array.GetLength(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Span{T}"/> from a given 2D <typeparamref name="T"/> array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the input array</typeparam>
|
||||
/// <param name="array">The input 2D <typeparamref name="T"/> array</param>
|
||||
/// <param name="start">The index of the initial row to map from the input array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> that maps the desired items of the input array</returns>
|
||||
[Pure]
|
||||
public static Span<T> AsSpan<T>(this T[,] array, int start)
|
||||
{
|
||||
int interval = array.GetLength(0) - start;
|
||||
ref T r0 = ref array[start, 0];
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref r0, interval * array.GetLength(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Span{T}"/> from a given 2D <typeparamref name="T"/> array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the input array</typeparam>
|
||||
/// <param name="array">The input 2D <typeparamref name="T"/> array</param>
|
||||
/// <param name="start">The index of the initial row to map from the input array</param>
|
||||
/// <param name="length">The number of rows to map from the input array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> that maps the desired items of the input array</returns>
|
||||
[Pure]
|
||||
public static Span<T> AsSpan<T>(this T[,] array, int start, int length)
|
||||
{
|
||||
ref T r0 = ref array[start, 0];
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref r0, length * array.GetLength(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Span{T}"/> from a given 2D <typeparamref name="T"/> array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the input array</typeparam>
|
||||
/// <param name="array">The input 2D <typeparamref name="T"/> array</param>
|
||||
/// <param name="range">The range of rows to map from the input array</param>
|
||||
/// <returns>A <see cref="Span{T}"/> that maps the desired items of the input array</returns>
|
||||
[Pure]
|
||||
public static Span<T> AsSpan<T>(this T[,] array, Range range)
|
||||
{
|
||||
var indices = range.GetOffsetAndLength(array.GetLength(0));
|
||||
ref T r0 = ref array[indices.Offset, 0];
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref r0, indices.Length * array.GetLength(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
差分なしでファイル名を変更。
@@ -3,6 +3,7 @@ using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using Microsoft.Toolkit.HighPerformance.Extensions;
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
|
||||
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="6.1.1" />
|
||||
<PackageReference Include="Vortice.Direct3D12" Version="1.8.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<repository type="git" url="https://github.com/Sergio0694/ComputeSharp.git" branch="master" />
|
||||
<dependencies>
|
||||
<dependency id="Microsoft.Windows.SDK.Contracts" version="10.0.19041.1" />
|
||||
<dependency id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" />
|
||||
<dependency id="Microsoft.Toolkit.HighPerformance" version="6.1.1" />
|
||||
<dependency id="Vortice.Direct3D12" version="1.8.3" />
|
||||
<dependency id="ICSharpCode.Decompiler" version="5.0.2.5153" />
|
||||
<dependency id="Microsoft.CodeAnalysis.CSharp" version="3.7.0" />
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする