Exemplo n.º 1
0
        public void EnqueueDequeueTest()
        {
            PCQueue queue = new PCQueue();

            for (int i = 0; i < 10; i++)
            {
                queue.Enqueue(i);
            }

            for (int i = 0; i < 10; i++)
            {
                int dqed = -1;

                if (queue.Dequeue(ref dqed))
                {
                    Console.WriteLine(dqed + ":" + i);
                    if (dqed != i)
                    {
                        Assert.Fail();
                    }
                }
            }

            Assert.Pass();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            int outvalue = 0;

            Console.WriteLine("QueueTests");

            queue = new PCQueue();

            for (int i = 0; i < 20; i++)
            {
                queue.Enqueue(i);
            }

            queue.printList();

            for (int i = 0; i < 20; i++)
            {
                queue.Dequeue(ref outvalue);
            }

            Thread t1 = new Thread(() => Dtest());
            Thread t2 = new Thread(() => Etest());

            t1.Start();
            t2.Start();

            Console.WriteLine("SorterTests");
            ThreadPoolSleepSorter sorter = new ThreadPoolSleepSorter(Console.Out, 10);

            byte[] values = { 1, 7, 8, 2, 3, 4, 5, 6, 9, 10 };
            sorter.Sort(values);
            sorter.Dispose();

            Console.WriteLine("done");
        }
Exemplo n.º 3
0
        public void DequeueNullTest()
        {
            PCQueue queue = new PCQueue();

            int t = 0;

            Assert.IsFalse(queue.Dequeue(ref t));
        }
Exemplo n.º 4
0
        static public void Dtest()
        {
            int outvalue = 0;

            for (int i = 0; i < 500;)
            {
                queue.Dequeue(ref outvalue);
            }
        }
Exemplo n.º 5
0
        public void TestEnqueueDequeue()
        {
            int value = 0;

            for (int i = 0; i < 1000; i++)
            {
                queue.Enqueue(i);
            }

            bool result;

            for (int i = 0; i < 1000; i++)
            {
                result = queue.Dequeue(ref value);

                Assert.AreEqual(i, value);
                Assert.IsTrue(result);
            }

            result = queue.Dequeue(ref value);
            Assert.IsFalse(result);
        }
Exemplo n.º 6
0
        public void dequeue()
        {
            int j = 0;

            for (long i = 1; i < 100000000; i++)
            {
                while (queue1.Dequeue(ref j) == false)
                {
                }
                if (j == (int)(i % 1000))
                {
                }
                else
                {
                    Console.WriteLine("False");
                }
                //Console.WriteLine(j);
            }
        }
Exemplo n.º 7
0
        public void Dequeue()
        {
            //Arrange
            int outvalue = 0;

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

            //Act
            bool result = _queue.Dequeue(ref outvalue);

            //Assert
            Assert.AreEqual(1, outvalue);
            Assert.IsTrue(result);
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            PCQueue pCQueue   = new PCQueue();
            int     out_value = -1;
            bool    success   = false;

            for (int i = 0; i < 10; i++)
            {
                pCQueue.Enqueue(i);
            }

            //pCQueue.printQueue ();

            for (int i = 0; i < 11; i++)
            {
                success = pCQueue.Dequeue(ref out_value);
                Console.WriteLine("success = " + success);
                Console.WriteLine("out_value = " + out_value);
                out_value = -1;
            }



            /*using (ThreadPoolSleepSorter tpss =
             *      new ThreadPoolSleepSorter (Console.Out, 30)) {
             *      tpss.Sort (new byte[]{ 4, 2, 9, 3 , 5, 8, 7, 10, 1, 6});
             *      tpss.Sort (new byte[]{ 3, 0, 2 });
             *      tpss.Sort (new byte[]{ 0, 0, 0});
             *
             *      for (int i = 14; i > 0; i--) {
             *              tpss.Sort (new byte[]{ (byte)i });
             *      }
             *
             *      //Console.WriteLine ("Press ENTER to cancel wait.");
             *      //Console.ReadLine ();
             * }*/
        }