private static void Skip(ref ZipContext <T2, C2, T, C> context, out Option <Tuple <T, T2> > next) { context.bd.DetectBacktrack(); if (context.needsMove) { context.left.skip(ref context.left.context, out context.left.current); 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 <Tuple <T, T2> >(new Tuple <T, T2>(context.left.current.value, context.right.current.value)); } else { next = new Option <Tuple <T, T2> >(); context.bd.Release(); if (context.left.current.isSome) { context.left.dispose(ref context.left.context, out context.left.current); } else if (context.right.current.isSome) { context.right.dispose(ref context.right.context, out context.right.current); } } }
private static void Remove(ref ZipContext <T2, C2, T, C> context, out Option <Tuple <T, T2> > next) { context.bd.DetectBacktrack(); context.needsMove = false; 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.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); }
private static void Dispose(ref ZipContext <T2, C2, T, C> context, out Option <Tuple <T, T2> > next) { next = new Option <Tuple <T, T2> >(); context.bd.Release(); context.left.dispose(ref context.left.context, out context.left.current); context.right.dispose(ref context.right.context, out context.right.current); }