3980 lines
218 KiB
C#
3980 lines
218 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Collections.ObjectModel;
|
||
|
||
namespace System.Linq
|
||
{
|
||
/// <summary>Provides a set of static (Shared in Visual Basic) methods for querying objects that implement <see cref="T:System.Collections.Generic.IEnumerable`1" />.</summary>
|
||
// Token: 0x02000032 RID: 50
|
||
public static class Enumerable
|
||
{
|
||
/// <summary>Applies an accumulator function over a sequence.</summary>
|
||
/// <returns>The final accumulator value.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to aggregate over.</param>
|
||
/// <param name="func">An accumulator function to be invoked on each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="func" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x0600027B RID: 635 RVA: 0x0000CE3C File Offset: 0x0000B03C
|
||
public static TSource Aggregate<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, TSource> func)
|
||
{
|
||
Check.SourceAndFunc(source, func);
|
||
TSource tsource3;
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
if (!enumerator.MoveNext())
|
||
{
|
||
throw new InvalidOperationException("No elements in source list");
|
||
}
|
||
TSource tsource = enumerator.Current;
|
||
while (enumerator.MoveNext())
|
||
{
|
||
TSource tsource2 = enumerator.Current;
|
||
tsource = func(tsource, tsource2);
|
||
}
|
||
tsource3 = tsource;
|
||
}
|
||
return tsource3;
|
||
}
|
||
|
||
/// <summary>Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.</summary>
|
||
/// <returns>The final accumulator value.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to aggregate over.</param>
|
||
/// <param name="seed">The initial accumulator value.</param>
|
||
/// <param name="func">An accumulator function to be invoked on each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="func" /> is null.</exception>
|
||
// Token: 0x0600027C RID: 636 RVA: 0x0000CEC8 File Offset: 0x0000B0C8
|
||
public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
|
||
{
|
||
Check.SourceAndFunc(source, func);
|
||
TAccumulate taccumulate = seed;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
taccumulate = func(taccumulate, tsource);
|
||
}
|
||
return taccumulate;
|
||
}
|
||
|
||
/// <summary>Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.</summary>
|
||
/// <returns>The transformed final accumulator value.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to aggregate over.</param>
|
||
/// <param name="seed">The initial accumulator value.</param>
|
||
/// <param name="func">An accumulator function to be invoked on each element.</param>
|
||
/// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
|
||
/// <typeparam name="TResult">The type of the resulting value.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="func" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x0600027D RID: 637 RVA: 0x0000CF34 File Offset: 0x0000B134
|
||
public static TResult Aggregate<TSource, TAccumulate, TResult>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
|
||
{
|
||
Check.SourceAndFunc(source, func);
|
||
if (resultSelector == null)
|
||
{
|
||
throw new ArgumentNullException("resultSelector");
|
||
}
|
||
TAccumulate taccumulate = seed;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
taccumulate = func(taccumulate, tsource);
|
||
}
|
||
return resultSelector(taccumulate);
|
||
}
|
||
|
||
/// <summary>Determines whether all elements of a sequence satisfy a condition.</summary>
|
||
/// <returns>true if every element of the source sequence passes the test in the specified predicate, or if the sequence is empty; otherwise, false.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements to apply the predicate to.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x0600027E RID: 638 RVA: 0x0000CFB8 File Offset: 0x0000B1B8
|
||
public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (!predicate(tsource))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
/// <summary>Determines whether a sequence contains any elements.</summary>
|
||
/// <returns>true if the source sequence contains any elements; otherwise, false.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to check for emptiness.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600027F RID: 639 RVA: 0x0000D02C File Offset: 0x0000B22C
|
||
public static bool Any<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
ICollection<TSource> collection = source as ICollection<TSource>;
|
||
if (collection != null)
|
||
{
|
||
return collection.Count > 0;
|
||
}
|
||
bool flag;
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
flag = enumerator.MoveNext();
|
||
}
|
||
return flag;
|
||
}
|
||
|
||
/// <summary>Determines whether any element of a sequence satisfies a condition.</summary>
|
||
/// <returns>true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to apply the predicate to.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x06000280 RID: 640 RVA: 0x0000D098 File Offset: 0x0000B298
|
||
public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (predicate(tsource))
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>Returns the input typed as <see cref="T:System.Collections.Generic.IEnumerable`1" />.</summary>
|
||
/// <returns>The input sequence typed as <see cref="T:System.Collections.Generic.IEnumerable`1" />.</returns>
|
||
/// <param name="source">The sequence to type as <see cref="T:System.Collections.Generic.IEnumerable`1" />.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
// Token: 0x06000281 RID: 641 RVA: 0x0000D10C File Offset: 0x0000B30C
|
||
public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
return source;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000282 RID: 642 RVA: 0x0000D110 File Offset: 0x0000B310
|
||
public static double Average(this IEnumerable<int> source)
|
||
{
|
||
Check.Source(source);
|
||
long num = 0L;
|
||
int num2 = 0;
|
||
foreach (int num3 in source)
|
||
{
|
||
checked
|
||
{
|
||
num += unchecked((long)num3);
|
||
}
|
||
num2++;
|
||
}
|
||
if (num2 == 0)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return (double)num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000283 RID: 643 RVA: 0x0000D18C File Offset: 0x0000B38C
|
||
public static double Average(this IEnumerable<long> source)
|
||
{
|
||
Check.Source(source);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (long num3 in source)
|
||
{
|
||
num += num3;
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return (double)num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x06000284 RID: 644 RVA: 0x0000D20C File Offset: 0x0000B40C
|
||
public static double Average(this IEnumerable<double> source)
|
||
{
|
||
Check.Source(source);
|
||
double num = 0.0;
|
||
long num2 = 0L;
|
||
foreach (double num3 in source)
|
||
{
|
||
double num4 = num3;
|
||
num += num4;
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x06000285 RID: 645 RVA: 0x0000D290 File Offset: 0x0000B490
|
||
public static float Average(this IEnumerable<float> source)
|
||
{
|
||
Check.Source(source);
|
||
float num = 0f;
|
||
long num2 = 0L;
|
||
foreach (float num3 in source)
|
||
{
|
||
float num4 = num3;
|
||
num += num4;
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / (float)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000286 RID: 646 RVA: 0x0000D310 File Offset: 0x0000B510
|
||
public static decimal Average(this IEnumerable<decimal> source)
|
||
{
|
||
Check.Source(source);
|
||
decimal num = 0m;
|
||
long num2 = 0L;
|
||
foreach (decimal num3 in source)
|
||
{
|
||
num += num3;
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000287 RID: 647 RVA: 0x0000D39C File Offset: 0x0000B59C
|
||
public static double? Average(this IEnumerable<int?> source)
|
||
{
|
||
Check.Source(source);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (int? num3 in source)
|
||
{
|
||
if (num3 != null)
|
||
{
|
||
num += (long)num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?((double)num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000288 RID: 648 RVA: 0x0000D43C File Offset: 0x0000B63C
|
||
public static double? Average(this IEnumerable<long?> source)
|
||
{
|
||
Check.Source(source);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (long? num3 in source)
|
||
{
|
||
if (num3 != null)
|
||
{
|
||
checked
|
||
{
|
||
num += num3.Value;
|
||
}
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?((double)num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000289 RID: 649 RVA: 0x0000D4DC File Offset: 0x0000B6DC
|
||
public static double? Average(this IEnumerable<double?> source)
|
||
{
|
||
Check.Source(source);
|
||
double num = 0.0;
|
||
long num2 = 0L;
|
||
foreach (double? num3 in source)
|
||
{
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?(num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x0600028A RID: 650 RVA: 0x0000D580 File Offset: 0x0000B780
|
||
public static decimal? Average(this IEnumerable<decimal?> source)
|
||
{
|
||
Check.Source(source);
|
||
decimal num = 0m;
|
||
long num2 = 0L;
|
||
foreach (decimal? num3 in source)
|
||
{
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new decimal?(num / num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the average of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600028B RID: 651 RVA: 0x0000D630 File Offset: 0x0000B830
|
||
public static float? Average(this IEnumerable<float?> source)
|
||
{
|
||
Check.Source(source);
|
||
float num = 0f;
|
||
long num2 = 0L;
|
||
foreach (float? num3 in source)
|
||
{
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new float?(num / (float)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x0600028C RID: 652 RVA: 0x0000D6D0 File Offset: 0x0000B8D0
|
||
public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += (long)selector(tsource);
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return (double)num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x0600028D RID: 653 RVA: 0x0000D758 File Offset: 0x0000B958
|
||
public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
int? num3 = selector(tsource);
|
||
if (num3 != null)
|
||
{
|
||
num += (long)num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?((double)num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x0600028E RID: 654 RVA: 0x0000D804 File Offset: 0x0000BA04
|
||
public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
checked
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return (double)num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
// Token: 0x0600028F RID: 655 RVA: 0x0000D888 File Offset: 0x0000BA88
|
||
public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
long? num3 = selector(tsource);
|
||
if (num3 != null)
|
||
{
|
||
checked
|
||
{
|
||
num += num3.Value;
|
||
}
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?((double)num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x06000290 RID: 656 RVA: 0x0000D930 File Offset: 0x0000BB30
|
||
public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
double num = 0.0;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / (double)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x06000291 RID: 657 RVA: 0x0000D9BC File Offset: 0x0000BBBC
|
||
public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
double num = 0.0;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
double? num3 = selector(tsource);
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new double?(num / (double)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x06000292 RID: 658 RVA: 0x0000DA6C File Offset: 0x0000BC6C
|
||
public static float Average<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
float num = 0f;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / (float)num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x06000293 RID: 659 RVA: 0x0000DAF4 File Offset: 0x0000BCF4
|
||
public static float? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
float num = 0f;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
float? num3 = selector(tsource);
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new float?(num / (float)num2);
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate an average.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000294 RID: 660 RVA: 0x0000DBA0 File Offset: 0x0000BDA0
|
||
public static decimal Average<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
decimal num = 0m;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
num2 += 1L;
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return num / num2;
|
||
}
|
||
|
||
/// <summary>Computes the average of a sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
|
||
/// <param name="source">A sequence of values to calculate the average of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum of the elements in the sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000295 RID: 661 RVA: 0x0000DC34 File Offset: 0x0000BE34
|
||
public static decimal? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
decimal num = 0m;
|
||
long num2 = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
decimal? num3 = selector(tsource);
|
||
if (num3 != null)
|
||
{
|
||
num += num3.Value;
|
||
num2 += 1L;
|
||
}
|
||
}
|
||
if (num2 == 0L)
|
||
{
|
||
return null;
|
||
}
|
||
return new decimal?(num / num2);
|
||
}
|
||
|
||
/// <summary>Converts the elements of an <see cref="T:System.Collections.IEnumerable" /> to the specified type.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains each element of the source sequence converted to the specified type.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.IEnumerable" /> that contains the elements to be converted.</param>
|
||
/// <typeparam name="TResult">The type to convert the elements of <paramref name="source" /> to.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidCastException">An element in the sequence cannot be cast to type <paramref name="TResult" />.</exception>
|
||
// Token: 0x06000296 RID: 662 RVA: 0x0000DCEC File Offset: 0x0000BEEC
|
||
public static IEnumerable<TResult> Cast<TResult>(this IEnumerable source)
|
||
{
|
||
Check.Source(source);
|
||
IEnumerable<TResult> enumerable = source as IEnumerable<TResult>;
|
||
if (enumerable != null)
|
||
{
|
||
return enumerable;
|
||
}
|
||
return Enumerable.CreateCastIterator<TResult>(source);
|
||
}
|
||
|
||
// Token: 0x06000297 RID: 663 RVA: 0x0000DD14 File Offset: 0x0000BF14
|
||
private static IEnumerable<TResult> CreateCastIterator<TResult>(IEnumerable source)
|
||
{
|
||
foreach (object obj in source)
|
||
{
|
||
TResult element = (TResult)((object)obj);
|
||
yield return element;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Concatenates two sequences.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the concatenated elements of the two input sequences.</returns>
|
||
/// <param name="first">The first sequence to concatenate.</param>
|
||
/// <param name="second">The sequence to concatenate to the first sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x06000298 RID: 664 RVA: 0x0000DD40 File Offset: 0x0000BF40
|
||
public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
return Enumerable.CreateConcatIterator<TSource>(first, second);
|
||
}
|
||
|
||
// Token: 0x06000299 RID: 665 RVA: 0x0000DD50 File Offset: 0x0000BF50
|
||
private static IEnumerable<TSource> CreateConcatIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
foreach (TSource element in first)
|
||
{
|
||
yield return element;
|
||
}
|
||
foreach (TSource element2 in second)
|
||
{
|
||
yield return element2;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Determines whether a sequence contains a specified element by using the default equality comparer.</summary>
|
||
/// <returns>true if the source sequence contains an element that has the specified value; otherwise, false.</returns>
|
||
/// <param name="source">A sequence in which to locate a value.</param>
|
||
/// <param name="value">The value to locate in the sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600029A RID: 666 RVA: 0x0000DD88 File Offset: 0x0000BF88
|
||
public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value)
|
||
{
|
||
ICollection<TSource> collection = source as ICollection<TSource>;
|
||
if (collection != null)
|
||
{
|
||
return collection.Contains(value);
|
||
}
|
||
return source.Contains(value, null);
|
||
}
|
||
|
||
/// <summary>Determines whether a sequence contains a specified element by using a specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
|
||
/// <returns>true if the source sequence contains an element that has the specified value; otherwise, false.</returns>
|
||
/// <param name="source">A sequence in which to locate a value.</param>
|
||
/// <param name="value">The value to locate in the sequence.</param>
|
||
/// <param name="comparer">An equality comparer to compare values.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600029B RID: 667 RVA: 0x0000DDB4 File Offset: 0x0000BFB4
|
||
public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.Source(source);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (comparer.Equals(tsource, value))
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>Returns the number of elements in a sequence.</summary>
|
||
/// <returns>The number of elements in the input sequence.</returns>
|
||
/// <param name="source">A sequence that contains elements to be counted.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The number of elements in <paramref name="source" /> is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x0600029C RID: 668 RVA: 0x0000DE38 File Offset: 0x0000C038
|
||
public static int Count<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
ICollection<TSource> collection = source as ICollection<TSource>;
|
||
if (collection != null)
|
||
{
|
||
return collection.Count;
|
||
}
|
||
int num = 0;
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
while (enumerator.MoveNext())
|
||
{
|
||
num++;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Returns a number that represents how many elements in the specified sequence satisfy a condition.</summary>
|
||
/// <returns>A number that represents how many elements in the sequence satisfy the condition in the predicate function.</returns>
|
||
/// <param name="source">A sequence that contains elements to be tested and counted.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The number of elements in <paramref name="source" /> is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x0600029D RID: 669 RVA: 0x0000DEAC File Offset: 0x0000C0AC
|
||
public static int Count<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
int num = 0;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (selector(tsource))
|
||
{
|
||
num++;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> object that contains the default value for the <paramref name="TSource" /> type if <paramref name="source" /> is empty; otherwise, <paramref name="source" />.</returns>
|
||
/// <param name="source">The sequence to return a default value for if it is empty.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600029E RID: 670 RVA: 0x0000DF20 File Offset: 0x0000C120
|
||
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
return source.DefaultIfEmpty(default(TSource));
|
||
}
|
||
|
||
/// <summary>Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains <paramref name="defaultValue" /> if <paramref name="source" /> is empty; otherwise, <paramref name="source" />.</returns>
|
||
/// <param name="source">The sequence to return the specified value for if it is empty.</param>
|
||
/// <param name="defaultValue">The value to return if the sequence is empty.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
// Token: 0x0600029F RID: 671 RVA: 0x0000DF3C File Offset: 0x0000C13C
|
||
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source, TSource defaultValue)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.CreateDefaultIfEmptyIterator<TSource>(source, defaultValue);
|
||
}
|
||
|
||
// Token: 0x060002A0 RID: 672 RVA: 0x0000DF4C File Offset: 0x0000C14C
|
||
private static IEnumerable<TSource> CreateDefaultIfEmptyIterator<TSource>(IEnumerable<TSource> source, TSource defaultValue)
|
||
{
|
||
bool empty = true;
|
||
foreach (TSource item in source)
|
||
{
|
||
empty = false;
|
||
yield return item;
|
||
}
|
||
if (empty)
|
||
{
|
||
yield return defaultValue;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Returns distinct elements from a sequence by using the default equality comparer to compare values.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains distinct elements from the source sequence.</returns>
|
||
/// <param name="source">The sequence to remove duplicate elements from.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002A1 RID: 673 RVA: 0x0000DF84 File Offset: 0x0000C184
|
||
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
return source.Distinct(null);
|
||
}
|
||
|
||
/// <summary>Returns distinct elements from a sequence by using a specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains distinct elements from the source sequence.</returns>
|
||
/// <param name="source">The sequence to remove duplicate elements from.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002A2 RID: 674 RVA: 0x0000DF90 File Offset: 0x0000C190
|
||
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.Source(source);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
return Enumerable.CreateDistinctIterator<TSource>(source, comparer);
|
||
}
|
||
|
||
// Token: 0x060002A3 RID: 675 RVA: 0x0000DFAC File Offset: 0x0000C1AC
|
||
private static IEnumerable<TSource> CreateDistinctIterator<TSource>(IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
|
||
{
|
||
HashSet<TSource> items = new HashSet<TSource>(comparer);
|
||
foreach (TSource element in source)
|
||
{
|
||
if (!items.Contains(element))
|
||
{
|
||
items.Add(element);
|
||
yield return element;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
// Token: 0x060002A4 RID: 676 RVA: 0x0000DFE4 File Offset: 0x0000C1E4
|
||
private static TSource ElementAt<TSource>(this IEnumerable<TSource> source, int index, Enumerable.Fallback fallback)
|
||
{
|
||
long num = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
long num2 = (long)index;
|
||
long num3 = num;
|
||
num = num3 + 1L;
|
||
if (num2 == num3)
|
||
{
|
||
return tsource;
|
||
}
|
||
}
|
||
if (fallback == Enumerable.Fallback.Throw)
|
||
{
|
||
throw new ArgumentOutOfRangeException();
|
||
}
|
||
return default(TSource);
|
||
}
|
||
|
||
/// <summary>Returns the element at a specified index in a sequence.</summary>
|
||
/// <returns>The element at the specified position in the source sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="index">The zero-based index of the element to retrieve.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||
/// <paramref name="index" /> is less than 0 or greater than or equal to the number of elements in <paramref name="source" />.</exception>
|
||
// Token: 0x060002A5 RID: 677 RVA: 0x0000E06C File Offset: 0x0000C26C
|
||
public static TSource ElementAt<TSource>(this IEnumerable<TSource> source, int index)
|
||
{
|
||
Check.Source(source);
|
||
if (index < 0)
|
||
{
|
||
throw new ArgumentOutOfRangeException();
|
||
}
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list != null)
|
||
{
|
||
return list[index];
|
||
}
|
||
return source.ElementAt(index, Enumerable.Fallback.Throw);
|
||
}
|
||
|
||
/// <summary>Returns the element at a specified index in a sequence or a default value if the index is out of range.</summary>
|
||
/// <returns>default(<paramref name="TSource" />) if the index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="index">The zero-based index of the element to retrieve.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002A6 RID: 678 RVA: 0x0000E0AC File Offset: 0x0000C2AC
|
||
public static TSource ElementAtOrDefault<TSource>(this IEnumerable<TSource> source, int index)
|
||
{
|
||
Check.Source(source);
|
||
if (index < 0)
|
||
{
|
||
return default(TSource);
|
||
}
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list != null)
|
||
{
|
||
return (index >= list.Count) ? default(TSource) : list[index];
|
||
}
|
||
return source.ElementAt(index, Enumerable.Fallback.Default);
|
||
}
|
||
|
||
/// <summary>Returns an empty <see cref="T:System.Collections.Generic.IEnumerable`1" /> that has the specified type argument.</summary>
|
||
/// <returns>An empty <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose type argument is <paramref name="TResult" />.</returns>
|
||
/// <typeparam name="TResult">The type to assign to the type parameter of the returned generic <see cref="T:System.Collections.Generic.IEnumerable`1" />.</typeparam>
|
||
// Token: 0x060002A7 RID: 679 RVA: 0x0000E108 File Offset: 0x0000C308
|
||
public static IEnumerable<TResult> Empty<TResult>()
|
||
{
|
||
return new TResult[0];
|
||
}
|
||
|
||
/// <summary>Produces the set difference of two sequences by using the default equality comparer to compare values.</summary>
|
||
/// <returns>A sequence that contains the set difference of the elements of two sequences.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements that are not also in <paramref name="second" /> will be returned.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x060002A8 RID: 680 RVA: 0x0000E110 File Offset: 0x0000C310
|
||
public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
return first.Except(second, null);
|
||
}
|
||
|
||
/// <summary>Produces the set difference of two sequences by using the specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</summary>
|
||
/// <returns>A sequence that contains the set difference of the elements of two sequences.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements that are not also in <paramref name="second" /> will be returned.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x060002A9 RID: 681 RVA: 0x0000E11C File Offset: 0x0000C31C
|
||
public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
return Enumerable.CreateExceptIterator<TSource>(first, second, comparer);
|
||
}
|
||
|
||
// Token: 0x060002AA RID: 682 RVA: 0x0000E13C File Offset: 0x0000C33C
|
||
private static IEnumerable<TSource> CreateExceptIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
HashSet<TSource> items = new HashSet<TSource>(second, comparer);
|
||
foreach (TSource element in first)
|
||
{
|
||
if (!items.Contains(element, comparer))
|
||
{
|
||
yield return element;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
// Token: 0x060002AB RID: 683 RVA: 0x0000E184 File Offset: 0x0000C384
|
||
private static TSource First<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Enumerable.Fallback fallback)
|
||
{
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (predicate(tsource))
|
||
{
|
||
return tsource;
|
||
}
|
||
}
|
||
if (fallback == Enumerable.Fallback.Throw)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return default(TSource);
|
||
}
|
||
|
||
/// <summary>Returns the first element of a sequence.</summary>
|
||
/// <returns>The first element in the specified sequence.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the first element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">The source sequence is empty.</exception>
|
||
// Token: 0x060002AC RID: 684 RVA: 0x0000E208 File Offset: 0x0000C408
|
||
public static TSource First<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list == null)
|
||
{
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
if (enumerator.MoveNext())
|
||
{
|
||
return enumerator.Current;
|
||
}
|
||
}
|
||
throw new InvalidOperationException();
|
||
}
|
||
if (list.Count != 0)
|
||
{
|
||
return list[0];
|
||
}
|
||
throw new InvalidOperationException();
|
||
}
|
||
|
||
/// <summary>Returns the first element in a sequence that satisfies a specified condition.</summary>
|
||
/// <returns>The first element in the sequence that passes the test in the specified predicate function.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">No element satisfies the condition in <paramref name="predicate" />.-or-The source sequence is empty.</exception>
|
||
// Token: 0x060002AD RID: 685 RVA: 0x0000E294 File Offset: 0x0000C494
|
||
public static TSource First<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.First(predicate, Enumerable.Fallback.Throw);
|
||
}
|
||
|
||
/// <summary>Returns the first element of a sequence, or a default value if the sequence contains no elements.</summary>
|
||
/// <returns>default(<paramref name="TSource" />) if <paramref name="source" /> is empty; otherwise, the first element in <paramref name="source" />.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the first element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002AE RID: 686 RVA: 0x0000E2A8 File Offset: 0x0000C4A8
|
||
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
if (enumerator.MoveNext())
|
||
{
|
||
return enumerator.Current;
|
||
}
|
||
}
|
||
return default(TSource);
|
||
}
|
||
|
||
/// <summary>Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.</summary>
|
||
/// <returns>default(<paramref name="TSource" />) if <paramref name="source" /> is empty or if no element passes the test specified by <paramref name="predicate" />; otherwise, the first element in <paramref name="source" /> that passes the test specified by <paramref name="predicate" />.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x060002AF RID: 687 RVA: 0x0000E318 File Offset: 0x0000C518
|
||
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.First(predicate, Enumerable.Fallback.Default);
|
||
}
|
||
|
||
// Token: 0x060002B0 RID: 688 RVA: 0x0000E32C File Offset: 0x0000C52C
|
||
private static List<T> ContainsGroup<K, T>(Dictionary<K, List<T>> items, K key, IEqualityComparer<K> comparer)
|
||
{
|
||
IEqualityComparer<K> equalityComparer = comparer ?? EqualityComparer<K>.Default;
|
||
foreach (KeyValuePair<K, List<T>> keyValuePair in items)
|
||
{
|
||
if (equalityComparer.Equals(keyValuePair.Key, key))
|
||
{
|
||
return keyValuePair.Value;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function.</summary>
|
||
/// <returns>An IEnumerable<IGrouping<TKey, TSource>> in C# or IEnumerable(Of IGrouping(Of TKey, TSource)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2" /> object contains a sequence of objects and a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x060002B1 RID: 689 RVA: 0x0000E3B8 File Offset: 0x0000C5B8
|
||
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.GroupBy(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.</summary>
|
||
/// <returns>An IEnumerable<IGrouping<TKey, TSource>> in C# or IEnumerable(Of IGrouping(Of TKey, TSource)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2" /> object contains a collection of objects and a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x060002B2 RID: 690 RVA: 0x0000E3C4 File Offset: 0x0000C5C4
|
||
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeySelector(source, keySelector);
|
||
return source.CreateGroupByIterator(keySelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002B3 RID: 691 RVA: 0x0000E3D8 File Offset: 0x0000C5D8
|
||
private static IEnumerable<IGrouping<TKey, TSource>> CreateGroupByIterator<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Dictionary<TKey, List<TSource>> groups = new Dictionary<TKey, List<TSource>>();
|
||
List<TSource> nullList = new List<TSource>();
|
||
int counter = 0;
|
||
int nullCounter = -1;
|
||
foreach (TSource element in source)
|
||
{
|
||
TKey key = keySelector(element);
|
||
if (key == null)
|
||
{
|
||
nullList.Add(element);
|
||
if (nullCounter == -1)
|
||
{
|
||
nullCounter = counter;
|
||
counter++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
List<TSource> group = Enumerable.ContainsGroup<TKey, TSource>(groups, key, comparer);
|
||
if (group == null)
|
||
{
|
||
group = new List<TSource>();
|
||
groups.Add(key, group);
|
||
counter++;
|
||
}
|
||
group.Add(element);
|
||
}
|
||
}
|
||
counter = 0;
|
||
foreach (KeyValuePair<TKey, List<TSource>> group2 in groups)
|
||
{
|
||
if (counter == nullCounter)
|
||
{
|
||
yield return new Grouping<TKey, TSource>(default(TKey), nullList);
|
||
counter++;
|
||
}
|
||
yield return new Grouping<TKey, TSource>(group2.Key, group2.Value);
|
||
counter++;
|
||
}
|
||
if (counter == nullCounter)
|
||
{
|
||
yield return new Grouping<TKey, TSource>(default(TKey), nullList);
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.</summary>
|
||
/// <returns>An IEnumerable<IGrouping<TKey, TElement>> in C# or IEnumerable(Of IGrouping(Of TKey, TElement)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2" /> object contains a collection of objects of type <paramref name="TElement" /> and a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="elementSelector">A function to map each source element to an element in the <see cref="T:System.Linq.IGrouping`2" />.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the elements in the <see cref="T:System.Linq.IGrouping`2" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
|
||
// Token: 0x060002B4 RID: 692 RVA: 0x0000E420 File Offset: 0x0000C620
|
||
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
|
||
{
|
||
return source.GroupBy(keySelector, elementSelector, null);
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function.</summary>
|
||
/// <returns>An IEnumerable<IGrouping<TKey, TElement>> in C# or IEnumerable(Of IGrouping(Of TKey, TElement)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2" /> object contains a collection of objects of type <paramref name="TElement" /> and a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="elementSelector">A function to map each source element to an element in an <see cref="T:System.Linq.IGrouping`2" />.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the elements in the <see cref="T:System.Linq.IGrouping`2" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
|
||
// Token: 0x060002B5 RID: 693 RVA: 0x0000E42C File Offset: 0x0000C62C
|
||
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeyElementSelectors(source, keySelector, elementSelector);
|
||
return source.CreateGroupByIterator(keySelector, elementSelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002B6 RID: 694 RVA: 0x0000E440 File Offset: 0x0000C640
|
||
private static IEnumerable<IGrouping<TKey, TElement>> CreateGroupByIterator<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Dictionary<TKey, List<TElement>> groups = new Dictionary<TKey, List<TElement>>();
|
||
List<TElement> nullList = new List<TElement>();
|
||
int counter = 0;
|
||
int nullCounter = -1;
|
||
foreach (TSource item in source)
|
||
{
|
||
TKey key = keySelector(item);
|
||
TElement element = elementSelector(item);
|
||
if (key == null)
|
||
{
|
||
nullList.Add(element);
|
||
if (nullCounter == -1)
|
||
{
|
||
nullCounter = counter;
|
||
counter++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
List<TElement> group = Enumerable.ContainsGroup<TKey, TElement>(groups, key, comparer);
|
||
if (group == null)
|
||
{
|
||
group = new List<TElement>();
|
||
groups.Add(key, group);
|
||
counter++;
|
||
}
|
||
group.Add(element);
|
||
}
|
||
}
|
||
counter = 0;
|
||
foreach (KeyValuePair<TKey, List<TElement>> group2 in groups)
|
||
{
|
||
if (counter == nullCounter)
|
||
{
|
||
yield return new Grouping<TKey, TElement>(default(TKey), nullList);
|
||
counter++;
|
||
}
|
||
yield return new Grouping<TKey, TElement>(group2.Key, group2.Value);
|
||
counter++;
|
||
}
|
||
if (counter == nullCounter)
|
||
{
|
||
yield return new Grouping<TKey, TElement>(default(TKey), nullList);
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function.</summary>
|
||
/// <returns>A collection of elements of type <paramref name="TResult" /> where each element represents a projection over a group and its key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="elementSelector">A function to map each source element to an element in an <see cref="T:System.Linq.IGrouping`2" />.</param>
|
||
/// <param name="resultSelector">A function to create a result value from each group.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the elements in each <see cref="T:System.Linq.IGrouping`2" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector" />.</typeparam>
|
||
// Token: 0x060002B7 RID: 695 RVA: 0x0000E494 File Offset: 0x0000C694
|
||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
|
||
{
|
||
return source.GroupBy(keySelector, elementSelector, resultSelector, null);
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.</summary>
|
||
/// <returns>A collection of elements of type <paramref name="TResult" /> where each element represents a projection over a group and its key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="elementSelector">A function to map each source element to an element in an <see cref="T:System.Linq.IGrouping`2" />.</param>
|
||
/// <param name="resultSelector">A function to create a result value from each group.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys with.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the elements in each <see cref="T:System.Linq.IGrouping`2" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector" />.</typeparam>
|
||
// Token: 0x060002B8 RID: 696 RVA: 0x0000E4A0 File Offset: 0x0000C6A0
|
||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.GroupBySelectors(source, keySelector, elementSelector, resultSelector);
|
||
return source.CreateGroupByIterator(keySelector, elementSelector, resultSelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002B9 RID: 697 RVA: 0x0000E4B8 File Offset: 0x0000C6B8
|
||
private static IEnumerable<TResult> CreateGroupByIterator<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
IEnumerable<IGrouping<TKey, TElement>> groups = source.GroupBy(keySelector, elementSelector, comparer);
|
||
foreach (IGrouping<TKey, TElement> group in groups)
|
||
{
|
||
yield return resultSelector(group.Key, group);
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.</summary>
|
||
/// <returns>A collection of elements of type <paramref name="TResult" /> where each element represents a projection over a group and its key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="resultSelector">A function to create a result value from each group.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector" />.</typeparam>
|
||
// Token: 0x060002BA RID: 698 RVA: 0x0000E51C File Offset: 0x0000C71C
|
||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
|
||
{
|
||
return source.GroupBy(keySelector, resultSelector, null);
|
||
}
|
||
|
||
/// <summary>Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer.</summary>
|
||
/// <returns>A collection of elements of type <paramref name="TResult" /> where each element represents a projection over a group and its key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements to group.</param>
|
||
/// <param name="keySelector">A function to extract the key for each element.</param>
|
||
/// <param name="resultSelector">A function to create a result value from each group.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys with.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector" />.</typeparam>
|
||
// Token: 0x060002BB RID: 699 RVA: 0x0000E528 File Offset: 0x0000C728
|
||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeyResultSelectors(source, keySelector, resultSelector);
|
||
return source.CreateGroupByIterator(keySelector, resultSelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002BC RID: 700 RVA: 0x0000E53C File Offset: 0x0000C73C
|
||
private static IEnumerable<TResult> CreateGroupByIterator<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
IEnumerable<IGrouping<TKey, TSource>> groups = source.GroupBy(keySelector, comparer);
|
||
foreach (IGrouping<TKey, TSource> group in groups)
|
||
{
|
||
yield return resultSelector(group.Key, group);
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements of type <paramref name="TResult" /> that are obtained by performing a grouped join on two sequences.</returns>
|
||
/// <param name="outer">The first sequence to join.</param>
|
||
/// <param name="inner">The sequence to join to the first sequence.</param>
|
||
/// <param name="outerKeySelector">A function to extract the join key from each element of the first sequence.</param>
|
||
/// <param name="innerKeySelector">A function to extract the join key from each element of the second sequence.</param>
|
||
/// <param name="resultSelector">A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.</param>
|
||
/// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam>
|
||
/// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam>
|
||
/// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result elements.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="outer" /> or <paramref name="inner" /> or <paramref name="outerKeySelector" /> or <paramref name="innerKeySelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x060002BD RID: 701 RVA: 0x0000E590 File Offset: 0x0000C790
|
||
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
|
||
{
|
||
return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, null);
|
||
}
|
||
|
||
/// <summary>Correlates the elements of two sequences based on key equality and groups the results. A specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> is used to compare keys.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements of type <paramref name="TResult" /> that are obtained by performing a grouped join on two sequences.</returns>
|
||
/// <param name="outer">The first sequence to join.</param>
|
||
/// <param name="inner">The sequence to join to the first sequence.</param>
|
||
/// <param name="outerKeySelector">A function to extract the join key from each element of the first sequence.</param>
|
||
/// <param name="innerKeySelector">A function to extract the join key from each element of the second sequence.</param>
|
||
/// <param name="resultSelector">A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to hash and compare keys.</param>
|
||
/// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam>
|
||
/// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam>
|
||
/// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result elements.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="outer" /> or <paramref name="inner" /> or <paramref name="outerKeySelector" /> or <paramref name="innerKeySelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x060002BE RID: 702 RVA: 0x0000E5A0 File Offset: 0x0000C7A0
|
||
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.JoinSelectors(outer, inner, outerKeySelector, innerKeySelector, resultSelector);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TKey>.Default;
|
||
}
|
||
return outer.CreateGroupJoinIterator(inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002BF RID: 703 RVA: 0x0000E5D4 File Offset: 0x0000C7D4
|
||
private static IEnumerable<TResult> CreateGroupJoinIterator<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
ILookup<TKey, TInner> innerKeys = inner.ToLookup(innerKeySelector, comparer);
|
||
foreach (TOuter element in outer)
|
||
{
|
||
TKey outerKey = outerKeySelector(element);
|
||
if (innerKeys.Contains(outerKey))
|
||
{
|
||
yield return resultSelector(element, innerKeys[outerKey]);
|
||
}
|
||
else
|
||
{
|
||
yield return resultSelector(element, Enumerable.Empty<TInner>());
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Produces the set intersection of two sequences by using the default equality comparer to compare values.</summary>
|
||
/// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements that also appear in <paramref name="second" /> will be returned.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements that also appear in the first sequence will be returned.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x060002C0 RID: 704 RVA: 0x0000E648 File Offset: 0x0000C848
|
||
public static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
return first.Intersect(second, null);
|
||
}
|
||
|
||
/// <summary>Produces the set intersection of two sequences by using the specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</summary>
|
||
/// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements that also appear in <paramref name="second" /> will be returned.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements that also appear in the first sequence will be returned.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x060002C1 RID: 705 RVA: 0x0000E654 File Offset: 0x0000C854
|
||
public static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
return Enumerable.CreateIntersectIterator<TSource>(first, second, comparer);
|
||
}
|
||
|
||
// Token: 0x060002C2 RID: 706 RVA: 0x0000E674 File Offset: 0x0000C874
|
||
private static IEnumerable<TSource> CreateIntersectIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
HashSet<TSource> items = new HashSet<TSource>(second, comparer);
|
||
foreach (TSource element in first)
|
||
{
|
||
if (items.Remove(element))
|
||
{
|
||
yield return element;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Correlates the elements of two sequences based on matching keys. A specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> is used to compare keys.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that has elements of type <paramref name="TResult" /> that are obtained by performing an inner join on two sequences.</returns>
|
||
/// <param name="outer">The first sequence to join.</param>
|
||
/// <param name="inner">The sequence to join to the first sequence.</param>
|
||
/// <param name="outerKeySelector">A function to extract the join key from each element of the first sequence.</param>
|
||
/// <param name="innerKeySelector">A function to extract the join key from each element of the second sequence.</param>
|
||
/// <param name="resultSelector">A function to create a result element from two matching elements.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to hash and compare keys.</param>
|
||
/// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam>
|
||
/// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam>
|
||
/// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result elements.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="outer" /> or <paramref name="inner" /> or <paramref name="outerKeySelector" /> or <paramref name="innerKeySelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x060002C3 RID: 707 RVA: 0x0000E6BC File Offset: 0x0000C8BC
|
||
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.JoinSelectors(outer, inner, outerKeySelector, innerKeySelector, resultSelector);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TKey>.Default;
|
||
}
|
||
return outer.CreateJoinIterator(inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
|
||
}
|
||
|
||
// Token: 0x060002C4 RID: 708 RVA: 0x0000E6F0 File Offset: 0x0000C8F0
|
||
private static IEnumerable<TResult> CreateJoinIterator<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
ILookup<TKey, TInner> innerKeys = inner.ToLookup(innerKeySelector, comparer);
|
||
foreach (TOuter element in outer)
|
||
{
|
||
TKey outerKey = outerKeySelector(element);
|
||
if (innerKeys.Contains(outerKey))
|
||
{
|
||
foreach (TInner innerElement in innerKeys[outerKey])
|
||
{
|
||
yield return resultSelector(element, innerElement);
|
||
}
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that has elements of type <paramref name="TResult" /> that are obtained by performing an inner join on two sequences.</returns>
|
||
/// <param name="outer">The first sequence to join.</param>
|
||
/// <param name="inner">The sequence to join to the first sequence.</param>
|
||
/// <param name="outerKeySelector">A function to extract the join key from each element of the first sequence.</param>
|
||
/// <param name="innerKeySelector">A function to extract the join key from each element of the second sequence.</param>
|
||
/// <param name="resultSelector">A function to create a result element from two matching elements.</param>
|
||
/// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam>
|
||
/// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam>
|
||
/// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam>
|
||
/// <typeparam name="TResult">The type of the result elements.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="outer" /> or <paramref name="inner" /> or <paramref name="outerKeySelector" /> or <paramref name="innerKeySelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x060002C5 RID: 709 RVA: 0x0000E764 File Offset: 0x0000C964
|
||
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
|
||
{
|
||
return outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, null);
|
||
}
|
||
|
||
// Token: 0x060002C6 RID: 710 RVA: 0x0000E774 File Offset: 0x0000C974
|
||
private static TSource Last<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Enumerable.Fallback fallback)
|
||
{
|
||
bool flag = true;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (predicate(tsource2))
|
||
{
|
||
tsource = tsource2;
|
||
flag = false;
|
||
}
|
||
}
|
||
if (!flag)
|
||
{
|
||
return tsource;
|
||
}
|
||
if (fallback == Enumerable.Fallback.Throw)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the last element of a sequence.</summary>
|
||
/// <returns>The value at the last position in the source sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the last element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">The source sequence is empty.</exception>
|
||
// Token: 0x060002C7 RID: 711 RVA: 0x0000E804 File Offset: 0x0000CA04
|
||
public static TSource Last<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
ICollection<TSource> collection = source as ICollection<TSource>;
|
||
if (collection != null && collection.Count == 0)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list != null)
|
||
{
|
||
return list[list.Count - 1];
|
||
}
|
||
bool flag = true;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
tsource = tsource2;
|
||
flag = false;
|
||
}
|
||
if (!flag)
|
||
{
|
||
return tsource;
|
||
}
|
||
throw new InvalidOperationException();
|
||
}
|
||
|
||
/// <summary>Returns the last element of a sequence that satisfies a specified condition.</summary>
|
||
/// <returns>The last element in the sequence that passes the test in the specified predicate function.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">No element satisfies the condition in <paramref name="predicate" />.-or-The source sequence is empty.</exception>
|
||
// Token: 0x060002C8 RID: 712 RVA: 0x0000E8C0 File Offset: 0x0000CAC0
|
||
public static TSource Last<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.Last(predicate, Enumerable.Fallback.Throw);
|
||
}
|
||
|
||
/// <summary>Returns the last element of a sequence, or a default value if the sequence contains no elements.</summary>
|
||
/// <returns>default(<paramref name="TSource" />) if the source sequence is empty; otherwise, the last element in the <see cref="T:System.Collections.Generic.IEnumerable`1" />.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the last element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002C9 RID: 713 RVA: 0x0000E8D4 File Offset: 0x0000CAD4
|
||
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list != null)
|
||
{
|
||
return (list.Count <= 0) ? default(TSource) : list[list.Count - 1];
|
||
}
|
||
bool flag = true;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
tsource = tsource2;
|
||
flag = false;
|
||
}
|
||
if (!flag)
|
||
{
|
||
return tsource;
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.</summary>
|
||
/// <returns>default(<paramref name="TSource" />) if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return an element from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x060002CA RID: 714 RVA: 0x0000E988 File Offset: 0x0000CB88
|
||
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.Last(predicate, Enumerable.Fallback.Default);
|
||
}
|
||
|
||
/// <summary>Returns an <see cref="T:System.Int64" /> that represents the total number of elements in a sequence.</summary>
|
||
/// <returns>The number of elements in the source sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements to be counted.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The number of elements exceeds <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x060002CB RID: 715 RVA: 0x0000E99C File Offset: 0x0000CB9C
|
||
public static long LongCount<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
long num = 0L;
|
||
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
|
||
{
|
||
while (enumerator.MoveNext())
|
||
{
|
||
num += 1L;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Returns an <see cref="T:System.Int64" /> that represents how many elements in a sequence satisfy a condition.</summary>
|
||
/// <returns>A number that represents how many elements in the sequence satisfy the condition in the predicate function.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements to be counted.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The number of matching elements exceeds <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x060002CC RID: 716 RVA: 0x0000EA00 File Offset: 0x0000CC00
|
||
public static long LongCount<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
if (selector(tsource))
|
||
{
|
||
num += 1L;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002CD RID: 717 RVA: 0x0000EA74 File Offset: 0x0000CC74
|
||
public static int Max(this IEnumerable<int> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<int, int>(source, int.MinValue, (int a, int b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002CE RID: 718 RVA: 0x0000EAB0 File Offset: 0x0000CCB0
|
||
public static long Max(this IEnumerable<long> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<long, long>(source, long.MinValue, (long a, long b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002CF RID: 719 RVA: 0x0000EAF0 File Offset: 0x0000CCF0
|
||
public static double Max(this IEnumerable<double> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<double, double>(source, double.MinValue, (double a, double b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002D0 RID: 720 RVA: 0x0000EB30 File Offset: 0x0000CD30
|
||
public static float Max(this IEnumerable<float> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<float, float>(source, float.MinValue, (float a, float b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002D1 RID: 721 RVA: 0x0000EB6C File Offset: 0x0000CD6C
|
||
public static decimal Max(this IEnumerable<decimal> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<decimal, decimal>(source, decimal.MinValue, (decimal a, decimal b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of nullable <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the maximum value in the sequence. </returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002D2 RID: 722 RVA: 0x0000EBA4 File Offset: 0x0000CDA4
|
||
public static int? Max(this IEnumerable<int?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<int>(source, (int a, int b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of nullable <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the maximum value in the sequence. </returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002D3 RID: 723 RVA: 0x0000EBD0 File Offset: 0x0000CDD0
|
||
public static long? Max(this IEnumerable<long?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<long>(source, (long a, long b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of nullable <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002D4 RID: 724 RVA: 0x0000EBFC File Offset: 0x0000CDFC
|
||
public static double? Max(this IEnumerable<double?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<double>(source, (double a, double b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of nullable <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002D5 RID: 725 RVA: 0x0000EC28 File Offset: 0x0000CE28
|
||
public static float? Max(this IEnumerable<float?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<float>(source, (float a, float b) => Math.Max(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a sequence of nullable <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the maximum value in the sequence. </returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002D6 RID: 726 RVA: 0x0000EC54 File Offset: 0x0000CE54
|
||
public static decimal? Max(this IEnumerable<decimal?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<decimal>(source, (decimal a, decimal b) => Math.Max(a, b));
|
||
}
|
||
|
||
// Token: 0x060002D7 RID: 727 RVA: 0x0000EC80 File Offset: 0x0000CE80
|
||
private static T? IterateNullable<T>(IEnumerable<T?> source, Func<T, T, T> selector) where T : struct
|
||
{
|
||
bool flag = true;
|
||
T? t = null;
|
||
foreach (T? t2 in source)
|
||
{
|
||
if (t2 != null)
|
||
{
|
||
if (t == null)
|
||
{
|
||
t = new T?(t2.Value);
|
||
}
|
||
else
|
||
{
|
||
t = new T?(selector(t2.Value, t.Value));
|
||
}
|
||
flag = false;
|
||
}
|
||
}
|
||
if (flag)
|
||
{
|
||
return null;
|
||
}
|
||
return t;
|
||
}
|
||
|
||
// Token: 0x060002D8 RID: 728 RVA: 0x0000ED44 File Offset: 0x0000CF44
|
||
private static TRet? IterateNullable<TSource, TRet>(IEnumerable<TSource> source, Func<TSource, TRet?> source_selector, Func<TRet?, TRet?, bool> selector) where TRet : struct
|
||
{
|
||
bool flag = true;
|
||
TRet? tret = null;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
TRet? tret2 = source_selector(tsource);
|
||
if (tret == null)
|
||
{
|
||
tret = tret2;
|
||
}
|
||
else if (selector(tret2, tret))
|
||
{
|
||
tret = tret2;
|
||
}
|
||
flag = false;
|
||
}
|
||
if (flag)
|
||
{
|
||
return null;
|
||
}
|
||
return tret;
|
||
}
|
||
|
||
// Token: 0x060002D9 RID: 729 RVA: 0x0000EDEC File Offset: 0x0000CFEC
|
||
private static TSource IterateNullable<TSource>(IEnumerable<TSource> source, Func<TSource, TSource, bool> selector)
|
||
{
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (tsource2 != null)
|
||
{
|
||
if (tsource == null || selector(tsource2, tsource))
|
||
{
|
||
tsource = tsource2;
|
||
}
|
||
}
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
// Token: 0x060002DA RID: 730 RVA: 0x0000EE78 File Offset: 0x0000D078
|
||
private static TSource IterateNonNullable<TSource>(IEnumerable<TSource> source, Func<TSource, TSource, bool> selector)
|
||
{
|
||
TSource tsource = default(TSource);
|
||
bool flag = true;
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (flag)
|
||
{
|
||
tsource = tsource2;
|
||
flag = false;
|
||
}
|
||
else if (selector(tsource2, tsource))
|
||
{
|
||
tsource = tsource2;
|
||
}
|
||
}
|
||
if (flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the maximum value in a generic sequence.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002DB RID: 731 RVA: 0x0000EF08 File Offset: 0x0000D108
|
||
public static TSource Max<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
Comparer<TSource> comparer = Comparer<TSource>.Default;
|
||
Func<TSource, TSource, bool> func = (TSource a, TSource b) => comparer.Compare(a, b) > 0;
|
||
if (default(TSource) == null)
|
||
{
|
||
return Enumerable.IterateNullable<TSource>(source, func);
|
||
}
|
||
return Enumerable.IterateNonNullable<TSource>(source, func);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002DC RID: 732 RVA: 0x0000EF5C File Offset: 0x0000D15C
|
||
public static int Max<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, int>(source, int.MinValue, (TSource a, int b) => Math.Max(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002DD RID: 733 RVA: 0x0000EF9C File Offset: 0x0000D19C
|
||
public static long Max<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, long>(source, long.MinValue, (TSource a, long b) => Math.Max(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002DE RID: 734 RVA: 0x0000EFE0 File Offset: 0x0000D1E0
|
||
public static double Max<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, double>(source, double.MinValue, (TSource a, double b) => Math.Max(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002DF RID: 735 RVA: 0x0000F024 File Offset: 0x0000D224
|
||
public static float Max<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, float>(source, float.MinValue, (TSource a, float b) => Math.Max(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002E0 RID: 736 RVA: 0x0000F064 File Offset: 0x0000D264
|
||
public static decimal Max<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, decimal>(source, decimal.MinValue, (TSource a, decimal b) => Math.Max(selector(a), b));
|
||
}
|
||
|
||
// Token: 0x060002E1 RID: 737 RVA: 0x0000F0A8 File Offset: 0x0000D2A8
|
||
private static U Iterate<T, U>(IEnumerable<T> source, U initValue, Func<T, U, U> selector)
|
||
{
|
||
bool flag = true;
|
||
foreach (T t in source)
|
||
{
|
||
initValue = selector(t, initValue);
|
||
flag = false;
|
||
}
|
||
if (flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return initValue;
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E2 RID: 738 RVA: 0x0000F11C File Offset: 0x0000D31C
|
||
public static int? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, int>(source, selector, (int? a, int? b) => a != null && b != null && a.Value > b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E3 RID: 739 RVA: 0x0000F138 File Offset: 0x0000D338
|
||
public static long? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, long>(source, selector, (long? a, long? b) => a != null && b != null && a.Value > b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E4 RID: 740 RVA: 0x0000F154 File Offset: 0x0000D354
|
||
public static double? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, double>(source, selector, (double? a, double? b) => a != null && b != null && a.Value > b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E5 RID: 741 RVA: 0x0000F170 File Offset: 0x0000D370
|
||
public static float? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, float>(source, selector, (float? a, float? b) => a != null && b != null && a.Value > b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E6 RID: 742 RVA: 0x0000F18C File Offset: 0x0000D38C
|
||
public static decimal? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, decimal>(source, selector, (decimal? a, decimal? b) => a != null && b != null && a.Value > b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a generic sequence and returns the maximum resulting value.</summary>
|
||
/// <returns>The maximum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the maximum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002E7 RID: 743 RVA: 0x0000F1A8 File Offset: 0x0000D3A8
|
||
public static TResult Max<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.Select(selector).Max<TResult>();
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002E8 RID: 744 RVA: 0x0000F1C0 File Offset: 0x0000D3C0
|
||
public static int Min(this IEnumerable<int> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<int, int>(source, int.MaxValue, (int a, int b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002E9 RID: 745 RVA: 0x0000F1FC File Offset: 0x0000D3FC
|
||
public static long Min(this IEnumerable<long> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<long, long>(source, long.MaxValue, (long a, long b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002EA RID: 746 RVA: 0x0000F23C File Offset: 0x0000D43C
|
||
public static double Min(this IEnumerable<double> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<double, double>(source, double.MaxValue, (double a, double b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002EB RID: 747 RVA: 0x0000F27C File Offset: 0x0000D47C
|
||
public static float Min(this IEnumerable<float> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<float, float>(source, float.MaxValue, (float a, float b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002EC RID: 748 RVA: 0x0000F2B8 File Offset: 0x0000D4B8
|
||
public static decimal Min(this IEnumerable<decimal> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.Iterate<decimal, decimal>(source, decimal.MaxValue, (decimal a, decimal b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of nullable <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002ED RID: 749 RVA: 0x0000F2F0 File Offset: 0x0000D4F0
|
||
public static int? Min(this IEnumerable<int?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<int>(source, (int a, int b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of nullable <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002EE RID: 750 RVA: 0x0000F31C File Offset: 0x0000D51C
|
||
public static long? Min(this IEnumerable<long?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<long>(source, (long a, long b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of nullable <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002EF RID: 751 RVA: 0x0000F348 File Offset: 0x0000D548
|
||
public static double? Min(this IEnumerable<double?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<double>(source, (double a, double b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of nullable <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002F0 RID: 752 RVA: 0x0000F374 File Offset: 0x0000D574
|
||
public static float? Min(this IEnumerable<float?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<float>(source, (float a, float b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a sequence of nullable <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>A value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002F1 RID: 753 RVA: 0x0000F3A0 File Offset: 0x0000D5A0
|
||
public static decimal? Min(this IEnumerable<decimal?> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.IterateNullable<decimal>(source, (decimal a, decimal b) => Math.Min(a, b));
|
||
}
|
||
|
||
/// <summary>Returns the minimum value in a generic sequence.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002F2 RID: 754 RVA: 0x0000F3CC File Offset: 0x0000D5CC
|
||
public static TSource Min<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
Comparer<TSource> comparer = Comparer<TSource>.Default;
|
||
Func<TSource, TSource, bool> func = (TSource a, TSource b) => comparer.Compare(a, b) < 0;
|
||
if (default(TSource) == null)
|
||
{
|
||
return Enumerable.IterateNullable<TSource>(source, func);
|
||
}
|
||
return Enumerable.IterateNonNullable<TSource>(source, func);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002F3 RID: 755 RVA: 0x0000F420 File Offset: 0x0000D620
|
||
public static int Min<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, int>(source, int.MaxValue, (TSource a, int b) => Math.Min(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002F4 RID: 756 RVA: 0x0000F460 File Offset: 0x0000D660
|
||
public static long Min<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, long>(source, long.MaxValue, (TSource a, long b) => Math.Min(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002F5 RID: 757 RVA: 0x0000F4A4 File Offset: 0x0000D6A4
|
||
public static double Min<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, double>(source, double.MaxValue, (TSource a, double b) => Math.Min(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002F6 RID: 758 RVA: 0x0000F4E8 File Offset: 0x0000D6E8
|
||
public static float Min<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, float>(source, float.MaxValue, (TSource a, float b) => Math.Min(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">
|
||
/// <paramref name="source" /> contains no elements.</exception>
|
||
// Token: 0x060002F7 RID: 759 RVA: 0x0000F528 File Offset: 0x0000D728
|
||
public static decimal Min<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.Iterate<TSource, decimal>(source, decimal.MaxValue, (TSource a, decimal b) => Math.Min(selector(a), b));
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002F8 RID: 760 RVA: 0x0000F56C File Offset: 0x0000D76C
|
||
public static int? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, int>(source, selector, (int? a, int? b) => a != null && b != null && a.Value < b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002F9 RID: 761 RVA: 0x0000F588 File Offset: 0x0000D788
|
||
public static long? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, long>(source, selector, (long? a, long? b) => a != null && b != null && a.Value < b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002FA RID: 762 RVA: 0x0000F5A4 File Offset: 0x0000D7A4
|
||
public static float? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, float>(source, selector, (float? a, float? b) => a != null && b != null && a.Value < b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002FB RID: 763 RVA: 0x0000F5C0 File Offset: 0x0000D7C0
|
||
public static double? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, double>(source, selector, (double? a, double? b) => a != null && b != null && a.Value < b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.</summary>
|
||
/// <returns>The value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002FC RID: 764 RVA: 0x0000F5DC File Offset: 0x0000D7DC
|
||
public static decimal? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.IterateNullable<TSource, decimal>(source, selector, (decimal? a, decimal? b) => a != null && b != null && a.Value < b.Value);
|
||
}
|
||
|
||
/// <summary>Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.</summary>
|
||
/// <returns>The minimum value in the sequence.</returns>
|
||
/// <param name="source">A sequence of values to determine the minimum value of.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x060002FD RID: 765 RVA: 0x0000F5F8 File Offset: 0x0000D7F8
|
||
public static TResult Min<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.Select(selector).Min<TResult>();
|
||
}
|
||
|
||
/// <summary>Filters the elements of an <see cref="T:System.Collections.IEnumerable" /> based on a specified type.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements from the input sequence of type <paramref name="TResult" />.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.IEnumerable" /> whose elements to filter.</param>
|
||
/// <typeparam name="TResult">The type to filter the elements of the sequence on.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x060002FE RID: 766 RVA: 0x0000F610 File Offset: 0x0000D810
|
||
public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.CreateOfTypeIterator<TResult>(source);
|
||
}
|
||
|
||
// Token: 0x060002FF RID: 767 RVA: 0x0000F620 File Offset: 0x0000D820
|
||
private static IEnumerable<TResult> CreateOfTypeIterator<TResult>(IEnumerable source)
|
||
{
|
||
foreach (object element in source)
|
||
{
|
||
if (element is TResult)
|
||
{
|
||
yield return (TResult)((object)element);
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Sorts the elements of a sequence in ascending order according to a key.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted according to a key.</returns>
|
||
/// <param name="source">A sequence of values to order.</param>
|
||
/// <param name="keySelector">A function to extract a key from an element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000300 RID: 768 RVA: 0x0000F64C File Offset: 0x0000D84C
|
||
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.OrderBy(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Sorts the elements of a sequence in ascending order by using a specified comparer.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted according to a key.</returns>
|
||
/// <param name="source">A sequence of values to order.</param>
|
||
/// <param name="keySelector">A function to extract a key from an element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000301 RID: 769 RVA: 0x0000F658 File Offset: 0x0000D858
|
||
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeySelector(source, keySelector);
|
||
return new OrderedSequence<TSource, TKey>(source, keySelector, comparer, SortDirection.Ascending);
|
||
}
|
||
|
||
/// <summary>Sorts the elements of a sequence in descending order according to a key.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted in descending order according to a key.</returns>
|
||
/// <param name="source">A sequence of values to order.</param>
|
||
/// <param name="keySelector">A function to extract a key from an element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000302 RID: 770 RVA: 0x0000F66C File Offset: 0x0000D86C
|
||
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.OrderByDescending(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Sorts the elements of a sequence in descending order by using a specified comparer.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted in descending order according to a key.</returns>
|
||
/// <param name="source">A sequence of values to order.</param>
|
||
/// <param name="keySelector">A function to extract a key from an element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000303 RID: 771 RVA: 0x0000F678 File Offset: 0x0000D878
|
||
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeySelector(source, keySelector);
|
||
return new OrderedSequence<TSource, TKey>(source, keySelector, comparer, SortDirection.Descending);
|
||
}
|
||
|
||
/// <summary>Generates a sequence of integral numbers within a specified range.</summary>
|
||
/// <returns>An IEnumerable<Int32> in C# or IEnumerable(Of Int32) in Visual Basic that contains a range of sequential integral numbers.</returns>
|
||
/// <param name="start">The value of the first integer in the sequence.</param>
|
||
/// <param name="count">The number of sequential integers to generate.</param>
|
||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||
/// <paramref name="count" /> is less than 0.-or-<paramref name="start" /> + <paramref name="count" /> -1 is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x06000304 RID: 772 RVA: 0x0000F68C File Offset: 0x0000D88C
|
||
public static IEnumerable<int> Range(int start, int count)
|
||
{
|
||
if (count < 0)
|
||
{
|
||
throw new ArgumentOutOfRangeException("count");
|
||
}
|
||
long num = (long)start + (long)count - 1L;
|
||
if (num > 2147483647L)
|
||
{
|
||
throw new ArgumentOutOfRangeException();
|
||
}
|
||
return Enumerable.CreateRangeIterator(start, (int)num);
|
||
}
|
||
|
||
// Token: 0x06000305 RID: 773 RVA: 0x0000F6D0 File Offset: 0x0000D8D0
|
||
private static IEnumerable<int> CreateRangeIterator(int start, int upto)
|
||
{
|
||
for (int i = start; i <= upto; i++)
|
||
{
|
||
yield return i;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Generates a sequence that contains one repeated value.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains a repeated value.</returns>
|
||
/// <param name="element">The value to be repeated.</param>
|
||
/// <param name="count">The number of times to repeat the value in the generated sequence.</param>
|
||
/// <typeparam name="TResult">The type of the value to be repeated in the result sequence.</typeparam>
|
||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||
/// <paramref name="count" /> is less than 0.</exception>
|
||
// Token: 0x06000306 RID: 774 RVA: 0x0000F708 File Offset: 0x0000D908
|
||
public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count)
|
||
{
|
||
if (count < 0)
|
||
{
|
||
throw new ArgumentOutOfRangeException();
|
||
}
|
||
return Enumerable.CreateRepeatIterator<TResult>(element, count);
|
||
}
|
||
|
||
// Token: 0x06000307 RID: 775 RVA: 0x0000F720 File Offset: 0x0000D920
|
||
private static IEnumerable<TResult> CreateRepeatIterator<TResult>(TResult element, int count)
|
||
{
|
||
for (int i = 0; i < count; i++)
|
||
{
|
||
yield return element;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Inverts the order of the elements in a sequence.</summary>
|
||
/// <returns>A sequence whose elements correspond to those of the input sequence in reverse order.</returns>
|
||
/// <param name="source">A sequence of values to reverse.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000308 RID: 776 RVA: 0x0000F758 File Offset: 0x0000D958
|
||
public static IEnumerable<TSource> Reverse<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.CreateReverseIterator<TSource>(source);
|
||
}
|
||
|
||
// Token: 0x06000309 RID: 777 RVA: 0x0000F768 File Offset: 0x0000D968
|
||
private static IEnumerable<TSource> CreateReverseIterator<TSource>(IEnumerable<TSource> source)
|
||
{
|
||
IList<TSource> list = source as IList<TSource>;
|
||
if (list == null)
|
||
{
|
||
list = new List<TSource>(source);
|
||
}
|
||
for (int i = list.Count - 1; i >= 0; i--)
|
||
{
|
||
yield return list[i];
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence into a new form.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
|
||
/// <param name="source">A sequence of values to invoke a transform function on.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600030A RID: 778 RVA: 0x0000F794 File Offset: 0x0000D994
|
||
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.CreateSelectIterator<TSource, TResult>(source, selector);
|
||
}
|
||
|
||
// Token: 0x0600030B RID: 779 RVA: 0x0000F7A4 File Offset: 0x0000D9A4
|
||
private static IEnumerable<TResult> CreateSelectIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||
{
|
||
foreach (TSource element in source)
|
||
{
|
||
yield return selector(element);
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence into a new form by incorporating the element's index.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the transform function on each element of <paramref name="source" />.</returns>
|
||
/// <param name="source">A sequence of values to invoke a transform function on.</param>
|
||
/// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the value returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600030C RID: 780 RVA: 0x0000F7DC File Offset: 0x0000D9DC
|
||
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, TResult> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.CreateSelectIterator<TSource, TResult>(source, selector);
|
||
}
|
||
|
||
// Token: 0x0600030D RID: 781 RVA: 0x0000F7EC File Offset: 0x0000D9EC
|
||
private static IEnumerable<TResult> CreateSelectIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, int, TResult> selector)
|
||
{
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
yield return selector(element, counter);
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence to an <see cref="T:System.Collections.Generic.IEnumerable`1" /> and flattens the resulting sequences into one sequence.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
|
||
/// <param name="source">A sequence of values to project.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the elements of the sequence returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600030E RID: 782 RVA: 0x0000F824 File Offset: 0x0000DA24
|
||
public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.CreateSelectManyIterator<TSource, TResult>(source, selector);
|
||
}
|
||
|
||
// Token: 0x0600030F RID: 783 RVA: 0x0000F834 File Offset: 0x0000DA34
|
||
private static IEnumerable<TResult> CreateSelectManyIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
|
||
{
|
||
foreach (TSource element in source)
|
||
{
|
||
foreach (TResult item in selector(element))
|
||
{
|
||
yield return item;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence to an <see cref="T:System.Collections.Generic.IEnumerable`1" />, and flattens the resulting sequences into one sequence. The index of each source element is used in the projected form of that element.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the one-to-many transform function on each element of an input sequence.</returns>
|
||
/// <param name="source">A sequence of values to project.</param>
|
||
/// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the elements of the sequence returned by <paramref name="selector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x06000310 RID: 784 RVA: 0x0000F86C File Offset: 0x0000DA6C
|
||
public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return Enumerable.CreateSelectManyIterator<TSource, TResult>(source, selector);
|
||
}
|
||
|
||
// Token: 0x06000311 RID: 785 RVA: 0x0000F87C File Offset: 0x0000DA7C
|
||
private static IEnumerable<TResult> CreateSelectManyIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)
|
||
{
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
foreach (TResult item in selector(element, counter))
|
||
{
|
||
yield return item;
|
||
}
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence to an <see cref="T:System.Collections.Generic.IEnumerable`1" />, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the one-to-many transform function <paramref name="collectionSelector" /> on each element of <paramref name="source" /> and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
|
||
/// <param name="source">A sequence of values to project.</param>
|
||
/// <param name="collectionSelector">A transform function to apply to each element of the input sequence.</param>
|
||
/// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TCollection">The type of the intermediate elements collected by <paramref name="collectionSelector" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the elements of the resulting sequence.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x06000312 RID: 786 RVA: 0x0000F8B4 File Offset: 0x0000DAB4
|
||
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> selector)
|
||
{
|
||
Check.SourceAndCollectionSelectors(source, collectionSelector, selector);
|
||
return Enumerable.CreateSelectManyIterator<TSource, TCollection, TResult>(source, collectionSelector, selector);
|
||
}
|
||
|
||
// Token: 0x06000313 RID: 787 RVA: 0x0000F8C8 File Offset: 0x0000DAC8
|
||
private static IEnumerable<TResult> CreateSelectManyIterator<TSource, TCollection, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> selector)
|
||
{
|
||
foreach (TSource element in source)
|
||
{
|
||
foreach (TCollection collection in collectionSelector(element))
|
||
{
|
||
yield return selector(element, collection);
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Projects each element of a sequence to an <see cref="T:System.Collections.Generic.IEnumerable`1" />, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. The index of each source element is used in the intermediate projected form of that element.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose elements are the result of invoking the one-to-many transform function <paramref name="collectionSelector" /> on each element of <paramref name="source" /> and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
|
||
/// <param name="source">A sequence of values to project.</param>
|
||
/// <param name="collectionSelector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
|
||
/// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TCollection">The type of the intermediate elements collected by <paramref name="collectionSelector" />.</typeparam>
|
||
/// <typeparam name="TResult">The type of the elements of the resulting sequence.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
|
||
// Token: 0x06000314 RID: 788 RVA: 0x0000F910 File Offset: 0x0000DB10
|
||
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> selector)
|
||
{
|
||
Check.SourceAndCollectionSelectors(source, collectionSelector, selector);
|
||
return Enumerable.CreateSelectManyIterator<TSource, TCollection, TResult>(source, collectionSelector, selector);
|
||
}
|
||
|
||
// Token: 0x06000315 RID: 789 RVA: 0x0000F924 File Offset: 0x0000DB24
|
||
private static IEnumerable<TResult> CreateSelectManyIterator<TSource, TCollection, TResult>(IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> selector)
|
||
{
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
TSource tsource = element;
|
||
int num;
|
||
counter = (num = counter) + 1;
|
||
foreach (TCollection collection in collectionSelector(tsource, num))
|
||
{
|
||
yield return selector(element, collection);
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
// Token: 0x06000316 RID: 790 RVA: 0x0000F96C File Offset: 0x0000DB6C
|
||
private static TSource Single<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Enumerable.Fallback fallback)
|
||
{
|
||
bool flag = false;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (predicate(tsource2))
|
||
{
|
||
if (flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
flag = true;
|
||
tsource = tsource2;
|
||
}
|
||
}
|
||
if (!flag && fallback == Enumerable.Fallback.Throw)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.</summary>
|
||
/// <returns>The single element of the input sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the single element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">The input sequence contains more than one element.-or-The input sequence is empty.</exception>
|
||
// Token: 0x06000317 RID: 791 RVA: 0x0000FA08 File Offset: 0x0000DC08
|
||
public static TSource Single<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
bool flag = false;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
flag = true;
|
||
tsource = tsource2;
|
||
}
|
||
if (!flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.</summary>
|
||
/// <returns>The single element of the input sequence that satisfies a condition.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return a single element from.</param>
|
||
/// <param name="predicate">A function to test an element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">No element satisfies the condition in <paramref name="predicate" />.-or-More than one element satisfies the condition in <paramref name="predicate" />.-or-The source sequence is empty.</exception>
|
||
// Token: 0x06000318 RID: 792 RVA: 0x0000FA90 File Offset: 0x0000DC90
|
||
public static TSource Single<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.Single(predicate, Enumerable.Fallback.Throw);
|
||
}
|
||
|
||
/// <summary>Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.</summary>
|
||
/// <returns>The single element of the input sequence, or default(<paramref name="TSource" />) if the sequence contains no elements.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return the single element of.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">The input sequence contains more than one element.</exception>
|
||
// Token: 0x06000319 RID: 793 RVA: 0x0000FAA4 File Offset: 0x0000DCA4
|
||
public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
bool flag = false;
|
||
TSource tsource = default(TSource);
|
||
foreach (TSource tsource2 in source)
|
||
{
|
||
if (flag)
|
||
{
|
||
throw new InvalidOperationException();
|
||
}
|
||
flag = true;
|
||
tsource = tsource2;
|
||
}
|
||
return tsource;
|
||
}
|
||
|
||
/// <summary>Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.</summary>
|
||
/// <returns>The single element of the input sequence that satisfies the condition, or default(<paramref name="TSource" />) if no such element is found.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return a single element from.</param>
|
||
/// <param name="predicate">A function to test an element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
/// <exception cref="T:System.InvalidOperationException">More than one element satisfies the condition in <paramref name="predicate" />.</exception>
|
||
// Token: 0x0600031A RID: 794 RVA: 0x0000FB20 File Offset: 0x0000DD20
|
||
public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.Single(predicate, Enumerable.Fallback.Default);
|
||
}
|
||
|
||
/// <summary>Bypasses a specified number of elements in a sequence and then returns the remaining elements.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements that occur after the specified index in the input sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return elements from.</param>
|
||
/// <param name="count">The number of elements to skip before returning the remaining elements.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600031B RID: 795 RVA: 0x0000FB34 File Offset: 0x0000DD34
|
||
public static IEnumerable<TSource> Skip<TSource>(this IEnumerable<TSource> source, int count)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.CreateSkipIterator<TSource>(source, count);
|
||
}
|
||
|
||
// Token: 0x0600031C RID: 796 RVA: 0x0000FB44 File Offset: 0x0000DD44
|
||
private static IEnumerable<TSource> CreateSkipIterator<TSource>(IEnumerable<TSource> source, int count)
|
||
{
|
||
IEnumerator<TSource> enumerator = source.GetEnumerator();
|
||
try
|
||
{
|
||
do
|
||
{
|
||
int num;
|
||
count = (num = count) - 1;
|
||
if (num <= 0)
|
||
{
|
||
goto Block_4;
|
||
}
|
||
}
|
||
while (enumerator.MoveNext());
|
||
yield break;
|
||
Block_4:
|
||
while (enumerator.MoveNext())
|
||
{
|
||
TSource tsource = enumerator.Current;
|
||
yield return tsource;
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
enumerator.Dispose();
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by <paramref name="predicate" />.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return elements from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x0600031D RID: 797 RVA: 0x0000FB7C File Offset: 0x0000DD7C
|
||
public static IEnumerable<TSource> SkipWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return Enumerable.CreateSkipWhileIterator<TSource>(source, predicate);
|
||
}
|
||
|
||
// Token: 0x0600031E RID: 798 RVA: 0x0000FB8C File Offset: 0x0000DD8C
|
||
private static IEnumerable<TSource> CreateSkipWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
bool yield = false;
|
||
foreach (TSource element in source)
|
||
{
|
||
if (yield)
|
||
{
|
||
yield return element;
|
||
}
|
||
else if (!predicate(element))
|
||
{
|
||
yield return element;
|
||
yield = true;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by <paramref name="predicate" />.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to return elements from.</param>
|
||
/// <param name="predicate">A function to test each source element for a condition; the second parameter of the function represents the index of the source element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x0600031F RID: 799 RVA: 0x0000FBC4 File Offset: 0x0000DDC4
|
||
public static IEnumerable<TSource> SkipWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return Enumerable.CreateSkipWhileIterator<TSource>(source, predicate);
|
||
}
|
||
|
||
// Token: 0x06000320 RID: 800 RVA: 0x0000FBD4 File Offset: 0x0000DDD4
|
||
private static IEnumerable<TSource> CreateSkipWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
int counter = 0;
|
||
bool yield = false;
|
||
foreach (TSource element in source)
|
||
{
|
||
if (yield)
|
||
{
|
||
yield return element;
|
||
}
|
||
else if (!predicate(element, counter))
|
||
{
|
||
yield return element;
|
||
yield = true;
|
||
}
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x06000321 RID: 801 RVA: 0x0000FC0C File Offset: 0x0000DE0C
|
||
public static int Sum(this IEnumerable<int> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.Sum((int a, int b) => checked(a + b));
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x06000322 RID: 802 RVA: 0x0000FC38 File Offset: 0x0000DE38
|
||
public static int? Sum(this IEnumerable<int?> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.SumNullable(new int?(0), (int? total, int? element) => (element == null) ? total : ((total == null || element == null) ? null : new int?(checked(total.Value + element.Value))));
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x06000323 RID: 803 RVA: 0x0000FC6C File Offset: 0x0000DE6C
|
||
public static int Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
int num = 0;
|
||
checked
|
||
{
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
return num;
|
||
}
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
|
||
// Token: 0x06000324 RID: 804 RVA: 0x0000FCD8 File Offset: 0x0000DED8
|
||
public static int? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.SumNullable(new int?(0), delegate(int? a, TSource b)
|
||
{
|
||
int? num = selector(b);
|
||
return (num == null) ? a : ((a == null) ? null : new int?(checked(a.Value + num.Value)));
|
||
});
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000325 RID: 805 RVA: 0x0000FD18 File Offset: 0x0000DF18
|
||
public static long Sum(this IEnumerable<long> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.Sum((long a, long b) => checked(a + b));
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000326 RID: 806 RVA: 0x0000FD44 File Offset: 0x0000DF44
|
||
public static long? Sum(this IEnumerable<long?> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.SumNullable(new long?(0L), (long? total, long? element) => (element == null) ? total : ((total == null || element == null) ? null : new long?(checked(total.Value + element.Value))));
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000327 RID: 807 RVA: 0x0000FD84 File Offset: 0x0000DF84
|
||
public static long Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
long num = 0L;
|
||
checked
|
||
{
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
return num;
|
||
}
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
|
||
// Token: 0x06000328 RID: 808 RVA: 0x0000FDF0 File Offset: 0x0000DFF0
|
||
public static long? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.SumNullable(new long?(0L), delegate(long? a, TSource b)
|
||
{
|
||
long? num = selector(b);
|
||
return (num == null) ? a : ((a == null) ? null : new long?(checked(a.Value + num.Value)));
|
||
});
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000329 RID: 809 RVA: 0x0000FE30 File Offset: 0x0000E030
|
||
public static double Sum(this IEnumerable<double> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.Sum((double a, double b) => a + b);
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600032A RID: 810 RVA: 0x0000FE5C File Offset: 0x0000E05C
|
||
public static double? Sum(this IEnumerable<double?> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.SumNullable(new double?(0.0), (double? total, double? element) => (element == null) ? total : ((total == null || element == null) ? null : new double?(total.Value + element.Value)));
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600032B RID: 811 RVA: 0x0000FE98 File Offset: 0x0000E098
|
||
public static double Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
double num = 0.0;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600032C RID: 812 RVA: 0x0000FF0C File Offset: 0x0000E10C
|
||
public static double? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.SumNullable(new double?(0.0), delegate(double? a, TSource b)
|
||
{
|
||
double? num = selector(b);
|
||
return (num == null) ? a : ((a == null) ? null : new double?(a.Value + num.Value));
|
||
});
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600032D RID: 813 RVA: 0x0000FF54 File Offset: 0x0000E154
|
||
public static float Sum(this IEnumerable<float> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.Sum((float a, float b) => a + b);
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x0600032E RID: 814 RVA: 0x0000FF80 File Offset: 0x0000E180
|
||
public static float? Sum(this IEnumerable<float?> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.SumNullable(new float?(0f), (float? total, float? element) => (element == null) ? total : ((total == null || element == null) ? null : new float?(total.Value + element.Value)));
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x0600032F RID: 815 RVA: 0x0000FFB8 File Offset: 0x0000E1B8
|
||
public static float Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
float num = 0f;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
// Token: 0x06000330 RID: 816 RVA: 0x00010028 File Offset: 0x0000E228
|
||
public static float? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.SumNullable(new float?(0f), delegate(float? a, TSource b)
|
||
{
|
||
float? num = selector(b);
|
||
return (num == null) ? a : ((a == null) ? null : new float?(a.Value + num.Value));
|
||
});
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000331 RID: 817 RVA: 0x0001006C File Offset: 0x0000E26C
|
||
public static decimal Sum(this IEnumerable<decimal> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.Sum((decimal a, decimal b) => a + b);
|
||
}
|
||
|
||
/// <summary>Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.</summary>
|
||
/// <returns>The sum of the values in the sequence.</returns>
|
||
/// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000332 RID: 818 RVA: 0x00010098 File Offset: 0x0000E298
|
||
public static decimal? Sum(this IEnumerable<decimal?> source)
|
||
{
|
||
Check.Source(source);
|
||
return source.SumNullable(new decimal?(0m), (decimal? total, decimal? element) => (element == null) ? total : ((total == null || element == null) ? null : new decimal?(total.Value + element.Value)));
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000333 RID: 819 RVA: 0x000100DC File Offset: 0x0000E2DC
|
||
public static decimal Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
decimal num = 0m;
|
||
foreach (TSource tsource in source)
|
||
{
|
||
num += selector(tsource);
|
||
}
|
||
return num;
|
||
}
|
||
|
||
/// <summary>Computes the sum of the sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.</summary>
|
||
/// <returns>The sum of the projected values.</returns>
|
||
/// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
||
/// <param name="selector">A transform function to apply to each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
|
||
/// <exception cref="T:System.OverflowException">The sum is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
|
||
// Token: 0x06000334 RID: 820 RVA: 0x00010150 File Offset: 0x0000E350
|
||
public static decimal? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
|
||
{
|
||
Check.SourceAndSelector(source, selector);
|
||
return source.SumNullable(new decimal?(0m), delegate(decimal? a, TSource b)
|
||
{
|
||
decimal? num = selector(b);
|
||
return (num == null) ? a : ((a == null) ? null : new decimal?(a.Value + num.Value));
|
||
});
|
||
}
|
||
|
||
// Token: 0x06000335 RID: 821 RVA: 0x00010194 File Offset: 0x0000E394
|
||
private static TR Sum<TA, TR>(this IEnumerable<TA> source, Func<TR, TA, TR> selector)
|
||
{
|
||
TR tr = default(TR);
|
||
long num = 0L;
|
||
foreach (TA ta in source)
|
||
{
|
||
tr = selector(tr, ta);
|
||
num += 1L;
|
||
}
|
||
return tr;
|
||
}
|
||
|
||
// Token: 0x06000336 RID: 822 RVA: 0x00010208 File Offset: 0x0000E408
|
||
private static TR SumNullable<TA, TR>(this IEnumerable<TA> source, TR zero, Func<TR, TA, TR> selector)
|
||
{
|
||
TR tr = zero;
|
||
foreach (TA ta in source)
|
||
{
|
||
tr = selector(tr, ta);
|
||
}
|
||
return tr;
|
||
}
|
||
|
||
/// <summary>Returns a specified number of contiguous elements from the start of a sequence.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the specified number of elements from the start of the input sequence.</returns>
|
||
/// <param name="source">The sequence to return elements from.</param>
|
||
/// <param name="count">The number of elements to return.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000337 RID: 823 RVA: 0x0001026C File Offset: 0x0000E46C
|
||
public static IEnumerable<TSource> Take<TSource>(this IEnumerable<TSource> source, int count)
|
||
{
|
||
Check.Source(source);
|
||
return Enumerable.CreateTakeIterator<TSource>(source, count);
|
||
}
|
||
|
||
// Token: 0x06000338 RID: 824 RVA: 0x0001027C File Offset: 0x0000E47C
|
||
private static IEnumerable<TSource> CreateTakeIterator<TSource>(IEnumerable<TSource> source, int count)
|
||
{
|
||
if (count <= 0)
|
||
{
|
||
yield break;
|
||
}
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
yield return element;
|
||
if (++counter == count)
|
||
{
|
||
yield break;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Returns elements from a sequence as long as a specified condition is true.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements from the input sequence that occur before the element at which the test no longer passes.</returns>
|
||
/// <param name="source">A sequence to return elements from.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x06000339 RID: 825 RVA: 0x000102B4 File Offset: 0x0000E4B4
|
||
public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return Enumerable.CreateTakeWhileIterator<TSource>(source, predicate);
|
||
}
|
||
|
||
// Token: 0x0600033A RID: 826 RVA: 0x000102C4 File Offset: 0x0000E4C4
|
||
private static IEnumerable<TSource> CreateTakeWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
foreach (TSource element in source)
|
||
{
|
||
if (!predicate(element))
|
||
{
|
||
yield break;
|
||
}
|
||
yield return element;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements from the input sequence that occur before the element at which the test no longer passes.</returns>
|
||
/// <param name="source">The sequence to return elements from.</param>
|
||
/// <param name="predicate">A function to test each source element for a condition; the second parameter of the function represents the index of the source element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x0600033B RID: 827 RVA: 0x000102FC File Offset: 0x0000E4FC
|
||
public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return Enumerable.CreateTakeWhileIterator<TSource>(source, predicate);
|
||
}
|
||
|
||
// Token: 0x0600033C RID: 828 RVA: 0x0001030C File Offset: 0x0000E50C
|
||
private static IEnumerable<TSource> CreateTakeWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
if (!predicate(element, counter))
|
||
{
|
||
yield break;
|
||
}
|
||
yield return element;
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted according to a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Linq.IOrderedEnumerable`1" /> that contains elements to sort.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x0600033D RID: 829 RVA: 0x00010344 File Offset: 0x0000E544
|
||
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.ThenBy(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted according to a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Linq.IOrderedEnumerable`1" /> that contains elements to sort.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x0600033E RID: 830 RVA: 0x00010350 File Offset: 0x0000E550
|
||
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeySelector(source, keySelector);
|
||
return source.CreateOrderedEnumerable<TKey>(keySelector, comparer, false);
|
||
}
|
||
|
||
/// <summary>Performs a subsequent ordering of the elements in a sequence in descending order, according to a key.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted in descending order according to a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Linq.IOrderedEnumerable`1" /> that contains elements to sort.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x0600033F RID: 831 RVA: 0x00010364 File Offset: 0x0000E564
|
||
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.ThenByDescending(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.</summary>
|
||
/// <returns>An <see cref="T:System.Linq.IOrderedEnumerable`1" /> whose elements are sorted in descending order according to a key.</returns>
|
||
/// <param name="source">An <see cref="T:System.Linq.IOrderedEnumerable`1" /> that contains elements to sort.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000340 RID: 832 RVA: 0x00010370 File Offset: 0x0000E570
|
||
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeySelector(source, keySelector);
|
||
return source.CreateOrderedEnumerable<TKey>(keySelector, comparer, true);
|
||
}
|
||
|
||
/// <summary>Creates an array from a <see cref="T:System.Collections.Generic.IEnumerable`1" />.</summary>
|
||
/// <returns>An array that contains the elements from the input sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create an array from.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000341 RID: 833 RVA: 0x00010384 File Offset: 0x0000E584
|
||
public static TSource[] ToArray<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
ICollection<TSource> collection = source as ICollection<TSource>;
|
||
if (collection != null)
|
||
{
|
||
TSource[] array = new TSource[collection.Count];
|
||
collection.CopyTo(array, 0);
|
||
return array;
|
||
}
|
||
return new List<TSource>(source).ToArray();
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Collections.Generic.Dictionary`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to specified key selector and element selector functions.</summary>
|
||
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2" /> that contains values of type <paramref name="TElement" /> selected from the input sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Collections.Generic.Dictionary`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.-or-<paramref name="keySelector" /> produces a key that is null.</exception>
|
||
/// <exception cref="T:System.ArgumentException">
|
||
/// <paramref name="keySelector" /> produces duplicate keys for two elements.</exception>
|
||
// Token: 0x06000342 RID: 834 RVA: 0x000103C8 File Offset: 0x0000E5C8
|
||
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
|
||
{
|
||
return source.ToDictionary(keySelector, elementSelector, null);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Collections.Generic.Dictionary`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function, a comparer, and an element selector function.</summary>
|
||
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2" /> that contains values of type <paramref name="TElement" /> selected from the input sequence.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Collections.Generic.Dictionary`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.-or-<paramref name="keySelector" /> produces a key that is null.</exception>
|
||
/// <exception cref="T:System.ArgumentException">
|
||
/// <paramref name="keySelector" /> produces duplicate keys for two elements.</exception>
|
||
// Token: 0x06000343 RID: 835 RVA: 0x000103D4 File Offset: 0x0000E5D4
|
||
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeyElementSelectors(source, keySelector, elementSelector);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TKey>.Default;
|
||
}
|
||
Dictionary<TKey, TElement> dictionary = new Dictionary<TKey, TElement>(comparer);
|
||
foreach (TSource tsource in source)
|
||
{
|
||
dictionary.Add(keySelector(tsource), elementSelector(tsource));
|
||
}
|
||
return dictionary;
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Collections.Generic.Dictionary`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function.</summary>
|
||
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2" /> that contains keys and values.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Collections.Generic.Dictionary`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.-or-<paramref name="keySelector" /> produces a key that is null.</exception>
|
||
/// <exception cref="T:System.ArgumentException">
|
||
/// <paramref name="keySelector" /> produces duplicate keys for two elements.</exception>
|
||
// Token: 0x06000344 RID: 836 RVA: 0x0001045C File Offset: 0x0000E65C
|
||
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.ToDictionary(keySelector, null);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Collections.Generic.Dictionary`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function and key comparer.</summary>
|
||
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2" /> that contains keys and values.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Collections.Generic.Dictionary`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the keys returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.-or-<paramref name="keySelector" /> produces a key that is null.</exception>
|
||
/// <exception cref="T:System.ArgumentException">
|
||
/// <paramref name="keySelector" /> produces duplicate keys for two elements.</exception>
|
||
// Token: 0x06000345 RID: 837 RVA: 0x00010468 File Offset: 0x0000E668
|
||
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
return source.ToDictionary(keySelector, Enumerable.Function<TSource>.Identity, comparer);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Collections.Generic.List`1" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" />.</summary>
|
||
/// <returns>A <see cref="T:System.Collections.Generic.List`1" /> that contains elements from the input sequence.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Collections.Generic.List`1" /> from.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> is null.</exception>
|
||
// Token: 0x06000346 RID: 838 RVA: 0x00010478 File Offset: 0x0000E678
|
||
public static List<TSource> ToList<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
Check.Source(source);
|
||
return new List<TSource>(source);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Linq.Lookup`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function.</summary>
|
||
/// <returns>A <see cref="T:System.Linq.Lookup`2" /> that contains keys and values.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Linq.Lookup`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000347 RID: 839 RVA: 0x00010488 File Offset: 0x0000E688
|
||
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
{
|
||
return source.ToLookup(keySelector, Enumerable.Function<TSource>.Identity, null);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Linq.Lookup`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function and key comparer.</summary>
|
||
/// <returns>A <see cref="T:System.Linq.Lookup`2" /> that contains keys and values.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Linq.Lookup`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
|
||
// Token: 0x06000348 RID: 840 RVA: 0x00010498 File Offset: 0x0000E698
|
||
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
return source.ToLookup(keySelector, (TSource element) => element, comparer);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Linq.Lookup`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to specified key selector and element selector functions.</summary>
|
||
/// <returns>A <see cref="T:System.Linq.Lookup`2" /> that contains values of type <paramref name="TElement" /> selected from the input sequence.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Linq.Lookup`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
|
||
// Token: 0x06000349 RID: 841 RVA: 0x000104B0 File Offset: 0x0000E6B0
|
||
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
|
||
{
|
||
return source.ToLookup(keySelector, elementSelector, null);
|
||
}
|
||
|
||
/// <summary>Creates a <see cref="T:System.Linq.Lookup`2" /> from an <see cref="T:System.Collections.Generic.IEnumerable`1" /> according to a specified key selector function, a comparer and an element selector function.</summary>
|
||
/// <returns>A <see cref="T:System.Linq.Lookup`2" /> that contains values of type <paramref name="TElement" /> selected from the input sequence.</returns>
|
||
/// <param name="source">The <see cref="T:System.Collections.Generic.IEnumerable`1" /> to create a <see cref="T:System.Linq.Lookup`2" /> from.</param>
|
||
/// <param name="keySelector">A function to extract a key from each element.</param>
|
||
/// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare keys.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector" />.</typeparam>
|
||
/// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
|
||
// Token: 0x0600034A RID: 842 RVA: 0x000104BC File Offset: 0x0000E6BC
|
||
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
|
||
{
|
||
Check.SourceAndKeyElementSelectors(source, keySelector, elementSelector);
|
||
List<TElement> list = null;
|
||
Dictionary<TKey, List<TElement>> dictionary = new Dictionary<TKey, List<TElement>>(comparer ?? EqualityComparer<TKey>.Default);
|
||
foreach (TSource tsource in source)
|
||
{
|
||
TKey tkey = keySelector(tsource);
|
||
List<TElement> list2;
|
||
if (tkey == null)
|
||
{
|
||
if (list == null)
|
||
{
|
||
list = new List<TElement>();
|
||
}
|
||
list2 = list;
|
||
}
|
||
else if (!dictionary.TryGetValue(tkey, out list2))
|
||
{
|
||
list2 = new List<TElement>();
|
||
dictionary.Add(tkey, list2);
|
||
}
|
||
list2.Add(elementSelector(tsource));
|
||
}
|
||
return new Lookup<TKey, TElement>(dictionary, list);
|
||
}
|
||
|
||
/// <summary>Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.</summary>
|
||
/// <returns>true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to compare to <paramref name="second" />.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to compare to the first sequence.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x0600034B RID: 843 RVA: 0x00010590 File Offset: 0x0000E790
|
||
public static bool SequenceEqual<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
return first.SequenceEqual(second, null);
|
||
}
|
||
|
||
/// <summary>Determines whether two sequences are equal by comparing their elements by using a specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
|
||
/// <returns>true if the two source sequences are of equal length and their corresponding elements compare equal according to <paramref name="comparer" />; otherwise, false.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to compare to <paramref name="second" />.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to compare to the first sequence.</param>
|
||
/// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to use to compare elements.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x0600034C RID: 844 RVA: 0x0001059C File Offset: 0x0000E79C
|
||
public static bool SequenceEqual<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
bool flag;
|
||
using (IEnumerator<TSource> enumerator = first.GetEnumerator())
|
||
{
|
||
using (IEnumerator<TSource> enumerator2 = second.GetEnumerator())
|
||
{
|
||
while (enumerator.MoveNext())
|
||
{
|
||
if (!enumerator2.MoveNext())
|
||
{
|
||
return false;
|
||
}
|
||
if (!comparer.Equals(enumerator.Current, enumerator2.Current))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
flag = !enumerator2.MoveNext();
|
||
}
|
||
}
|
||
return flag;
|
||
}
|
||
|
||
/// <summary>Produces the union of two sequences by using the default equality comparer.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements from both input sequences, excluding duplicates.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements form the first set for the union.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements form the second set for the union.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x0600034D RID: 845 RVA: 0x00010674 File Offset: 0x0000E874
|
||
public static IEnumerable<TSource> Union<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
return first.Union(second, null);
|
||
}
|
||
|
||
/// <summary>Produces the set union of two sequences by using a specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains the elements from both input sequences, excluding duplicates.</returns>
|
||
/// <param name="first">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements form the first set for the union.</param>
|
||
/// <param name="second">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> whose distinct elements form the second set for the union.</param>
|
||
/// <param name="comparer">The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> to compare values.</param>
|
||
/// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
|
||
// Token: 0x0600034E RID: 846 RVA: 0x00010688 File Offset: 0x0000E888
|
||
public static IEnumerable<TSource> Union<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
Check.FirstAndSecond(first, second);
|
||
if (comparer == null)
|
||
{
|
||
comparer = EqualityComparer<TSource>.Default;
|
||
}
|
||
return Enumerable.CreateUnionIterator<TSource>(first, second, comparer);
|
||
}
|
||
|
||
// Token: 0x0600034F RID: 847 RVA: 0x000106A8 File Offset: 0x0000E8A8
|
||
private static IEnumerable<TSource> CreateUnionIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
|
||
{
|
||
HashSet<TSource> items = new HashSet<TSource>(comparer);
|
||
foreach (TSource element in first)
|
||
{
|
||
if (!items.Contains(element))
|
||
{
|
||
items.Add(element);
|
||
yield return element;
|
||
}
|
||
}
|
||
foreach (TSource element2 in second)
|
||
{
|
||
if (!items.Contains(element2, comparer))
|
||
{
|
||
items.Add(element2);
|
||
yield return element2;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Filters a sequence of values based on a predicate.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements from the input sequence that satisfy the condition.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to filter.</param>
|
||
/// <param name="predicate">A function to test each element for a condition.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x06000350 RID: 848 RVA: 0x000106F0 File Offset: 0x0000E8F0
|
||
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return Enumerable.CreateWhereIterator<TSource>(source, predicate);
|
||
}
|
||
|
||
// Token: 0x06000351 RID: 849 RVA: 0x00010700 File Offset: 0x0000E900
|
||
private static IEnumerable<TSource> CreateWhereIterator<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
|
||
{
|
||
foreach (TSource element in source)
|
||
{
|
||
if (predicate(element))
|
||
{
|
||
yield return element;
|
||
}
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
/// <summary>Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.</summary>
|
||
/// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains elements from the input sequence that satisfy the condition.</returns>
|
||
/// <param name="source">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> to filter.</param>
|
||
/// <param name="predicate">A function to test each source element for a condition; the second parameter of the function represents the index of the source element.</param>
|
||
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
|
||
/// <exception cref="T:System.ArgumentNullException">
|
||
/// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
|
||
// Token: 0x06000352 RID: 850 RVA: 0x00010738 File Offset: 0x0000E938
|
||
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
Check.SourceAndPredicate(source, predicate);
|
||
return source.CreateWhereIterator(predicate);
|
||
}
|
||
|
||
// Token: 0x06000353 RID: 851 RVA: 0x00010748 File Offset: 0x0000E948
|
||
private static IEnumerable<TSource> CreateWhereIterator<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
|
||
{
|
||
int counter = 0;
|
||
foreach (TSource element in source)
|
||
{
|
||
if (predicate(element, counter))
|
||
{
|
||
yield return element;
|
||
}
|
||
counter++;
|
||
}
|
||
yield break;
|
||
}
|
||
|
||
// Token: 0x06000354 RID: 852 RVA: 0x00010780 File Offset: 0x0000E980
|
||
internal static ReadOnlyCollection<TSource> ToReadOnlyCollection<TSource>(this IEnumerable<TSource> source)
|
||
{
|
||
if (source == null)
|
||
{
|
||
return Enumerable.ReadOnlyCollectionOf<TSource>.Empty;
|
||
}
|
||
ReadOnlyCollection<TSource> readOnlyCollection = source as ReadOnlyCollection<TSource>;
|
||
if (readOnlyCollection != null)
|
||
{
|
||
return readOnlyCollection;
|
||
}
|
||
return new ReadOnlyCollection<TSource>(source.ToArray<TSource>());
|
||
}
|
||
|
||
// Token: 0x02000033 RID: 51
|
||
private enum Fallback
|
||
{
|
||
// Token: 0x040000E2 RID: 226
|
||
Default,
|
||
// Token: 0x040000E3 RID: 227
|
||
Throw
|
||
}
|
||
|
||
// Token: 0x02000034 RID: 52
|
||
private class Function<T>
|
||
{
|
||
// Token: 0x040000E4 RID: 228
|
||
public static readonly Func<T, T> Identity = (T t) => t;
|
||
}
|
||
|
||
// Token: 0x02000035 RID: 53
|
||
private class ReadOnlyCollectionOf<T>
|
||
{
|
||
// Token: 0x040000E6 RID: 230
|
||
public static readonly ReadOnlyCollection<T> Empty = new ReadOnlyCollection<T>(new T[0]);
|
||
}
|
||
}
|
||
}
|