Exemple #1
0
        private static void Skip(ref GroupJoinContext <U, K, T2, T, C> context, out Option <U> 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)
            {
                var bd = BacktrackDetector.Borrow();
                next = new Option <U>(context.resultSelector(
                                          context.chained.current.value,
                                          context.lookup.GetValues(context.outerSelector(context.chained.current.value)).SlinqAndKeep(bd)));
                bd.TryReleaseShared();
            }
            else
            {
                next = new Option <U>();
                context.bd.Release();
                if (context.release)
                {
                    context.lookup.DisposeInBackground();
                }
            }
        }
                #pragma warning restore 0414

        private SelectOptionContext(Slinq <T, C> chained, DelegateFunc <T, Option <U> > selector)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.selector  = selector;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private PredicateContext(Slinq <T, C> chained, DelegateFunc <T, bool> predicate)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.predicate = predicate;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #4
0
 public static Slinq <T, LinkedContext <T> > Slinq(LinkedHeadTail <T> list, bool release)
 {
     return(new Slinq <T, LinkedContext <T> >(
                skip,
                remove,
                dispose,
                new LinkedContext <T>(list, BacktrackDetector.Borrow(), release)));
 }
Exemple #5
0
                #pragma warning restore 0414

        private IntContext(Slinq <T, C> chained, int count)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.count     = count;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private FuncContext(T seed, DelegateFunc <T, T> selector)
        {
            this.needsMove = false;
            this.acc       = seed;
            this.selector  = selector;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #7
0
                #pragma warning restore 0414

        private FuncOptionContext(T seed, DelegateFunc <T, Option <T> > selector)
        {
            this.needsMove = false;
            this.acc       = new Option <T>(seed);
            this.selector  = selector;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #8
0
                #pragma warning restore 0414

        private GroupByContext(Lookup <K, T> lookup, bool release)
        {
            this.lookup  = lookup;
            this.release = release;
            this.runner  = lookup.keys.head;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private LinkedListContext(LinkedListNode <T> node, int step)
        {
            this.needsMove = false;
            this.node      = node;
            this.step      = step;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #10
0
#pragma warning restore 0414

        private FuncContext(T seed, Func <T, T> selector)
        {
            needsMove     = false;
            acc           = seed;
            this.selector = selector;

            bd = BacktrackDetector.Borrow();
        }
Exemple #11
0
                #pragma warning restore 0414

        private SelectContext(Slinq <T, C> chained, Func <T, U> selector)
        {
            needsMove     = false;
            this.chained  = chained;
            this.selector = selector;

            bd = BacktrackDetector.Borrow();
        }
Exemple #12
0
                #pragma warning restore 0414

        private FlattenContext(Slinq <Slinq <T, C1>, C2> chained)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.selected  = chained.current.isSome ? chained.current.value : new Slinq <T, C1>();

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #13
0
                #pragma warning restore 0414

        private ConcatContext(Slinq <T, C> first, Slinq <T, C2> second)
        {
            this.needsMove = false;
            this.first     = first;
            this.second    = second;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private EitherContext(Slinq <T, C> left, Slinq <T, C2> right, bool isLeft)
        {
            needsMove   = false;
            this.isLeft = isLeft;
            this.left   = left;
            this.right  = right;

            bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private SelectSlinqContext(Slinq <T, C> chained, DelegateFunc <T, Slinq <U, UC> > selector)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.selected  = chained.current.isSome ? selector(chained.current.value) : new Slinq <U, UC>();
            this.selector  = selector;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #16
0
                #pragma warning restore 0414

        private IListContext(IList <T> list, int startIndex, int step)
        {
            this.list  = list;
            this.size  = list.Count;
            this.index = startIndex - step;
            this.step  = step;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #17
0
                #pragma warning restore 0414

        private ZipContext(Slinq <T, C> left, Slinq <T2, C2> right, ZipRemoveFlags removeFlags)
        {
            this.needsMove   = false;
            this.left        = left;
            this.right       = right;
            this.removeFlags = removeFlags;

            this.bd = BacktrackDetector.Borrow();
        }
Exemple #18
0
                #pragma warning restore 0414

        private AggregateContext(Slinq <T, C> chained, U seed, Func <U, T, U> selector)
        {
            needsMove     = false;
            this.chained  = chained;
            acc           = seed;
            this.selector = selector;

            bd = BacktrackDetector.Borrow();
        }
Exemple #19
0
                #pragma warning restore 0414

        private HashSetContext(Slinq <T, C> chained, Disposable <HashSet <T> > hashSet, bool release)
        {
            this.needsMove = false;
            this.chained   = chained;
            this.hashSet   = hashSet;
            this.release   = release;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private BufferPredicateContext(Slinq <T, C> slinq, DelegateFunc <T, T, bool> pred)
        {
            needsMove = false;
            chained   = slinq;
            predicate = pred;
            acc       = null;
            release   = ListPool <List <T> > .Instance.Borrow();

            bd = BacktrackDetector.Borrow();
        }
Exemple #21
0
                #pragma warning restore 0414

        private GroupJoinContext(Lookup <K, T2> lookup, Slinq <T, C> outer, DelegateFunc <T, K> outerSelector, DelegateFunc <T, Slinq <T2, LinkedContext <T2> >, U> resultSelector, bool release)
        {
            this.needsMove      = false;
            this.lookup         = lookup;
            this.outerSelector  = outerSelector;
            this.resultSelector = resultSelector;
            this.chained        = outer;
            this.release        = release;

            this.bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private JoinContext(Lookup <K, T2> lookup, Slinq <T, C> outer, Func <T, K> outerSelector, Func <T, T2, U> resultSelector, bool release)
        {
            needsMove           = false;
            this.lookup         = lookup;
            this.outerSelector  = outerSelector;
            this.resultSelector = resultSelector;
            chained             = outer;
            this.release        = release;

            LinkedHeadTail <T2> iht;

            inner = chained.current.isSome && lookup.dictionary.TryGetValue(outerSelector(chained.current.value), out iht) ? iht.head : null;

            bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private IEnumerableContext(IEnumerable <T> enumerable)
        {
            enumerator = enumerable.GetEnumerator();

            bd = BacktrackDetector.Borrow();
        }
                #pragma warning restore 0414

        private OptionContext(Option <T> option)
        {
            this.option = option;

            bd = BacktrackDetector.Borrow();
        }