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
 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));
     }
 }
Esempio n. 4
0
 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));
     }
 }
Esempio n. 5
0
        private PersistentQueue <T> CheckNormal()
        {
            PersistentQueue <T> newQueue = this.AdditionalsOperations();

            return(new PersistentQueue <T>(
                       newQueue.Left,
                       newQueue.LeftRecopy,
                       newQueue.Right,
                       newQueue.RightRecopy,
                       newQueue.TempRight,
                       newQueue.TempRight.Count != 0,
                       newQueue.ToCopy,
                       newQueue.Copied));
        }
Esempio n. 6
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. 7
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());
     }
 }
Esempio n. 8
0
        private PersistentQueue <T> CheckNormal()
        {
            PersistentQueue <T> Q = this.AdditionalsOperations();

            return(new PersistentQueue <T>(Q.L, Q.Li, Q.R, Q.Ri, Q.S, Q.S.Count != 0, Q.toCopy, Q.copied));
        }