public void NodesAreExtractedInOrderOfLowerPriority2()
        {
            var pQueue = new PQueue();
            var node1 = pQueue.Insert("A:11");
            var node2 = pQueue.Insert("A:12");
            var node3 = pQueue.Insert("A:13");

            pQueue.IncreasePriority(node1);
            var extractedNodeA = pQueue.Extract();
            Assert.AreEqual(node2, extractedNodeA);

            pQueue.IncreasePriority(node3);
            var extractedNodeB = pQueue.Extract();
            Assert.AreEqual(node1, extractedNodeB);
        }
        public void CanRemoveSpecificNode()
        {
            var pQueue = new PQueue();
            var node1 = pQueue.Insert("A:11");
            var node2 = pQueue.Insert("A:12");
            var node3 = pQueue.Insert("A:13");

            pQueue.Remove(node2);

            var extractedNodeA = pQueue.Extract();
            Assert.AreEqual(node1, extractedNodeA);

            var extractedNodeB = pQueue.Extract();
            Assert.AreEqual(node3, extractedNodeB);

            Assert.IsTrue(pQueue.IsEmpty());
        }
Exemple #3
0
        public void IncreasePriorityWorksWithOneObject()
        {
            var pQueue = new PQueue();
            string key = "theKey";
            var createdNode = pQueue.Insert(key);
            int originalPriority = createdNode.Priority;
            pQueue.IncreasePriority(createdNode);
            var extractedNode = pQueue.Extract();

            Assert.IsTrue(extractedNode.Priority > originalPriority);
        }
Exemple #4
0
        public void ExtractMethodReturnAProperObject()
        {
            var pQueue = new PQueue();
            string key = "theKey";
            var createdNode = pQueue.Insert(key);
            var extractedNode = pQueue.Extract();

            Assert.IsNotNull(extractedNode);
            Assert.AreEqual(createdNode.Key, extractedNode.Key);
            Assert.AreEqual(createdNode.Priority, extractedNode.Priority);
        }