diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs index 600413c8b..68be78928 100644 --- a/Assets/Scripts/ServerShared/Galaxy.cs +++ b/Assets/Scripts/ServerShared/Galaxy.cs @@ -7,7 +7,6 @@ using System.Threading; using System.Threading.Tasks; using DataStructures.ViliWonka.Heap; using Ink.Runtime; -using JM.LinqFaster; using UniRx; using CultMath; using static CultMath.math; diff --git a/Assets/Scripts/ServerShared/ItemInstance.cs b/Assets/Scripts/ServerShared/ItemInstance.cs index fc7bd85b5..da75134ce 100644 --- a/Assets/Scripts/ServerShared/ItemInstance.cs +++ b/Assets/Scripts/ServerShared/ItemInstance.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using GameCult.Caching; -//using JM.LinqFaster; using MessagePack; using MessagePack.Formatters; using Newtonsoft.Json; diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 25b467992..9bad8be23 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -11,7 +11,6 @@ using CultMath; using static CultMath.math; using float2 = CultMath.float2; using Random = CultMath.Random; -using JM.LinqFaster; using UniRx; using float4 = CultMath.float4; diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster.meta deleted file mode 100644 index 4ed731785..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8a827381b8571114091cd0fc9c0ebd1f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs deleted file mode 100644 index 9c60a91e6..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - /// - /// Provides faster array and list specific extension methods with - /// the same semantics as the Linq extensions methods. - /// - public static partial class LinqFaster - { - - // ------------------------------ Arrays -------------------------- - - /// - /// Applies an accumulator function over an array. - /// - /// An array to aggregate over. - /// An accumulator function to be invoked on each element - /// The final accumulator value - public static TSource AggregateF(this TSource[] source, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - TSource result = source[0]; - for (int i = 1; i < source.Length; i++) - { - result = func(result, source[i]); - } - return result; - } - - /// - /// Applies an accumulator function over an array. The specified seed - /// value is used as the initial accumulator value. - /// - /// An array to aggregate over. - /// The initial accumulator value. - /// An accumulator function to be invoked on each element - /// The final accumulator value - public static TAccumulate AggregateF(this TSource[] source, TAccumulate seed, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - TAccumulate result = seed; - foreach (var v in source) - { - result = func(result, v); - } - return result; - } - - /// - /// Applies an accumulator function over an array. The specified seed - /// value is used as the initial accumulator value, and the specified - /// function is used to select the result value. - /// - /// An array to aggregate over. - /// The initial accumulator value. - /// An accumulator function to be invoked on each element - /// A function to transform the final accumulator value into the result value. - /// The transformed final accumulator value - public static TResult AggregateF(this TSource[] source, TAccumulate seed, Func func, Func resultSelector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (resultSelector == null) - { - throw Error.ArgumentNull("resultSelector"); - } - - TAccumulate result = seed; - foreach (var v in source) - { - result = func(result, v); - } - return resultSelector(result); - } - - // ------------------------------ Lists -------------------------- - - /// - /// Applies an accumulator function over a List. - /// - /// - /// A List to aggregate over. - /// An accumulator function to be invoked on each element - /// The final accumulator value - public static TSource AggregateF(this List source, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - TSource result = source[0]; - for (int i = 1; i < source.Count; i++) - { - result = func(result, source[i]); - } - return result; - } - - /// - /// Applies an accumulator function over a List. The specified seed - /// value is used as the initial accumulator value. - /// - /// A List to aggregate over. - /// The initial accumulator value. - /// An accumulator function to be invoked on each element - /// The final accumulator value - public static TAccumulate AggregateF(this List source, TAccumulate seed, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - TAccumulate result = seed; - for (int i = 0; i < source.Count; i++) - { - result = func(result, source[i]); - } - return result; - } - - /// - /// Applies an accumulator function over a List. The specified seed - /// value is used as the initial accumulator value, and the specified - /// function is used to select the result value. - /// - /// A List to aggregate over. - /// The initial accumulator value. - /// An accumulator function to be invoked on each element - /// A function to transform the final accumulator value into the result value. - /// The transformed final accumulator value - public static TResult AggregateF(this List source, TAccumulate seed, Func func, Func resultSelector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (resultSelector == null) - { - throw Error.ArgumentNull("resultSelector"); - } - - TAccumulate result = seed; - for (int i = 0; i < source.Count; i++) - { - result = func(result, source[i]); - } - return resultSelector(result); - } - - } -} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs.meta deleted file mode 100644 index 58da970d6..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Aggregate.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: c982561dda0276f48b28c8fa12295ad4 -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs deleted file mode 100644 index bd73fbec3..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Determines whether an array contains any elements - /// - /// The array to check for emptiness - /// true if the source array contains any elements, otherwise, false/ - public static bool AnyF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - return source.Length > 0; - } - - - - /// - /// Determines whether any element of an array satifies a condition. - /// - /// An array whose elements to apply the predicate to. - /// A function to test each element for a condition. - /// true if any elements in the source array pass the test in the specified predicate; otherwise, false. - public static bool AnyF(this TSource[] source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - return Array.Exists(source, predicate); - } - - - /// - /// Determines whether all elements of an array satisfy a condition. - /// - /// An array that contains the elements to apply the predicate to. - /// A function to test each element for a condition. - /// true if every element of the source array passes the test in the specified - /// predicate, or if the array is empty; otherwise, false - public static bool AllF(this TSource[] source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - return Array.TrueForAll(source, predicate); - } - - - - - - // -------------------------- Lists -------------------------------------------- - /// - /// Determines whether a list contains any elements - /// - /// The list to check for emptiness - /// true if the source list contains any elements, otherwise, false/ - public static bool AnyF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - return source.Count > 0; - } - - /// - /// Determines whether any element of an array satifies a condition. - /// - /// An array whose elements to apply the predicate to. - /// A function to test each element for a condition. - /// true if any elements in the source array pass the test in the specified predicate; otherwise, false. - public static bool AnyF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - return source.Exists(predicate); - } - - /// - /// Determines whether all elements of a list satisfy a condition. - /// - /// A list that contains the elements to apply the predicate to. - /// A function to test each element for a condition. - /// true if every element of the source array passes the test in the specified - /// predicate, or if the list is empty; otherwise, false - public static bool AllF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - return source.TrueForAll(predicate); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs.meta deleted file mode 100644 index 1cc9f27a4..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/AnyAll.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 0f33f6b80d5e4d24bb1f5b42a26585e8 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs deleted file mode 100644 index 25ca15f51..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs +++ /dev/null @@ -1,633 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Computes the average of an array - /// - /// The array to calculate the average of. - /// The average of the array. - public static double AverageF(this int[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Length; i++) - { - sum += source[i]; - } - } - return (double)sum / source.Length; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Length; i++) - { - sum += selector(source[i]); - } - } - return (double)sum / source.Length; - } - - /// - /// Computes the average of an array - /// - /// The array to calculate the average of. - /// The average of the array. - public static double AverageF(this long[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Length; i++) - { - sum += source[i]; - } - } - return (double)sum / source.Length; - } - - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Length; i++) - { - sum += selector(source[i]); - } - } - return (double)sum / source.Length; - } - - /// - /// Computes the average of an array - /// - /// The array to calculate the average of. - /// The average of the array. - public static float AverageF(this float[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - double sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += source[i]; - } - - return (float)(sum / source.Length); - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static float AverageF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += selector(source[i]); - } - - return (float)(sum / source.Length); - } - - /// - /// Computes the average of an array - /// - /// The array to calculate the average of. - /// The average of the array. - public static double AverageF(this double[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - double sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += source[i]; - } - - return sum / source.Length; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += selector(source[i]); - } - - return sum / source.Length; - } - - /// - /// Computes the average of an array - /// - /// The array to calculate the average of. - /// The average of the array. - public static decimal AverageF(this decimal[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - decimal sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += source[i]; - } - - return sum / source.Length; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static decimal AverageF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - - decimal sum = 0; - - for (int i = 0; i < source.Length; i++) - { - sum += selector(source[i]); - } - - return sum / source.Length; - } - - // -------------------------- Lists -------------------------------------------- - - /// - /// Computes the average of a list. - /// - /// The list to calculate the average of. - /// The average of the list. - public static double AverageF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - } - return (double)sum / source.Count; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - } - return (double)sum / source.Count; - } - - /// - /// Computes the average of a list. - /// - /// The list to calculate the average of. - /// The average of the list. - public static double AverageF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - } - return (double)sum / source.Count; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - } - return (double)sum / source.Count; - } - - /// - /// Computes the average of a list. - /// - /// The list to calculate the average of. - /// The average of the list. - public static float AverageF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return (float)(sum / source.Count); - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static float AverageF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return (float)(sum / source.Count); - } - - /// - /// Computes the average of a list. - /// - /// The list to calculate the average of. - /// The average of the list. - public static double AverageF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return sum / source.Count; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static double AverageF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return sum / source.Count; - } - - /// - /// Computes the average of a list. - /// - /// The list to calculate the average of. - /// The average of the list. - public static decimal AverageF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - decimal sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return sum / source.Count; - } - - /// - /// Computes the average of values obtained by invoking a transform function on - /// each element of the input array. - /// - /// The array to calculate the transformed average of. - /// A transform function to apply to each element. - /// The average of the array. - public static decimal AverageF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - - decimal sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return sum / source.Count; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs.meta deleted file mode 100644 index a4ab01ad2..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Average.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 03ad52f1464dca347a72680cef2af96a -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs deleted file mode 100644 index 1b7fc1334..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Determines whether an array contains a specified element by using the - /// provided IEqualityComparer. - /// - /// An array in which to locate a value. - /// The value to locate. - /// An equality comparer to compare values. - /// true if the source sequence contains an element that has the specified value; otherwise, false. - public static bool ContainsF(this TSource[] source, TSource value, IEqualityComparer comparer = null) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (comparer == null) - { - return Array.IndexOf(source, value) != -1; - } - - - foreach (TSource e in source) - { - if (comparer.Equals(e, value)) - { - return true; - } - } - - return false; - } - - // -------------------------- Lists -------------------------------------------- - - /// - /// Determines whether a list contains a specified element by using the - /// provided IEqualityComparer. - /// - /// A list in which to locate a value. - /// The value to locate. - /// An equality comparer to compare values. - /// true if the source sequence contains an element that has the specified value; otherwise, false. - public static bool ContainsF(this List source, TSource value, IEqualityComparer comparer = null) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (comparer == null) - { - return source.IndexOf(value) != -1; - } - - - for (int i = 0; i < source.Count; i++) - { - if (comparer.Equals(source[i], value)) - { - return true; - } - } - - return false; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs.meta deleted file mode 100644 index 85c8d78c7..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Contains.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b2bd3dc5ff6476641a57d43d3692ce23 -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs deleted file mode 100644 index a844f3eaa..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- Arrays -------------------------------------------- - - /// - /// Returns a number that represents how many elements in the specified - /// array satisfy a condition. - /// - /// An array that contains elements to be tested and counted. - /// A function to test each element for a condition. - /// A number that represents how many elements in the array satisfy the condition - /// in the predicate function. - public static int CountF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - int count = 0; - for (int i = 0; i < source.Length; i++) - { - checked - { - if (predicate(source[i])) - { - count++; - } - } - } - - return count; - } - - - // ------------------------------ Lists --------------------- - - /// - /// Returns a number that represents how many elements in the specified - /// list satisfy a condition. - /// - /// A list that contains elements to be tested and counted. - /// A function to test each element for a condition. - /// A number that represents how many elements in the list satisfy the condition - /// in the predicate function. - public static int CountF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - int count = 0; - for (int i = 0; i < source.Count; i++) - { - checked - { - if (predicate(source[i])) - { - count++; - } - } - } - - return count; - } - - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs.meta deleted file mode 100644 index 2c4f37b21..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Count.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 5337c0db0f170274587167b132a927c7 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs deleted file mode 100644 index be96e5580..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- LISTS -------------------------------------------- - - - /// - /// Removes duplicate elements from source, does not maintain order. Elements will be - /// sorted in ascending order. - /// - /// The list to remove duplicate elements from. - /// Optional IEqualityComparer to compare values. - /// Optional IComparer to compare values. - public static void DistinctInPlaceF(this List source, IEqualityComparer eqComparer = null, IComparer comparer = null) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (comparer == null) - { - comparer = Comparer.Default; - } - - if (eqComparer == null) - { - eqComparer = EqualityComparer.Default; - } - - source.Sort(comparer); - - TSource oldV = source[0]; - int pos = 1; - for (int i = 1; i < source.Count; i++) - { - var newV = source[i]; - source[pos] = newV; - if (!eqComparer.Equals(newV, oldV)) - { - pos++; - } - oldV = newV; - } - source.RemoveRange(pos, source.Count - pos); - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs.meta deleted file mode 100644 index bb6b0fb55..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Distinct.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: d04d64ff5ae302449a864bfaae8dcfda -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs deleted file mode 100644 index 51f818a40..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- Arrays -------------------------------------------- - - /// - /// Returns the first element of an array. - /// - /// The array to return the first element of. - /// The first element in the specified array. - public static T FirstF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - return source[0]; - } - - /// - /// Returns the first element in an array that satisfies a specified condition. - /// - /// An array to return an element from. - /// A function to teast each element for a condition. - /// The first element that satisfies the condition. - public static T FirstF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - return source[i]; - } - } - - throw Error.NoMatch(); - } - - - - - /// - /// Returns the first element of an array, or a default value if the - /// array contains no elements. - /// - /// The array to return the first element of. - /// default value if source is empty, otherwise, the first element - /// in source. - public static T FirstOrDefaultF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - return default(T); - } - return source[0]; - } - - /// - /// Returns the first element of the sequence that satisfies a condition or a - /// default value if no such element is found. - /// - /// An IEnumerable to return an element from. - /// A function to test each element for a condition. - /// - public static T FirstOrDefaultF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - return source[i]; - } - } - - return default(T); - } - - // -------------------------- Lists -------------------------------------------- - - /// - /// Returns the first element of a list - /// - /// The list to return the first element of. - /// The first element in the specified list. - public static T FirstF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - return source[0]; - } - - /// - /// Returns the first element in a list that satisfies a specified condition. - /// - /// An list to return an element from. - /// A function to teast each element for a condition. - /// The first element in the list that satisfies the condition. - public static T FirstF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var firstIndex = source.FindIndex(predicate); - if (firstIndex == -1) - throw Error.NoMatch(); - else - return source[firstIndex]; - } - - /// - /// Returns the first element of an array, or a default value if the - /// array contains no elements. - /// - /// The array to return the first element of. - /// default value if source is empty, otherwise, the first element - /// in source. - public static T FirstOrDefaultF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - return default(T); - } - return source[0]; - } - - /// - /// Returns the first element of the sequence that satisfies a condition or a - /// default value if no such element is found. - /// - /// An IEnumerable to return an element from. - /// A function to test each element for a condition. - /// - public static T FirstOrDefaultF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var firstIndex = source.FindIndex(predicate); - if (firstIndex == -1) - return default(T); - else - return source[firstIndex]; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs.meta deleted file mode 100644 index b438fed5c..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/First.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 7c8f855844813a24f8d07be8c7d7b7c5 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs deleted file mode 100644 index cb8d8a6e8..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // -------------------------- Arrays -------------------------------------------- - - /// - /// Returns the last element of a sequence. - /// - /// An sequence to return the last element of. - /// The value at the last position in the source sequence. - public static T LastF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - return source[source.Length - 1]; - } - - /// - /// Returns the last element of a sequence that satisfies a specified condition. - /// - /// A sequence to return an element from. - /// A function to test each element for a condition. - /// - public static T LastF(this T[] source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var lastIndex = Array.FindLastIndex(source, predicate); - - if (lastIndex == -1) - throw Error.NoMatch(); - else - return source[lastIndex]; - } - - /// - /// Returns the last element of a sequence, or a default value if the sequence contains no elements. - /// - /// An sequence to return the last element of. - /// default value if the source sequence is empty; otherwise, - /// the last element in the sequence - public static T LastOrDefaultF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - return default(T); - } - return source[source.Length - 1]; - } - - /// - /// Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. - /// - /// A sequence to return the last element of. - /// A function to test each element for a condition. - /// default value if the sequence is empty or if no elements pass the test - /// in the predicate function; otherwise, the last element that passes the test in the - /// predicate function. - public static T LastOrDefaultF(this T[] source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var lastIndex = Array.FindLastIndex(source, predicate); - - if (lastIndex == -1) - return default(T); - else - return source[lastIndex]; - } - - // -------------------------- Lists -------------------------------------------- - - /// - /// Returns the last element of a sequence. - /// - /// An sequence to return the last element of. - /// The value at the last position in the source sequence. - public static T LastF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - return source[source.Count - 1]; - } - - /// - /// Returns the last element of a sequence that satisfies a specified condition. - /// - /// A sequence to return an element from. - /// A function to test each element for a condition. - /// - public static T LastF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var lastIndex = source.FindLastIndex(predicate); - - if (lastIndex == -1) - throw Error.NoMatch(); - else - return source[lastIndex]; - } - - /// - /// Returns the last element of a sequence, or a default value if the sequence contains no elements. - /// - /// An sequence to return the last element of. - /// default value if the source sequence is empty; otherwise, - /// the last element in the sequence - public static T LastOrDefaultF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - return default(T); - } - return source[source.Count - 1]; - } - - /// - /// Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. - /// - /// A sequence to return the last element of. - /// A function to test each element for a condition. - /// default value if the sequence is empty or if no elements pass the test - /// in the predicate function; otherwise, the last element that passes the test in the - /// predicate function. - public static T LastOrDefaultF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var lastIndex = source.FindLastIndex(predicate); - - if (lastIndex == -1) - return default(T); - else - return source[lastIndex]; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs.meta deleted file mode 100644 index 0b0e795b1..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Last.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: aaf88d2684a9a9145ae297d38036fc14 -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs deleted file mode 100644 index 4e208567b..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs +++ /dev/null @@ -1,779 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - //int, long, float,double, decimal - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static T MaxF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - T r = default(T); - if (r == null) - { - r = source[0]; - for (int i = 1; i < source.Length; i++) - { - if (source[i] != null && comparer.Compare(source[i], r) > 0) r = source[i]; - } - } - else - { - r = source[0]; - for (int i = 1; i < source.Length; i++) - { - if (comparer.Compare(source[i], r) > 0) r = source[i]; - } - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static TResult MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (selector == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - TResult r = default(TResult); - if (r == null) - { - r = selector(source[0]); - for (int i = 1; i < source.Length; i++) - { - var v = selector(source[i]); - if (v != null && comparer.Compare(v, r) > 0) r = v; - } - } - else - { - r = selector(source[0]); - for (int i = 1; i < source.Length; i++) - { - var v = selector(source[i]); - if (comparer.Compare(v, r) > 0) r = v; - } - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static int MaxF(this int[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - int r = int.MinValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static int MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int r = int.MinValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static long MaxF(this long[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - long r = long.MinValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static long MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long r = long.MinValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static float MaxF(this float[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - float r = source[0]; - int startIndex = 0; - for (; startIndex < source.Length; startIndex++) - { - if (!float.IsNaN(source[startIndex])) - { - r = source[startIndex]; - break; - } - } - for (int i = startIndex; i < source.Length; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static float MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - float r = selector(source[0]); - int startIndex = 0; - for (; startIndex < source.Length; startIndex++) - { - var v = selector(source[startIndex]); - if (!float.IsNaN(v)) - { - r = v; - break; - } - } - for (int i = startIndex; i < source.Length; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static double MaxF(this double[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - double r = source[0]; - int startIndex = 0; - for (; startIndex < source.Length; startIndex++) - { - if (!double.IsNaN(source[startIndex])) - { - r = source[startIndex]; - break; - } - } - for (int i = startIndex; i < source.Length; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static double MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double r = selector(source[0]); - int startIndex = 0; - for (; startIndex < source.Length; startIndex++) - { - var v = selector(source[startIndex]); - if (!double.IsNaN(v)) - { - r = v; - break; - } - } - for (int i = startIndex; i < source.Length; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static decimal MaxF(this decimal[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MinValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static decimal MaxF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - decimal r = decimal.MinValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static T MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - T r = default(T); - if (r == null) - { - r = source[0]; - for (int i = 1; i < source.Count; i++) - { - if (source[i] != null && comparer.Compare(source[i], r) > 0) r = source[i]; - } - } - else - { - r = source[0]; - for (int i = 1; i < source.Count; i++) - { - if (comparer.Compare(source[i], r) > 0) r = source[i]; - } - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static TResult MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - TResult r = default(TResult); - if (r == null) - { - r = selector(source[0]); - for (int i = 1; i < source.Count; i++) - { - var v = selector(source[i]); - if (v != null && comparer.Compare(v, r) > 0) r = v; - } - } - else - { - r = selector(source[0]); - for (int i = 1; i < source.Count; i++) - { - var v = selector(source[i]); - if (comparer.Compare(v, r) > 0) r = v; - } - } - return r; - } - - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static int MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - int r = int.MinValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static int MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int r = int.MinValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static long MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - long r = long.MinValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static long MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("source"); - } - long r = long.MinValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static float MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - float r = source[0]; - int startIndex = 0; - for (; startIndex < source.Count; startIndex++) - { - if (!float.IsNaN(source[startIndex])) - { - r = source[startIndex]; - break; - } - } - for (int i = startIndex; i < source.Count; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static float MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - float r = selector(source[0]); - int startIndex = 0; - for (; startIndex < source.Count; startIndex++) - { - var v = selector(source[startIndex]); - if (!float.IsNaN(v)) - { - r = v; - break; - } - } - for (int i = startIndex; i < source.Count; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static double MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - double r = source[0]; - int startIndex = 0; - for (; startIndex < source.Count; startIndex++) - { - if (!double.IsNaN(source[startIndex])) - { - r = source[startIndex]; - break; - } - } - for (int i = startIndex; i < source.Count; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static double MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - double r = selector(source[0]); - int startIndex = 0; - for (; startIndex < source.Count; startIndex++) - { - var v = selector(source[startIndex]); - if (!double.IsNaN(v)) - { - r = v; - break; - } - } - for (int i = startIndex; i < source.Count; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - /// - /// Returns the maximum value in a sequence of values. - /// - /// A sequence of values to determine the maximum of. - /// The maximum value in the sequence - public static decimal MaxF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MinValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] > r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static decimal MaxF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MinValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v > r) r = v; - } - return r; - } - - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs.meta deleted file mode 100644 index fd07caf68..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Max.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: c48e3dffd69eb0a4e8e135b38d3d9bf0 -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs deleted file mode 100644 index 6261bc93e..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs +++ /dev/null @@ -1,711 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - //int, long, float,double, decimal - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static T MinF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - T r = default(T); - if (r == null) - { - r = source[0]; - for (int i = 1; i < source.Length; i++) - { - if (source[i] != null && comparer.Compare(source[i], r) < 0) r = source[i]; - } - } - else - { - r = source[0]; - for (int i = 1; i < source.Length; i++) - { - if (comparer.Compare(source[i], r) < 0) r = source[i]; - } - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static TResult MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - TResult r = default(TResult); - if (r == null) - { - r = selector(source[0]); - for (int i = 1; i < source.Length; i++) - { - var v = selector(source[i]); - if (v != null && comparer.Compare(v, r) < 0) r = v; - } - } - else - { - r = selector(source[0]); - for (int i = 1; i < source.Length; i++) - { - var v = selector(source[i]); - if (comparer.Compare(v, r) < 0) r = v; - } - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static int MinF(this int[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - int r = int.MaxValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static int MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int r = int.MaxValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static long MinF(this long[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - long r = long.MaxValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static long MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long r = long.MaxValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static float MinF(this float[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - float r = float.MaxValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] < r) r = source[i]; - else if (float.IsNaN(source[i])) return source[i]; - - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static float MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - float r = float.MaxValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - else if (float.IsNaN(v)) return v; - - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static double MinF(this double[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - double r = double.MaxValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] < r) r = source[i]; - else if (double.IsNaN(source[i])) return source[i]; - } - - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static double MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - double r = double.MaxValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - else if (double.IsNaN(v)) return v; - - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static decimal MinF(this decimal[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MaxValue; - for (int i = 0; i < source.Length; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static decimal MinF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Length == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - decimal r = decimal.MaxValue; - for (int i = 0; i < source.Length; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static T MinF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - T r = default(T); - if (r == null) - { - r = source[0]; - for (int i = 1; i < source.Count; i++) - { - if (source[i] != null && comparer.Compare(source[i], r) < 0) r = source[i]; - } - } - else - { - r = source[0]; - for (int i = 1; i < source.Count; i++) - { - if (comparer.Compare(source[i], r) < 0) r = source[i]; - } - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static int MinF(this Listsource) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - int r = int.MaxValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static int MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int r = int.MaxValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static long MinF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - long r = long.MaxValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static long MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("source"); - } - long r = long.MaxValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static float MinF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - float r = float.MaxValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] < r) r = source[i]; - else if (float.IsNaN(source[i])) return source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static float MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - float r = float.MaxValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - else if (float.IsNaN(v)) return v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static double MinF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - double r = double.MaxValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] < r) r = source[i]; - else if (double.IsNaN(source[i])) return source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static double MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double r = double.MaxValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - else if (double.IsNaN(v)) return v; - } - return r; - } - - /// - /// Returns the minimum value in a sequence of values. - /// - /// A sequence of values to determine the minimum of. - /// The minimum value in the sequence - public static decimal MinF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MaxValue; - for (int i = 0; i < source.Count; i++) - { - if (source[i] < r) r = source[i]; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static decimal MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (source.Count == 0) - { - throw Error.NoElements(); - } - decimal r = decimal.MaxValue; - for (int i = 0; i < source.Count; i++) - { - var v = selector(source[i]); - if (v < r) r = v; - } - return r; - } - - /// - /// Invokes a transform function on each element of a sequence and returns the maximum value. - /// - /// A sequence of values to determine the maximum value of. - /// A transform function to apply to each element. - /// The maximum value in the transform of the sequence. - public static TResult MinF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - Comparer comparer = Comparer.Default; - TResult r = default(TResult); - if (r == null) - { - r = selector(source[0]); - for (int i = 1; i < source.Count; i++) - { - var v = selector(source[i]); - if (v != null && comparer.Compare(v, r) < 0) r = v; - } - } - else - { - r = selector(source[0]); - for (int i = 1; i < source.Count; i++) - { - var v = selector(source[i]); - if (comparer.Compare(v, r) < 0) r = v; - } - } - return r; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs.meta deleted file mode 100644 index 160ec1524..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Min.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e778ffbe0914c7c4e88564ff2ba27fff -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs deleted file mode 100644 index 80b344c64..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using JM.LinqFaster.Utils; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - /// - /// Sorts the elements of a sequence in ascending order according to a key. - /// Unlike standard Linq NOT a stable sort. - /// - /// A sequence of values to order. - /// A function to extract a key from an element. - /// A Comparer to compare keys. - /// A sequence whose alements are ordered according to a key - public static TSource[] OrderByF(this TSource[] source, Func keySelector,IComparer comparer = null) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (keySelector == null) - { - throw Error.ArgumentNull("keySelector"); - } - - if (comparer == null) - { - comparer = Comparer.Default; - } - - var keys = new TKey[source.Length]; - for (int i = 0; i < keys.Length; i++) - { - keys[i] = keySelector(source[i]); - } - var result = (TSource[])source.Clone(); - Array.Sort(keys,result,comparer); - return result; - } - - /// - /// Sorts the elements of a sequence in descending order according to a key. - /// Unlike standard Linq NOT a stable sort. - /// - /// A sequence of values to order. - /// A function to extract a key from an element. - /// A Comparer to compare keys. - /// A sequence whose alements are ordered according to a key - public static TSource[] OrderByDescendingF(this TSource[] source, Func keySelector, IComparer comparer = null) { - if (source == null) { - throw Error.ArgumentNull("source"); - } - - if (keySelector == null) { - throw Error.ArgumentNull("keySelector"); - } - - if (comparer == null) { - comparer = Comparer.Default; - } - - var keys = new TKey[source.Length]; - for (int i = 0; i < keys.Length; i++) { - keys[i] = keySelector(source[i]); - } - var result = (TSource[])source.Clone(); - Array.Sort(keys, result, comparer.Reverse()); - return result; - } - - - // ---------------------- Lists - - /// - /// Sorts the elements of a sequence in ascending order according to a key. - /// Unlike standard Linq NOT a stable sort. - /// - /// A sequence of values to order. - /// A function to extract a key from an element. - /// A Comparer to compare keys. - /// A sequence whose alements are ordered according to a key - public static List OrderByF(this List source, Func keySelector, IComparer comparer = null) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (keySelector == null) - { - throw Error.ArgumentNull("keySelector"); - } - - if (comparer == null) - { - comparer = Comparer.Default; - } - - var result = new List(source); - var lambdaComparer = new LambdaComparer(keySelector, comparer); - result.Sort(lambdaComparer); - return result; - } - - /// - /// Sorts the elements of a sequence in descending order according to a key. - /// Unlike standard Linq NOT a stable sort. - /// - /// A sequence of values to order. - /// A function to extract a key from an element. - /// A Comparer to compare keys. - /// A sequence whose alements are ordered according to a key - public static List OrderByDescendingF(this List source, Func keySelector, IComparer comparer = null) { - if (source == null) { - throw Error.ArgumentNull("source"); - } - - if (keySelector == null) { - throw Error.ArgumentNull("keySelector"); - } - - if (comparer == null) { - comparer = Comparer.Default; - } - - var result = new List(source); - var lambdaComparer = new ReverseLambdaComparer(keySelector, comparer); - result.Sort(lambdaComparer); - return result; - } - - - - } -} - - - - - - diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs.meta deleted file mode 100644 index 2635b634f..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/OrderBy.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 0905671e8837b8746ab9d2540689f16c -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs deleted file mode 100644 index 9599a3e3b..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - /// - /// Generates a sequence of integral numbers within a specified range. - /// - /// The value of the first integer in the sequence. - /// The number of sequential integers to generate. - /// A sequence that contains a range of sequential integral numbers. - public static int[] RangeArrayF(int start, int count) - { - long max = ((long)start) + count - 1; - if (count < 0 || max > int.MaxValue) - { - throw Error.ArgumentOutOfRange("count"); - } - - - int[] result = new int[count]; - for (int i = 0; i < result.Length; i++) - { - result[i] = i + start; - } - return result; - - } - - - /// - /// Generates a sequence of integral numbers within a specified range. - /// - /// The value of the first integer in the sequence. - /// The number of sequential integers to generate. - /// A sequence that contains a range of sequential integral numbers. - public static List RangeListF(int start, int count) - { - long max = ((long)start) + count - 1; - if (count < 0 || max > int.MaxValue) - { - throw Error.ArgumentOutOfRange("count"); - } - - - var result = new List(count); - for (int i = 0; i < count; i++) - { - result.Add(i + start); - } - return result; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs.meta deleted file mode 100644 index 5aa97552a..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 2b57c73286e4b784a897b514585dcdc2 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs deleted file mode 100644 index dee933986..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs +++ /dev/null @@ -1,46 +0,0 @@ - - -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // ------------------------ Arrays --------------------------- - - /// - /// Generates a sequence that contains one repeated value. - /// - /// The value to be repeated. - /// The number of times to repeat the value in the generated sequence. - /// A sequence that contains a repeated value - public static T[] RepeatArrayF(T element, int count) - { - var result = new T[count]; - for (int i = 0; i < result.Length; i++) - { - result[i] = element; - } - return result; - } - - // ------------------------ Lists --------------------------- - - /// - /// Generates a sequence that contains one repeated value. - /// - /// The value to be repeated. - /// The number of times to repeat the value in the generated sequence. - /// A sequence that contains a repeated value - public static List RepeatListF(T element, int count) - { - var result = new List(count); - for (int i = 0; i < count; i++) - { - result.Add(element); - } - return result; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs.meta deleted file mode 100644 index d89b50ca9..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: a9a067c2d04a41e499adfde8c8ab6956 -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs deleted file mode 100644 index 3b8b3fcc6..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - /// - /// Inverts the order of the elements in a sequence. - /// - /// A sequence of values to reverse. - /// A sequence whose elements correspond to those of the input sequence in reverse order. - public static T[] ReverseF(this T[] source) - { - var result = new T[source.Length]; - long lenLessOne = source.Length - 1; - for (int i = 0; i < result.Length; i++) - { - result[i] = source[lenLessOne - i]; - } - return result; - } - - - /// - /// Inverts the order of the elements in a sequence in place. - /// - /// A sequence of values to reverse. - public static void ReverseInPlaceF(this T[] source) - { - Array.Reverse(source); - } - - /// - /// Inverts the order of the elements in a sequence. - /// - /// A sequence of values to reverse. - /// A sequence whose elements correspond to those of the input sequence in reverse order. - public static List ReverseF(this List source) - { - var result = new List(source.Count); - for (int i = source.Count - 1; i >= 0; i--) - { - result.Add(source[i]); - } - return result; - } - - /// - /// Inverts the order of the elements in a sequence in place. - /// - /// A sequence of values to reverse. - public static void ReverseInPlaceF(this List source) - { - source.Reverse(); - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs.meta deleted file mode 100644 index 26f1c7810..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Reverse.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 060a1817dc4b6a14997095dfc23c4d3b -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs deleted file mode 100644 index 60178ed7d..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Projects each element of a sequence into a new form in place. - /// - /// A sequence of values to invoke a transform function on (map). - /// A transform function to apply (map) to each element. - public static void SelectInPlaceF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - for (int i = 0; i < source.Length; i++) - { - source[i] = selector(source[i]); - } - } - - /// - /// Projects each element of a sequence into a new form, in place, by incorporating the element's index. - /// - /// A sequence of values to invoke a transform function on. - /// A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - public static void SelectInPlaceF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - for (int i = 0; i < source.Length; i++) - { - source[i] = selector(source[i], i); - } - } - - - /// - /// Projects each element of a sequence into a new form. (map in every other language) - /// - /// A sequence of values to invoke a transform function on (map). - /// A transform function to apply (map) to each element. - /// A sequence whose elements are the result of invoking the transform function on each element (mapping) of source. - public static TResult[] SelectF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var r = new TResult[source.Length]; - for (int i = 0; i < source.Length; i++) - { - r[i] = selector(source[i]); - } - return r; - } - - - - /// - /// Projects each element of a sequence into a new form by incorporating the element's index. - /// - /// A sequence of values to invoke a transform function on. - /// A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - /// A sequence whose elements are the result of invoking the transform function on each element of source. - public static TResult[] SelectF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - var r = new TResult[source.Length]; - for (int i = 0; i < source.Length; i++) - { - r[i] = selector(source[i], i); - } - return r; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Projects each element of a sequence into a new form in place. - /// - /// A sequence of values to invoke a transform function on (map). - /// A transform function to apply (map) to each element. - public static void SelectInPlaceF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - for (int i = 0; i < source.Count; i++) - { - source[i] = selector(source[i]); - } - } - - /// - /// Projects each element of a sequence into a new form, in place, by incorporating the element's index. - /// - /// A sequence of values to invoke a transform function on. - /// A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - public static void SelectInPlaceF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - for (int i = 0; i < source.Count; i++) - { - source[i] = selector(source[i], i); - } - } - - - /// - /// Projects each element of a sequence into a new form. (map in every other language) - /// - /// A sequence of values to invoke a transform function on (map). - /// A transform function to apply (map) to each element. - /// A sequence whose elements are the result of invoking the transform function on each element (mapping) of source. - public static List SelectF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var r = new List(source.Count); - - for (int i = 0; i < source.Count; i++) - { - r.Add(selector(source[i])); - } - - return r; - } - - - /// - /// Projects each element of a sequence into a new form by incorporating the element's index. - /// - /// A sequence of values to invoke a transform function on. - /// A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - /// A sequence whose elements are the result of invoking the transform function on each element of source. - public static List SelectF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var r = new List(source.Count); - - for (int i = 0; i < source.Count; i++) - { - r.Add(selector(source[i],i)); - } - - return r; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs.meta deleted file mode 100644 index 16887d6bd..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Select.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 26eaf75f376ca7147a6c161177592aca -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs deleted file mode 100644 index 42fca8faf..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // -------------------------- Arrays -------------------------------------------- - - /// - /// Projects each element of a sequence to another sequence and flattens the resulting sequences into one sequence. - /// Yo dawg, I heard you like sequences. - /// - /// A sequence of values to project. - /// A transform function to apply to each element. - /// A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. - public static TResult[] SelectManyF(this TSource[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var result = new List(source.Length); - for (int i = 0; i < source.Length; i++) - { - var va = selector(source[i]); - for (int j = 0; j < va.Length; j++) - { - result.Add(va[j]); - } - } - return result.ToArray(); - } - - /// - /// Projects each element of a sequence to another sequence and flattens the resulting sequences into one sequence - /// utilizing the index of each element. - /// - /// A sequence of values to project. - /// A transform function to apply to each element and it's index. - /// A sequence whose elements are the result of invoking the one-to-many transform function on each element and index of the input sequence. - public static TResult[] SelectManyF(this TSource[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var result = new List(source.Length); - for (int i = 0; i < source.Length; i++) - { - var va = selector(source[i], i); - for (int j = 0; j < va.Length; j++) - { - result.Add(va[j]); - } - } - return result.ToArray(); - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Projects each element of a sequence to another sequence and flattens the resulting sequences into one sequence. - /// Yo dawg, I heard you like sequences. - /// - /// A sequence of values to project. - /// A transform function to apply to each element. - /// A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. - public static List SelectManyF(this List source, Func> selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var result = new List(source.Count); - for (int i = 0; i < source.Count; i++) - { - var va = selector(source[i]); - for (int j = 0; j < va.Count; j++) - { - result.Add(va[j]); - } - } - return result; - } - - /// - /// Projects each element of a sequence to another sequence and flattens the resulting sequences into one sequence - /// utilizing the index of each element. - /// - /// A sequence of values to project. - /// A transform function to apply to each element and it's index. - /// A sequence whose elements are the result of invoking the one-to-many transform function on each element and index of the input sequence. - public static List SelectManyF(this List source, Func> selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - var result = new List(source.Count); - for (int i = 0; i < source.Count; i++) - { - var va = selector(source[i], i); - for (int j = 0; j < va.Count; j++) - { - result.Add(va[j]); - } - } - return result; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs.meta deleted file mode 100644 index 5744f31fa..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectMany.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 8c94982c6c13eb2479b832d2210b5451 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs deleted file mode 100644 index fbcba9831..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Combines Select and Where into a single call for optimal - /// performance. - /// - /// The input sequence to filter and select - /// The transformation to apply before filtering. - /// The predicate with which to filter result. - /// A seqence transformed and then filtered by selector and predicate. - public static TResult[] SelectWhereF(this T[] source, Func selector, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new TResult[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - var s = selector(source[i]); - if (predicate(s)) - { - result[idx] = s; - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - /// - /// Combines Select and Where with indexes into a single call for optimal - /// performance. - /// - /// The input sequence to filter and select - /// The transformation with index to apply before filtering. - /// The predicate with index with which to filter result. - /// A seqence transformed and then filtered by selector and predicate with indexes. - public static TResult[] SelectWhereF(this T[] source, Func selector, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new TResult[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - var s = selector(source[i], i); - if (predicate(s, i)) - { - result[idx] = s; - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Combines Select and Where into a single call for optimal - /// performance. - /// - /// The input sequence to filter and select - /// The transformation to apply before filtering. - /// The predicate with which to filter result. - /// A seqence transformed and then filtered by selector and predicate. - public static List SelectWhereF(this List source, Func selector, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var r = new List(); - for (int i = 0; i < source.Count; i++) - { - var s = selector(source[i]); - if (predicate(s)) r.Add(s); - } - return r; - } - - /// - /// Combines Select and Where with indexes into a single call for optimal - /// performance. - /// - /// The input sequence to filter and select - /// The transformation with index to apply before filtering. - /// The predicate with index with which to filter result. - /// A seqence transformed and then filtered by selector and predicate with indexes. - public static List SelectWhereF(this List source, Func selector, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var r = new List(); - for (int i = 0; i < source.Count; i++) - { - var s = selector(source[i], i); - if (predicate(s, i)) r.Add(s); - } - return r; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs.meta deleted file mode 100644 index f87fe3a7f..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SelectWhere.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: d0a9e823f84f85049ae653bf4fc8c7b9 -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs deleted file mode 100644 index 1c86a5ac6..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - - public static partial class LinqFaster - { - - /// - /// Determines whether two sequences are equal by comparing the elements by using the - /// provided comparer or the default equality comparer for their type if none is provided. - /// - /// A sequence to compare to second. - /// A sequence to compare to first. - /// An optional Comparer to use for the comparison. - /// true of the two sources are of equal length and their corresponding - /// elements are equal according to the equality comparer. Otherwise, false. - public static bool SequenceEqualF(T[] first, T[] second, IEqualityComparer comparer = null) - { - if (comparer == null) - { - comparer = EqualityComparer.Default; - } - - if (first == null) - { - throw Error.ArgumentNull("first"); - } - - if (second == null) - { - throw Error.ArgumentNull("second"); - } - - if (first.Length != second.Length) return false; - - for (int i = 0; i < first.Length; i++) - { - if (!comparer.Equals(first[i], second[i])) return false; - } - - return true; - } - - /// - /// Determines whether two sequences are equal by comparing the elements by using the - /// provided comparer or the default equality comparer for their type if none is provided. - /// - /// A sequence to compare to second. - /// A sequence to compare to first. - /// An optional Comparer to use for the comparison. - /// true of the two sources are of equal length and their corresponding - /// elements are equal according to the equality comparer. Otherwise, false. - public static bool SequenceEqualF(List first, List second, IEqualityComparer comparer = null) - { - if (comparer == null) - { - comparer = EqualityComparer.Default; - } - - if (first == null) - { - throw Error.ArgumentNull("first"); - } - - if (second == null) - { - throw Error.ArgumentNull("second"); - } - - if (first.Count != second.Count) return false; - - for (int i = 0; i < first.Count; i++) - { - if (!comparer.Equals(first[i], second[i])) return false; - } - - return true; - } - - /// - /// Determines whether two sequences are equal by comparing the elements by using the - /// provided comparer or the default equality comparer for their type if none is provided. - /// - /// A sequence to compare to second. - /// A sequence to compare to first. - /// An optional Comparer to use for the comparison. - /// true of the two sources are of equal length and their corresponding - /// elements are equal according to the equality comparer. Otherwise, false. - public static bool SequenceEqualF(T[] first, List second, IEqualityComparer comparer = null) - { - if (comparer == null) - { - comparer = EqualityComparer.Default; - } - - if (first == null) - { - throw Error.ArgumentNull("first"); - } - - if (second == null) - { - throw Error.ArgumentNull("second"); - } - - if (first.Length != second.Count) return false; - - for (int i = 0; i < first.Length; i++) - { - if (!comparer.Equals(first[i], second[i])) return false; - } - - return true; - } - - /// - /// Determines whether two sequences are equal by comparing the elements by using the - /// provided comparer or the default equality comparer for their type if none is provided. - /// - /// A sequence to compare to second. - /// A sequence to compare to first. - /// An optional Comparer to use for the comparison. - /// true of the two sources are of equal length and their corresponding - /// elements are equal according to the equality comparer. Otherwise, false. - public static bool SequenceEqualF(List first, T[] second, IEqualityComparer comparer = null) - { - if (comparer == null) - { - comparer = EqualityComparer.Default; - } - - if (first == null) - { - throw Error.ArgumentNull("first"); - } - - if (second == null) - { - throw Error.ArgumentNull("second"); - } - - if (first.Count != second.Length) return false; - - for (int i = 0; i < first.Count; i++) - { - if (!comparer.Equals(first[i], second[i])) return false; - } - - return true; - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs.meta deleted file mode 100644 index 0caa2acfc..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/SequenceEqual.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 7fe4476c042c98d4dbae1292ea8da673 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs deleted file mode 100644 index 35f61f441..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs +++ /dev/null @@ -1,275 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // --------------------------- Arrays ---------------------------- - - /// - /// Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. - /// - /// A sequence to return the single element of - /// The single element of the input sequence or default if no elements exist. - public static T SingleF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - throw Error.NoElements(); - } - - if (source.Length > 1) { - throw Error.MoreThanOneElement(); - } - - return source[0]; - } - - /// - /// Returns the only element of a sequence, or the default if no elements exist, and throws an exception if there is not exactly one element in the sequence. - /// - /// A sequence to return the single element of - /// The single element of the input sequence - public static T SingleOrDefaultF(this T[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Length == 0) - { - return default(T); - } - - if (source.Length > 1) { - throw Error.MoreThanOneElement(); - } - - return source[0]; - } - - /// - /// Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. - /// - /// A sequence to return a single element from. - /// A function to test an element for a condition. - /// The single element of the input sequence that satisfies a condition. - public static T SingleF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - T result = default(T); - bool foundMatch = false; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - if (foundMatch) - { - throw Error.MoreThanOneMatch(); - } - - result = source[i]; - foundMatch = true; - } - } - - if (foundMatch) - { - return result; - } - else - { - throw Error.NoMatch(); - } - } - - /// - /// Returns the only element of a sequence that satisfies a specified condition, or a default value if - /// no such element exists, and throws an exception if more than one such element exists. - /// - /// A sequence to return a single element from. - /// A function to test an element for a condition. - /// The single element of the input sequence that satisfies a condition or default value if no such element is found. - public static T SingleOrDefaultF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - - T result = default(T); - bool foundMatch = false; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - if (foundMatch) - { - throw Error.MoreThanOneMatch(); - } - - result = source[i]; - foundMatch = true; - } - } - - return result; - } - - - // --------------------------- Lists ---------------------------- - - /// - /// Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. - /// - /// A sequence to return the single element of - /// The single element of the input sequence - public static T SingleF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - throw Error.NoElements(); - } - - if (source.Count > 1) { - throw Error.MoreThanOneElement(); - } - - return source[0]; - } - - /// - /// Returns the only element of a sequence, or default if no elements exist, and throws an exception if there is not exactly one element in the sequence. - /// - /// A sequence to return the single element of - /// The single element of the input sequence or default if no elements exist. - public static T SingleOrDefaultF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (source.Count == 0) - { - return default(T); - } - - if (source.Count > 1) { - throw Error.MoreThanOneElement(); - } - - return source[0]; - } - - /// - /// Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. - /// - /// A sequence to return a single element from. - /// A function to test an element for a condition. - /// The single element of the input sequence that satisfies a condition. - public static T SingleF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - T result = default(T); - bool foundMatch = false; - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i])) - { - if (foundMatch) - { - throw Error.MoreThanOneMatch(); - } - - result = source[i]; - foundMatch = true; - } - } - - if (foundMatch) - { - return result; - } - else - { - throw Error.NoMatch(); - } - } - - /// - /// Returns the only element of a sequence that satisfies a specified condition, or a default value if - /// no such element exists, and throws an exception if more than one such element exists. - /// - /// A sequence to return a single element from. - /// A function to test an element for a condition. - /// The single element of the input sequence that satisfies a condition or default value if no such element is found. - public static T SingleOrDefaultF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - T result = default(T); - bool foundMatch = false; - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i])) - { - if (foundMatch) - { - throw Error.MoreThanOneMatch(); - } - - result = source[i]; - foundMatch = true; - } - } - - return result; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs.meta deleted file mode 100644 index 377aaffdc..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Single.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 50d60901bb3bf014e8d8e1ceef8c4741 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs deleted file mode 100644 index c63322cc0..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - /// - /// Bypasses a specified number of elements in a sequence and then returns the remaining elements. - /// - /// A sequence to return elements from. - /// The number of elements to skip before returning the remaining elements. - /// A sequence that contains the elements that occur after the specified index in the input sequence. - public static T[] SkipF(this T[] source, int count) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (count < 0) - { - count = 0; - } - else if (count > source.Length) - { - return new T[0]; - } - - var result = new T[source.Length - count]; - Array.Copy(source, count, result, 0, result.Length); - return result; - } - - /// - /// Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. - /// - /// A sequence to return elements from. - /// A function to test each element for a condition. - /// A sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. - public static T[] SkipWhileF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - int i = 0; - for (; i < source.Length; i++) - { - if (!predicate(source[i])) break; - } - var result = new T[source.Length - i]; - Array.Copy(source, i, result, 0, result.Length); - return result; - } - - - - // ------------- Lists ---------------- - - /// - /// Bypasses a specified number of elements in a sequence and then returns the remaining elements. - /// - /// A sequence to return elements from. - /// The number of elements to skip before returning the remaining elements. - /// A sequence that contains the elements that occur after the specified index in the input sequence. - public static List SkipF(this List source, int count) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (count < 0) - { - count = 0; - } - else if (count > source.Count) - { - return new List(); - } - - var result = new List(source.Count - count); - for (int i = count; i < source.Count; i++) - { - result.Add(source[i]); - } - return result; - } - - /// - /// Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. - /// - /// A sequence to return elements from. - /// A function to test each element for a condition. - /// A sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. - public static List SkipWhileF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - int i = 0; - for (; i < source.Count; i++) - { - if (!predicate(source[i])) { - break; - } - } - - var result = new List(source.Count - i); - for (; i < source.Count; i++) - { - result.Add(source[i]); - } - return result; - } - - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs.meta deleted file mode 100644 index eee1c658d..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Skip.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 0266806ba237aed45b52c7709de1fe6b -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs deleted file mode 100644 index f184936f4..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs +++ /dev/null @@ -1,504 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static int SumF(this int[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - int sum = 0; - checked - { - foreach (var v in source) - { - sum += v; - } - } - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static int SumF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int sum = 0; - checked - { - foreach (var v in source) - { - sum += selector(v); - } - } - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static long SumF(this long[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - long sum = 0; - checked - { - foreach (var v in source) - { - sum += v; - } - } - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static long SumF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - foreach (var v in source) - { - sum += selector(v); - } - } - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static float SumF(this float[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - - foreach (var v in source) - { - sum += v; - } - - return (float)sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static float SumF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - foreach (var v in source) - { - sum += selector(v); - } - - return (float)sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static double SumF(this double[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - foreach (var v in source) - { - sum += v; - } - - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static double SumF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - foreach (var v in source) - { - sum += selector(v); - } - - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static decimal SumF(this decimal[] source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - decimal sum = 0; - - foreach (var v in source) - { - sum += v; - } - - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static decimal SumF(this T[] source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - decimal sum = 0; - foreach (var v in source) - { - sum += selector(v); - } - - return sum; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static int SumF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - int sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - } - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static int SumF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - } - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static long SumF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - } - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static long SumF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - } - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static float SumF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return (float)sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static float SumF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return (float)sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static double SumF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static double SumF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return sum; - } - - /// - /// Adds a sequence of values. - /// - /// The sequence to add. - /// The sum of the sequence. - public static decimal SumF(this List source) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - decimal sum = 0; - - for (int i = 0; i < source.Count; i++) - { - sum += source[i]; - } - - return sum; - } - - /// - /// Adds the transformed sequence of elements. - /// - /// The sequence of values to transform then sum. - /// A transformation function. - /// The sum of the transformed elements. - public static decimal SumF(this List source, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - decimal sum = 0; - for (int i = 0; i < source.Count; i++) - { - sum += selector(source[i]); - } - - return sum; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs.meta deleted file mode 100644 index 0431e0e47..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Sum.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: c45ad2500ea1ddd46af3645fba2bfc4c -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs deleted file mode 100644 index bc412795e..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs +++ /dev/null @@ -1,188 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - /// - /// Returns a specified number of contiguous elements from the start of a sequence. - /// - /// The sequence to return elements from. - /// The number of elements to return. - /// A sequence that contains the specified number of elements from the start of the input sequence. - public static T[] TakeF(this T[] source, int count) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (count < 0) - { - count = 0; - } - else if (count > source.Length) - { - count = source.Length; - } - - var result = new T[count]; - Array.Copy(source, 0, result, 0, count); - return result; - } - - /// - /// Returns elements from a sequence as long as a specified condition is true. - /// - /// A sequence to return elements from. - /// A function to test each element for a condition. - /// A sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. - public static T[] TakeWhileF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new List(); - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - result.Add(source[i]); - else - return result.ToArray(); - } - return result.ToArray(); - } - - /// - /// Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function. - /// - /// The sequence to return elements from. - /// A function to test each source element for a condition; the second parameter of the function represents the index of the source element. - /// A sequence that contains elements from the input sequence that occur before the element at which the test no longer passes. - public static T[] TakeWhileF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new List(); - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i],i)) - result.Add(source[i]); - else - return result.ToArray(); - } - return result.ToArray(); - } - - - - // ------------- Lists ---------------- - - /// - /// Returns a specified number of contiguous elements from the start of a sequence. - /// - /// The sequence to return elements from. - /// The number of elements to return. - /// A sequence that contains the specified number of elements from the start of the input sequence. - public static List TakeF(this List source, int count) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (count < 0) - { - count = 0; - } - else if (count > source.Count) - { - count = source.Count; - } - - var result = new List(count); - for (int i = 0; i < count; i++) - { - result.Add(source[i]); - } - return result; - } - - /// - /// Returns elements from a sequence as long as a specified condition is true. - /// - /// A sequence to return elements from. - /// A function to test each element for a condition. - /// A sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. - public static List TakeWhileF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new List(); - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i])) - { - result.Add(source[i]); - } - else - { - return result; - } - } - - return result; - } - - /// - /// Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function. - /// - /// The sequence to return elements from. - /// A function to test each source element for a condition; the second parameter of the function represents the index of the source element. - /// A sequence that contains elements from the input sequence that occur before the element at which the test no longer passes. - public static List TakeWhileF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new List(); - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i], i)) - result.Add(source[i]); - else - return result; - } - return result; - } - - - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs.meta deleted file mode 100644 index c813c015a..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Take.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: f9aaaef92e9c332418190038d49b4389 -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils.meta deleted file mode 100644 index 3f90fa564..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: d27acc7ea045f65488b96d108768512f -folderAsset: yes -timeCreated: 1518622476 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs deleted file mode 100644 index 6e292a76d..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace JM.LinqFaster.Utils { - - //Takes a comparer, and creates a reverse comparer, for Descending sorts - internal sealed class ComparerReverser : IComparer { - private readonly IComparer wrappedComparer; - - public ComparerReverser(IComparer wrappedComparer) { - this.wrappedComparer = wrappedComparer; - } -#if !(UNITY_4 || UNITY_5) - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - public int Compare(T x, T y) { - return wrappedComparer.Compare(y, x); - } - } - - - internal static class ComparerExtensions { - - // Lets us reverse a comparere with comparer.Reverse(); - public static IComparer Reverse(this IComparer comparer) { - return new ComparerReverser(comparer); - } - } - - internal sealed class LambdaComparer : IComparer { - IComparer comparer; - Func selector; - - public LambdaComparer(Func selector, IComparer comparer) { - this.comparer = comparer; - this.selector = selector; - } -#if !(UNITY_4 || UNITY_5) - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - public int Compare(T x, T y) { - return comparer.Compare(selector(x), selector(y)); - } - } - - internal sealed class ReverseLambdaComparer : IComparer { - IComparer comparer; - Func selector; - - public ReverseLambdaComparer(Func selector, IComparer comparer) { - this.comparer = comparer; - this.selector = selector; - } -#if !(UNITY_4 || UNITY_5) - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - public int Compare(T x, T y) { - return comparer.Compare(selector(y), selector(x)); - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs.meta deleted file mode 100644 index 14c655949..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/ComparerMagic.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 58968b2b3f2b61943a1723873cdb7288 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs deleted file mode 100644 index a6eaddbeb..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if !(UNITY_4 || UNITY_5) -using System; -using System.Collections.Concurrent; - - -namespace JM.LinqFaster.Utils -{ - internal static class CustomPartition - { - public static OrderablePartitioner> MakePartition(int len, int? batchSize) - { - if (batchSize == null) - { - return Partitioner.Create(0, len); - } - else - { - return Partitioner.Create(0, len, batchSize.Value); - } - } - - public static OrderablePartitioner> MakeSIMDPartition(int len, int chunkSize, int? batchSize) - { - int chunkLen = len - len % chunkSize; - int numChunks = chunkLen / chunkSize; - if (batchSize == null) - { - return Partitioner.Create(0, numChunks,numChunks/Environment.ProcessorCount); - } - else - { - return Partitioner.Create(0, numChunks, batchSize.Value); - } - } - - } -} -#endif \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs.meta deleted file mode 100644 index ecb57cd06..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/CustomPartition.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 117a499c9c8ce1a47a30c4cb3de95a14 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs deleted file mode 100644 index 8955bd469..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -internal static class Error -{ - internal static Exception ArgumentNull(string s) { return new ArgumentNullException(s); } - - internal static Exception ArgumentOutOfRange(string s) { return new ArgumentOutOfRangeException(s); } - - internal static Exception MoreThanOneElement() { return new InvalidOperationException("Sequence contains more than one element"); } - - internal static Exception MoreThanOneMatch() { return new InvalidOperationException("Sequence contains more than one matching element"); } - - internal static Exception NoElements() { return new InvalidOperationException("Sequence contains no elements"); } - - internal static Exception NoMatch() { return new InvalidOperationException("Sequence contains no matching element"); } - - internal static Exception NotSupported() { return new NotSupportedException(); } -} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs.meta deleted file mode 100644 index 4918b5629..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/Error.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 2f77eee1e24f34f438756aca3d8506d9 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs deleted file mode 100644 index 8bfbe88af..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs +++ /dev/null @@ -1,323 +0,0 @@ -#if !(UNITY_4 || UNITY_5) - -using System; -using System.Runtime.CompilerServices; - -/* - - C# has no way to constrain a generic to only primitive types. - You can only constrain them to value types via: - where T : struct - All primitives are value types but not all value types are - primitives. Thus, when you try to do operations like + > < == - on generic value types, you get a compiler error. These methods - work around that by checking the type, casting, and performing the - operation. The JIT elides all of the non relevant bits of the If statement - for each generic type, so this is remarkably still fast. Since these are - only used for the SIMD specific operations, and the SIMD library - works exactly this way as well, it does not add any problems that - don't already exist when you use .NET SIMD. Which is, if you create a - Vector where T is a non primitive value type, you will get a runtime error. - */ -namespace JM.LinqFaster.Utils -{ - internal static class GenericOperators - { - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T Add(T a, T b) - { - if (typeof(T) == typeof(Byte)) - { - return (T)(object)((Byte)(object)a + (Byte)(object)b); - } - else if (typeof(T) == typeof(SByte)) - { - return (T)(object)((SByte)(object)a + (SByte)(object)b); - } - else if (typeof(T) == typeof(UInt16)) - { - return (T)(object)((UInt16)(object)a + (UInt16)(object)b); - } - else if (typeof(T) == typeof(Int16)) - { - return (T)(object)((Int16)(object)a + (Int16)(object)b); - } - else if (typeof(T) == typeof(UInt32)) - { - return (T)(object)((UInt32)(object)a + (UInt32)(object)b); - } - else if (typeof(T) == typeof(Int32)) - { - return (T)(object)((Int32)(object)a + (Int32)(object)b); - } - else if (typeof(T) == typeof(UInt64)) - { - return (T)(object)((UInt64)(object)a + (UInt64)(object)b); - } - else if (typeof(T) == typeof(Int64)) - { - return (T)(object)((Int64)(object)a + (Int64)(object)b); - } - else if (typeof(T) == typeof(Single)) - { - return (T)(object)((Single)(object)a + (Single)(object)b); - } - else if (typeof(T) == typeof(Double)) - { - return (T)(object)((Double)(object)a + (Double)(object)b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool GreaterThan(T a, T b) - { - if (typeof(T) == typeof(Byte)) - { - return ((Byte)(object)a > (Byte)(object)b); - } - else if (typeof(T) == typeof(SByte)) - { - return ((SByte)(object)a > (SByte)(object)b); - } - else if (typeof(T) == typeof(UInt16)) - { - return ((UInt16)(object)a > (UInt16)(object)b); - } - else if (typeof(T) == typeof(Int16)) - { - return ((Int16)(object)a > (Int16)(object)b); - } - else if (typeof(T) == typeof(UInt32)) - { - return ((UInt32)(object)a > (UInt32)(object)b); - } - else if (typeof(T) == typeof(Int32)) - { - return ((Int32)(object)a > (Int32)(object)b); - } - else if (typeof(T) == typeof(UInt64)) - { - return ((UInt64)(object)a > (UInt64)(object)b); - } - else if (typeof(T) == typeof(Int64)) - { - return ((Int64)(object)a > (Int64)(object)b); - } - else if (typeof(T) == typeof(Single)) - { - return ((Single)(object)a > (Single)(object)b); - } - else if (typeof(T) == typeof(Double)) - { - return ((Double)(object)a > (Double)(object)b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool Equals(T a, T b) - { - if (typeof(T) == typeof(Byte)) - { - return ((Byte)(object)a == (Byte)(object)b); - } - else if (typeof(T) == typeof(SByte)) - { - return ((SByte)(object)a == (SByte)(object)b); - } - else if (typeof(T) == typeof(UInt16)) - { - return ((UInt16)(object)a == (UInt16)(object)b); - } - else if (typeof(T) == typeof(Int16)) - { - return ((Int16)(object)a == (Int16)(object)b); - } - else if (typeof(T) == typeof(UInt32)) - { - return ((UInt32)(object)a == (UInt32)(object)b); - } - else if (typeof(T) == typeof(Int32)) - { - return ((Int32)(object)a == (Int32)(object)b); - } - else if (typeof(T) == typeof(UInt64)) - { - return ((UInt64)(object)a == (UInt64)(object)b); - } - else if (typeof(T) == typeof(Int64)) - { - return ((Int64)(object)a == (Int64)(object)b); - } - else if (typeof(T) == typeof(Single)) - { - return ((Single)(object)a == (Single)(object)b); - } - else if (typeof(T) == typeof(Double)) - { - return ((Double)(object)a == (Double)(object)b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool LessThan(T a, T b) - { - if (typeof(T) == typeof(Byte)) - { - return ((Byte)(object)a < (Byte)(object)b); - } - else if (typeof(T) == typeof(SByte)) - { - return ((SByte)(object)a < (SByte)(object)b); - } - else if (typeof(T) == typeof(UInt16)) - { - return ((UInt16)(object)a < (UInt16)(object)b); - } - else if (typeof(T) == typeof(Int16)) - { - return ((Int16)(object)a < (Int16)(object)b); - } - else if (typeof(T) == typeof(UInt32)) - { - return ((UInt32)(object)a < (UInt32)(object)b); - } - else if (typeof(T) == typeof(Int32)) - { - return ((Int32)(object)a < (Int32)(object)b); - } - else if (typeof(T) == typeof(UInt64)) - { - return ((UInt64)(object)a < (UInt64)(object)b); - } - else if (typeof(T) == typeof(Int64)) - { - return ((Int64)(object)a < (Int64)(object)b); - } - else if (typeof(T) == typeof(Single)) - { - return ((Single)(object)a < (Single)(object)b); - } - else if (typeof(T) == typeof(Double)) - { - return ((Double)(object)a < (Double)(object)b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Divide(T a, double b) - { - if (typeof(T) == typeof(Byte)) - { - return (double)(object)((Byte)(object)a /b) ; - } - else if (typeof(T) == typeof(SByte)) - { - return (double)(object)((SByte)(object)a /b); - } - else if (typeof(T) == typeof(UInt16)) - { - return (double)(object)((UInt16)(object)a / b); - } - else if (typeof(T) == typeof(Int16)) - { - return (double)(object)((Int16)(object)a / b); - } - else if (typeof(T) == typeof(UInt32)) - { - return (double)(object)((UInt32)(object)a / b); - } - else if (typeof(T) == typeof(Int32)) - { - return (double)(object)((Int32)(object)a /b); - } - else if (typeof(T) == typeof(UInt64)) - { - return (double)(object)((UInt64)(object)a / b); - } - else if (typeof(T) == typeof(Int64)) - { - return (double)(object)((Int64)(object)a /b); - } - else if (typeof(T) == typeof(Single)) - { - return (double)(object)((Single)(object)a /b); - } - else if (typeof(T) == typeof(Double)) - { - return (double)(object)((Double)(object)a / b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DivideFloat(T a, float b) - { - if (typeof(T) == typeof(Byte)) - { - return (float)(object)((Byte)(object)a / b); - } - else if (typeof(T) == typeof(SByte)) - { - return (float)(object)((SByte)(object)a / b); - } - else if (typeof(T) == typeof(UInt16)) - { - return (float)(object)((UInt16)(object)a / b); - } - else if (typeof(T) == typeof(Int16)) - { - return (float)(object)((Int16)(object)a / b); - } - else if (typeof(T) == typeof(UInt32)) - { - return (float)(object)((UInt32)(object)a / b); - } - else if (typeof(T) == typeof(Int32)) - { - return (float)(object)((Int32)(object)a / b); - } - else if (typeof(T) == typeof(UInt64)) - { - return (float)(object)((UInt64)(object)a / b); - } - else if (typeof(T) == typeof(Int64)) - { - return (float)(object)((Int64)(object)a / b); - } - else if (typeof(T) == typeof(Single)) - { - return (float)(object)((Single)(object)a / b); - } - else if (typeof(T) == typeof(Double)) - { - return (float)(object)((Double)(object)a / b); - } - else - { - throw new NotSupportedException("Nope"); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs.meta deleted file mode 100644 index e95da6b0e..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Utils/GenericOperators.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: c55248b8089617346a6a1b22dc43009f -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs deleted file mode 100644 index 7ceac11d3..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Filters a sequence of values based on a predicate. - /// - /// A sequence to filter. - /// A function to test each element for a condition. - /// A sequence that contains elements from the input sequence that satisfy the condition. - public static T[] WhereF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - T[] result = new T[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - result[idx] = source[i]; - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - /// - /// Filters a sequence of values based on a predicate that includes the index in it's logic. - /// - /// A sequence to filter. - /// A function to test each element for a condition along with the element's index. - /// A sequence that contains elements from the input sequence that satisfy the condition. - public static T[] WhereF(this T[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - - T[] result = new T[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i], i)) - { - result[idx] = source[i]; - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Filters a sequence of values based on a predicate. - /// - /// A sequence to filter. - /// A function to test each element for a condition. - /// A sequence that contains elements from the input sequence that satisfy the condition. - public static List WhereF(this List source, Predicate predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - return source.FindAll(predicate); - } - - - /// - /// Filters a sequence of values based on a predicate that includes the index in it's logic. - /// - /// A sequence to filter. - /// A function to test each element for a condition along with the element's index. - /// A sequence that contains elements from the input sequence that satisfy the condition. - public static List WhereF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - List r = new List(); - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i], i)) r.Add(source[i]); - } - return r; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs.meta deleted file mode 100644 index 33e02fd2b..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Where.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 089655aa3554c044c827c1c259eb1e00 -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs deleted file mode 100644 index ded7a4a60..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs +++ /dev/null @@ -1,335 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - - public static partial class LinqFaster - { - // ----------------------------- Arrays ------------------ - - /// - /// Combines Where and Aggregate for optimal performance - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static T WhereAggregateF(this T[] source, Func predicate, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - var result = default(T); - - int i = 0; - for (; i < source.Length; i++) - { - if (predicate(source[i])) - { - result = source[i]; - i++; - break; - } - } - for (; i < source.Length; i++) - { - if (predicate(source[i])) - { - result = func(result, source[i]); - } - } - return result; - } - - /// - /// Combines Where and Aggregate with index for optimal performance - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence and it's index with. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static T WhereAggregateF(this T[] source, Func predicate, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = default(T); - - int i = 0; - for (; i < source.Length; i++) - { - if (predicate(source[i], i)) - { - result = source[i]; - i++; - break; - } - } - for (; i < source.Length; i++) - { - if (predicate(source[i], i)) - { - result = func(result, source[i]); - } - } - return result; - } - - /// - /// Combines Where and Aggregate for optimal performance with a starting seed. - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The initial value to aggregate on. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static TAccumulate WhereAggregateF(this TSource[] source, Func predicate, TAccumulate seed, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - TAccumulate result = seed; - foreach (var v in source) - { - if (predicate(v)) - result = func(result, v); - } - return result; - } - - /// - /// Combines Where and Aggregate for optimal performance with a starting seed and a result transformation. - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The initial value to aggregate on. - /// The function to aggregate the filtered seqeuence. - /// A function to transform the final result. - /// The filtered then aggregated then transformed sequence. - public static TResult WhereAggregateF(this TSource[] source, Func predicate, TAccumulate seed, Func func, Func resultSelector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (resultSelector == null) - { - throw Error.ArgumentNull("resultSelector"); - } - - TAccumulate result = seed; - int count = 0; - foreach (var v in source) - { - if (predicate(v)) { - result = func(result, v); - count++; - } - } - return resultSelector(result); - } - - - // --------------------------- Lists ------------------------- - - /// - /// Combines Where and Aggregate for optimal performance - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static T WhereAggregateF(this List source, Func predicate, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - var result = default(T); - - int i = 0; - for (; i < source.Count; i++) - { - if (predicate(source[i])) - { - result = source[i]; - i++; - break; - } - } - for (; i < source.Count; i++) - { - if (predicate(source[i])) - { - result = func(result, source[i]); - } - } - return result; - } - - /// - /// Combines Where and Aggregate with index for optimal performance - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence and it's index with. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static T WhereAggregateF(this List source, Func predicate, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = default(T); - - int i = 0; - for (; i < source.Count; i++) - { - if (predicate(source[i], i)) - { - result = source[i]; - i++; - break; - } - } - for (; i < source.Count; i++) - { - if (predicate(source[i], i)) - { - result = func(result, source[i]); - } - } - return result; - } - - /// - /// Combines Where and Aggregate for optimal performance with a starting seed. - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The initial value to aggregate on. - /// The function to aggregate the filtered seqeuence. - /// The filtered then aggregated sequence. - public static TAccumulate WhereAggregateF(this List source, Func predicate, TAccumulate seed, Func func) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - TAccumulate result = seed; - for (int i = 0; i < source.Count; i++) - { - var v = source[i]; - if (predicate(v)) - result = func(result, v); - } - return result; - } - - /// - /// Combines Where and Aggregate for optimal performance with a starting seed and a result transformation. - /// - /// The input to filter then aggregate. - /// The function to filter the input sequence with. - /// The initial value to aggregate on. - /// The function to aggregate the filtered seqeuence. - /// A function to transform the final result. - /// The filtered then aggregated then transformed sequence. - public static TResult WhereAggregateF(this List source, Func predicate, TAccumulate seed, Func func, Func resultSelector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (func == null) - { - throw Error.ArgumentNull("func"); - } - - if (resultSelector == null) - { - throw Error.ArgumentNull("resultSelector"); - } - - TAccumulate result = seed; - for (int i = 0; i < source.Count; i++) - { - var v = source[i]; - if (predicate(v)) - result = func(result, v); - } - return resultSelector(result); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs.meta deleted file mode 100644 index 691c8274c..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereAggregate.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: ba74d3462bb50a647b34d3988b598cda -timeCreated: 1518622477 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs deleted file mode 100644 index 065ce75bf..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - - /// - /// Combined Where and Select for optimal performance. - /// - /// The input sequence to filter then transform. - /// A function to use to filter the sequence. - /// A function to transform the filtered elements. - /// A sequence of filtered and transformed elements. - public static TResult[] WhereSelectF(this T[] source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (selector == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new TResult[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i])) - { - result[idx] = selector(source[i]); - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - /// - /// Combined Where and Select for optimal performance that uses the index in the - /// predicate and selector. - /// - /// The input sequence to filter then transform. - /// A function to use to filter the sequence. - /// A function to transform the filtered elements. - /// A sequence of filtered and transformed elements. - public static TResult[] WhereSelectF(this T[] source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (selector == null) - { - throw Error.ArgumentNull("predicate"); - } - - var result = new TResult[source.Length]; - int idx = 0; - for (int i = 0; i < source.Length; i++) - { - if (predicate(source[i], i)) - { - result[idx] = selector(source[i], idx); - idx++; - } - } - Array.Resize(ref result, idx); - return result; - } - - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Combined Where and Select for optimal performance. - /// - /// The input sequence to filter then transform. - /// A function to use to filter the sequence. - /// A function to transform the filtered elements. - /// A sequence of filtered and transformed elements. - public static List WhereSelectF(this List source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (selector == null) - { - throw Error.ArgumentNull("predicate"); - } - - var r = new List(); - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i])) r.Add(selector(source[i])); - } - return r; - } - - /// - /// Combined Where and Select for optimal performance that uses the index in the - /// predicate and selector. - /// - /// The input sequence to filter then transform. - /// A function to use to filter the sequence. - /// A function to transform the filtered elements. - /// A sequence of filtered and transformed elements. - public static List WhereSelectF(this List source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (predicate == null) - { - throw Error.ArgumentNull("predicate"); - } - - if (selector == null) - { - throw Error.ArgumentNull("predicate"); - } - - var r = new List(); - int idx = 0; - for (int i = 0; i < source.Count; i++) - { - if (predicate(source[i], i)) { - r.Add(selector(source[i], idx)); - idx++; - } - } - - - return r; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs.meta deleted file mode 100644 index bb861a94d..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSelect.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 20a5c369792516b4f8326236fc378f5c -timeCreated: 1518622476 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs deleted file mode 100644 index ca796291c..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs +++ /dev/null @@ -1,594 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - // -------------------------- ARRAYS -------------------------------------------- - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static int WhereSumF(this int[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - int sum = 0; - checked - { - foreach (var v in source) - { - if (predicate(v)) - { - sum += v; - } - } - } - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static int WhereSumF(this T[] source,Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int sum = 0; - checked - { - foreach (var v in source) - { - if (predicate(v)) - { - sum += selector(v); - } - } - } - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static long WhereSumF(this long[] source,Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - long sum = 0; - checked - { - foreach (var v in source) - { - if (predicate(v)) - { - sum += v; - } - } - } - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static long WhereSumF(this T[] source,Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - foreach (var v in source) - { - if (predicate(v)) - { - sum += selector(v); - } - } - } - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static float WhereSumF(this float[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - - foreach (var v in source) - { - if (predicate(v)) - { - sum += v; - } - } - - return (float)sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static float WhereSumF(this T[] source, Func predicate,Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - foreach (var v in source) - { - if (predicate(v)) - { - sum += selector(v); - } - } - - return (float)sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static double WhereSumF(this double[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - foreach (var v in source) - { - if (predicate(v)) - { - sum += v; - } - } - - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static double WhereSumF(this T[] source, Func predicate,Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - foreach (var v in source) - { - if (predicate(v)) - { - sum += selector(v); - } - } - - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static decimal WhereSumF(this decimal[] source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - decimal sum = 0; - - foreach (var v in source) - { - if (predicate(v)) - { - sum += v; - } - } - - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static decimal WhereSumF(this T[] source,Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - decimal sum = 0; - foreach (var v in source) - { - if (predicate(v)) - { - sum += selector(v); - } - } - - return sum; - } - - // -------------------------- LISTS -------------------------------------------- - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static int WhereSumF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - int sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += s; - } - } - } - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static int WhereSumF(this List source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - int sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += selector(s); - } - } - } - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static long WhereSumF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += s; - } - } - } - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static long WhereSumF(this List source, Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - long sum = 0; - checked - { - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += selector(s); - } - } - } - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static float WhereSumF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += s; - } - } - - return (float)sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static float WhereSumF(this List source, Func predicate,Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += selector(s); - } - } - - return (float)sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static double WhereSumF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += s; - } - } - - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static double WhereSumF(this List source,Func predicate, Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - double sum = 0; - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += selector(s); - } - } - - return sum; - } - - /// - /// Adds the values in the sequence that match the where predicate. - /// - /// The sequence to add. - /// A function to filter the sequence with before summing. - /// The sum of the sequence. - public static decimal WhereSumF(this List source, Func predicate) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - decimal sum = 0; - - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += s; - } - } - - return sum; - } - - /// - /// Performs a filter with the where predicate, then sums the transformed values. - /// - /// The sequence of values to transform then sum. - /// A function to filter the sequence with before summing. - /// A transformation function. - /// The sum of the transformed elements. - public static decimal WhereSumF(this List source, Func predicate,Func selector) - { - if (source == null) - { - throw Error.ArgumentNull("source"); - } - - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - decimal sum = 0; - for (int i = 0; i < source.Count; i++) - { - var s = source[i]; - if (predicate(s)) - { - sum += selector(s); - } - } - - return sum; - } - - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs.meta deleted file mode 100644 index 970b3d052..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/WhereSum.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: dcc2e4320bd136e4aaecbc9978013e58 -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs b/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs deleted file mode 100644 index a0c18ac2f..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JM.LinqFaster -{ - public static partial class LinqFaster - { - - /// - /// Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. - /// - /// The first sequence to merge. - /// The second sequence to merge. - /// A function that specifies how to merge the elements from the two sequences. - /// A sequence that contains merged elements of two input sequences. - public static R[] ZipF(this T[] first, U[] second, Func selector) - { - if (first == null) - { - throw Error.ArgumentNull("first"); - } - if (second == null) - { - throw Error.ArgumentNull("second"); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - //maintain array bounds elision - if (first.Length < second.Length) - { - var result = new R[first.Length]; - for (int i = 0; i < first.Length; i++) - { - result[i] = selector(first[i], second[i]); - } - return result; - - } - else - { - var result = new R[second.Length]; - for (int i = 0; i < second.Length; i++) - { - result[i] = selector(first[i], second[i]); - } - return result; - } - - } - - /// - /// Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. - /// - /// The first sequence to merge. - /// The second sequence to merge. - /// A function that specifies how to merge the elements from the two sequences. - /// A sequence that contains merged elements of two input sequences. - public static List ZipF(this List first, List second, Func selector) - { - if (first == null) - { - throw Error.ArgumentNull("first"); - } - if (second == null) - { - throw Error.ArgumentNull("second"); - } - if (selector == null) - { - throw Error.ArgumentNull("selector"); - } - - //maintain array bounds elision - if (first.Count < second.Count) - { - var result = new List(first.Count); - for (int i = 0; i < first.Count; i++) - { - result.Add(selector(first[i], second[i])); - } - return result; - - } - else - { - var result = new List(second.Count); - for (int i = 0; i < second.Count; i++) - { - result.Add(selector(first[i], second[i])); - } - return result; - } - - } - } -} diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs.meta deleted file mode 100644 index c24ab41df..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/Zip.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: d5cec6dd8a8dd0b4ab39e3fd25d1fa7b -timeCreated: 1518622478 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt b/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt deleted file mode 100644 index ab9fb2c93..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt +++ /dev/null @@ -1,68 +0,0 @@ -LinqFaster - - -Usage Guide --------------------------------------------------------------------------- -LinqFaster provides specialized versions of the Linq extensions methods -optimized for working with arrays and lists. LinqFaster methods use the -same names as Linq, but with an F (for Fast) appended to them so that -you can use LinqFaster alongside regular Linq. The semantics are identical -except for OrderBy which does not do a stable sort like Linq does. - -Examples --------------------------------------------------------------------------- - //Create an array of with values -500 to 500 - var myArray = LinqFaster.RangeArrayF(-500, 500); - //Create a List with 1000 elements all set to 5.0 - var myList = LinqFaster.RepeatListF(5.0, 1000); - - //Compute sum, average, max,min - var sum = myArray.SumF(); - var average = myArray.AverageF(); - var min = myArray.Min(); - var max = myArray.Max(); - - //As above but on a transformation - var sum2 = myArray.SumF(x => x*x); - var average2 = myArray.AverageF(x => x*x); - var min2 = myArray.Min(x => x*x); - var max2 = myArray.Max(x => x*x); - - //Do a where and a select or select and where in a single pass - var newArray = myArray.WhereSelectF(x => x % 2 == 0,x=>x*x); - var newArray2 = myArray.SelectWhereF(x => x * x,x => x % 2 == 0); - - //Compute the sum of only the even values in a single pass - var filteredSum = myArray.WhereAggregateF(x => x % 2 == 0, (acc, x) => acc + x); - - //New in-place methods are provided where appropriate - myArray.SelectInPlace(x => x * x); - myArray.ReverseInPlace(); - - -Limitations --------------------------------------------------------------------------- -These are purely imperative implementations of the same higher order -functions that Linq provides, but unlike Linq they are not lazily evaluated. -This means that when chaining functions together such as: - -var a = data.Where(predicate).Select(transform).Aggregate(foo); -// or -var b = data.Select(selector).Sum(); - -Linq would not do any work until the calls to Sum() or Aggregate(), and thus -iterate over the collection only once and allocate very little. LinqFaster -used this way would iterate over the collection each time and allocate much -more. Sometimes the net result will still be faster overall but the better -approach is to use the combined LinqFaster operations such as -SelectWhere, WhereSelect, and WhereAggregate. For example the expressions -above would become: - -var a = data.WhereAggregate(predicate,transform,foo); -// and -var b = data.Sum(selector); - -This gets you the best of both worlds. The speed of memory locality and no -allocations at all. In short, think about how you are transforming your -data. In some cases normal Linq may be the better choice. - diff --git a/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt.meta b/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt.meta deleted file mode 100644 index 385789f31..000000000 --- a/Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: b03cc13e7e812ab47b88f91d54b43c4d -timeCreated: 1518622496 -licenseType: Free -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/tests/Aetheria.Shared.Tests/CreditsTests.cs b/tests/Aetheria.Shared.Tests/CreditsTests.cs index 72c54d442..139a43adc 100644 --- a/tests/Aetheria.Shared.Tests/CreditsTests.cs +++ b/tests/Aetheria.Shared.Tests/CreditsTests.cs @@ -29,7 +29,6 @@ namespace Aetheria.Shared.Tests // licence-like file is not here until someone has read it and written the reason. private static readonly System.Collections.Generic.Dictionary ReviewedNotCredited = new System.Collections.Generic.Dictionary { - ["Assets/Scripts/ServerShared/NIH/LinqFaster/readme.txt"] = "usage guide for LinqFaster; names no holder and no licence", ["Assets/Plugins/LowPoly_AsteroidsPack/README.pdf"] = "how to customise the asteroid pack; names no holder and no licence", ["Assets/Plugins/Celestial Body/Textures/_Sources.txt"] = "URLs of the source textures only; states no licence", };