@@ -38,7 +38,7 @@ type Interface interface {
38
38
// Init is idempotent with respect to the heap invariants
39
39
// and may be called whenever the heap invariants may have been invalidated.
40
40
// The complexity is O(n) where n = h.Len().
41
- func Init (h Interface ) {
41
+ func Init (h sort. Interface ) {
42
42
// heapify
43
43
n := h .Len ()
44
44
for i := n / 2 - 1 ; i >= 0 ; i -- {
@@ -80,13 +80,13 @@ func Remove(h Interface, i int) any {
80
80
// Changing the value of the element at index i and then calling Fix is equivalent to,
81
81
// but less expensive than, calling [Remove](h, i) followed by a Push of the new value.
82
82
// The complexity is O(log n) where n = h.Len().
83
- func Fix (h Interface , i int ) {
83
+ func Fix (h sort. Interface , i int ) {
84
84
if ! down (h , i , h .Len ()) {
85
85
up (h , i )
86
86
}
87
87
}
88
88
89
- func up (h Interface , j int ) {
89
+ func up (h sort. Interface , j int ) {
90
90
for {
91
91
i := (j - 1 ) / 2 // parent
92
92
if i == j || ! h .Less (j , i ) {
@@ -97,7 +97,7 @@ func up(h Interface, j int) {
97
97
}
98
98
}
99
99
100
- func down (h Interface , i0 , n int ) bool {
100
+ func down (h sort. Interface , i0 , n int ) bool {
101
101
i := i0
102
102
for {
103
103
j1 := 2 * i + 1
0 commit comments