コード例 #1
0
        public void MaxBinaryHeapDeleteMaximumValueTest()
        {
            MaxBinaryHeap <int, int> heap = new MaxBinaryHeap <int, int>();

            heap.Insert(2, 22);
            heap.Insert(3, 33);
            heap.Insert(1, 11);
            Assert.AreEqual(3, heap.Size);
            Assert.AreEqual(33, heap.DeleteMaximumValue());
            Assert.AreEqual(22, heap.DeleteMaximumValue());
            Assert.AreEqual(11, heap.DeleteMaximumValue());
            Assert.AreEqual(0, heap.Size);
        }
コード例 #2
0
        public void MaxBinaryHeapInsertTest()
        {
            MaxBinaryHeap <int, int> heap = new MaxBinaryHeap <int, int>();

            heap.Insert(1, 10);
            heap.Insert(4, 40);
            heap.Insert(2, 20);
            heap.Insert(5, 50);
            heap.Insert(13, 130);
            heap.Insert(6, 60);
            heap.Insert(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);
        }
コード例 #3
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);
        }
コード例 #4
0
 public void MaxBinaryHeapDeleteMaximumValueGuardTest()
 {
     MaxBinaryHeap <int, int> heap = new MaxBinaryHeap <int, int>();
     int result = heap.DeleteMaximumValue();
 }