summaryrefslogtreecommitdiff
path: root/libgo/go/container/heap/heap.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/container/heap/heap.go')
-rw-r--r--libgo/go/container/heap/heap.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/libgo/go/container/heap/heap.go b/libgo/go/container/heap/heap.go
index 67018e6baea..bbaf40a989d 100644
--- a/libgo/go/container/heap/heap.go
+++ b/libgo/go/container/heap/heap.go
@@ -79,7 +79,7 @@ func Remove(h Interface, i int) interface{} {
func up(h Interface, j int) {
for {
i := (j - 1) / 2 // parent
- if i == j || h.Less(i, j) {
+ if i == j || !h.Less(j, i) {
break
}
h.Swap(i, j)
@@ -97,7 +97,7 @@ func down(h Interface, i, n int) {
if j2 := j1 + 1; j2 < n && !h.Less(j1, j2) {
j = j2 // = 2*i + 2 // right child
}
- if h.Less(i, j) {
+ if !h.Less(j, i) {
break
}
h.Swap(i, j)