Esempio n. 1
0
        public bool MoveNext()
        {
            if (InnerLookup.IsDefaultValue())
            {
                InnerLookup = CommonImplementation.ToLookupImpl(ref Right, RightKeySelector, Comparer);
            }

            while (Left.MoveNext())
            {
                var cur    = Left.Current;
                var curKey = LeftKeySelector(cur);

                if (curKey == null)
                {
                    var nullGroup = EmptyCache <TKeyItem, TRightItem> .EmptyGrouping;
                    Current = ResultSelector(cur, new GroupedEnumerable <TKeyItem, TRightItem>(ref nullGroup));
                    return(true);
                }

                var forKey = InnerLookup[curKey];

                var asGrouped = new GroupedEnumerable <TKeyItem, TRightItem>(ref forKey);
                Current = ResultSelector(cur, asGrouped);
                return(true);
            }

            return(false);
        }
            > Zip <TOutItem, TFirstItem, TGenLookupKey, TGenLookupElement>(
            BuiltInEnumerable <TFirstItem> first,
            LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> second,
            Func <TFirstItem, GroupingEnumerable <TGenLookupKey, TGenLookupElement>, TOutItem> resultSelector
            )
        {
            var firstBridged = Bridge(first, nameof(first));

            if (second.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(second));
            }
            if (resultSelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(resultSelector));
            }

            return
                (CommonImplementation.ZipImpl <
                     TOutItem,
                     TFirstItem,
                     GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
                     BuiltInEnumerable <TFirstItem>,
                     BuiltInEnumerator <TFirstItem>,
                     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
                     LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
                     >(RefLocal(firstBridged), ref second, resultSelector));
        }
Esempio n. 3
0
 public void Dispose()
 {
     Left.Dispose();
     Right.Dispose();
     InnerLookup = default(LookupSpecificEnumerable <TKeyItem, TRightItem>);
     NeedsYield  = default(GroupingEnumerator <TRightItem>);
     CurrentKey  = default(TLeftItem);
 }
