Exemplo n.º 1
0
        public void CheckClearQueue(int[] array)
        {
            var queue = new GenericQueue <int>(array);

            queue.Clear();
            Assert.That(queue.ToArray, Is.EqualTo(new int[] { }));
        }
Exemplo n.º 2
0
        public void CheckDequeue(int[] array)
        {
            var queue   = new GenericQueue <int>(array);
            var element = queue.Dequeue();

            Assert.That(element, Is.EqualTo(array[0]));
            Assert.That(queue.ToArray(), Is.EqualTo(array[1..]));
Exemplo n.º 3
0
        public void ClearTest(int[] arg)
        {
            GenericQueue <int> queue = new GenericQueue <int>(arg);

            queue.Clear();
            Assert.AreEqual(true, queue.IsEmpty());
        }
Exemplo n.º 4
0
        public int[] CheckAddElementToQueue(int[] array, int element)
        {
            var queue = new GenericQueue <int>(array);

            queue.Enqueue(element);
            return(queue.ToArray());
        }
Exemplo n.º 5
0
        public void DequeueTest(int[] arg)
        {
            GenericQueue <int> queue = new GenericQueue <int>(arg);

            queue.Dequeue();
            queue.Dequeue();
            Assert.AreEqual(new int[] { 3, 4 }, queue.ToArray());
        }
Exemplo n.º 6
0
        public void IsEmptyTest()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            Assert.AreEqual(true, queue.IsEmpty());
            queue.Enqueue(1);
            Assert.AreEqual(false, queue.IsEmpty());
        }
Exemplo n.º 7
0
        public void PeekTest(int[] arg)
        {
            GenericQueue <int> queue = new GenericQueue <int>(arg);

            queue.Dequeue();
            queue.Dequeue();
            Assert.AreEqual(3, queue.Peek());
        }
        public void GenericQueue_Enqueue_Success()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(5);
            int[] expected = { 10, 5 };
            CollectionAssert.AreEqual(queue, expected);
        }
Exemplo n.º 9
0
        public void Constructor_Collection_Tests(int[] expected)
        {
            List <int> test = new List <int>()
            {
                1, 2, 3, 4, 5
            };
            GenericQueue <int> testQueue = new GenericQueue <int>(test);

            CollectionAssert.AreEqual(testQueue.ToArray(), expected);
        }
Exemplo n.º 10
0
        public void Constructor_Capacity_Test(int capacity, int[] expected)
        {
            GenericQueue <int> test = new GenericQueue <int>(capacity);

            for (int i = 1; i <= 5; i++)
            {
                test.Enqueue(i);
            }
            CollectionAssert.AreEqual(test.ToArray(), expected);
        }
Exemplo n.º 11
0
        public void EnqueTest(int[] arg)
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            Assert.AreEqual(queue.ToArray(), arg);
        }
Exemplo n.º 12
0
        public void GenericQueue_Dequeue_Success()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(5);
            int dequeuedItem = queue.Dequeue();
            int expected     = 10;

            Assert.AreEqual(expected, dequeuedItem);
        }
Exemplo n.º 13
0
        public void GenericQueue_Clear()
        {
            GenericQueue <int> queue = new GenericQueue <int>();
            GenericQueue <int> empty = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(5);
            queue.Clear();

            CollectionAssert.AreEqual(queue, empty);
        }
Exemplo n.º 14
0
        public void EnumeratorTest()
        {
            GenericQueue <int> queue = new GenericQueue <int>(Enumerable.Range(1, 1000).ToList());
            int i = 1;

            foreach (int elem in queue)
            {
                Assert.AreEqual(i, elem);
                i++;
            }
        }
Exemplo n.º 15
0
        public void GenericQueueTest()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(11);
            queue.Enqueue(12);
            Assert.AreEqual(10, queue.Dequeue());
            Assert.AreEqual(11, queue.Dequeue());
            Assert.AreEqual(12, queue.Dequeue());
        }
Exemplo n.º 16
0
        public void GenericQueue_IEnumerable()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);

            int[] expected = { 1, 2, 3 };

            Assert.AreEqual(expected, queue);
        }
