Exemplo n.º 1
0
        public void CanPeekValues()
        {
            var dict = new PriorityDictionary <Point, float>();

            for (var x = 0; x < 10; x++)
            {
                for (var y = 0; y < 10; y++)
                {
                    dict.Add(new Point(x, y), ((x - 2) * (x - 2.5f)) + ((y - 3) * (y - 3.2f)));
                }
            }

            var min = dict.PopMin();

            Assert.AreEqual(0, min.Value, 0.01f);
            Assert.AreEqual(new Point(2, 3), min.Key);

            min = dict.PeekMin();
            Assert.AreEqual(0.5, min.Value, 0.01f);
            Assert.AreEqual(new Point(3, 3), min.Key);

            var max = dict.PeekMax();

            Assert.AreEqual(80.3f, max.Value, 0.01f);
            Assert.AreEqual(new Point(9, 9), max.Key);
        }
Exemplo n.º 2
0
        public void CanRemoveMinValue()
        {
            var dict = new PriorityDictionary <int, string>();

            dict.Add(1, "BBB");
            dict.Add(2, "AAA");
            var min = dict.PopMin();

            Assert.AreEqual("AAA", min.Value);
            Assert.AreEqual(2, min.Key);
        }