/// <summary> /// Context-preserving variant of <see cref="SourceOperations.Grouped{TOut,TMat}"/> /// Each output group will be associated with a `Seq` of corresponding context elements. /// </summary> public static SourceWithContext <IReadOnlyList <TCtx>, IReadOnlyList <TOut>, TMat> Grouped <TCtx, TOut, TMat>( this SourceWithContext <TCtx, TOut, TMat> flow, int n) { var stage = new Grouped <(TOut, TCtx)>(n); return(flow.Via(Flow.FromGraph(stage).Select(itemsWithContexts => { var items = new List <TOut>(n); var ctxs = new List <TCtx>(n); foreach (var tuple in itemsWithContexts) { items.Add(tuple.Item1); ctxs.Add(tuple.Item2); } return ((IReadOnlyList <TOut>)items, (IReadOnlyList <TCtx>)ctxs); }))); }
/// <summary> /// Context-preserving variant of <see cref="SourceOperations.SelectMany{T,TOut,TMat}"/>. /// The context of the input element will be associated with each of the output elements calculated from /// this input element. /// </summary> public static SourceWithContext <TCtx, TOut2, TMat> SelectConcat <TCtx, TOut, TOut2, TMat>( this SourceWithContext <TCtx, TOut, TMat> flow, Func <TOut, IEnumerable <TOut2> > fn) => StatefulSelectConcat(flow, () => fn);