示例#1
0
        public void TestMinMax2()
        {
            MQueue queue = new MQueue();

            queue.Enqueue(7, 0, 1);
            Assert.AreEqual(0, queue.Min());
            Assert.AreEqual(7, queue.Max());

            queue.Dequeue();
            Assert.AreEqual(0, queue.Min());
            Assert.AreEqual(1, queue.Max());

            queue.Dequeue();
            Assert.AreEqual(1, queue.Min());
            Assert.AreEqual(1, queue.Max());
        }
示例#2
0
        static void Main(string[] args)
        {
            MQueue queue = new MQueue();

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

            while (true)
            {
                Console.WriteLine("Нажмите любую клавишу...");

                queue.Dequeue();
                queue.Enqueue(new Random().Next(-10, 10));

                ConsoleKeyInfo c = Console.ReadKey();
                Console.Clear();

                Console.WriteLine("Состояние очереди:");
                foreach (var item in queue)
                {
                    Console.Write("{0}\t", item);
                }
                Console.WriteLine("\nМинимум:{0}\nМаксимум:{1}",
                                  queue.Min(), queue.Max());
            }
        }
示例#3
0
        public void TestMinMax1()
        {
            MQueue queue = new MQueue();

            queue.Enqueue(1, 2, 3);
            Assert.AreEqual(1, queue.Min());
            Assert.AreEqual(3, queue.Max());

            queue.Dequeue();
            Assert.AreEqual(2, queue.Min());
            Assert.AreEqual(3, queue.Max());

            queue.Dequeue();
            Assert.AreEqual(3, queue.Min());
            Assert.AreEqual(3, queue.Max());
        }
示例#4
0
 private void Update()
 {
     mutex.WaitOne();
     tbQueue.Text = "";
     foreach (var i in queue)
     {
         tbQueue.Text += i.ToString() + "   ";
     }
     tbMinimum.Text = queue.Min().ToString();
     tbMaximum.Text = queue.Max().ToString();
     mutex.ReleaseMutex();
 }