Advertisement
jtentor

DemoQueue4 - SpecialQueue.cs

May 18th, 2020
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DemoQueue4
  8. {
  9.     class SpecialQueue<ELEMENT> : System.Collections.Generic.Queue<ELEMENT>
  10.     {
  11.         public SpecialQueue<ELEMENT> join(Queue<ELEMENT> other)
  12.         {
  13.             SpecialQueue<ELEMENT> result = new SpecialQueue<ELEMENT>();
  14.  
  15.             ELEMENT[] data = this.ToArray();
  16.             foreach (ELEMENT e in data)
  17.             {
  18.                 result.Enqueue(e);
  19.             }
  20.  
  21.             data = other.ToArray();
  22.             foreach (ELEMENT e in data)
  23.             {
  24.                 result.Enqueue(e);
  25.             }
  26.  
  27.             return result;
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement