示例#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));
            }
        }
示例#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)));
        }
示例#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));
        }
示例#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);
        }
示例#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 !");
     }
 }
示例#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)));
        }
示例#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));
        }
示例#8
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(App2(new List <T>(), rightFT));
 }
示例#9
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(rightFT);
 }
示例#10
0
 public override FTree <T> Merge(FTree <T> rightFT)
 {
     return(rightFT.Push_Front(theSingle));
 }
示例#11
0
 public ViewL(X head, FTree <X> ftTail)
 {
     this.head   = head;
     this.ftTail = ftTail;
 }
示例#12
0
 public abstract FTree <T> App2(List <T> ts, FTree <T> rightFT);
示例#13
0
 public abstract FTree <T> Merge(FTree <T> rightFT);
示例#14
0
 public ViewR(FTree <X> ftInit, X last)
 {
     this.ftInit = ftInit;
     this.last   = last;
 }