MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / heapifyDown

Function heapifyDown

sort/heapsort.go:100–115  ·  view source on GitHub ↗
(slice []T, N, i int, moreFunc func(i, j int) bool, swapFunc func(i, j int))

Source from the content-addressed store, hash-verified

98}
99
100func heapifyDown[T any](slice []T, N, i int, moreFunc func(i, j int) bool, swapFunc func(i, j int)) {
101 l, r := 2*i+1, 2*i+2
102 max := i
103
104 if l < N && moreFunc(l, max) {
105 max = l
106 }
107 if r < N && moreFunc(r, max) {
108 max = r
109 }
110 if max != i {
111 swapFunc(i, max)
112
113 heapifyDown(slice, N, max, moreFunc, swapFunc)
114 }
115}
116
117type Comparable interface {
118 Idx() int

Callers 2

heapifyDownMethod · 0.85
HeapSortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected