public static T Last <T>(this ImmutableSegmentedList <T> immutableList) { // In the event of an empty list, generate the same exception // that the linq extension method would. return(immutableList.Count > 0 ? immutableList[immutableList.Count - 1] : Enumerable.Last(immutableList)); }
public static T Last <T>(this ImmutableArray <T> immutableArray) { // In the event of an empty array, generate the same exception // that the linq extension method would. return(immutableArray.Length > 0 ? immutableArray[immutableArray.Length - 1] : Enumerable.Last(immutableArray.array)); }
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 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 static T Last <T>(this ImmutableSegmentedList <T> .Builder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } // In the event of an empty list, generate the same exception // that the linq extension method would. return(builder.Count > 0 ? builder[builder.Count - 1] : Enumerable.Last(builder)); }
public void BlinqShouldEqualLinqNativeSequenceRunLastPredicate([ArrayValues] int[] sourceArr) { using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent)) { var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.Last(source, EqualsZero.Invoke)); if (expected.exception != null) { return; } var actual = ExceptionAndValue(() => source.RunLast(EqualsZero)); AssertAreEqual(expected, actual); } }
public void BlinqShouldEqualLinqNativeSequenceScheduleLastOrDefault([ArrayValues] int[] sourceArr) { using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent)) { var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.Last(source)); if (expected.exception != null) { return; } var actual = ExceptionAndValue(() => source.ScheduleLastOrDefault().Complete()); AssertAreEqual(expected, actual); } }
public static TSource Last <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate) => LinqEnumerable.Last(source, predicate);
public static TSource Last <TSource>(this IEnumerable <TSource> source) => LinqEnumerable.Last(source);