Esempio n. 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));
 }
Esempio n. 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));
 }
Esempio n. 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();
    }
Esempio n. 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);
     }
 }
Esempio n. 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));
        }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 8
0
 public static TSource Last <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate) =>
 LinqEnumerable.Last(source, predicate);
Esempio n. 9
0
 public static TSource Last <TSource>(this IEnumerable <TSource> source) =>
 LinqEnumerable.Last(source);