Example #1
0
        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);
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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);
        }
Example #4
0
 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);
 }