Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -16,13 +16,9 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(source));
}
AppendPrependIterator<TSource> appendable = source as AppendPrependIterator<TSource>;
if (appendable != null)
{
return appendable.Append(element);
}
return new AppendPrepend1Iterator<TSource>(source, element, appending: true);
return source is AppendPrependIterator<TSource> appendable
? appendable.Append(element)
: new AppendPrepend1Iterator<TSource>(source, element, appending: true);
}
public static IEnumerable<TSource> Prepend<TSource>(this IEnumerable<TSource> source, TSource element)
@@ -32,13 +28,9 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(source));
}
AppendPrependIterator<TSource> appendable = source as AppendPrependIterator<TSource>;
if (appendable != null)
{
return appendable.Prepend(element);
}
return new AppendPrepend1Iterator<TSource>(source, element, appending: false);
return source is AppendPrependIterator<TSource> appendable
? appendable.Prepend(element)
: new AppendPrepend1Iterator<TSource>(source, element, appending: false);
}
/// <summary>
@@ -245,8 +237,7 @@ namespace System.Linq
public override int GetCount(bool onlyIfCheap)
{
IIListProvider<TSource> listProv = _source as IIListProvider<TSource>;
if (listProv != null)
if (_source is IIListProvider<TSource> listProv)
{
int count = listProv.GetCount(onlyIfCheap);
return count == -1 ? -1 : count + 1;
@@ -389,8 +380,7 @@ namespace System.Linq
++index;
}
ICollection<TSource> sourceCollection = _source as ICollection<TSource>;
if (sourceCollection != null)
if (_source is ICollection<TSource> sourceCollection)
{
sourceCollection.CopyTo(array, index);
}
@@ -437,8 +427,7 @@ namespace System.Linq
public override int GetCount(bool onlyIfCheap)
{
IIListProvider<TSource> listProv = _source as IIListProvider<TSource>;
if (listProv != null)
if (_source is IIListProvider<TSource> listProv)
{
int count = listProv.GetCount(onlyIfCheap);
return count == -1 ? -1 : count + _appendCount + _prependCount;

View File

@@ -28,8 +28,7 @@ namespace System.Linq
/// <param name="source">The enumerable to be store.</param>
internal Buffer(IEnumerable<TElement> source)
{
IIListProvider<TElement> iterator = source as IIListProvider<TElement>;
if (iterator != null)
if (source is IIListProvider<TElement> iterator)
{
TElement[] array = iterator.ToArray();
_items = array;

View File

@@ -37,15 +37,14 @@ namespace System.Linq
{
return typedSource;
}
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
return CastIterator<TResult>(source);
}
private static IEnumerable<TResult> CastIterator<TResult>(IEnumerable source)
{
foreach (object obj in source)

View File

@@ -21,10 +21,9 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(second));
}
var firstConcat = first as ConcatIterator<TSource>;
return firstConcat != null ?
firstConcat.Concat(second) :
new Concat2Iterator<TSource>(first, second);
return first is ConcatIterator<TSource> firstConcat
? firstConcat.Concat(second)
: new Concat2Iterator<TSource>(first, second);
}
/// <summary>
@@ -61,9 +60,9 @@ namespace System.Linq
internal override ConcatIterator<TSource> Concat(IEnumerable<TSource> next)
{
bool hasOnlyCollections = _first is ICollection<TSource> &&
_second is ICollection<TSource> &&
next is ICollection<TSource>;
bool hasOnlyCollections = next is ICollection<TSource> &&
_first is ICollection<TSource> &&
_second is ICollection<TSource>;
return new ConcatNIterator<TSource>(this, next, 2, hasOnlyCollections);
}
@@ -138,7 +137,7 @@ namespace System.Linq
/// <remarks>
/// To handle chains of >= 3 sources, we chain the <see cref="Concat"/> iterators together and allow
/// <see cref="GetEnumerable"/> to fetch enumerables from the previous sources. This means that rather
/// than each <see cref="MoveNext"/> and <see cref="Current"/> calls having to traverse all of the previous
/// than each <see cref="IEnumerator{T}.MoveNext"/> and <see cref="IEnumerator{T}.Current"/> calls having to traverse all of the previous
/// sources, we only have to traverse all of the previous sources once per chained enumerable. An alternative
/// would be to use an array to store all of the enumerables, but this has a much better memory profile and
/// without much additional run-time cost.
@@ -166,7 +165,7 @@ namespace System.Linq
/// </summary>
/// <remarks>
/// This flag allows us to determine in O(1) time whether we can preallocate for <see cref="ToArray"/>
/// and <see cref="ToList"/>, and whether we can get the count of the iterator cheaply.
/// and <see cref="ConcatIterator{TSource}.ToList"/>, and whether we can get the count of the iterator cheaply.
/// </remarks>
private readonly bool _hasOnlyCollections;

View File

@@ -8,16 +8,10 @@ namespace System.Linq
{
public static partial class Enumerable
{
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 Contains(source, value, null);
}
public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value) =>
source is ICollection<TSource> collection
? collection.Contains(value)
: Contains(source, value, null);
public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
{

View File

@@ -16,20 +16,17 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(source));
}
ICollection<TSource> collectionoft = source as ICollection<TSource>;
if (collectionoft != null)
if (source is ICollection<TSource> collectionoft)
{
return collectionoft.Count;
}
IIListProvider<TSource> listProv = source as IIListProvider<TSource>;
if (listProv != null)
if (source is IIListProvider<TSource> listProv)
{
return listProv.GetCount(onlyIfCheap: false);
}
ICollection collection = source as ICollection;
if (collection != null)
if (source is ICollection collection)
{
return collection.Count;
}

View File

@@ -24,12 +24,7 @@ namespace System.Linq
{
public SystemCore_EnumerableDebugView(IEnumerable<T> enumerable)
{
if (enumerable == null)
{
throw new ArgumentNullException(nameof(enumerable));
}
_enumerable = enumerable;
_enumerable = enumerable ?? throw Error.ArgumentNull(nameof(enumerable));
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
@@ -53,25 +48,14 @@ namespace System.Linq
internal sealed class SystemCore_EnumerableDebugViewEmptyException : Exception
{
public string Empty
{
get
{
return SR.EmptyEnumerable;
}
}
public string Empty => SR.EmptyEnumerable;
}
internal sealed class SystemCore_EnumerableDebugView
{
public SystemCore_EnumerableDebugView(IEnumerable enumerable)
{
if (enumerable == null)
{
throw new ArgumentNullException(nameof(enumerable));
}
_enumerable = enumerable;
_enumerable = enumerable ?? throw Error.ArgumentNull(nameof(enumerable));
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]

View File

@@ -10,10 +10,8 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source)
{
return DefaultIfEmpty(source, default(TSource));
}
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source) =>
DefaultIfEmpty(source, default(TSource));
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source, TSource defaultValue)
{
@@ -38,10 +36,7 @@ namespace System.Linq
_default = defaultValue;
}
public override Iterator<TSource> Clone()
{
return new DefaultIfEmptyIterator<TSource>(_source, _default);
}
public override Iterator<TSource> Clone() => new DefaultIfEmptyIterator<TSource>(_source, _default);
public override bool MoveNext()
{
@@ -112,8 +107,7 @@ namespace System.Linq
}
else
{
IIListProvider<TSource> listProv = _source as IIListProvider<TSource>;
count = listProv == null ? -1 : listProv.GetCount(onlyIfCheap: true);
count = _source is IIListProvider<TSource> listProv ? listProv.GetCount(onlyIfCheap: true) : -1;
}
return count == 0 ? 1 : count;

View File

@@ -9,10 +9,7 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source)
{
return Distinct(source, null);
}
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source) => Distinct(source, null);
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
{
@@ -42,10 +39,7 @@ namespace System.Linq
_comparer = comparer;
}
public override Iterator<TSource> Clone()
{
return new DistinctIterator<TSource>(_source, _comparer);
}
public override Iterator<TSource> Clone() => new DistinctIterator<TSource>(_source, _comparer);
public override bool MoveNext()
{
@@ -102,20 +96,11 @@ namespace System.Linq
return set;
}
public TSource[] ToArray()
{
return FillSet().ToArray();
}
public TSource[] ToArray() => FillSet().ToArray();
public List<TSource> ToList()
{
return FillSet().ToList();
}
public List<TSource> ToList() => FillSet().ToList();
public int GetCount(bool onlyIfCheap)
{
return onlyIfCheap ? -1 : FillSet().Count;
}
public int GetCount(bool onlyIfCheap) => onlyIfCheap ? -1 : FillSet().Count;
}
}
}

