Exemplo n.º 1
0
        public void CountAfterPeek()
        {
            var q = new Queuel <int>();

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

            q.Peek();
            Assert.AreEqual(20, q.Count);

            q.Enqueue(20);

            q.Peek();
            Assert.AreEqual(21, q.Count);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Queuel <int> ql = new Queuel <int>();

            var time = System.Diagnostics.Stopwatch.StartNew();

            for (int i = 0; i < 100000; i++)
            {
                ql.Enqueue(i);
            }
            ql.Contains(1);
            ql.Peek();
            for (int i = 0; i < 100000; i++)
            {
                ql.Dequeue();
            }

            time.Stop();
            var    res    = time.Elapsed;
            string eltime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}",
                                          res.Hours,
                                          res.Minutes,
                                          res.Seconds,
                                          res.Milliseconds);

            Console.WriteLine("Lab queue - {0}", eltime);


            Queue <int> qd = new Queue <int>();

            time = System.Diagnostics.Stopwatch.StartNew();


            for (int i = 0; i < 100000; i++)
            {
                qd.Enqueue(i);
            }
            qd.Contains(1);
            qd.Peek();
            for (int i = 0; i < 100000; i++)
            {
                qd.Dequeue();
            }

            time.Stop();
            res    = time.Elapsed;
            eltime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}",
                                   res.Hours,
                                   res.Minutes,
                                   res.Seconds,
                                   res.Milliseconds);
            Console.WriteLine("Default queue - {0}", eltime);
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public void CountInDecreasingTests()
        {
            var q = new Queuel <int>();

            for (int i = 0; i < 100; i++)
            {
                q.Enqueue(i);
            }

            Assert.AreEqual(100, q.Count);

            q.Peek();
            Assert.AreEqual(100, q.Count);

            for (int i = 0; i < 50; i++)
            {
                q.Dequeue();
            }
            Assert.AreEqual(50, q.Count);
        }
Exemplo n.º 4
0
        public void ContainsIsCorrect()
        {
            var q = new Queuel <int>();

            for (int i = 0; i < 100; i++)
            {
                q.Enqueue(i);
            }

            Assert.AreEqual(false, q.Contains(-1));
            Assert.AreEqual(true, q.Contains(50));

            q.Enqueue(150);
            Assert.AreEqual(true, q.Contains(150));

            q.Dequeue();
            Assert.AreEqual(false, q.Contains(0));

            q.Peek();
            Assert.AreEqual(true, q.Contains(1));
        }