public static unsafe void Prepend <TElement>(this IPrepend <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged { for (Int32 i = length - 1; i >= 0; i--) { collection.Prepend(elements[i]); } }
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, ReadOnlySpan <TElement> elements) { for (Int32 i = elements.Length - 1; i >= 0; i--) { collection.Prepend(elements[i]); } }
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <typeparam name="TEnumerator">The type of the enumerator for the <paramref name="elements"/>.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement, TEnumerator>(this IPrepend <TElement> collection, IGetEnumerator <TElement, TEnumerator>?elements) where TEnumerator : notnull, ICurrent <TElement>, IMoveNext { if (elements is not null) { foreach (TElement element in elements) { collection.Prepend(element); } } }
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, Collections.Generic.IEnumerable <TElement>?elements) { if (elements is not null) { foreach (TElement element in elements) { collection.Prepend(element); } } }
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend(this IPrepend <Char> collection, String?elements) => Prepend(collection, elements.AsSpan());
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, Span <TElement> elements) => Prepend(collection, (ReadOnlySpan <TElement>)elements);
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, ReadOnlyMemory <TElement> elements) => Prepend(collection, elements.Span);
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, ArraySegment <TElement> elements) => Prepend(collection, elements.AsSpan());
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, params TElement[]?elements) => Prepend(collection, elements.AsSpan());