示例#1
0
        static FTreeM <OrderedElement <T, M>, M> OrdMerge(FTreeM <OrderedElement <T, M>, M> ordTree1, FTreeM <OrderedElement <T, M>, M> ordTree2)
        {
            ViewL <OrderedElement <T, M>, M> lView2 = ordTree2.LeftView();

            if (lView2 == null)
            {
                return(ordTree1);
            }
            //else
            OrderedElement <T, M>             bHead = lView2.head;
            FTreeM <OrderedElement <T, M>, M> bTail = lView2.ftTail;

            // Split ordTree1 on elems <= and then > bHead
            Pair <FTreeM <OrderedElement <T, M>, M>, FTreeM <OrderedElement <T, M>, M> >
            tree1Split = ordTree1.SeqSplit
                             (new MPredicate <M>
                                 (FP.Curry <M, M, bool>(LessThanOrEqual2, bHead.Measure()))
                             );

            FTreeM <OrderedElement <T, M>, M> leftTree1  = tree1Split.First;
            FTreeM <OrderedElement <T, M>, M> rightTree1 = tree1Split.Second;

            // OrdMerge the tail of ordTree2
            //          with the right-split part of ordTree1
            FTreeM <OrderedElement <T, M>, M>
            mergedRightparts = OrdMerge(bTail, rightTree1);

            return(leftTree1.Merge(mergedRightparts.PushFront(bHead)));
        }
示例#2
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);
        }
示例#3
0
        Pair <OrderedSequence <T, M>, OrderedSequence <T, M> > Partition(M vK)
        {
            Pair <FTreeM <OrderedElement <T, M>, M>, FTreeM <OrderedElement <T, M>, M> > baseSeqSplit = _tree.SeqSplit(new MPredicate <M>(FP.Curry <M, M, bool>(LessThanOrEqual2, vK)));

            var left = new OrderedSequence <T, M>(_key, baseSeqSplit.First);

            var right = new OrderedSequence <T, M>(_key, baseSeqSplit.Second);

            return(new Pair <OrderedSequence <T, M>, OrderedSequence <T, M> >(left, right));
        }