Advertisement
abasar

CopyQueue()

Nov 21st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. public static Queue<int> Copy_Queue(Queue<int> q)
  2.         {
  3.             Queue<int> qhelp = new Queue<int>();
  4.             Queue<int> qnew = new Queue<int>();
  5.  
  6.             while (!q.IsEmpty())
  7.             {
  8.                 qhelp.Insert(q.Head());
  9.                 qnew.Insert(q.Remove());
  10.             }
  11.  
  12.             while (!qhelp.IsEmpty())
  13.             {
  14.                 q.Insert(qhelp.Remove());
  15.             }
  16.  
  17.             return qnew;
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement