Example #1
0
        public void MaxBinaryHeapPercolateUpTest()
        {
            var heapData = GetMaxHeapTestData();

            Assert.AreEqual(0, MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 0));
            Assert.AreEqual(1, MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 1));
            Assert.AreEqual(2, MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 2));
            heapData[5] = new BinaryHeapBase <int, int> .KeyValuePair(20, 20);

            Assert.AreEqual(0, MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 5));
            CollectionAssertEx.AreEqual(new int[] { 20, 13, 17, 1, 4, 6, 5 }, heapData.Select(x => x.Key));
            heapData[6] = new BinaryHeapBase <int, int> .KeyValuePair(18, 18);

            Assert.AreEqual(2, MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 6));
            CollectionAssertEx.AreEqual(new int[] { 20, 13, 18, 1, 4, 6, 17 }, heapData.Select(x => x.Key));
        }
Example #2
0
        public void MaxBinaryHeapPercolateUpGuardCase2Test()
        {
            var heapData = GetMaxHeapTestData();

            MaxBinaryHeap <int, int> .PercolateUp(heapData, heapData.Length, 7);
        }