示例#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);