Exemplo n.º 1
0
 private static IEnumerable <TResult> JoinIterator <TOuter, TInner, TKey, TResult>(IEnumerable <TOuter> outer, IEnumerable <TInner> inner, Func <TOuter, TKey> outerKeySelector, Func <TInner, TKey> innerKeySelector, Func <TOuter, TInner, TResult> resultSelector, IEqualityComparer <TKey> comparer)
 {
     using (IEnumerator <TOuter> e = outer.GetEnumerator())
     {
         if (e.MoveNext())
         {
             Consumables.Lookup <TKey, TInner> lookup = Consumer.Lookup.ConsumeForJoin(inner, innerKeySelector, comparer);
             if (lookup.Count != 0)
             {
                 do
                 {
                     TOuter item = e.Current;
                     Grouping <TKey, TInner> g = lookup.GetGrouping(outerKeySelector(item), create: false);
                     if (g != null)
                     {
                         int count = g._count;
                         if (count == 1)
                         {
                             yield return(resultSelector(item, g._element));
                         }
                         else
                         {
                             TInner[] elements = g._elementsOrNull;
                             for (int i = 0; i != count; ++i)
                             {
                                 yield return(resultSelector(item, elements[i]));
                             }
                         }
                     }
                 }while (e.MoveNext());
             }
         }
     }
 }
Exemplo n.º 2
0
 private static IEnumerable <TResult> GroupJoinIterator <TOuter, TInner, TKey, TResult>(IEnumerable <TOuter> outer, IEnumerable <TInner> inner, Func <TOuter, TKey> outerKeySelector, Func <TInner, TKey> innerKeySelector, Func <TOuter, IEnumerable <TInner>, TResult> resultSelector, IEqualityComparer <TKey> comparer)
 {
     using (IEnumerator <TOuter> e = outer.GetEnumerator())
     {
         if (e.MoveNext())
         {
             Consumables.Lookup <TKey, TInner> lookup = Consumer.Lookup.ConsumeForJoin(inner, innerKeySelector, comparer);
             do
             {
                 TOuter item = e.Current;
                 yield return(resultSelector(item, lookup[outerKeySelector(item)]));
             }while (e.MoveNext());
         }
     }
 }
Exemplo n.º 3
0
 public SystemLinq_ConsumablesLookupDebugView(Consumables.Lookup <TKey, TElement> lookup)
 {
     _lookup = lookup;
 }