Exemplo n.º 17
0
        public void GenericQueue_Enqueue_Success()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);
            queue.Enqueue(6);
            int[] expected = { 1, 2, 3, 4, 5, 6 };

            NUnit.Framework.CollectionAssert.AreEqual(queue, expected);
        }
Exemplo n.º 18
0
        public void Enqueue_And_Dequeue_Tests(int[] data1)
        {
            GenericQueue <int> test1 = new GenericQueue <int>(data1);

            test1.Dequeue();
            test1.Dequeue();
            GenericQueue <int> test2 = new GenericQueue <int>(10);

            for (int i = 3; i <= 10; i++)
            {
                test2.Enqueue(i);
            }
            CollectionAssert.AreEqual(test1, test2);
        }
Exemplo n.º 19
0
        public void GenericQueue_Peek()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(5);
            int oldCount = queue.Count();
            int result   = queue.Peek();
            int expected = 10;
            int newCount = queue.Count();

            Assert.AreEqual(expected, result);
            Assert.AreEqual(oldCount, newCount);
        }
Exemplo n.º 20
0
 public static void INP_QUEUE(GenericQueue <int> a)
 {
     do
     {
         int x;
         Console.Write("Gia tri (nhap <=0 de ket thuc): ");
         int.TryParse(Console.ReadLine(), out x);
         if (x <= 0)
         {
             break;
         }
         a.Enqueue(x);
         Console.WriteLine(">> Da Enqueue {0} thanh cong", x);
     } while (true);
 }
Exemplo n.º 21
0
        public void GenericQueue_Clear_Success()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);
            queue.Enqueue(6);
            queue.Clear();
            int[] expected = { };

            NUnit.Framework.Assert.AreEqual(expected, queue);
        }
Exemplo n.º 22
0
        public void GenericQueue_GetEnumeratorTest()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(11);
            queue.Enqueue(12);
            int[] res   = { 10, 11, 12 };
            int   index = 0;

            foreach (var num in queue)
            {
                Assert.AreEqual(res[index], num);
                index++;
            }
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            var queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);
            queue.Enqueue(6);
            queue.Enqueue(7);
            var t = queue.ToArray();

            foreach (var i in queue)
            {
                Console.Write(i + " ");
            }
        }
Exemplo n.º 24
0
        public void GenericQueue_Peek_Success()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);
            queue.Enqueue(6);
            int[] expected   = { 1, 2, 3, 4, 5, 6 };
            int   peekedItem = queue.Peek();
            int   expected1  = 1;

            NUnit.Framework.Assert.AreEqual(expected1, peekedItem);

            NUnit.Framework.CollectionAssert.AreEqual(queue, expected);
        }
Exemplo n.º 25
0
        public void GenericQueue_Dequeue_Success()
        {
            GenericQueue <string> queue = new GenericQueue <string>();

            queue.Enqueue("a");
            queue.Enqueue("b");
            queue.Enqueue("c");
            queue.Enqueue("d");
            queue.Enqueue("e");
            queue.Enqueue("f");
            string dequeuedItem = queue.Dequeue();
            string expected     = "a";

            string[] expected1 = { "b", "c", "d", "e", "f" };

            NUnit.Framework.Assert.AreEqual(expected, dequeuedItem);

            NUnit.Framework.CollectionAssert.AreEqual(queue, expected1);
        }
Exemplo n.º 26
0
        private static void Main()
        {
            var list = new List <Person>
            {
                new Person {
                    Age = 20, Name = "Billy"
                },
                new Person {
                    Age = 19, Name = "Van"
                },
                new Person {
                    Age = 33, Name = "Kojima"
                },
                new Person {
                    Age = 4, Name = "Kazuma"
                },
                new Person {
                    Age = 12, Name = "Subaru"
                }
            };

            var sortedListAsc = list.Sort((a, b) => a != null && a.CompareTo(b) > 0);

            foreach (var item in sortedListAsc)
            {
                Console.WriteLine(item.Age + " - " + item.Name);
            }

            Console.WriteLine();
            Console.WriteLine("root of n degree: " + NewtonMethod.NewtonMethod.Pow(5, 10));
            Console.WriteLine(Math.Pow(10, (double)1 / 5));

            var q = new GenericQueue <string>(5);

            q.Enqueue("First item");
            q.Enqueue("Second item");
            q.Enqueue("Third item");
            q.Enqueue("Fourth item");

            Console.WriteLine("Deleted: " + q.Dequeue());
            Console.WriteLine("Deleted: " + q.Dequeue());
        }
