public static TSource[] ToArray <TSource>(this IEnumerable <TSource> source) { if (source == null) { throw Error.ArgumentNull("source"); } IIListProvider <TSource> arrayProvider = source as IIListProvider <TSource>; return(arrayProvider != null?arrayProvider.ToArray() : EnumerableHelpers.ToArray(source)); }
/// <summary> /// Fully enumerates the provided enumerable and stores its items into an array. /// </summary> /// <param name="source">The enumerable to be store.</param> internal Buffer(IEnumerable <TElement> source) { IIListProvider <TElement> iterator = source as IIListProvider <TElement>; if (iterator != null) { TElement[] array = iterator.ToArray(); _items = array; _count = array.Length; } else { _items = EnumerableHelpers.ToArray(source, out _count); } }
public IGrouping <TKey, TElement>[] ToArray() { IIListProvider <IGrouping <TKey, TElement> > lookup = Lookup <TKey, TElement> .Create(_source, _keySelector, _elementSelector, _comparer); return(lookup.ToArray()); }