using System; using System.Collections; using UnityEngine.TestTools; namespace BracerLib.Utility { [ExcludeFromCoverage] public static class ArrayExtensions { public static bool Contains(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(this T[] array, U value, Func predicate) { for (var i = 0; i < array.Length; i++) { if (predicate(array[i], value)) return true; } return false; } public static T[] Subset(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; } }