private static void Dispose(ref FlattenContext <T, C1, C2> context, out Option <T> next) { next = new Option <T>(); context.bd.Release(); context.chained.dispose(ref context.chained.context, out context.chained.current); context.selected.dispose(ref context.selected.context, out context.selected.current); }
private static void Remove(ref FlattenContext <T, C1, C2> context, out Option <T> next) { context.bd.DetectBacktrack(); context.needsMove = false; context.selected.remove(ref context.selected.context, out context.selected.current); Skip(ref context, out next); }
private static void Skip(ref FlattenContext <T, C1, C2> context, out Option <T> next) { context.bd.DetectBacktrack(); if (context.needsMove) { context.selected.skip(ref context.selected.context, out context.selected.current); } else { context.needsMove = true; } if (!context.selected.current.isSome && context.chained.current.isSome) { context.chained.skip(ref context.chained.context, out context.chained.current); while (context.chained.current.isSome) { context.selected = context.chained.current.value; if (context.selected.current.isSome) { break; } else { context.chained.skip(ref context.chained.context, out context.chained.current); } } } next = context.selected.current; if (!next.isSome) { context.bd.Release(); } }