private static void TakeWhileSkip(ref PredicateContext <T, C> context, out Option <T> next) { context.bd.DetectBacktrack(); if (context.needsMove) { context.chained.skip(ref context.chained.context, out context.chained.current); } else { context.needsMove = true; } if (!context.chained.current.isSome) { next = context.chained.current; context.bd.Release(); } else if (context.predicate(context.chained.current.value)) { next = context.chained.current; } else { next = new Option <T>(); context.bd.Release(); context.chained.dispose(ref context.chained.context, out context.chained.current); } }
private static void WhereSkip(ref PredicateContext <T, C> context, out Option <T> next) { context.bd.DetectBacktrack(); if (context.needsMove) { context.chained.skip(ref context.chained.context, out context.chained.current); } else { context.needsMove = true; } while (context.chained.current.isSome && !context.predicate(context.chained.current.value)) { context.chained.skip(ref context.chained.context, out context.chained.current); } next = context.chained.current; if (!next.isSome) { context.bd.Release(); } }
private static void TakeWhileRemove(ref PredicateContext <T, C> context, out Option <T> next) { context.bd.DetectBacktrack(); context.needsMove = false; context.chained.remove(ref context.chained.context, out context.chained.current); TakeWhileSkip(ref context, out next); }
private static void Dispose(ref PredicateContext <T, C> context, out Option <T> next) { next = new Option <T>(); context.bd.Release(); context.chained.dispose(ref context.chained.context, out context.chained.current); }