Пример #1
0
 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));
 }
Пример #2
0
 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));
 }
Пример #3
0
    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();
    }
Пример #4
0
 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);
     }
 }
Пример #5
0
        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));
        }
Пример #6
0
 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);
     }
 }
Пример #7
0
 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);
     }
 }
Пример #8
0
 public static TSource Last <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate) =>
 LinqEnumerable.Last(source, predicate);
Пример #9
0
 public static TSource Last <TSource>(this IEnumerable <TSource> source) =>
 LinqEnumerable.Last(source);