/// <summary> /// Concatenates two ordered sequences. /// </summary> /// <param name="left">The first ordered sequence to concatenate.</param> /// <param name="right"> /// The sequence that follows same ordering rules as the first ordered sequence /// to concatenate to the first ordered sequence. /// </param> public static OrderedEnumerable <T, TKey> Concat <T, TKey>( this OrderedEnumerable <T, TKey> left, IEnumerable <T> right) { return(Concat(left, right.AsOrderedLike(left), left.Comparer) .AsOrderedLike(left)); }
/// <summary> /// Produces the set difference of two ordered sequences. /// </summary> /// <param name="left"> /// An ordered sequence whose elements /// that are not also in second will be returned. /// </param> /// <param name="right"> /// An ordered sequence that follows same ordering rules as the first ordered sequence /// whose elements that also occur in the first ordered sequence /// will cause those elements to be removed from the returned sequence. /// </param> public static OrderedEnumerable <T, TKey> Except <T, TKey>( this OrderedEnumerable <T, TKey> left, IEnumerable <T> right) { return(Except(left, right.AsOrderedLike(left), left.Comparer) .AsOrderedLike(left) .Distinct()); }
/// <summary> /// Projects each element of an ordered sequence /// and flattens the resulting ordered sequences into one ordered sequence. The index of each source /// element is used in the projected form of that element. /// </summary> /// <param name="source">An ordered sequence of values to project.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the element.</param> public static OrderedEnumerable <TResult, TResultKey> SelectMany <TSource, TSourceKey, TResult, TResultKey>( this OrderedEnumerable <TSource, TSourceKey> source, OrderedEnumerable <TResult, TResultKey> seed, Func <TSource, int, IEnumerable <TResult> > selector) { return(SelectMany(source, selector, seed.Comparer) .AsOrderedLike(seed)); }
internal static OrderedEnumerable <U, TKey> AsOrderedLike <T, U, TKey>( this IEnumerable <U> source, Func <U, TKey> keySelector, OrderedEnumerable <T, TKey> parent) => new OrderedEnumerable <U, TKey>( source, keySelector, parent.KeyComparer, parent.Descending);
internal static OrderedEnumerable <OrderedGrouping <TKey, T>, TKey> AsOrderedLike <T, TKey>( this IEnumerable <IGrouping <TKey, T> > source, OrderedEnumerable <T, TKey> parent) => source .Select(group => new OrderedGrouping <TKey, T>( group, parent.KeySelector, parent.KeyComparer, parent.Descending)) .AsOrderedLike(group => group.Key, parent);
/// <summary> /// Correlates the elements of two ordered sequences based on matching keys. /// </summary> /// <param name="outer">The first ordered sequence to join.</param> /// <param name="inner"> /// The sequence that follows same ordering rules as the first sequence /// to join to the first sequence. /// </param> /// <param name="resultSelector"> /// 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="resultKeySelector">A function to extract the key from each element of the result sequence.</param> public static OrderedEnumerable <TResult, TKey> Join <TOuter, TInner, TKey, TResult>( this OrderedEnumerable <TOuter, TKey> outer, IEnumerable <TInner> inner, Func <TInner, TKey> innerKeySelector, Func <TOuter, TInner, TResult> resultSelector, Func <TResult, TKey> resultKeySelector) { return(Join( outer, inner.AsOrderedLike(innerKeySelector, outer), outer.KeySelector, innerKeySelector, resultSelector, outer.KeyComparer) .AsOrderedLike(resultKeySelector, outer)); }
/// <summary> /// Groups the elements of an ordered sequence. /// </summary> /// <param name="source">An ordered sequence whose elements to group.</param> public static OrderedEnumerable <OrderedGrouping <TKey, T>, TKey> GroupBy <T, TKey>( this OrderedEnumerable <T, TKey> source) { return(GroupBy(source, source.KeySelector, source.KeyComparer) .AsOrderedLike(source)); }
internal static OrderedEnumerable <T, TKey> AsOrderedLike <T, TKey>( this IEnumerable <T> source, OrderedEnumerable <T, TKey> parent) => AsOrderedLike(source, parent.KeySelector, parent);
/// <summary> /// Returns distinct elements from an ordered sequence. /// </summary> /// <param name="source">The ordered sequence to remove duplicate elements from.</param> public static OrderedEnumerable <T, TKey> Distinct <T, TKey>( this OrderedEnumerable <T, TKey> source) { return(Distinct <T>(source, source.Comparer) .AsOrderedLike(source)); }