Exemplo n.º 27
0
 static void Main(string[] args)
 {
     GenericQueue<int> example = new GenericQueue<int>();
     Console.WriteLine(example.QueueEmpty());
     example.Enqueue(15);
     example.Enqueue(25);
     example.Enqueue(35);
     example.Enqueue(45);
     Console.WriteLine(example.QueueEmpty());
     Console.WriteLine(example.Dequeue());
     Console.WriteLine(example.Dequeue());
     example.Enqueue(1);
     example.Enqueue(1);
     Console.WriteLine(example.Dequeue());
     Console.WriteLine(example.Dequeue());
     Console.WriteLine(example.QueueEmpty());
     Console.WriteLine(example.Dequeue());
     Console.WriteLine(example.Dequeue());
     Console.WriteLine(example.QueueEmpty());
     Console.WriteLine(example.Dequeue());
 }
        public void CategorizeByModel()
        {
            //Method to categorize droids in the order of Astromech, Janitor, Utility, Protocol
            GenericStack<IDroid> protocolStack = new GenericStack<IDroid>();
            GenericStack<IDroid> utilityStack = new GenericStack<IDroid>();
            GenericStack<IDroid> janitorStack = new GenericStack<IDroid>();
            GenericStack<IDroid> astromechStack = new GenericStack<IDroid>();

            foreach (IDroid droid in droidCollection)
            {
                if (droid != null)
                {
                    switch (droid.GetModel())
                    {   //Go through the droidCollection and separate the droids into stacks by Model
                        case "PROTOCOL":
                            protocolStack.Add(droid);
                            break;
                        case "UTILITY":
                            utilityStack.Add(droid);
                            break;
                        case "JANITOR":
                            janitorStack.Add(droid);
                            break;
                        case "ASTROMECH":
                            astromechStack.Add(droid);
                            break;
                        default:
                            break;
                    }
                }
            }

            //Create the queue and add the stacks to it in the desired order
            GenericQueue<IDroid> droidQueue = new GenericQueue<IDroid>();
            droidQueue.AddStack(astromechStack);
            droidQueue.AddStack(janitorStack);
            droidQueue.AddStack(utilityStack);
            droidQueue.AddStack(protocolStack);

            droidCollection = new IDroid[droidQueue.Depth];

            for (int i = 0; i < droidQueue.Depth; i++)
            {
                droidCollection[i] = (IDroid)droidQueue.Retrieve(i + 1).Droid;
            }
        }
Exemplo n.º 29
0
        public void GenericQueue_Empty_InvalidOperationException()
        {
            GenericQueue <int> queue = new GenericQueue <int>();

            Assert.Throws <InvalidOperationException>(() => queue.Dequeue());
        }
