コード例 #1
0
        public void TestPeek()
        {
            PairPriorityQueue <float, string> testQueue = new PairPriorityQueue <float, string>();

            testQueue.Enqueue(1.0f, "a");
            testQueue.Enqueue(2.0f, "b");
            testQueue.Enqueue(0.0f, "c");

            Assert.AreEqual("b", testQueue.Peek().Item);
        }
コード例 #2
0
        public void TestCount()
        {
            PairPriorityQueue <float, string> testQueue = new PairPriorityQueue <float, string>();

            Assert.AreEqual(0, testQueue.Count);
            testQueue.Enqueue(12.34f, "a");
            Assert.AreEqual(1, testQueue.Count);
            testQueue.Enqueue(56.78f, "b");
            Assert.AreEqual(2, testQueue.Count);
            testQueue.Dequeue();
            Assert.AreEqual(1, testQueue.Count);
            testQueue.Enqueue(9.0f, "c");
            Assert.AreEqual(2, testQueue.Count);
            testQueue.Clear();
            Assert.AreEqual(0, testQueue.Count);
        }
コード例 #3
0
        public void TestEnumerator()
        {
            PairPriorityQueue <float, string> testQueue = new PairPriorityQueue <float, string>();

            testQueue.Enqueue(1.0f, "a");
            testQueue.Enqueue(2.0f, "b");
            testQueue.Enqueue(0.0f, "c");

            List <PriorityItemPair <float, string> > testList =
                new List <PriorityItemPair <float, string> >();

            foreach (PriorityItemPair <float, string> entry in testQueue)
            {
                testList.Add(entry);
            }

            CollectionAssert.AreEquivalent(testQueue, testList);
        }
コード例 #4
0
        public void TestCopyTo()
        {
            PairPriorityQueue <float, string> testQueue = new PairPriorityQueue <float, string>();

            testQueue.Enqueue(1.0f, "a");
            testQueue.Enqueue(9.0f, "i");
            testQueue.Enqueue(2.0f, "b");
            testQueue.Enqueue(8.0f, "h");
            testQueue.Enqueue(3.0f, "c");
            testQueue.Enqueue(7.0f, "g");
            testQueue.Enqueue(4.0f, "d");
            testQueue.Enqueue(6.0f, "f");
            testQueue.Enqueue(5.0f, "e");

            PriorityItemPair <float, string>[] itemArray = new PriorityItemPair <float, string> [9];
            testQueue.CopyTo(itemArray, 0);

            CollectionAssert.AreEquivalent(testQueue, itemArray);
        }
コード例 #5
0
        public void TestOrdering()
        {
            PairPriorityQueue <float, string> testQueue = new PairPriorityQueue <float, string>();

            testQueue.Enqueue(1.0f, "a");
            testQueue.Enqueue(9.0f, "i");
            testQueue.Enqueue(2.0f, "b");
            testQueue.Enqueue(8.0f, "h");
            testQueue.Enqueue(3.0f, "c");
            testQueue.Enqueue(7.0f, "g");
            testQueue.Enqueue(4.0f, "d");
            testQueue.Enqueue(6.0f, "f");
            testQueue.Enqueue(5.0f, "e");

            Assert.AreEqual("i", testQueue.Dequeue().Item);
            Assert.AreEqual("h", testQueue.Dequeue().Item);
            Assert.AreEqual("g", testQueue.Dequeue().Item);
            Assert.AreEqual("f", testQueue.Dequeue().Item);
            Assert.AreEqual("e", testQueue.Dequeue().Item);
            Assert.AreEqual("d", testQueue.Dequeue().Item);
            Assert.AreEqual("c", testQueue.Dequeue().Item);
            Assert.AreEqual("b", testQueue.Dequeue().Item);
            Assert.AreEqual("a", testQueue.Dequeue().Item);
        }