示例#1
0
        public void DecreaseKeyTest(IHeap <int> heap, bool isMin)
        {
            var num    = RandomNumber();
            var tmpLst = new List <int>(TestList)
            {
                num
            };

            tmpLst.Sort();
            if (!isMin)
            {
                tmpLst.Reverse();
            }
            var node = heap.Insert(isMin ? num + 1 : num - 1);

            node.Value = num;
            heap.DecreaseKey(node);
            var heapList = GetHeapList(isMin).ToList();

            Console.WriteLine("isMin:" + isMin);
            Console.WriteLine("Expect:" + string.Join(", ", tmpLst));
            Console.WriteLine("Result:" + string.Join(", ", heapList));
            Assert.IsTrue(tmpLst.SequenceEqual(heapList));
        }