Esempio n. 4
0
        public static int Count <TLookupKey, TLookupElement>(this LookupSpecificEnumerable <TLookupKey, TLookupElement> source)
        {
            if (source.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(source));
            }

            return(source.Count);
        }
 public bool SequenceEqual <TGenKey, TGenElement>(
     LookupSpecificEnumerable <TGenKey, TGenElement> first,
     LookupSpecificEnumerable <TGenKey, TGenElement> second
     )
 {
     return
         (CommonImplementation.SequenceEqual <
              GroupingEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>
              >(ref first, ref second, null));
 }
 public bool SequenceEqual <TGenKey, TGenElement>(
     PlaceholderEnumerable <GroupingEnumerable <TGenKey, TGenElement> > first,
     LookupSpecificEnumerable <TGenKey, TGenElement> second
     )
 {
     return
         (CommonImplementation.SequenceEqual <
              GroupingEnumerable <TGenKey, TGenElement>,
              PlaceholderEnumerable <GroupingEnumerable <TGenKey, TGenElement> >,
              PlaceholderEnumerator <GroupingEnumerable <TGenKey, TGenElement> >,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>
              >(RefParam(first), ref second, null));
 }
 public bool SequenceEqual <TGenKey, TGenElement>(
     LookupSpecificEnumerable <TGenKey, TGenElement> first,
     LookupDefaultEnumerable <TGenKey, TGenElement> second,
     IEqualityComparer <GroupingEnumerable <TGenKey, TGenElement> > comparer
     )
 {
     return
         (CommonImplementation.SequenceEqual <
              GroupingEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>,
              LookupDefaultEnumerable <TGenKey, TGenElement>,
              LookupDefaultEnumerator <TGenKey, TGenElement>
              >(ref first, ref second, comparer));
 }
 public bool SequenceEqual <TGenKey, TGenElement, TGenInItem2, TGenEnumerable2, TGenEnumerator2>(
     LookupSpecificEnumerable <TGenKey, TGenElement> first,
     GroupBySpecificEnumerable <TGenInItem2, TGenKey, TGenElement, TGenEnumerable2, TGenEnumerator2> second
     )
     where TGenEnumerable2 : struct, IStructEnumerable <TGenInItem2, TGenEnumerator2>
     where TGenEnumerator2 : struct, IStructEnumerator <TGenInItem2>
 {
     return
         (CommonImplementation.SequenceEqual <
              GroupingEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>,
              GroupBySpecificEnumerable <TGenInItem2, TGenKey, TGenElement, TGenEnumerable2, TGenEnumerator2>,
              GroupBySpecificEnumerator <TGenInItem2, TGenKey, TGenElement, TGenEnumerator2>
              >(ref first, ref second, null));
 }
 public bool SequenceEqual <TGenInItem, TGenKey, TGenElement, TGenEnumerable, TGenEnumerator>(
     GroupByDefaultEnumerable <TGenInItem, TGenKey, TGenElement, TGenEnumerable, TGenEnumerator> first,
     LookupSpecificEnumerable <TGenKey, TGenElement> second
     )
     where TGenEnumerable : struct, IStructEnumerable <TGenInItem, TGenEnumerator>
     where TGenEnumerator : struct, IStructEnumerator <TGenInItem>
 {
     return
         (CommonImplementation.SequenceEqual <
              GroupingEnumerable <TGenKey, TGenElement>,
              GroupByDefaultEnumerable <TGenInItem, TGenKey, TGenElement, TGenEnumerable, TGenEnumerator>,
              GroupByDefaultEnumerator <TGenInItem, TGenKey, TGenElement, TGenEnumerator>,
              LookupSpecificEnumerable <TGenKey, TGenElement>,
              LookupSpecificEnumerator <TGenKey, TGenElement>
              >(ref first, ref second, null));
 }
     > Concat <TGenLookupKey, TGenLookupElement>(
     PlaceholderEnumerable <GroupingEnumerable <TGenLookupKey, TGenLookupElement> > first,
     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> second
     )
 {
     return
         (CommonImplementation.Concat <
              GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
              PlaceholderEnumerable <GroupingEnumerable <TGenLookupKey, TGenLookupElement> >,
              PlaceholderEnumerator <GroupingEnumerable <TGenLookupKey, TGenLookupElement> >,
              LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
              >(
              RefParam(first),
              ref second
              ));
 }
     > Concat <TGenLookupKey, TGenLookupElement>(
     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> first,
     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> second
     )
 {
     return
         (CommonImplementation.Concat <
              GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
              >(
              ref first,
              ref second
              ));
 }
