Ejemplo n.º 1
0
        static void Example1()
        {
            _commonQueue = new CommonQueue <int>();
            List <int> checkList = new List <int>();

            for (int i = 0; i < 66; i++)
            {
                new Thread(() => PutElements(i)).Start();
                new Thread(() => GetElements()).Start();
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static void testCommonQueue()
        {
            var queues = new CommonQueue <string>();

            for (int i = 1; i <= 100; i++)
            {
                queues.Enqueue(i.ToString());
            }

            Console.WriteLine(queues.ToString());
            Console.WriteLine(queues.Dequeue());
            Console.WriteLine(queues.Dequeue());
            Console.WriteLine(queues.Dequeue());
            Console.WriteLine(queues.ToString());
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
#if stack
            CommonStack stack = new CommonStack();
            IntStack    stackItem;
            int         max = 5;

            int status = stack.Initialize(out stackItem, max);
            if (StackAndQueue.Satatus.Error.Equals(status))
            {
                Console.WriteLine("Stack error");
            }

            stack.Push(ref stackItem, 1);
            stack.Push(ref stackItem, 2);
            stack.Push(ref stackItem, 3);
            stack.Push(ref stackItem, 4);
            stack.Push(ref stackItem, 5);

            int seekValue = 0;
            stack.Seek(ref stackItem, ref seekValue);
            Console.WriteLine(seekValue);
#endif
            CommonQueue queue = new CommonQueue();
            IntQueue    queueItem;
            int         max = 5;

            int status = queue.Initialize(out queueItem, max);
            queue.Enqueue(ref queueItem, 1);
            queue.Enqueue(ref queueItem, 2);
            queue.Enqueue(ref queueItem, 3);
            queue.Enqueue(ref queueItem, 4);
            queue.Enqueue(ref queueItem, 5);

            queue.Print(ref queueItem);

            int x = 0;
            queue.Dequeue(ref queueItem, ref x); Console.WriteLine("Dequeue = {0}", x);
            queue.Dequeue(ref queueItem, ref x); Console.WriteLine("Dequeue = {0}", x);
            queue.Dequeue(ref queueItem, ref x); Console.WriteLine("Dequeue = {0}", x);

            queue.Enqueue(ref queueItem, 1);
            queue.Print(ref queueItem);
            Console.ReadLine();
        }