View File

@@ -15,11 +15,9 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(source));
}
IPartition<TSource> partition = source as IPartition<TSource>;
if (partition != null)
if (source is IPartition<TSource> partition)
{
bool found;
TSource element = partition.TryGetElementAt(index, out found);
TSource element = partition.TryGetElementAt(index, out bool found);
if (found)
{
return element;
@@ -27,8 +25,7 @@ namespace System.Linq
}
else
{
IList<TSource> list = source as IList<TSource>;
if (list != null)
if (source is IList<TSource> list)
{
return list[index];
}
@@ -60,17 +57,14 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(source));
}
IPartition<TSource> partition = source as IPartition<TSource>;
if (partition != null)
if (source is IPartition<TSource> partition)
{
bool found;
return partition.TryGetElementAt(index, out found);
return partition.TryGetElementAt(index, out bool _);
}
if (index >= 0)
{
IList<TSource> list = source as IList<TSource>;
if (list != null)
if (source is IList<TSource> list)
{
if (index < list.Count)
{

View File

@@ -8,14 +8,8 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source)
{
return source;
}
public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source) => source;
public static IEnumerable<TResult> Empty<TResult>()
{
return Array.Empty<TResult>();
}
public static IEnumerable<TResult> Empty<TResult>() => Array.Empty<TResult>();
}
}

