Exemplo n.º 1
0
        public void MaxBinaryHeapBuildTest()
        {
            MaxBinaryHeap <int, int> heap = new MaxBinaryHeap <int, int>();

            heap.Build(
                new BinaryHeapBase <int, int> .KeyValuePair(1, 10),
                new BinaryHeapBase <int, int> .KeyValuePair(4, 40),
                new BinaryHeapBase <int, int> .KeyValuePair(2, 20),
                new BinaryHeapBase <int, int> .KeyValuePair(5, 50),
                new BinaryHeapBase <int, int> .KeyValuePair(13, 130),
                new BinaryHeapBase <int, int> .KeyValuePair(6, 60),
                new BinaryHeapBase <int, int> .KeyValuePair(17, 170)
                );
            List <int> valueList = new List <int>();

            while (heap.Size != 0)
            {
                valueList.Add(heap.DeleteMaximumValue());
            }
            CollectionAssert.AreEqual(new int[] { 170, 130, 60, 50, 40, 20, 10 }, valueList);
        }
Exemplo n.º 2
0
        public void MaxBinaryHeapBuildGuardTest()
        {
            MaxBinaryHeap <int, int> heap = new MaxBinaryHeap <int, int>();

            heap.Build(null);
        }