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
db6b62e7
Kaydet (Commit)
db6b62e7
authored
Eyl 05, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Inline cmp_lt().
üst
1784ff02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
_heapqmodule.c
Modules/_heapqmodule.c
+11
-15
No files found.
Modules/_heapqmodule.c
Dosyayı görüntüle @
db6b62e7
...
...
@@ -8,12 +8,6 @@ annotated by François Pinard, and converted to C by Raymond Hettinger.
#include "Python.h"
static
int
cmp_lt
(
PyObject
*
x
,
PyObject
*
y
)
{
return
PyObject_RichCompareBool
(
x
,
y
,
Py_LT
);
}
static
int
_siftdown
(
PyListObject
*
heap
,
Py_ssize_t
startpos
,
Py_ssize_t
pos
)
{
...
...
@@ -34,7 +28,7 @@ _siftdown(PyListObject *heap, Py_ssize_t startpos, Py_ssize_t pos)
while
(
pos
>
startpos
){
parentpos
=
(
pos
-
1
)
>>
1
;
parent
=
PyList_GET_ITEM
(
heap
,
parentpos
);
cmp
=
cmp_lt
(
newitem
,
parent
);
cmp
=
PyObject_RichCompareBool
(
newitem
,
parent
,
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
newitem
);
return
-
1
;
...
...
@@ -74,9 +68,10 @@ _siftup(PyListObject *heap, Py_ssize_t pos)
/* Set childpos to index of smaller child. */
rightpos
=
childpos
+
1
;
if
(
rightpos
<
endpos
)
{
cmp
=
cmp_lt
(
cmp
=
PyObject_RichCompareBool
(
PyList_GET_ITEM
(
heap
,
childpos
),
PyList_GET_ITEM
(
heap
,
rightpos
));
PyList_GET_ITEM
(
heap
,
rightpos
),
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
newitem
);
return
-
1
;
...
...
@@ -219,7 +214,7 @@ heappushpop(PyObject *self, PyObject *args)
return
item
;
}
cmp
=
cmp_lt
(
PyList_GET_ITEM
(
heap
,
0
),
item
);
cmp
=
PyObject_RichCompareBool
(
PyList_GET_ITEM
(
heap
,
0
),
item
,
Py_LT
);
if
(
cmp
==
-
1
)
return
NULL
;
if
(
cmp
==
0
)
{
...
...
@@ -318,7 +313,7 @@ nlargest(PyObject *self, PyObject *args)
else
goto
sortit
;
}
cmp
=
cmp_lt
(
sol
,
elem
);
cmp
=
PyObject_RichCompareBool
(
sol
,
elem
,
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
elem
);
goto
fail
;
...
...
@@ -373,7 +368,7 @@ _siftdownmax(PyListObject *heap, Py_ssize_t startpos, Py_ssize_t pos)
while
(
pos
>
startpos
){
parentpos
=
(
pos
-
1
)
>>
1
;
parent
=
PyList_GET_ITEM
(
heap
,
parentpos
);
cmp
=
cmp_lt
(
parent
,
newitem
);
cmp
=
PyObject_RichCompareBool
(
parent
,
newitem
,
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
newitem
);
return
-
1
;
...
...
@@ -413,9 +408,10 @@ _siftupmax(PyListObject *heap, Py_ssize_t pos)
/* Set childpos to index of smaller child. */
rightpos
=
childpos
+
1
;
if
(
rightpos
<
endpos
)
{
cmp
=
cmp_lt
(
cmp
=
PyObject_RichCompareBool
(
PyList_GET_ITEM
(
heap
,
rightpos
),
PyList_GET_ITEM
(
heap
,
childpos
));
PyList_GET_ITEM
(
heap
,
childpos
),
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
newitem
);
return
-
1
;
...
...
@@ -488,7 +484,7 @@ nsmallest(PyObject *self, PyObject *args)
else
goto
sortit
;
}
cmp
=
cmp_lt
(
elem
,
los
);
cmp
=
PyObject_RichCompareBool
(
elem
,
los
,
Py_LT
);
if
(
cmp
==
-
1
)
{
Py_DECREF
(
elem
);
goto
fail
;
...
...
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