Beispiel #1
0
        public void PeekRepeats()
        {
            IQueue <int> q = new FifoQueue <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(123, val);
            Assert.AreEqual(2, q.Count);
        }
Beispiel #2
0
        public void EnumeratorIsFifo()
        {
            int          i;
            IQueue <int> q = new FifoQueue <int>();

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

            i = 0;
            foreach (int j in q)
            {
                Assert.AreEqual(i, j);
                i++;
            }
        }
Beispiel #3
0
        public void FifoOrdering()
        {
            int          i;
            IQueue <int> q = new FifoQueue <int>();

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

            Assert.AreEqual(100, q.Count);

            for (i = 0; i < 100; i++)
            {
                int val = q.Dequeue();
                Assert.AreEqual(i, val);
            }

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