Esempio n. 1
0
 public override Pair <FTreeM <T, M>, FTreeM <T, M> > SeqSplit(MPredicate <M> predicate)
 {
     return(new Pair <FTreeM <T, M>, FTreeM <T, M> >
                (new EmptyFTreeM <T, M>(theMonoid),
                new EmptyFTreeM <T, M>(theMonoid)
                ));
 }
Esempio n. 2
0
 public override Split <FTreeM <T, M>, T, M> Split(MPredicate <M> predicate, M acc)
 {
     return(new Split <FTreeM <T, M>, T, M>
                (new EmptyFTreeM <T, M>(theMonoid),
                theSingle,
                new EmptyFTreeM <T, M>(theMonoid)
                ));
 }
Esempio n. 3
0
        Split(MPredicate <uint> predicate, uint acc)
        {
            Split <SizedElement <T>, FTreeM <SizedElement <T>, uint>, uint> internSplit
                = treeRep.Split(predicate, acc);

            internSplit = new Split <SizedElement <T>, FTreeM <SizedElement <T>, uint>, uint>(new Seq <T>(internSplit.Left), internSplit.Item, new Seq <T>(internSplit.Right));

            return(internSplit);
        }
Esempio n. 4
0
        SeqSplit(MPredicate <uint> predicate)
        {
            Pair <FTreeM <SizedElem <T>, uint>, FTreeM <SizedElem <T>, uint> > internPair
                = treeRep.SeqSplit(predicate);

            internPair.first  = new Seq <T>(internPair.first);
            internPair.second = new Seq <T>(internPair.second);

            return(internPair);
        }
Esempio n. 5
0
        SeqSplit(MPredicate <double> predicate)
        {
            Pair <FTreeM <CompElem <T>, double>, FTreeM <CompElem <T>, double> > internPair
                = treeRep.SeqSplit(predicate);

            internPair.first  = new PriorityQueue <T>(internPair.first);
            internPair.second = new PriorityQueue <T>(internPair.second);

            return(internPair);
        }
Esempio n. 6
0
        SeqSplit(MPredicate <uint> predicate)
        {
            Pair <FTreeM <SizedElement <T>, uint>, FTreeM <SizedElement <T>, uint> > internPair
                = treeRep.SeqSplit(predicate);

            internPair = new Pair <FTreeM <SizedElement <T>, uint>, FTreeM <SizedElement <T>, uint> >(new Seq <T>(internPair.First),
                                                                                                      new Seq <T>(internPair.Second));

            return(internPair);
        }
Esempio n. 7
0
        Split(MPredicate <double> predicate, double acc)
        {
            Split <FTreeM <CompElem <T>, double>, CompElem <T>, double> internSplit
                = treeRep.Split(predicate, acc);

            internSplit.left =
                new PriorityQueue <T>(internSplit.left);
            internSplit.right =
                new PriorityQueue <T>(internSplit.right);

            return(internSplit);
        }
Esempio n. 8
0
        Split(MPredicate <uint> predicate, uint acc)
        {
            Split <FTreeM <SizedElem <T>, uint>, SizedElem <T>, uint> internSplit
                = treeRep.Split(predicate, acc);

            internSplit.left =
                new Seq <T>(internSplit.left);
            internSplit.right =
                new Seq <T>(internSplit.right);

            return(internSplit);
        }
Esempio n. 9
0
        public override Split <FTreeM <T, M>, T, M> Split(MPredicate <M> predicate, M acc)
        {
            M vPr = theMonoid.theOp(acc, frontDig.Measure());

            if (predicate(vPr))
            {
                Split <Digit <T, M>, T, M>
                frontSplit = frontDig.Split(predicate, acc);

                return(new Split <FTreeM <T, M>, T, M>
                           (FTreeM <T, M> .FromSequence(frontSplit.left.digNodes, theMonoid),
                           frontSplit.splitItem,
                           FTreeM <T, M> .Create(frontSplit.right.digNodes, innerFT, backDig)
                           ));
            }
            //else
            M vM = theMonoid.theOp(vPr, innerFT.Measure());

            if (predicate(vM))
            {
                var midSplit = innerFT.Split(predicate, vPr);

                var midLeft = midSplit.left;
                var midItem = midSplit.splitItem;

                var splitMidLeft =
                    (new Digit <T, M>(theMonoid, midItem.theNodes)).Split
                        (predicate,
                        theMonoid.theOp(vPr, midLeft.Measure())
                        );

                T finalsplitItem = splitMidLeft.splitItem;

                FTreeM <T, M> finalLeftTree =
                    FTreeM <T, M> .CreateR(frontDig, midLeft, splitMidLeft.left.digNodes);

                FTreeM <T, M> finalRightTree =
                    FTreeM <T, M> .Create(splitMidLeft.right.digNodes, midSplit.right, backDig);

                return(new Split <FTreeM <T, M>, T, M>
                           (finalLeftTree, finalsplitItem, finalRightTree));
            }
            //else
            Split <Digit <T, M>, T, M>
            backSplit = backDig.Split(predicate, vM);

            return(new Split <FTreeM <T, M>, T, M>
                       (FTreeM <T, M> .CreateR(frontDig, innerFT, backSplit.left.digNodes),
                       backSplit.splitItem,
                       FTreeM <T, M> .FromSequence(backSplit.right.digNodes, theMonoid)
                       ));
        }
