Exemple #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)));
        }
Exemple #2
0
        public override ViewL <CompElement <T>, double> LeftView()
        {
            ViewL <CompElement <T>, double> internLView = _treeRep.LeftView();

            internLView.ftTail = new PriorityQueue <T>(internLView.ftTail);

            return(internLView);
        }
Exemple #3
0
        public OrderedSequence <T, M> PushFront(OrderedElement <T, M> ordEl)
        {
            ViewL <OrderedElement <T, M>, M> viewL = _tree.LeftView();

            if (viewL != null)
            {
                if (_tree.LeftView().head.Measure()
                    .CompareTo(ordEl.Measure())
                    < 0)
                {
                    throw new Exception(
                              "OrderedSequence Error: PushFront() of an element greater than the smallest seq el."
                              );
                }
            }
            //else
            return(new OrderedSequence <T, M>(_key, _tree.PushFront(ordEl)));
        }