using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IPA.Utilities { /// /// Extensions for that don't currently exist in System.Linq. /// public static class EnumerableExtensions { /// /// Adds a value to the beginning of the sequence. /// /// the type of the elements of /// a sequence of values /// the value to prepend to /// a new sequence beginning with public static IEnumerable Prepend(this IEnumerable seq, T prep) => new PrependEnumerable(seq, prep); private sealed class PrependEnumerable : IEnumerable { private readonly IEnumerable rest; private readonly T first; public PrependEnumerable(IEnumerable rest, T first) { this.rest = rest; this.first = first; } public IEnumerator GetEnumerator() { yield return first; foreach (var v in rest) yield return v; } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } }