Exemplo n.º 1
0
        private static void Remove(ref ZipAllContext <T2, C2, T, C> context, out Option <Tuple <Option <T>, Option <T2> > > next)
        {
            context.bd.DetectBacktrack();

            context.needsMove = false;

            if (!context.left.current.isSome)
            {
                // noop
            }
            else if ((context.removeFlags & ZipRemoveFlags.Left) == ZipRemoveFlags.Left)
            {
                context.left.remove(ref context.left.context, out context.left.current);
            }
            else
            {
                context.left.skip(ref context.left.context, out context.left.current);
            }

            if (!context.right.current.isSome)
            {
                // noop
            }
            else if ((context.removeFlags & ZipRemoveFlags.Right) == ZipRemoveFlags.Right)
            {
                context.right.remove(ref context.right.context, out context.right.current);
            }
            else
            {
                context.right.skip(ref context.right.context, out context.right.current);
            }

            Skip(ref context, out next);
        }
Exemplo n.º 2
0
        private static void Dispose(ref ZipAllContext <T2, C2, T, C> context, out Option <Tuple <Option <T>, Option <T2> > > next)
        {
            next = new Option <Tuple <Option <T>, Option <T2> > >();

            context.bd.Release();

            if (context.left.current.isSome)
            {
                context.left.dispose(ref context.left.context, out context.left.current);
                if (context.right.current.isSome)
                {
                    context.right.dispose(ref context.right.context, out context.right.current);
                }
            }
            else
            {
                context.right.dispose(ref context.right.context, out context.right.current);
            }
        }
Exemplo n.º 3
0
        private static void Skip(ref ZipAllContext <T2, C2, T, C> context, out Option <ValueTuple <Option <T>, Option <T2> > > next)
        {
            context.bd.DetectBacktrack();

            if (context.needsMove)
            {
                if (context.left.current.isSome)
                {
                    context.left.skip(ref context.left.context, out context.left.current);
                    if (context.right.current.isSome)
                    {
                        context.right.skip(ref context.right.context, out context.right.current);
                    }
                }
                else
                {
                    context.right.skip(ref context.right.context, out context.right.current);
                }
            }
            else
            {
                context.needsMove = true;
            }

            if (context.left.current.isSome || context.right.current.isSome)
            {
                next = new Option <ValueTuple <Option <T>, Option <T2> > >(
                    new ValueTuple <Option <T>, Option <T2> >(context.left.current, context.right.current));
            }
            else
            {
                next = new Option <ValueTuple <Option <T>, Option <T2> > >();
            }

            if (!next.isSome)
            {
                context.bd.Release();
            }
        }