public void Reset() { this.toTraverse = new RopeDeque(); this.toTraverse.Add(initialRope); this.currentRope = null; this.Init(); }
public Rope Rebalance(Rope r) { List <Rope> leafNodes = new List <Rope>(); RopeDeque toExamine = new RopeDeque(); // begin a depth first loop toExamine.Add(r); while (toExamine.Count > 0) { Rope rExamine = toExamine.Pop(); if (rExamine is ConcatenationRope) { toExamine.Add(((ConcatenationRope)rExamine).GetRight()); toExamine.Add(((ConcatenationRope)rExamine).GetLeft()); continue; } else { leafNodes.Add(rExamine); } } Rope result = Merge(leafNodes, 0, leafNodes.Count); return(result); }
public ConcatenationRopeEnumerator(ConcatenationRope concatenationRope, int start) { this.initialRope = concatenationRope; this.toTraverse = new RopeDeque(); this.toTraverse.Add(concatenationRope); this.currentRope = null; this.initStart = start; this.Init(); if (start < 0 || start > concatenationRope.Length()) { throw new ArgumentOutOfRangeException("Rope index out of range: " + start); } this.MoveNext(start); }