Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
975a8e8f
Kaydet (Commit)
975a8e8f
authored
Mar 05, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use LT in all comparisons
üst
221760a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
heapq.py
Lib/heapq.py
+3
-3
No files found.
Lib/heapq.py
Dosyayı görüntüle @
975a8e8f
...
@@ -181,7 +181,7 @@ def heapify(x):
...
@@ -181,7 +181,7 @@ def heapify(x):
def
_heappushpop_max
(
heap
,
item
):
def
_heappushpop_max
(
heap
,
item
):
"""Maxheap version of a heappush followed by a heappop."""
"""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
item
,
heap
[
0
]
=
heap
[
0
],
item
_siftup_max
(
heap
,
0
)
_siftup_max
(
heap
,
0
)
return
item
return
item
...
@@ -312,7 +312,7 @@ def _siftdown_max(heap, startpos, pos):
...
@@ -312,7 +312,7 @@ def _siftdown_max(heap, startpos, pos):
while
pos
>
startpos
:
while
pos
>
startpos
:
parentpos
=
(
pos
-
1
)
>>
1
parentpos
=
(
pos
-
1
)
>>
1
parent
=
heap
[
parentpos
]
parent
=
heap
[
parentpos
]
if
newitem
>
parent
:
if
parent
<
newitem
:
heap
[
pos
]
=
parent
heap
[
pos
]
=
parent
pos
=
parentpos
pos
=
parentpos
continue
continue
...
@@ -329,7 +329,7 @@ def _siftup_max(heap, pos):
...
@@ -329,7 +329,7 @@ def _siftup_max(heap, pos):
while
childpos
<
endpos
:
while
childpos
<
endpos
:
# Set childpos to index of larger child.
# Set childpos to index of larger child.
rightpos
=
childpos
+
1
rightpos
=
childpos
+
1
if
rightpos
<
endpos
and
not
heap
[
childpos
]
>
heap
[
right
pos
]:
if
rightpos
<
endpos
and
not
heap
[
rightpos
]
<
heap
[
child
pos
]:
childpos
=
rightpos
childpos
=
rightpos
# Move the larger child up.
# Move the larger child up.
heap
[
pos
]
=
heap
[
childpos
]
heap
[
pos
]
=
heap
[
childpos
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment