Beispiel #1
0
        public override FTree <T> App2(List <T> ts, FTree <T> rightFT)
        {
            if (!(rightFT is DeepFTree <T>))
            {
                FTree <T> resultFT = this;

                foreach (T t in ts)
                {
                    resultFT = resultFT.Push_Back(t);
                }

                return((rightFT is EmptyFTree <T>)
                          ? resultFT
                          : resultFT.Push_Back(rightFT.LeftView().head));
            }
            else
            {
                var deepRight = rightFT as DeepFTree <T>;
                var cmbList   = new List <T>(backDig.digNodes);

                cmbList.AddRange(ts);
                cmbList.AddRange(deepRight.frontDig.digNodes);

                return(new DeepFTree <T>(frontDig, innerFT.App2(FTree <T> .ListOfNodes(cmbList), deepRight.innerFT), deepRight.backDig));
            }
        }
Beispiel #2
0
        public override ViewL <T> LeftView()
        {
            T head = frontDig.digNodes[0];

            var newFront = new List <T>(frontDig.digNodes);

            newFront.RemoveAt(0);

            return(new ViewL <T>(head, FTree <T> .Create(newFront, innerFT, backDig)));
        }
Beispiel #3
0
        public override ViewR <T> RightView()
        {
            int lastIndex = backDig.digNodes.Count - 1;
            T   last      = backDig.digNodes[lastIndex];

            List <T> newBack = new List <T>(backDig.digNodes);

            newBack.RemoveAt(lastIndex);

            return(new ViewR <T>(FTree <T> .CreateR(frontDig, innerFT, newBack), last));
        }
Beispiel #4
0
        public override FTree <T> App2(List <T> ts, FTree <T> rightFT)
        {
            var resultFT = rightFT;

            for (int i = ts.Count - 1; i >= 0; i--)
            {
                resultFT = resultFT.Push_Front(ts[i]);
            }

            return(resultFT);
        }
Beispiel #5
0
 public DeepFTree(Digit <T> frontDig, FTree <Node <T> > innerFT, Digit <T> backDig)
 {
     if (frontDig.digNodes.Count > 0)
     {
         this.frontDig = frontDig;
         this.innerFT  = innerFT;
         this.backDig  = backDig;
     }
     else
     {
         throw new Exception("The DeepFTree() constructor is passed an empty frontDig !");
     }
 }
Beispiel #6
0
        public static FTree <T> CreateR(Digit <T> frontDig, FTree <Node <T> > innerFT, List <T> backList)
        {
            if (backList.Count > 0)
            {
                return(new DeepFTree <T>(frontDig, innerFT, new Digit <T>(backList)));
            }

            if (innerFT is EmptyFTree <Node <T> > )
            {
                return(FromSequence(frontDig.digNodes));
            }

            var innerRight = innerFT.RightView();
            var newlstBack = innerRight.last.theNodes;

            return(new DeepFTree <T>(frontDig, innerRight.ftInit, new Digit <T>(newlstBack)));
        }
Beispiel #7
0
        public static FTree <T> Create(List <T> frontList, FTree <Node <T> > innerFT, Digit <T> backDig)
        {
            if (frontList.Count > 0)
            {
                return(new DeepFTree <T>(new Digit <T>(frontList), innerFT, backDig));
            }

            if (innerFT is EmptyFTree <Node <T> > )
            {
                return(FromSequence(backDig.digNodes));
            }

            var innerLeft   = innerFT.LeftView();
            var newlstFront = innerLeft.head.theNodes;

            return(new DeepFTree <T>(new Digit <T>(newlstFront), innerLeft.ftTail, backDig));
        }
Beispiel #8
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(App2(new List <T>(), rightFT));
 }
Beispiel #9
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(rightFT);
 }
Beispiel #10
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(rightFT.Push_Front(theSingle));
 }
Beispiel #11
0
 public ViewL(X head, FTree <X> ftTail)
 {
     this.head   = head;
     this.ftTail = ftTail;
 }
Beispiel #12
0
 public abstract FTree <T> App2(List <T> ts, FTree <T> rightFT);
Beispiel #13
0
 public abstract FTree <T> Merge(FTree <T> rightFT);
Beispiel #14
0
 public ViewR(FTree <X> ftInit, X last)
 {
     this.ftInit = ftInit;
     this.last   = last;
 }