public void AscendingPriorityQueueGetValueGuardCase2Test()
        {
            AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();

            priorityQueue.Insert(1, 11);
            var result = priorityQueue.GetValue(1);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
Ejemplo n.º 6
0
    public IEnumerator <T> GetEnumerator()
    {
        var clone = new AscendingPriorityQueue <T>(_comparer, _items);

        while (true)
        {
            var x = clone.MayDequeue();
            if (!x.HasValue)
            {
                yield break;
            }
            yield return(x.ForceGetValue());
        }
    }
        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);
        }
 public void AscendingPriorityQueueGetMinimumValueGuardTest()
 {
     AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();
     var result = priorityQueue.GetMinimumValue();
 }
 public void AscendingPriorityQueueGetValueGuardCase3Test()
 {
     AscendingPriorityQueue <int, int> priorityQueue = new AscendingPriorityQueue <int, int>();
     var result = priorityQueue.GetValue(0);
 }
        public void AscendingPriorityQueueInsertGuardTest()
        {
            AscendingPriorityQueue <string, int> priorityQueue = new AscendingPriorityQueue <string, int>();

            priorityQueue.Insert(null, 1);
        }