public void LinqNativeSequence() { var second = new NativeArray <int>(source, Allocator.Persistent); MeasureLinq(() => Linq.ToList(Linq.Concat(source, second))).Run(); second.Dispose(); }
/// <summary> /// Sets the client select context. /// </summary> /// <param name="selectState">State of the select.</param> private void LoadClientSelects(IDictionary <string, bool> selectState) { ClientContextService clientContextService = PageWorkItem.Services.Get <ClientContextService>(); if (clientContextService != null) { if (clientContextService.CurrentContext.ContainsKey("ct_selectedTargetsCtrlId")) { foreach (var value in Enumerable.Where(clientContextService.CurrentContext, value => value.Key == "ct_selectedTargetsCtrlId")) { txtSelectedTargets.Value = value.Value; } } string clientContext = txtSelectedTargets.Value; if (!string.IsNullOrEmpty(clientContext)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(clientContext); XmlNodeList targetNodes = xmlDoc.DocumentElement.SelectNodes("//Targets/Target"); foreach (XmlNode tn in targetNodes) { string id = tn.Attributes["Id"].Value; string selected = tn.Attributes["Selected"].Value; if (selectState.ContainsKey(id)) { selectState.Remove(id); } selectState.Add(id, Convert.ToBoolean(selected)); } txtSelectedTargets.Value = string.Empty; } } }
private static void Update() { if (!active) { return; } activeTime += Time.deltaTime; // make sure we are not autosimulating Physics.autoSimulation = false; // see if all our bool allSleeping = Enumerable.Aggregate(Enumerable.Where(workList, body => body != null), true, (current, body) => current & body.IsSleeping()); if (allSleeping || activeTime >= timeToSettle) { Physics.autoSimulation = cachedAutoSimulation; active = false; } else { Physics.Simulate(Time.deltaTime); } }
public void Linq_int( [ValueSource(typeof(Values_int), nameof(Values_int.Values))] int[] sourceArr ) { var src = new NativeArray <int>(sourceArr, Allocator.Persistent); MakeMeasurement("Linq_int", () => Linq.Average(src)).Run(); src.Dispose(); }
public void LinqSelect_double( [ValueSource(typeof(SelectValues), nameof(SelectValues.Values))] int[] sourceArr ) { var src = new NativeArray <int>(sourceArr, Allocator.Persistent); MakeMeasurement("Linq_double", () => Linq.Average(src, IntTo_double.Invoke)).Run(); src.Dispose(); }
public void Linq_double( [ValueSource(typeof(Values_double), nameof(Values_double.Values))] double[] sourceArr ) { var src = new NativeArray <double>(sourceArr, Allocator.Persistent); MakeMeasurement("Linq_double", () => Linq.Average(src)).Run(); src.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayFirstOrDefault([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.FirstOrDefault(source)); var actual = ExceptionAndValue(() => source.FirstOrDefault()); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayMinComparableSelector([ArrayValues] int[] sourceArr) { var arr = Linq.ToArray(Linq.Select(sourceArr, (i) => (Comparable)i)); var srcNativeArray = new NativeArray <Comparable>(arr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Min(srcNativeArray, SelectSelf <Comparable>().Invoke)); var actual = ExceptionAndValue(() => Blinq.Min(srcNativeArray, SelectSelf <Comparable>())); srcNativeArray.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayWhereWithIndex([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Where(source, EqualToIndex.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.Where(source, EqualToIndex))); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySelectManyIndexResultSelector([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.SelectMany(sourceNativeArr, (x, i) => RepeatAmountPlusIndex.Invoke(x, i), AddToIndex.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.SelectMany(sourceNativeArr, RepeatAmountPlusIndex, AddToIndex))); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySelect([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Select(source, IntToLong.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.Select(source, IntToLong))); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayLastPredicate([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Last(source, EqualsZero.Invoke)); var actual = ExceptionAndValue(() => source.Last(EqualsZero)); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayOrderByDescending([OrderValues] Order[] sourceArr) { var source = new NativeArray <Order>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.OrderByDescending(source, SelectFirst.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.OrderByDescending(source, SelectFirst))); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySequenceCountPredicate([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Count(sourceNativeArr, EqualsOne.Invoke)); var actual = ExceptionAndValue(() => Blinq.Count(sourceNativeArr, EqualsOne)); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayDefaultIfEmpty([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.DefaultIfEmpty(source, 1))); var actual = ExceptionAndValue(() => Linq.ToArray(source.DefaultIfEmpty(1))); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqValueSequenceThenBy([OrderValues] Order[] sourceArr) { var sourceNativeArr = new NativeArray <Order>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.ThenBy(Linq.OrderBy(source, SelectSecond.Invoke), SelectFirst.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.ThenBy(Blinq.OrderBy(source, SelectSecond), SelectFirst))); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySumSelector_float( [ValueSource(typeof(Values_float), nameof(Values_float.Values))] float[] sourceArr ) { var srcNativeArray = new NativeArray <float>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Sum(srcNativeArray, SelectSelf <float>().Invoke)); var actual = ExceptionAndValue(() => Blinq.Sum(srcNativeArray, SelectSelf <float>())); srcNativeArray.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySum_int( [ValueSource(typeof(Values_int), nameof(Values_int.Values))] int[] sourceArr ) { var srcNativeArray = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Sum(srcNativeArray)); var actual = ExceptionAndValue(() => Blinq.Sum(srcNativeArray)); srcNativeArray.Dispose(); }
public void BlinqShouldEqualLinqValueSequenceTakeWhile([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.TakeWhile(source, EqualToIndex.Invoke))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.TakeWhile(source, EqualToIndex))); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public static NativeArray <T> ToNativeArray <T>(this IEnumerable <T> source, Allocator allocator) where T : struct { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(new NativeArray <T>(LinqEnumerable.ToArray(source), allocator)); }
public void BlinqShouldEqualLinqNativeArrayElementAt([ArrayValues] int[] sourceArr) { var index = 10; var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ElementAt(source, index)); var actual = ExceptionAndValue(() => Blinq.ElementAt(source, index)); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeSequenceFirstOrDefaultPredicate([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.FirstOrDefault(source, EqualsZero.Invoke)); var actual = ExceptionAndValue(() => source.FirstOrDefault(EqualsZero)); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayPrepend([ArrayValues] int[] sourceArr) { int item = 1; var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Prepend(source, item))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.Prepend(source, item))); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayContainsComparer([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var(expectedException, expectedValue) = ExceptionAndValue(() => Linq.Contains(source, 7, default(RemainderTwoComparer))); var(actualException, actualValue) = ExceptionAndValue(() => source.Contains(7, default(RemainderTwoComparer))); Assert.AreEqual(expectedException, actualException); Assert.AreEqual(expectedValue, actualValue); source.Dispose(); }
public void BlinqShouldEqualLinqNativeSequenceLast([ArrayValues] int[] sourceArr) { using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent)) { var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.Last(source)); var actual = ExceptionAndValue(() => source.Last()); AssertAreEqual(expected, actual); } }
public void BlinqShouldEqualLinqValueSequenceLongCount([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.LongCount(source)); var actual = ExceptionAndValue(() => Blinq.LongCount(source)); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqValueSequenceSelectMany([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.SelectMany(source, (x) => RepeatAmount.Invoke(x)))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.SelectMany(source, RepeatAmount))); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayMinSelector_double( [ValueSource(typeof(Values_double), nameof(Values_double.Values))] double[] sourceArr ) { var srcNativeArray = new NativeArray <double>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.Min(srcNativeArray, SelectSelf <double>().Invoke)); var actual = ExceptionAndValue(() => Blinq.Min(srcNativeArray, SelectSelf <double>())); srcNativeArray.Dispose(); }
public void BlinqShouldEqualLinqNativeArraySequenceEqualArray([ArrayValues] int[] sourceArr, [ArrayValues] int[] secondArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var secondNativeArr = new NativeArray <int>(secondArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.SequenceEqual(sourceNativeArr, secondNativeArr)); var actual = ExceptionAndValue(() => Blinq.SequenceEqual(sourceNativeArr, secondNativeArr)); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); secondNativeArr.Dispose(); }
public void BlinqShouldEqualLinqNativeArrayUnion([ArrayValues] int[] sourceArr, [ArrayValues] int[] secondArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var second = new NativeArray <int>(secondArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Union(source, second))); var actual = ExceptionAndValue(() => Linq.ToArray(Blinq.Union(source, second))); AssertAreEqual(expected, actual); source.Dispose(); second.Dispose(); }