Esempio n. 12
0
 internal GroupJoinSpecificEnumerator(
     ref TLeftEnumerator left,
     ref TRightEnumerator right,
     Func <TLeftItem, TKeyItem> leftKeySelector,
     Func <TRightItem, TKeyItem> rightKeySelector,
     Func <TLeftItem, GroupedEnumerable <TKeyItem, TRightItem>, TOutItem> resultSelector,
     IEqualityComparer <TKeyItem> comparer
     )
 {
     Left             = left;
     Right            = right;
     LeftKeySelector  = leftKeySelector;
     RightKeySelector = rightKeySelector;
     ResultSelector   = resultSelector;
     InnerLookup      = default(LookupSpecificEnumerable <TKeyItem, TRightItem>);
     Current          = default(TOutItem);
     Comparer         = comparer;
 }
     > Concat <TGenLookupKey, TGenLookupElement, TGenGroupByInItem2, TGenGroupByEnumerable2, TGenGroupByEnumerator2>(
     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> first,
     GroupBySpecificEnumerable <TGenGroupByInItem2, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerable2, TGenGroupByEnumerator2> second
     )
     where TGenGroupByEnumerable2 : struct, IStructEnumerable <TGenGroupByInItem2, TGenGroupByEnumerator2>
     where TGenGroupByEnumerator2 : struct, IStructEnumerator <TGenGroupByInItem2>
 {
     return
         (CommonImplementation.Concat <
              GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>,
              GroupBySpecificEnumerable <TGenGroupByInItem2, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerable2, TGenGroupByEnumerator2>,
              GroupBySpecificEnumerator <TGenGroupByInItem2, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerator2>
              >(
              ref first,
              ref second
              ));
 }
     > Concat <TGenGroupByInItem, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerable, TGenGroupByEnumerator>(
     GroupBySpecificEnumerable <TGenGroupByInItem, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerable, TGenGroupByEnumerator> first,
     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> second
     )
     where TGenGroupByEnumerable : struct, IStructEnumerable <TGenGroupByInItem, TGenGroupByEnumerator>
     where TGenGroupByEnumerator : struct, IStructEnumerator <TGenGroupByInItem>
 {
     return
         (CommonImplementation.Concat <
              GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
              GroupBySpecificEnumerable <TGenGroupByInItem, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerable, TGenGroupByEnumerator>,
              GroupBySpecificEnumerator <TGenGroupByInItem, TGenLookupKey, TGenLookupElement, TGenGroupByEnumerator>,
              LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
              LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
              >(
              ref first,
              ref second
              ));
 }
            > Except <TGenGroupByKey, TGenGroupByElement>(
            BuiltInEnumerable <GroupingEnumerable <TGenGroupByKey, TGenGroupByElement> > first,
            LookupSpecificEnumerable <TGenGroupByKey, TGenGroupByElement> second
            )
        {
            var firstBridge = Bridge(first, nameof(first));

            if (second.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(second));
            }

            return(CommonImplementation.ExceptImpl <
                       GroupingEnumerable <TGenGroupByKey, TGenGroupByElement>,
                       BuiltInEnumerable <GroupingEnumerable <TGenGroupByKey, TGenGroupByElement> >,
                       BuiltInEnumerator <GroupingEnumerable <TGenGroupByKey, TGenGroupByElement> >,
                       LookupSpecificEnumerable <TGenGroupByKey, TGenGroupByElement>,
                       LookupSpecificEnumerator <TGenGroupByKey, TGenGroupByElement>
                       >(RefLocal(firstBridge), ref second));
        }
Esempio n. 16
0
            > Join <TOutItem, TJoinKeyItem, TJoinLeftItem, TGenLookupKey, TGenLookupElement>(
            BuiltInEnumerable <TJoinLeftItem> outer,
            LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> inner,
            Func <TJoinLeftItem, TJoinKeyItem> outerKeySelector,
            Func <GroupingEnumerable <TGenLookupKey, TGenLookupElement>, TJoinKeyItem> innerKeySelector,
            Func <TJoinLeftItem, GroupingEnumerable <TGenLookupKey, TGenLookupElement>, TOutItem> resultSelector,
            IEqualityComparer <TJoinKeyItem> comparer
            )
        {
            var outerBridge = Bridge(outer, nameof(outer));

            if (inner.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(inner));
            }

            if (outerKeySelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(outerKeySelector));
            }
            if (innerKeySelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(innerKeySelector));
            }
            if (resultSelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(resultSelector));
            }

            return
                (CommonImplementation.JoinImpl <
                     TOutItem,
                     TJoinKeyItem,
                     TJoinLeftItem,
                     BuiltInEnumerable <TJoinLeftItem>,
                     BuiltInEnumerator <TJoinLeftItem>,
                     GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
                     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
                     LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
                     >(RefLocal(outerBridge), ref inner, outerKeySelector, innerKeySelector, resultSelector, comparer));
        }
