This commit is contained in:
2025-09-17 18:56:28 +08:00
commit 54c72710a5
5244 changed files with 5717609 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System;
namespace DestroyIt
{
public static class ArrayExtensions
{
/// <summary>Provides a quick way to remove elements from a standard array.</summary>
public static T[] RemoveAllAt<T>(this T[] array, int[] removeIndices)
{
T[] newArray = new T[0];
if (removeIndices.Length == 0) return array;
if (removeIndices.Length >= array.Length) return newArray;
newArray = new T[array.Length];
int i = 0;
int j = 0;
int itemsKept = 0;
while (i < array.Length)
{
bool keepItem = true;
for (int x = 0; x < removeIndices.Length; x++)
{
if (i == removeIndices[x])
keepItem = false;
}
if (keepItem)
{
itemsKept++;
newArray[j] = array[i];
j++;
}
i++;
}
Array.Resize(ref newArray, itemsKept);
return newArray;
}
}
}