Esempio n. 10
0
        public override Pair <FTreeM <T, M>, FTreeM <T, M> > SeqSplit(MPredicate <M> predicate)
        {
            if (!predicate(Measure()))
            {
                return(new Pair <FTreeM <T, M>, FTreeM <T, M> >
                           (this,
                           new EmptyFTreeM <T, M>(theMonoid)
                           ));
            }
            //else
            Split <FTreeM <T, M>, T, M> theSplit = Split(predicate, theMonoid.zero);

            return(new Pair <FTreeM <T, M>, FTreeM <T, M> >
                       (theSplit.left, theSplit.right.Push_Front(theSplit.splitItem)
                       ));
        }
Esempio n. 11
0
        public override Pair <FTreeM <T, M>, FTreeM <T, M> > SeqSplit(MPredicate <M> predicate)
        {
            M theMeasure = theSingle.Measure();

            if (predicate(theMeasure))
            {
                return(new Pair <FTreeM <T, M>, FTreeM <T, M> >
                           (new EmptyFTreeM <T, M>(theMonoid),
                           this
                           ));
            }
            //else
            return(new Pair <FTreeM <T, M>, FTreeM <T, M> >
                       (this,
                       new EmptyFTreeM <T, M>(theMonoid)
                       ));
        }
Esempio n. 12
0
            // Assumption: predicate is false on the left end
            //             and true on the right end of the container
            public Split <Digit <U, V>, U, V> Split(MPredicate <V> predicate, V acc)
            {
                int cnt = digNodes.Count;

                if (cnt == 0)
                {
                    throw new Exception("Error: Split of an empty Digit attempted!");
                }
                //else
                U headItem = digNodes[0];

                if (cnt == 1)
                {
                    return(new Split <Digit <U, V>, U, V>
                               (new Digit <U, V>(theMonoid, new List <U>()),
                               headItem,
                               new Digit <U, V>(theMonoid, new List <U>())
                               ));
                }
                //else
                List <U>     digNodesTail = new List <U>(digNodes.GetRange(1, cnt - 1));
                Digit <U, V> digitTail    = new Digit <U, V>(theMonoid, digNodesTail);

                V acc1 = theMonoid.theOp(acc, headItem.Measure());

                if (predicate(acc1))
                {
                    return(new Split <Digit <U, V>, U, V>
                               (new Digit <U, V>(theMonoid, new List <U>()),
                               headItem,
                               digitTail
                               ));
                }
                //else
                Split <Digit <U, V>, U, V> tailSplit = digitTail.Split(predicate, acc1);

                tailSplit.left.digNodes.Insert(0, headItem);

                return(tailSplit);
            }
Esempio n. 13
0
 public T Lookup(MPredicate <M> predicate, M acc)
 {
     return(dropUntil(predicate).LeftView().head);
 }
Esempio n. 14
0
 public FTreeM <T, M> dropUntil(MPredicate <M> predicate)
 {
     return(SeqSplit(predicate).second);
 }
Esempio n. 15
0
 public FTreeM <T, M> takeUntil(MPredicate <M> predicate)
 {
     return(SeqSplit(predicate).first);
 }
Esempio n. 16
0
 public abstract Pair <FTreeM <T, M>, FTreeM <T, M> > SeqSplit(MPredicate <M> predicate);
Esempio n. 17
0
        public override Pair <FTreeM <CompElement <T>, double>, FTreeM <CompElement <T>, double> > SeqSplit(MPredicate <double> predicate)
        {
            Pair <FTreeM <CompElement <T>, double>, FTreeM <CompElement <T>, double> > internPair
                = _treeRep.SeqSplit(predicate);

            internPair = new Pair <FTreeM <CompElement <T>, double>, FTreeM <CompElement <T>, double> >(new PriorityQueue <T>(internPair.First), new PriorityQueue <T>(internPair.Second));

            return(internPair);
        }
Esempio n. 18
0
 public override Split <FTreeM <T, M>, T, M> Split(MPredicate <M> predicate, M acc)
 {
     throw new Exception("Error: Split attempted on an EmptyFTreeM !");
 }
Esempio n. 19
0
 public abstract Split <FTreeM <T, M>, T, M> Split(MPredicate <M> predicate, M acc);
Esempio n. 20
0
        public override Split <CompElement <T>, FTreeM <CompElement <T>, double>, double> Split(MPredicate <double> predicate, double acc)
        {
            Split <CompElement <T>, FTreeM <CompElement <T>, double>, double> internSplit
                = _treeRep.Split(predicate, acc);

            internSplit = new Split <CompElement <T>, FTreeM <CompElement <T>, double>, double>(new PriorityQueue <T>(internSplit.Left),
                                                                                                internSplit.Item, new PriorityQueue <T>(internSplit.Right));

            return(internSplit);
        }