Initial commit

This commit is contained in:
2026-06-02 18:57:47 -04:00
commit 59d26a915d
268 changed files with 41240 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
using System;
using System.Collections;
using UnityEngine.TestTools;
namespace BracerLib.Utility
{
[ExcludeFromCoverage]
public static class ArrayExtensions
{
public static bool Contains<T>(this T[] array, T value) where T : IComparable
{
for (var i = 0; i < array.Length; i++)
{
if (array[i].CompareTo(value) == 0)
return true;
}
return false;
}
public static bool Contains<T, U>(this T[] array, U value, Func<T, U, bool> predicate)
{
for (var i = 0; i < array.Length; i++)
{
if (predicate(array[i], value))
return true;
}
return false;
}
public static T[] Subset<T>(this T[] data, int index, int length)
{
var result = new T[length];
Array.Copy(data, index, result, 0, length);
return result;
}
public static bool HasIndex(this IList list, int index) => index >= 0 && index < list.Count;
public static bool HasIndex(this Array array, int index) => index >= 0 && index < array.Length;
}
}