View File

@@ -10,9 +10,7 @@ namespace System.Linq
{
public static TSource First<TSource>(this IEnumerable<TSource> source)
{
bool found;
TSource first = source.TryGetFirst(out found);
TSource first = source.TryGetFirst(out bool found);
if (!found)
{
throw Error.NoElements();
@@ -23,9 +21,7 @@ namespace System.Linq
public static TSource First<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
bool found;
TSource first = source.TryGetFirst(predicate, out found);
TSource first = source.TryGetFirst(predicate, out bool found);
if (!found)
{
throw Error.NoMatch();
@@ -34,33 +30,25 @@ namespace System.Linq
return first;
}
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source)
{
bool found;
return source.TryGetFirst(out found);
}
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source) =>
source.TryGetFirst(out bool _);
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
bool found;
return source.TryGetFirst(predicate, out found);
}
public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
source.TryGetFirst(predicate, out bool _);
internal static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, out bool found)
private static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, out bool found)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
IPartition<TSource> partition = source as IPartition<TSource>;
if (partition != null)
if (source is IPartition<TSource> partition)
{
return partition.TryGetFirst(out found);
}
IList<TSource> list = source as IList<TSource>;
if (list != null)
if (source is IList<TSource> list)
{
if (list.Count > 0)
{
@@ -84,7 +72,7 @@ namespace System.Linq
return default(TSource);
}
internal static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
private static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
{
if (source == null)
{
@@ -96,8 +84,7 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(predicate));
}
OrderedEnumerable<TSource> ordered = source as OrderedEnumerable<TSource>;
if (ordered != null)
if (source is OrderedEnumerable<TSource> ordered)
{
return ordered.TryGetFirst(predicate, out found);
}

View File

@@ -10,45 +10,29 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
return new GroupedEnumerable<TSource, TKey>(source, keySelector, null);
}
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) =>
new GroupedEnumerable<TSource, TKey>(source, keySelector, null);
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
return new GroupedEnumerable<TSource, TKey>(source, keySelector, comparer);
}
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) =>
new GroupedEnumerable<TSource, TKey>(source, keySelector, comparer);
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, null);
}
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) =>
new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, null);
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)
{
return new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
}
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) =>
new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
{
return new GroupedResultEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, null);
}
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector) =>
new GroupedResultEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, null);
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 new GroupedResultEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, null);
}
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) =>
new GroupedResultEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, null);
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)
{
return new GroupedResultEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, comparer);
}
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) =>
new GroupedResultEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, comparer);
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)
{
return new GroupedResultEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, comparer);
}
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) =>
new GroupedResultEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, comparer);
}
public interface IGrouping<out TKey, out TElement> : IEnumerable<TElement>
@@ -107,67 +91,32 @@ namespace System.Linq
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
// DDB195907: implement IGrouping<>.Key implicitly
// so that WPF binding works on this property.
public TKey Key
{
get { return _key; }
}
public TKey Key => _key;
int ICollection<TElement>.Count
{
get { return _count; }
}
int ICollection<TElement>.Count => _count;
bool ICollection<TElement>.IsReadOnly
{
get { return true; }
}
bool ICollection<TElement>.IsReadOnly => true;
void ICollection<TElement>.Add(TElement item)
{
throw Error.NotSupported();
}
void ICollection<TElement>.Add(TElement item) => throw Error.NotSupported();
void ICollection<TElement>.Clear()
{
throw Error.NotSupported();
}
void ICollection<TElement>.Clear() => throw Error.NotSupported();
bool ICollection<TElement>.Contains(TElement item)
{
return Array.IndexOf(_elements, item, 0, _count) >= 0;
}
bool ICollection<TElement>.Contains(TElement item) => Array.IndexOf(_elements, item, 0, _count) >= 0;
void ICollection<TElement>.CopyTo(TElement[] array, int arrayIndex)
{
void ICollection<TElement>.CopyTo(TElement[] array, int arrayIndex) =>
Array.Copy(_elements, 0, array, arrayIndex, _count);
}
bool ICollection<TElement>.Remove(TElement item)
{
throw Error.NotSupported();
}
bool ICollection<TElement>.Remove(TElement item) => throw Error.NotSupported();
int IList<TElement>.IndexOf(TElement item)
{
return Array.IndexOf(_elements, item, 0, _count);
}
int IList<TElement>.IndexOf(TElement item) => Array.IndexOf(_elements, item, 0, _count);
void IList<TElement>.Insert(int index, TElement item)
{
throw Error.NotSupported();
}
void IList<TElement>.Insert(int index, TElement item) => throw Error.NotSupported();
void IList<TElement>.RemoveAt(int index)
{
throw Error.NotSupported();
}
void IList<TElement>.RemoveAt(int index) => throw Error.NotSupported();
TElement IList<TElement>.this[int index]
{
@@ -198,31 +147,11 @@ namespace System.Linq
public GroupedResultEnumerable(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
if (keySelector == null)
{
throw Error.ArgumentNull(nameof(keySelector));
}
if (elementSelector == null)
{
throw Error.ArgumentNull(nameof(elementSelector));
}
if (resultSelector == null)
{
throw Error.ArgumentNull(nameof(resultSelector));
}
_source = source;
_keySelector = keySelector;
_elementSelector = elementSelector;
_source = source ?? throw Error.ArgumentNull(nameof(source));
_keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector));
_elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector));
_comparer = comparer;
_resultSelector = resultSelector;
_resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector));
}
public IEnumerator<TResult> GetEnumerator()
@@ -231,25 +160,16 @@ namespace System.Linq
return lookup.ApplyResultSelector(_resultSelector).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public TResult[] ToArray()
{
return Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).ToArray(_resultSelector);
}
public TResult[] ToArray() =>
Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).ToArray(_resultSelector);
public List<TResult> ToList()
{
return Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).ToList(_resultSelector);
}
public List<TResult> ToList() =>
Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).ToList(_resultSelector);
public int GetCount(bool onlyIfCheap)
{
return onlyIfCheap ? -1 : Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).Count;
}
public int GetCount(bool onlyIfCheap) =>
onlyIfCheap ? -1 : Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).Count;
}
internal sealed class GroupedResultEnumerable<TSource, TKey, TResult> : IIListProvider<TResult>
@@ -261,24 +181,9 @@ namespace System.Linq
public GroupedResultEnumerable(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
if (keySelector == null)
{
throw Error.ArgumentNull(nameof(keySelector));
}
if (resultSelector == null)
{
throw Error.ArgumentNull(nameof(resultSelector));
}
_source = source;
_keySelector = keySelector;
_resultSelector = resultSelector;
_source = source ?? throw Error.ArgumentNull(nameof(source));
_keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector));
_resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector));
_comparer = comparer;
}
@@ -288,25 +193,16 @@ namespace System.Linq
return lookup.ApplyResultSelector(_resultSelector).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public TResult[] ToArray()
{
return Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).ToArray(_resultSelector);
}
public TResult[] ToArray() =>
Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).ToArray(_resultSelector);
public List<TResult> ToList()
{
return Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).ToList(_resultSelector);
}
public List<TResult> ToList() =>
Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).ToList(_resultSelector);
public int GetCount(bool onlyIfCheap)
{
return onlyIfCheap ? -1 : Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).Count;
}
public int GetCount(bool onlyIfCheap) =>
onlyIfCheap ? -1 : Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).Count;
}
internal sealed class GroupedEnumerable<TSource, TKey, TElement> : IIListProvider<IGrouping<TKey, TElement>>
@@ -318,36 +214,16 @@ namespace System.Linq
public GroupedEnumerable(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
if (keySelector == null)
{
throw Error.ArgumentNull(nameof(keySelector));
}
if (elementSelector == null)
{
throw Error.ArgumentNull(nameof(elementSelector));
}
_source = source;
_keySelector = keySelector;
_elementSelector = elementSelector;
_source = source ?? throw Error.ArgumentNull(nameof(source));
_keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector));
_elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector));
_comparer = comparer;
}
public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator()
{
return Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).GetEnumerator();
}
public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator() =>
Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IGrouping<TKey, TElement>[] ToArray()
{
@@ -361,10 +237,8 @@ namespace System.Linq
return lookup.ToList();
}
public int GetCount(bool onlyIfCheap)
{
return onlyIfCheap ? -1 : Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).Count;
}
public int GetCount(bool onlyIfCheap) =>
onlyIfCheap ? -1 : Lookup<TKey, TElement>.Create(_source, _keySelector, _elementSelector, _comparer).Count;
}
internal sealed class GroupedEnumerable<TSource, TKey> : IIListProvider<IGrouping<TKey, TSource>>
@@ -375,30 +249,15 @@ namespace System.Linq
public GroupedEnumerable(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
if (keySelector == null)
{
throw Error.ArgumentNull(nameof(keySelector));
}
_source = source;
_keySelector = keySelector;
_source = source ?? throw Error.ArgumentNull(nameof(source));
_keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector));
_comparer = comparer;
}
public IEnumerator<IGrouping<TKey, TSource>> GetEnumerator()
{
return Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).GetEnumerator();
}
public IEnumerator<IGrouping<TKey, TSource>> GetEnumerator() =>
Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IGrouping<TKey, TSource>[] ToArray()
{
@@ -412,9 +271,7 @@ namespace System.Linq
return lookup.ToList();
}
public int GetCount(bool onlyIfCheap)
{
return onlyIfCheap ? -1 : Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).Count;
}
public int GetCount(bool onlyIfCheap) =>
onlyIfCheap ? -1 : Lookup<TKey, TSource>.Create(_source, _keySelector, _comparer).Count;
}
}

