// maxHeapityLoopBased to keep max heap properties by loop
// i is node index started by 1, only will be translated to 0 started index until operate array
maxHeapityLoopBased to keep max heap properties by loop
i is node index started by 1, only will be translated to 0 started index until operate array
// maxHeapityLoopBased to keep max heap properties by loop // i is node index started by 1 only will be translated to 0 started index until operate array
func (m *binaryHeap) maxHeapityLoopBased(in myInterface, i int) {
	for {
		left := m.leftChild(i)
		right := m.rightChild(i)
		largest := i
		if left <= m.heapSize && in.Less(largest-1, left-1) { 
			largest = left
		}
		if right <= m.heapSize && in.Less(largest-1, right-1) { 
			largest = right
		}
		if largest == i {
			break
		}
		in.Swap(largest-1, i-1) 
		i = largest
	}
}
func ( m * binaryHeap ) maxHeapityLoopBased ( in myInterface , i int ) { for { left := m . leftChild ( i ) right := m . rightChild ( i ) largest := i if left <= m . heapSize && in . Less ( largest - 1 , left - 1 ) { largest = left } if right <= m . heapSize && in . Less ( largest - 1 , right - 1 ) { largest = right } if largest == i { break } in . Swap ( largest - 1 , i - 1 ) i = largest } }
maxHeapityLoopBased to keep max heap properties by loop
i is node index started by 1, only will be translated to 0 started index until operate array
maxHeapityLoopBased to keep max heap properties by loop i is node index started by 1 only will be translated to 0 started index until operate array
// i will be the parent in the maxHeapity procedure // find largest from i,left,right // translate to 0 started index to operate array // translate to 0 started index to operate array // translate to 0 started index to operate array