Exemplo n.º 1
0
        public void PeekRepeats()
        {
            IQueue <int> q = new LifoQueue <int>();

            q.Enqueue(123);
            int val = q.Peek();

            Assert.AreEqual(123, val);
            Assert.AreEqual(1, q.Count);
            val = q.Peek();
            Assert.AreEqual(123, val);
            Assert.AreEqual(1, q.Count);
            q.Enqueue(456);
            val = q.Peek();
            Assert.AreEqual(456, val);
            Assert.AreEqual(2, q.Count);
        }
Exemplo n.º 2
0
        public void EnumeratorIsLifo()
        {
            int          i;
            IQueue <int> q = new LifoQueue <int>();

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

            i = 99;
            foreach (int j in q)
            {
                Assert.AreEqual(i, j);
                i--;
            }
        }
Exemplo n.º 3
0
        public void LifoOrdering()
        {
            int          i;
            IQueue <int> q = new LifoQueue <int>();

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

            Assert.AreEqual(100, q.Count);

            for (i = 99; i >= 0; i--)
            {
                int val = q.Dequeue();
                Assert.AreEqual(i, val);
            }

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