View File

@@ -113,10 +113,7 @@ namespace System.Linq
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
void IEnumerator.Reset()
{
throw Error.NotSupported();
}
void IEnumerator.Reset() => throw Error.NotSupported();
}
}
}

View File

@@ -10,9 +10,7 @@ namespace System.Linq
{
public static TSource Last<TSource>(this IEnumerable<TSource> source)
{
bool found;
TSource last = source.TryGetLast(out found);
TSource last = source.TryGetLast(out bool found);
if (!found)
{
throw Error.NoElements();
@@ -23,9 +21,7 @@ namespace System.Linq
public static TSource Last<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
bool found;
TSource last = source.TryGetLast(predicate, out found);
TSource last = source.TryGetLast(predicate, out bool found);
if (!found)
{
throw Error.NoMatch();
@@ -34,33 +30,25 @@ namespace System.Linq
return last;
}
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source)
{
bool found;
return source.TryGetLast(out found);
}
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source) =>
source.TryGetLast(out bool _);
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
bool found;
return source.TryGetLast(predicate, out found);
}
public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
source.TryGetLast(predicate, out bool _);
internal static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, out bool found)
private static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, out bool found)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
IPartition<TSource> partition = source as IPartition<TSource>;
if (partition != null)
if (source is IPartition<TSource> partition)
{
return partition.TryGetLast(out found);
}
IList<TSource> list = source as IList<TSource>;
if (list != null)
if (source is IList<TSource> list)
{
int count = list.Count;
if (count > 0)
@@ -87,12 +75,12 @@ namespace System.Linq
}
}
}
found = false;
return default(TSource);
}
internal static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
private static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
{
if (source == null)
{
@@ -104,14 +92,12 @@ namespace System.Linq
throw Error.ArgumentNull(nameof(predicate));
}
OrderedEnumerable<TSource> ordered = source as OrderedEnumerable<TSource>;
if (ordered != null)
if (source is OrderedEnumerable<TSource> ordered)
{
return ordered.TryGetLast(predicate, out found);
}
IList<TSource> list = source as IList<TSource>;
if (list != null)
if (source is IList<TSource> list)
{
for (int i = list.Count - 1; i >= 0; --i)
{

View File

@@ -10,10 +10,8 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
return ToLookup(source, keySelector, null);
}
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) =>
ToLookup(source, keySelector, null);
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
@@ -30,10 +28,8 @@ namespace System.Linq
return Lookup<TKey, TSource>.Create(source, keySelector, comparer);
}
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
{
return ToLookup(source, keySelector, elementSelector, null);
}
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) =>
ToLookup(source, keySelector, elementSelector, null);
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
{
@@ -124,10 +120,7 @@ namespace System.Linq
_groupings = new Grouping<TKey, TElement>[7];
}
public int Count
{
get { return _count; }
}
public int Count => _count;
public IEnumerable<TElement> this[TKey key]
{
@@ -143,10 +136,7 @@ namespace System.Linq
}
}
public bool Contains(TKey key)
{
return GetGrouping(key, create: false) != null;
}
public bool Contains(TKey key) => GetGrouping(key, create: false) != null;
public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator()
{
@@ -236,10 +226,7 @@ namespace System.Linq
return list;
}
int IIListProvider<IGrouping<TKey, TElement>>.GetCount(bool onlyIfCheap)
{
return _count;
}
int IIListProvider<IGrouping<TKey, TElement>>.GetCount(bool onlyIfCheap) => _count;
public IEnumerable<TResult> ApplyResultSelector<TResult>(Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
{
@@ -256,12 +243,9 @@ namespace System.Linq
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
internal int InternalGetHashCode(TKey key)
private int InternalGetHashCode(TKey key)
{
// Handle comparer implementations that throw when passed null
return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF;

View File

@@ -8,25 +8,17 @@ namespace System.Linq
{
public static partial class Enumerable
{
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
return new OrderedEnumerable<TSource, TKey>(source, keySelector, null, false, null);
}
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) =>
new OrderedEnumerable<TSource, TKey>(source, keySelector, null, false, null);
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, false, null);
}
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) =>
new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, false, null);
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
return new OrderedEnumerable<TSource, TKey>(source, keySelector, null, true, null);
}
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) =>
new OrderedEnumerable<TSource, TKey>(source, keySelector, null, true, null);
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
{
return new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, true, null);
}
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) =>
new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, true, null);
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{

View File

@@ -11,15 +11,10 @@ namespace System.Linq
{
internal IEnumerable<TElement> _source;
private int[] SortedMap(Buffer<TElement> buffer)
{
return GetEnumerableSorter().Sort(buffer._items, buffer._count);
}
private int[] SortedMap(Buffer<TElement> buffer) => GetEnumerableSorter().Sort(buffer._items, buffer._count);
private int[] SortedMap(Buffer<TElement> buffer, int minIdx, int maxIdx)
{
return GetEnumerableSorter().Sort(buffer._items, buffer._count, minIdx, maxIdx);
}
private int[] SortedMap(Buffer<TElement> buffer, int minIdx, int maxIdx) =>
GetEnumerableSorter().Sort(buffer._items, buffer._count, minIdx, maxIdx);
public IEnumerator<TElement> GetEnumerator()
{
@@ -73,8 +68,7 @@ namespace System.Linq
public int GetCount(bool onlyIfCheap)
{
IIListProvider<TElement> listProv = _source as IIListProvider<TElement>;
if (listProv != null)
if (_source is IIListProvider<TElement> listProv)
{
return listProv.GetCount(onlyIfCheap);
}
@@ -187,39 +181,22 @@ namespace System.Linq
return (count <= maxIdx ? count : maxIdx + 1) - minIdx;
}
private EnumerableSorter<TElement> GetEnumerableSorter()
{
return GetEnumerableSorter(null);
}
private EnumerableSorter<TElement> GetEnumerableSorter() => GetEnumerableSorter(null);
internal abstract EnumerableSorter<TElement> GetEnumerableSorter(EnumerableSorter<TElement> next);
internal CachingComparer<TElement> GetComparer()
{
return GetComparer(null);
}
private CachingComparer<TElement> GetComparer() => GetComparer(null);
internal abstract CachingComparer<TElement> GetComparer(CachingComparer<TElement> childComparer);
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
IOrderedEnumerable<TElement> IOrderedEnumerable<TElement>.CreateOrderedEnumerable<TKey>(Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending)
{
return new OrderedEnumerable<TElement, TKey>(_source, keySelector, comparer, descending, this);
}
IOrderedEnumerable<TElement> IOrderedEnumerable<TElement>.CreateOrderedEnumerable<TKey>(Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending) =>
new OrderedEnumerable<TElement, TKey>(_source, keySelector, comparer, @descending, this);
public IPartition<TElement> Skip(int count)
{
return new OrderedPartition<TElement>(this, count, int.MaxValue);
}
public IPartition<TElement> Skip(int count) => new OrderedPartition<TElement>(this, count, int.MaxValue);
public IPartition<TElement> Take(int count)
{
return new OrderedPartition<TElement>(this, 0, count - 1);
}
public IPartition<TElement> Take(int count) => new OrderedPartition<TElement>(this, 0, count - 1);
public TElement TryGetElementAt(int index, out bool found)
{
@@ -399,26 +376,16 @@ namespace System.Linq
internal sealed class OrderedEnumerable<TElement, TKey> : OrderedEnumerable<TElement>
{
internal readonly OrderedEnumerable<TElement> _parent;
internal readonly Func<TElement, TKey> _keySelector;
internal readonly IComparer<TKey> _comparer;
internal readonly bool _descending;
private readonly OrderedEnumerable<TElement> _parent;
private readonly Func<TElement, TKey> _keySelector;
private readonly IComparer<TKey> _comparer;
private readonly bool _descending;
internal OrderedEnumerable(IEnumerable<TElement> source, Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending, OrderedEnumerable<TElement> parent)
{
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
if (keySelector == null)
{
throw Error.ArgumentNull(nameof(keySelector));
}
_source = source;
_source = source ?? throw Error.ArgumentNull(nameof(source));
_parent = parent;
_keySelector = keySelector;
_keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector));
_comparer = comparer ?? Comparer<TKey>.Default;
_descending = descending;
}
@@ -552,15 +519,10 @@ namespace System.Linq
return map;
}
internal TElement ElementAt(TElement[] elements, int count, int idx)
{
return elements[QuickSelect(ComputeMap(elements, count), count - 1, idx)];
}
internal TElement ElementAt(TElement[] elements, int count, int idx) =>
elements[QuickSelect(ComputeMap(elements, count), count - 1, idx)];
private int CompareKeys(int index1, int index2)
{
return index1 == index2 ? 0 : CompareAnyKeys(index1, index2);
}
private int CompareKeys(int index1, int index2) => index1 == index2 ? 0 : CompareAnyKeys(index1, index2);
private void QuickSort(int[] map, int left, int right)
{
@@ -764,11 +726,11 @@ namespace System.Linq
internal sealed class EnumerableSorter<TElement, TKey> : EnumerableSorter<TElement>
{
internal readonly Func<TElement, TKey> _keySelector;
internal readonly IComparer<TKey> _comparer;
internal readonly bool _descending;
internal readonly EnumerableSorter<TElement> _next;
internal TKey[] _keys;
private readonly Func<TElement, TKey> _keySelector;
private readonly IComparer<TKey> _comparer;
private readonly bool _descending;
private readonly EnumerableSorter<TElement> _next;
private TKey[] _keys;
internal EnumerableSorter(Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending, EnumerableSorter<TElement> next)
{
@@ -786,10 +748,7 @@ namespace System.Linq
_keys[i] = _keySelector(elements[i]);
}
if (_next != null)
{
_next.ComputeKeys(elements, count);
}
_next?.ComputeKeys(elements, count);
}
internal override int CompareAnyKeys(int index1, int index2)

View File

@@ -108,10 +108,7 @@ namespace System.Linq
[ExcludeFromCodeCoverage] // Shouldn't be called, and as undefined can return or throw anything anyway.
object IEnumerator.Current => default(TElement);
void IEnumerator.Reset()
{
throw Error.NotSupported();
}
void IEnumerator.Reset() => throw Error.NotSupported();
void IDisposable.Dispose()
{
@@ -160,15 +157,9 @@ namespace System.Linq
_maxIndexInclusive = maxIdxInclusive;
}
public IEnumerator<TElement> GetEnumerator()
{
return _source.GetEnumerator(_minIndexInclusive, _maxIndexInclusive);
}
public IEnumerator<TElement> GetEnumerator() => _source.GetEnumerator(_minIndexInclusive, _maxIndexInclusive);
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IPartition<TElement> Skip(int count)
{
@@ -198,30 +189,16 @@ namespace System.Linq
return default(TElement);
}
public TElement TryGetFirst(out bool found)
{
return _source.TryGetElementAt(_minIndexInclusive, out found);
}
public TElement TryGetFirst(out bool found) => _source.TryGetElementAt(_minIndexInclusive, out found);
public TElement TryGetLast(out bool found)
{
return _source.TryGetLast(_minIndexInclusive, _maxIndexInclusive, out found);
}
public TElement TryGetLast(out bool found) =>
_source.TryGetLast(_minIndexInclusive, _maxIndexInclusive, out found);
public TElement[] ToArray()
{
return _source.ToArray(_minIndexInclusive, _maxIndexInclusive);
}
public TElement[] ToArray() => _source.ToArray(_minIndexInclusive, _maxIndexInclusive);
public List<TElement> ToList()
{
return _source.ToList(_minIndexInclusive, _maxIndexInclusive);
}
public List<TElement> ToList() => _source.ToList(_minIndexInclusive, _maxIndexInclusive);
public int GetCount(bool onlyIfCheap)
{
return _source.GetCount(_minIndexInclusive, _maxIndexInclusive, onlyIfCheap);
}
public int GetCount(bool onlyIfCheap) => _source.GetCount(_minIndexInclusive, _maxIndexInclusive, onlyIfCheap);
}
public static partial class Enumerable
@@ -246,10 +223,8 @@ namespace System.Linq
_maxIndexInclusive = maxIndexInclusive;
}
public override Iterator<TSource> Clone()
{
return new ListPartition<TSource>(_source, _minIndexInclusive, _maxIndexInclusive);
}
public override Iterator<TSource> Clone() =>
new ListPartition<TSource>(_source, _minIndexInclusive, _maxIndexInclusive);
public override bool MoveNext()
{
@@ -268,10 +243,8 @@ namespace System.Linq
return false;
}
public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
{
return new SelectListPartitionIterator<TSource, TResult>(_source, selector, _minIndexInclusive, _maxIndexInclusive);
}
public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) =>
new SelectListPartitionIterator<TSource, TResult>(_source, selector, _minIndexInclusive, _maxIndexInclusive);
public IPartition<TSource> Skip(int count)
{
@@ -371,10 +344,7 @@ namespace System.Linq
return list;
}
public int GetCount(bool onlyIfCheap)
{
return Count;
}
public int GetCount(bool onlyIfCheap) => Count;
}
/// <summary>
@@ -412,10 +382,8 @@ namespace System.Linq
private int Limit => unchecked((_maxIndexInclusive + 1) - _minIndexInclusive); // This is that upper bound.
public override Iterator<TSource> Clone()
{
return new EnumerablePartition<TSource>(_source, _minIndexInclusive, _maxIndexInclusive);
}
public override Iterator<TSource> Clone() =>
new EnumerablePartition<TSource>(_source, _minIndexInclusive, _maxIndexInclusive);
public override void Dispose()
{
@@ -507,10 +475,8 @@ namespace System.Linq
return false;
}
public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
{
return new SelectIPartitionIterator<TSource, TResult>(this, selector);
}
public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) =>
new SelectIPartitionIterator<TSource, TResult>(this, selector);
public IPartition<TSource> Skip(int count)
{

View File

@@ -40,10 +40,7 @@ namespace System.Linq
_end = unchecked(start + count);
}
public override Iterator<int> Clone()
{
return new RangeIterator(_start, _end - _start);
}
public override Iterator<int> Clone() => new RangeIterator(_start, _end - _start);
public override bool MoveNext()
{
@@ -101,10 +98,7 @@ namespace System.Linq
return list;
}
public int GetCount(bool onlyIfCheap)
{
return unchecked(_end - _start);
}
public int GetCount(bool onlyIfCheap) => unchecked(_end - _start);
public IPartition<int> Skip(int count)
{

Some files were not shown because too many files have changed in this diff Show More