Esempio n. 1
0
    /* Task 13: 
     * Implement the ADT queue as dynamic linked list.
     * Use generics (LinkedQueue<T>) to allow storing different data types in the queue.
     */

    static void Main(string[] args)
    {
        var customQueue = new CustomQueue<int>();
        customQueue.Enqueue(15);
        customQueue.Enqueue(25);
        customQueue.Enqueue(35);
        customQueue.Enqueue(45);

        Console.WriteLine("Custom Queue Count: {0}", customQueue.Count());
        Console.WriteLine("Removed element {0}", customQueue.Dequeue());
        Console.WriteLine("Custom Queue Count: {0}", customQueue.Count());
    }
Esempio n. 2
0
        public void TestQueueOnLargeDataAmount()
        {
            var queue         = new CustomQueue <int>();
            var array         = new int[10000];
            var arrayAsString = String.Empty;
            var queueAsString = String.Empty;

            for (int i = 0; i < 10000; i++)
            {
                queue.Enqueue(i);
                array[i] = i;
            }
            foreach (var item in array)
            {
                arrayAsString += item;
            }
            while (queue.Count() > 0)
            {
                queueAsString += queue.Dequeue();
            }
            Assert.AreEqual(arrayAsString, queueAsString);
        }
Esempio n. 3
0
        public void TestCountAfterCreation()
        {
            var queue = new CustomQueue <int>();

            Assert.AreEqual(0, queue.Count());
        }