Exemplo n.º 30
0
        public void SortbyModel()
        {
            GenericStack<ProtocolDroid> ProtocolStack = new GenericStack<ProtocolDroid>();
            GenericStack<UtilityDroid> UtilityStack = new GenericStack<UtilityDroid>();
            GenericStack<JanitorDroid> JanitorStack = new GenericStack<JanitorDroid>();
            GenericStack<AstromechDroid> AstromechStack = new GenericStack<AstromechDroid>();

            GenericQueue<Droid> DroidsQueue = new GenericQueue<Droid>();

            foreach (IDroid droid in droidCollection)
            {
                if (droid is ProtocolDroid)
                {
                    ProtocolStack.Push((ProtocolDroid)droid);
                }
                else if (droid is UtilityDroid)
                {
                    UtilityStack.Push((UtilityDroid)droid);
                }
                else if (droid is JanitorDroid)
                {
                    JanitorStack.Push((JanitorDroid)droid);
                }
                else if (droid is AstromechDroid)
                {
                    AstromechStack.Push((AstromechDroid)droid);
                }
            }

            while (ProtocolStack != null)
            {
                DroidsQueue.Enqueue(ProtocolStack.Pop());
            }
            while (UtilityStack != null)
            {
                DroidsQueue.Enqueue(UtilityStack.Pop());
            }
            while (JanitorStack != null)
            {
                DroidsQueue.Enqueue(JanitorStack.Pop());
            }
            while (AstromechStack != null)
            {
                DroidsQueue.Enqueue(AstromechStack.Pop());

            }

            while (DroidsQueue != null)
            {
                int i =0;
                droidCollection[i] = DroidsQueue.Dequeue();
                i++;
            }
        }
        public void SortModel()
        {
            GenericStack<UtilityDroid> UtilityDroidStack = new GenericStack<UtilityDroid>();
            GenericStack<AstromechDroid> AstromechDroidStack = new GenericStack<AstromechDroid>();
            GenericStack<ProtocolDroid> ProtocolDroidStack = new GenericStack<ProtocolDroid>();
            GenericStack<JanitorDroid> JanitorDroidStack = new GenericStack<JanitorDroid>();

            foreach(IDroid droids in droidCollection)
            {
                if(droids is UtilityDroid)
                {
                    UtilityDroidStack.Add((UtilityDroid)droids);
                }
                else if (droids is AstromechDroid)
                {
                    AstromechDroidStack.Add((AstromechDroid)droids);
                }
                else if (droids is ProtocolDroid)
                {
                    ProtocolDroidStack.Add((ProtocolDroid)droids);
                }
                else if (droids is JanitorDroid)
                {
                    JanitorDroidStack.Add((JanitorDroid)droids);
                }

                //*****************************************************************************************************************PROBLEM***********************************************************************************************************************************8*************************************************
                //Error	4	Argument 1: cannot convert from 'cis237assignment4.GenericStack<cis237assignment4.UtilityDroid>' to 'cis237assignment4.IDroid'	c:\users\jason\cis237\cis237assignment4\cis237assignment4\droidcollection.cs	174	23	cis237assignment4
                //Error	3	The best overloaded method match for 'cis237assignment4.GenericQueue<cis237assignment4.IDroid>.Add(cis237assignment4.IDroid)' has some invalid arguments	c:\users\jason\cis237\cis237assignment4\cis237assignment4\droidcollection.cs	175	13	cis237assignment4
                /************************************************************************************************************************************************************************************************************************************************/

            }
            GenericQueue<IDroid> Queue = new GenericQueue<IDroid>();
            //Queue.Add(AstromechDroidStack);
            //Queue.Add(UtilityDroidStack);
        }
Exemplo n.º 32
0
        //method to organize droids by type
        public bool Organize()
        {
            GenericStack<AstromechDroid> astromechStack = new GenericStack<AstromechDroid>();
            GenericStack<JanitorDroid> janitorStack = new GenericStack<JanitorDroid>();
            GenericStack<UtilityDroid> utilityStack = new GenericStack<UtilityDroid>();
            GenericStack<ProtocolDroid> protocolStack = new GenericStack<ProtocolDroid>();

            GenericQueue<IDroid> droidQueue = new GenericQueue<IDroid>();

            //Add droids to appropriate stack types
            for (int i = 0; i < lengthOfCollection; i++)
            {
                try
                {
                    astromechStack.Add((AstromechDroid)droidCollection[i]);
                }
                catch
                {
                    try
                    {
                        janitorStack.Add((JanitorDroid)droidCollection[i]);
                    }
                    catch
                    {
                        try
                        {
                            utilityStack.Add((UtilityDroid)droidCollection[i]);
                        }
                        catch
                        {
                            try
                            {
                                protocolStack.Add((ProtocolDroid)droidCollection[i]);
                            }
                            catch
                            {
                                return false;
                            }
                        }
                    }
                }
            }

            //Add droids in order to the queue
            while (astromechStack.Head != null)
            {
                droidQueue.Add((IDroid)astromechStack.Pop());
            }

            while (janitorStack.Head != null)
            {
                droidQueue.Add((IDroid)janitorStack.Pop());
            }

            while (utilityStack.Head != null)
            {
                droidQueue.Add((IDroid)utilityStack.Pop());
            }

            while (protocolStack.Head != null)
            {
                droidQueue.Add((IDroid)protocolStack.Pop());
            }

            //Dequeue droids back into the array
            for (int i = 0; droidQueue.Tail != null; i++)
            {
                droidCollection[i] = (IDroid)droidQueue.Dequeue();
            }

                return true;
        }
        public void SortByModel()
        {
            //Create generic stacks for each model type
            GenericStack<Droid> protocolStack = new GenericStack<Droid>();
            GenericStack<Droid> utilityStack = new GenericStack<Droid>();
            GenericStack<Droid> janitorStack = new GenericStack<Droid>();
            GenericStack<Droid> astromechStack = new GenericStack<Droid>();

            //Create new generic queue
            GenericQueue<Droid> droidQueue = new GenericQueue<Droid>();

            foreach (Droid droid in droidArray)
            {
                if (droid != null)
                {
                    switch (droid.GetModel())
                    {
                        case "Protocol":
                            protocolStack.Push(droid);
                            break;
                        case "Utility":
                            utilityStack.Push(droid);
                            break;
                        case "Janitor":
                            janitorStack.Push(droid);
                            break;
                        case "Astromech":
                            astromechStack.Push(droid);
                            break;
                        default:
                            break;
                    }
                }
            }

            //Get droids from each stack and enqueue them
            while (astromechStack.IsNotEmpty())
            {
                droidQueue.Enqueue(astromechStack.Pop());
            }
            while (janitorStack.IsNotEmpty())
            {
                droidQueue.Enqueue(janitorStack.Pop());
            }
            while (utilityStack.IsNotEmpty())
            {
                droidQueue.Enqueue(utilityStack.Pop());
            }
            while (protocolStack.IsNotEmpty())
            {
                droidQueue.Enqueue(protocolStack.Pop());
            }

            int i = 0;
            while (droidQueue.IsNotEmpty())
            {
                droidArray[i] = droidQueue.Dequeue();
                i++;
            }
        }
