Exemplo n.º 1
0
        public void IncreaseKey()
        {
            var job = new MockJob {
                Name = "cooking"
            };
            var job2 = new MockJob {
                Name = "homework"
            };
            var job3 = new MockJob {
                Name = "hoover"
            };
            var priorityQueue = new MaxPriorityQueue <MockJob>(new[] { new KeyValuePair <double, MockJob>(2.0, job), new KeyValuePair <double, MockJob>(1.1, job2), new KeyValuePair <double, MockJob>(2.5, job3) });

            priorityQueue.IncreaseKey(1, 3.0);
            Assert.AreEqual("homework", priorityQueue.Maximum().Name, "#E8");
        }
Exemplo n.º 2
0
        public void Insert()
        {
            var job = new MockJob {
                Name = "cooking"
            };
            var job2 = new MockJob {
                Name = "homework"
            };
            var job3 = new MockJob {
                Name = "hoover"
            };
            var priorityQueue = new MaxPriorityQueue <MockJob>(new[] { new KeyValuePair <double, MockJob>(2.0, job), new KeyValuePair <double, MockJob>(1.1, job2) });

            priorityQueue.Insert(new KeyValuePair <double, MockJob>(2.5, job3));
            Assert.AreEqual(3, priorityQueue.Count, "#E9");
            Assert.AreEqual("hoover", priorityQueue.Maximum().Name, "#E10");
        }
Exemplo n.º 3
0
        public void ExtractMax()
        {
            var job = new MockJob {
                Name = "cooking"
            };
            var priorityQueue = new MaxPriorityQueue <MockJob>(new[] { new KeyValuePair <double, MockJob>(2.0, job) });

            Assert.AreEqual(job.Name, priorityQueue.ExtractMax().Name, "#E2");
            Assert.AreEqual(0, priorityQueue.Count, "#E3");

            var job2 = new MockJob {
                Name = "homework"
            };
            var job3 = new MockJob {
                Name = "hoover"
            };

            priorityQueue = new MaxPriorityQueue <MockJob>(new[] { new KeyValuePair <double, MockJob>(2.0, job), new KeyValuePair <double, MockJob>(1.1, job2), new KeyValuePair <double, MockJob>(2.5, job3) });
            Assert.AreEqual("hoover", priorityQueue.ExtractMax().Name, "#E4");
            Assert.AreEqual(2, priorityQueue.Count, "#E5");
            Assert.AreEqual("cooking", priorityQueue.ExtractMax().Name, "#E6");
            Assert.AreEqual(1, priorityQueue.Count, "#E7");
        }