Esempio n. 1
0
 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());
     }
 }
Esempio n. 2
0
 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());
     }
 }
Esempio n. 3
0
 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());
     }
 }
Esempio n. 4
0
 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());
     }
 }