]> granicus.if.org Git - python/commitdiff
Use LT in all comparisons
authorRaymond Hettinger <python@rcn.com>
Tue, 5 Mar 2013 06:17:57 +0000 (01:17 -0500)
committerRaymond Hettinger <python@rcn.com>
Tue, 5 Mar 2013 06:17:57 +0000 (01:17 -0500)
Lib/heapq.py

index 82f61a2c32d17ac5b902628b85c0dbb1bc1e8780..6859821feeea910ab2d9422d8cf453ebbe8748ab 100644 (file)
@@ -181,7 +181,7 @@ def heapify(x):
 
 def _heappushpop_max(heap, item):
     """Maxheap version of a heappush followed by a heappop."""
-    if heap and heap[0] > item:
+    if heap and item < heap[0]:
         item, heap[0] = heap[0], item
         _siftup_max(heap, 0)
     return item
@@ -312,7 +312,7 @@ def _siftdown_max(heap, startpos, pos):
     while pos > startpos:
         parentpos = (pos - 1) >> 1
         parent = heap[parentpos]
-        if newitem > parent:
+        if parent < newitem:
             heap[pos] = parent
             pos = parentpos
             continue
@@ -329,7 +329,7 @@ def _siftup_max(heap, pos):
     while childpos < endpos:
         # Set childpos to index of larger child.
         rightpos = childpos + 1
-        if rightpos < endpos and not heap[childpos] > heap[rightpos]:
+        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
             childpos = rightpos
         # Move the larger child up.
         heap[pos] = heap[childpos]