Exemplo n.º 34
0
        public static void TestQueue()
        {
            GenericQueue <int> queue;

            queue = new GenericQueue <int>();
            GenericStack <int> stack;

            stack = new GenericStack <int>();
            var chon = 0;

            do
            {
                chon = MenuQueue();
                switch (chon)
                {
                case 1:
                {
                    INP_STACK(stack);
                    Console.WriteLine("STACK : ");
                    stack.print();
                    if (queue.Count == 0)
                    {
                        Console.WriteLine("Queue : NULL");
                    }
                    Console.WriteLine("---------Convert Stack to Queue----------");
                    Console.Write("Queue : ");
                    ConvertStackToQueue.ConverTo(stack, queue);
                    if (stack.Size == 0)
                    {
                        Console.WriteLine("Stack : NULL");
                    }
                    Console.WriteLine("\nPress any key to terminate...");
                    break;
                }

                case 2:
                {
                    var queue1 = new GenericQueue <int>();
                    INP_QUEUE(queue1);
                    Console.WriteLine("queue luc ban dau: " + queue1);
                    Console.WriteLine("queue luc sau khi dao nguoc: " + queue1.Reverse());
                    break;
                }

                case 3:
                {
                    Console.Write("+ Nhap Chuoi: ");
                    var str = Console.ReadLine();
                    Console.WriteLine("[Cach lam: chay cai phan tu chuoi tu 0 den het chuoi, \nneu gap phan tu khac rong thi Enqueue. " +
                                      "\nsau do cho queue dequeue vao string builder roi in ra]");
                    Console.WriteLine("Chuoi sau khi loai bo khoang trang: ");
                    Console.WriteLine("=> " + Chuoi.Trim(str));
                    break;
                }

                case 0:
                {
                    break;
                }

                default:
                {
                    Console.WriteLine("Unexpected Case");
                    break;
                }
                }
                Console.ReadKey();
                Console.Clear();
            } while (chon != 0);
        }
Exemplo n.º 35
0
 public void Setup()
 {
     _genericQueue = new GenericQueue <int>(10);
 }
