コード例 #1
0
        public void AscendingPriorityQueueGetMinimumValueTest()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            priorityQueue.Insert(2, 22);
            priorityQueue.Insert(1, 11);
            Assert.AreEqual(2, priorityQueue.Size);
            Assert.AreEqual(11, priorityQueue.GetMinimumValue());
            Assert.AreEqual(2, priorityQueue.Size);
        }
コード例 #2
0
        public void AscendingPriorityQueueIsEmptyTest()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            Assert.IsTrue(priorityQueue.IsEmpty);
            priorityQueue.Insert(1, 1);
            priorityQueue.Insert(2, 2);
            Assert.IsFalse(priorityQueue.IsEmpty);
            priorityQueue.Clear();
            Assert.IsTrue(priorityQueue.IsEmpty);
        }
コード例 #3
0
        public void AscendingPriorityQueueGetValueTest()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            priorityQueue.Insert(3, 33);
            priorityQueue.Insert(2, 22);
            priorityQueue.Insert(1, 11);
            Assert.AreEqual(3, priorityQueue.Size);
            Assert.AreEqual(11, priorityQueue.GetValue(0));
            Assert.AreEqual(22, priorityQueue.GetValue(1));
            Assert.AreEqual(33, priorityQueue.GetValue(2));
            Assert.AreEqual(3, priorityQueue.Size);
        }
コード例 #4
0
        public void AscendingPriorityQueueClearTest()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            Assert.AreEqual(0, priorityQueue.Size);
            priorityQueue.Clear();
            Assert.AreEqual(0, priorityQueue.Size);
            priorityQueue.Insert(1, 11);
            priorityQueue.Insert(2, 22);
            Assert.AreEqual(2, priorityQueue.Size);
            priorityQueue.Clear();
            Assert.AreEqual(0, priorityQueue.Size);
        }
コード例 #5
0
        public void AscendingPriorityQueueInsertTest()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            priorityQueue.Insert(3, 33);
            priorityQueue.Insert(2, 22);
            priorityQueue.Insert(1, 11);
            List <int> valueList = new List <int>();

            while (priorityQueue.Size != 0)
            {
                valueList.Add(priorityQueue.DeleteMinimumValue());
            }
            CollectionAssert.AreEqual(new int[] { 11, 22, 33 }, valueList);
        }
コード例 #6
0
        public void AscendingPriorityQueueGetValueGuardCase2Test()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            priorityQueue.Insert(1, 11);
            var result = priorityQueue.GetValue(1);
        }
コード例 #7
0
        public void AscendingPriorityQueueInsertGuardTest()
        {
            AscendingPriorityQueue <string, int> priorityQueue = new AscendingPriorityQueue <string, int>();

            priorityQueue.Insert(null, 1);
        }