Beispiel #1
0
        private void TryUnstackQueues(Side <TInLeft> lSide, Side <TInRight> rSide, LeftJoinParams <TInLeft, TInRight, TOut> leftJoinParams)
        {
            bool somethingChanged;

            do
            {
                somethingChanged = false;
                while (!rSide.IsEmpty && !lSide.IsEmpty && leftJoinParams.comparer.Compare(lSide.CurrentValue, rSide.CurrentValue) > 0)
                {
                    rSide.Dequeue();
                    somethingChanged = true;
                }

                int comparison;
                while (!lSide.IsEmpty && !rSide.IsEmpty && (comparison = leftJoinParams.comparer.Compare(lSide.CurrentValue, rSide.CurrentValue)) <= 0)
                {
                    TOut ret;
                    try
                    {
                        ret = leftJoinParams.selector(lSide.Dequeue(), comparison == 0 ? rSide.CurrentValue : default(TInRight));
                        this.PushValue(ret);
                    }
                    catch (Exception ex)
                    {
                        PushException(ex);
                    }
                    somethingChanged = true;
                }

                if (rSide.IsEmpty && rSide.IsComplete)
                {
                    while (!lSide.IsEmpty)
                    {
                        TOut ret;
                        try
                        {
                            ret = leftJoinParams.selector(lSide.Dequeue(), default(TInRight));
                            this.PushValue(ret);
                        }
                        catch (Exception ex)
                        {
                            PushException(ex);
                        }
                        somethingChanged = true;
                    }
                }
            } while (somethingChanged);
            if (lSide.IsComplete && (lSide.IsEmpty || rSide.IsComplete))
            {
                this.Complete();
            }
        }
Beispiel #2
0
        private void TryUnstackQueues(Side <TInLeft> lSide, Side <TInRight> rSide, LeftJoinParams <TInLeft, TInRight, TOut> leftJoinParams)
        {
            bool somethingChanged;

            do
            {
                if (CancellationToken.IsCancellationRequested)
                {
                    break;
                }
                somethingChanged = false;
                while (!rSide.IsEmpty && !lSide.IsEmpty && leftJoinParams.comparer.Compare(lSide.CurrentValue, rSide.CurrentValue) > 0)
                {
                    if (CancellationToken.IsCancellationRequested)
                    {
                        break;
                    }
                    rSide.Dequeue();
                    somethingChanged = true;
                }

                int comparison;
                while (!lSide.IsEmpty && !rSide.IsEmpty && (comparison = leftJoinParams.comparer.Compare(lSide.CurrentValue, rSide.CurrentValue)) <= 0)
                {
                    if (CancellationToken.IsCancellationRequested)
                    {
                        break;
                    }
                    this.TryPushValue(() => leftJoinParams.selector(lSide.Dequeue(), comparison == 0 ? rSide.CurrentValue : default(TInRight)));
                    somethingChanged = true;
                }

                if (rSide.IsEmpty && rSide.IsComplete)
                {
                    while (!lSide.IsEmpty)
                    {
                        if (CancellationToken.IsCancellationRequested)
                        {
                            break;
                        }
                        this.TryPushValue(() => leftJoinParams.selector(lSide.Dequeue(), default(TInRight)));
                        somethingChanged = true;
                    }
                }
            } while (somethingChanged);
            if (lSide.IsComplete && (lSide.IsEmpty || rSide.IsComplete))
            {
                this.Complete();
            }
        }