public PersistentQueue <T> Pop() { if (!recopy) { PersistentStack <T> Rn = R.Pop(); PersistentQueue <T> Q = new PersistentQueue <T>(L, Li, Rn, Ri, S, recopy, toCopy, copied); return(Q.CheckRecopy()); } else { PersistentStack <T> Rni = Ri.Pop(); PersistentStack <T> Rn = R; Int32 curCopy = toCopy; if (toCopy > 0) { --curCopy; } else { Rn = Rn.Pop(); } PersistentQueue <T> Q = new PersistentQueue <T>(L, Li, Rn, Rni, S, recopy, curCopy, copied); return(Q.CheckNormal()); } }
public PersistentQueue <T> Pop() { if (!IsRecopy) { PersistentStack <T> newRight = Right.Pop(); PersistentQueue <T> newQueue = new PersistentQueue <T>(Left, LeftRecopy, newRight, RightRecopy, TempRight, IsRecopy, ToCopy, Copied); return(newQueue.CheckRecopy()); } else { PersistentStack <T> newRightRecopy = RightRecopy.Pop(); PersistentStack <T> newRight = Right; Int32 curToCopy = ToCopy; if (ToCopy > 0) { --curToCopy; } else { newRight = Right.Pop(); } PersistentQueue <T> newQueue = new PersistentQueue <T>(Left, LeftRecopy, newRight, newRightRecopy, TempRight, IsRecopy, curToCopy, Copied); return(newQueue.CheckNormal()); } }
private PersistentQueue <T> CheckRecopy() { if (L.Count > R.Count) { PersistentQueue <T> Q = new PersistentQueue <T>(L, Li, R, R, S, true, R.Count, false); return(Q.CheckNormal()); } else { return(new PersistentQueue <T>(L, Li, R, Ri, S, false, toCopy, copied)); } }
private PersistentQueue <T> CheckRecopy() { if (Left.Count > Right.Count) { PersistentQueue <T> newQueue = new PersistentQueue <T>(Left, LeftRecopy, Right, Right, TempRight, true, Right.Count, false); return(newQueue.CheckNormal()); } else { return(new PersistentQueue <T>(Left, LeftRecopy, Right, RightRecopy, TempRight, false, ToCopy, Copied)); } }
public PersistentQueue <T> Push(T element) { if (!recopy) { PersistentStack <T> Ln = L.Push(element); PersistentQueue <T> Q = new PersistentQueue <T>(Ln, Li, R, Ri, S, recopy, toCopy, copied); return(Q.CheckRecopy()); } else { PersistentStack <T> Lni = Li.Push(element); PersistentQueue <T> Q = new PersistentQueue <T>(L, Lni, R, Ri, S, recopy, toCopy, copied); return(Q.CheckNormal()); } }
public PersistentQueue <T> Push(T element) { if (!IsRecopy) { PersistentStack <T> newLeft = Left.Push(element); PersistentQueue <T> newQueue = new PersistentQueue <T>(newLeft, LeftRecopy, Right, RightRecopy, TempRight, IsRecopy, ToCopy, Copied); return(newQueue.CheckRecopy()); } else { PersistentStack <T> newLeftRecopy = LeftRecopy.Push(element); PersistentQueue <T> newQueue = new PersistentQueue <T>(Left, newLeftRecopy, Right, RightRecopy, TempRight, IsRecopy, ToCopy, Copied); return(newQueue.CheckNormal()); } }