Esempio n. 17
0
        public bool SequenceEqual <TGenKey, TGenElement>(
            BuiltInEnumerable <GroupingEnumerable <TGenKey, TGenElement> > first,
            LookupSpecificEnumerable <TGenKey, TGenElement> second
            )
        {
            var firstBridge = Bridge(first, nameof(second));

            if (second.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(second));
            }

            return
                (CommonImplementation.SequenceEqualImpl <
                     GroupingEnumerable <TGenKey, TGenElement>,
                     BuiltInEnumerable <GroupingEnumerable <TGenKey, TGenElement> >,
                     BuiltInEnumerator <GroupingEnumerable <TGenKey, TGenElement> >,
                     LookupSpecificEnumerable <TGenKey, TGenElement>,
                     LookupSpecificEnumerator <TGenKey, TGenElement>
                     >(RefLocal(firstBridge), ref second));
        }
            > GroupJoin <TResult, TGroupJoinKey, TOuter, TGenLookupKey, TGenLookupElement>(
            BuiltInEnumerable <TOuter> outer,
            LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement> inner,
            Func <TOuter, TGroupJoinKey> outerKeySelector,
            Func <GroupingEnumerable <TGenLookupKey, TGenLookupElement>, TGroupJoinKey> innerKeySelector,
            Func <TOuter, GroupedEnumerable <TGroupJoinKey, GroupingEnumerable <TGenLookupKey, TGenLookupElement> >, TResult> resultSelector
            )
        {
            var outerBridge = Bridge(outer, nameof(outer));

            if (inner.IsDefaultValue())
            {
                throw CommonImplementation.Uninitialized(nameof(inner));
            }
            if (outerKeySelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(outerKeySelector));
            }
            if (innerKeySelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(innerKeySelector));
            }
            if (resultSelector == null)
            {
                throw CommonImplementation.ArgumentNull(nameof(resultSelector));
            }

            return
                (CommonImplementation.GroupJoinImpl <
                     TResult,
                     TGroupJoinKey,
                     TOuter,
                     BuiltInEnumerable <TOuter>,
                     BuiltInEnumerator <TOuter>,
                     GroupingEnumerable <TGenLookupKey, TGenLookupElement>,
                     LookupSpecificEnumerable <TGenLookupKey, TGenLookupElement>,
                     LookupSpecificEnumerator <TGenLookupKey, TGenLookupElement>
                     >(RefLocal(outerBridge), ref inner, outerKeySelector, innerKeySelector, resultSelector));
        }
Esempio n. 19
0
        public bool MoveNext()
        {
            if (InnerLookup.IsDefaultValue())
            {
                InnerLookup = CommonImplementation.ToLookupImpl(ref Right, RightKeySelector, Comparer);
            }

continueYielding:
            if (!NeedsYield.IsDefaultValue())
            {
                if (NeedsYield.MoveNext())
                {
                    var rightCur = NeedsYield.Current;
                    Current = ResultSelector(CurrentKey, rightCur);
                    return(true);
                }

                NeedsYield.Dispose();
                NeedsYield = default(GroupingEnumerator <TRightItem>);
            }

            while (Left.MoveNext())
            {
                var cur    = Left.Current;
                var curKey = LeftKeySelector(cur);

                if (curKey == null)
                {
                    continue;
                }

                CurrentKey = cur;
                NeedsYield = InnerLookup[curKey].GetEnumerator();
                goto continueYielding;
            }

            return(false);
        }
Esempio n. 20
0
 public void Dispose()
 {
     Left.Dispose();
     Right.Dispose();
     InnerLookup = default(LookupSpecificEnumerable <TKeyItem, TRightItem>);
 }
Esempio n. 21
0
 public static int Count <TLookupKey, TLookupElement>(this LookupSpecificEnumerable <TLookupKey, TLookupElement> source, Func <GroupingEnumerable <TLookupKey, TLookupElement>, bool> predicate)
 => CommonImplementation.Count <GroupingEnumerable <TLookupKey, TLookupElement>, LookupSpecificEnumerable <TLookupKey, TLookupElement>, LookupSpecificEnumerator <TLookupKey, TLookupElement> >(ref source, predicate);
Esempio n. 22
0
 public static System.Collections.Generic.Stack <GroupingEnumerable <TKey, TItem> > Stack <TKey, TItem>(LookupSpecificEnumerable <TKey, TItem> second)
 => StackImpl <GroupingEnumerable <TKey, TItem>, LookupSpecificEnumerable <TKey, TItem>, LookupSpecificEnumerator <TKey, TItem> >(ref second);
 public static System.Collections.Generic.LinkedList <GroupingEnumerable <TKey, TItem> > LinkedList <TKey, TItem>(LookupSpecificEnumerable <TKey, TItem> second)
 => LinkedListImpl <GroupingEnumerable <TKey, TItem>, LookupSpecificEnumerable <TKey, TItem>, LookupSpecificEnumerator <TKey, TItem> >(ref second);