Ejemplo n.º 1
0
        public void MaxBinaryHeapPercolateDownTest()
        {
            var heapData = GetMaxHeapTestData();

            Assert.AreEqual(3, MaxBinaryHeap <int, int> .PercolateDown(heapData, heapData.Length, 3));
            Assert.AreEqual(4, MaxBinaryHeap <int, int> .PercolateDown(heapData, heapData.Length, 4));
            Assert.AreEqual(5, MaxBinaryHeap <int, int> .PercolateDown(heapData, heapData.Length, 5));
            Assert.AreEqual(6, MaxBinaryHeap <int, int> .PercolateDown(heapData, heapData.Length, 6));
            heapData[0] = new BinaryHeapBase <int, int> .KeyValuePair(0, 0);

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

            Assert.AreEqual(6, MaxBinaryHeap <int, int> .PercolateDown(heapData, heapData.Length, 0));
            CollectionAssertEx.AreEqual(new int[] { 6, 4, 5, 1, 0, 2, 3 }, heapData.Select(x => x.Key));
        }
Ejemplo n.º 2
0
        public void MaxBinaryHeapPercolateDownGuardCase2Test()
        {
            var heapData = GetMaxHeapTestData();

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