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)); } }
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))); }
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)); }
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); }
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 !"); } }
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))); }
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)); }
public override FTree <T> Merge(FTree <T> rightFT) { return(App2(new List <T>(), rightFT)); }
public override FTree <T> Merge(FTree <T> rightFT) { return(rightFT); }
public override FTree <T> Merge(FTree <T> rightFT) { return(rightFT.Push_Front(theSingle)); }
public ViewL(X head, FTree <X> ftTail) { this.head = head; this.ftTail = ftTail; }
public abstract FTree <T> App2(List <T> ts, FTree <T> rightFT);
public abstract FTree <T> Merge(FTree <T> rightFT);
public ViewR(FTree <X> ftInit, X last) { this.ftInit = ftInit; this.last = last; }