Ejemplo n.º 1
0
        public void SimpleAddAndRemove()
        {
            var queue = new LLQueue <int>();

            for (int i = 0; i != 10; ++i)
            {
                queue.Enqueue(i);
            }
            int cur = 0;
            int res;
            int peek;

            queue.TryPeek(out peek);
            Assert.AreEqual(0, peek);
            while (queue.TryDequeue(out res))
            {
                Assert.AreEqual(cur++, res);
                if (queue.TryPeek(out peek))
                {
                    Assert.AreEqual(cur, peek);
                    Assert.IsFalse(queue.IsEmpty);
                }
                else
                {
                    Assert.IsTrue(queue.IsEmpty);
                }
            }
        }
Ejemplo n.º 2
0
 public void SimpleAddAndRemove()
 {
     var queue = new LLQueue<int>();
     for(int i = 0; i != 10; ++i)
         queue.Enqueue(i);
     int cur = 0;
     int res;
     int peek;
     queue.TryPeek(out peek);
     Assert.AreEqual(0, peek);
     while(queue.TryDequeue(out res))
     {
         Assert.AreEqual(cur++, res);
         if(queue.TryPeek(out peek))
         {
             Assert.AreEqual(cur, peek);
             Assert.IsFalse(queue.IsEmpty);
         }
         else
             Assert.IsTrue(queue.IsEmpty);
     }
 }