Exemplo n.º 36
0
 public void TearDown()
 {
     _genericQueue = null;
 }
        /// <summary>
        /// public method to Sort the droids into categories using a modified bucket sort
        /// </summary>
        public void SortIntoCategories()
        {
            //Create a generic stack for each type of droid, and pass in the droid type as the generic that will
            //come through on the stack class as T.
            GenericStack<ProtocolDroid> protocolStack = new GenericStack<ProtocolDroid>();
            GenericStack<UtilityDroid> utilityStack = new GenericStack<UtilityDroid>();
            GenericStack<JanitorDroid> janitorStack = new GenericStack<JanitorDroid>();
            GenericStack<AstromechDroid> astromechStack = new GenericStack<AstromechDroid>();

            //Create a queue to hold the droids as we pop them off the stack.
            GenericQueue<IDroid> categorizedDroidQueue = new GenericQueue<IDroid>();

            //For each IDroid in the droidCollection
            foreach (IDroid droid in this.droidCollection)
            {
                //if the droid is not null we want to process it. If it is null we will go to the else
                if (droid != null)
                {
                    //The testing of the droids must occur in this order. It must be done in the order of
                    //most specific droid to least specific.

                    //If we were to test a droid that IS of type Astromech against Utility BEFORE we test against
                    //Astromech, it would pass and be put into the Utility stack and not the Astromech. That is why it
                    //is important to test from most specific to least.

                    //If the droid is an Astromech, push it on the astromech stack
                    if (droid is AstromechDroid)
                    {
                        astromechStack.Push((AstromechDroid)droid);
                    }
                    //Else if it is a JanitorDroid, push it on the janitor stack
                    else if (droid is JanitorDroid)
                    {
                        janitorStack.Push((JanitorDroid)droid);
                    }
                    //Do for Utility
                    else if (droid is UtilityDroid)
                    {
                        utilityStack.Push((UtilityDroid)droid);
                    }
                    //Do for Protocol
                    else if (droid is ProtocolDroid)
                    {
                        protocolStack.Push((ProtocolDroid)droid);
                    }
                }
                //The droid we are trying to consider is null, break out of the loop.
                else
                {
                    break;
                }
            }

            //Now that the droids are all in thier respective stacks we can do the work
            //of poping them off of the stacks and adding them to the queue.
            //It is required that they be popped off from each stack in this order so that they have
            //the correct order going into the queue.

            //This is a primer pop. It gets the first droid off the stack, which could be null if the stack is empty
            AstromechDroid currentAstromechDroid = astromechStack.Pop();
            //While the droid that is popped off is not null
            while (currentAstromechDroid != null)
            {
                //Add the popped droid to the queue.
                categorizedDroidQueue.Enqueue(currentAstromechDroid);
                //Pop off the next droid for the loop test
                currentAstromechDroid = astromechStack.Pop();
            }

            //See above method for Astromech. It is the same except for Janitor
            JanitorDroid currentJanitorDroid = janitorStack.Pop();
            while (currentJanitorDroid != null)
            {
                categorizedDroidQueue.Enqueue(currentJanitorDroid);
                currentJanitorDroid = janitorStack.Pop();
            }

            //See above method for Astromech. It is the same except for Utility
            UtilityDroid currentUtilityDroid = utilityStack.Pop();
            while (currentUtilityDroid != null)
            {
                categorizedDroidQueue.Enqueue(currentUtilityDroid);
                currentUtilityDroid = utilityStack.Pop();
            }

            //See above method for Astromech. It is the same except for Protocol
            ProtocolDroid currentProtocolDroid = protocolStack.Pop();
            while (currentProtocolDroid != null)
            {
                categorizedDroidQueue.Enqueue(currentProtocolDroid);
                currentProtocolDroid = protocolStack.Pop();
            }

            //Now that the droids have all been removed from the stacks and put into the queue
            //we need to dequeue them all and put them back into the original array.

            //Set a int counter to 0.
            int counter = 0;

            //This is a primer dequeue that will get the first droid out of the queue.
            IDroid iDroid = categorizedDroidQueue.Dequeue();
            //While the dequeued droid is not null.
            while (iDroid != null)
            {
                //Add the droid to the droid collection using the int counter as the index
                this.droidCollection[counter] = iDroid;
                //increment the counter
                counter++;
                //dequeue the next droid off the queue so it can be used in the while condition
                iDroid = categorizedDroidQueue.Dequeue();
            }

            //set the lenght of the collection to the value of the counter. It should be the same, but in case it changed.
            this.lengthOfCollection = counter;
        }