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
67962ab1
Kaydet (Commit)
67962ab1
authored
Agu 02, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Model set.pop() after dict.popitem().
üst
6a694508
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
12 deletions
+34
-12
setobject.h
Include/setobject.h
+4
-0
setobject.c
Objects/setobject.c
+30
-12
No files found.
Include/setobject.h
Dosyayı görüntüle @
67962ab1
...
@@ -13,6 +13,10 @@ There are three kinds of slots in the table:
...
@@ -13,6 +13,10 @@ There are three kinds of slots in the table:
1. Unused: key == NULL
1. Unused: key == NULL
2. Active: key != NULL and key != dummy
2. Active: key != NULL and key != dummy
3. Dummy: key == dummy
3. Dummy: key == dummy
Note: .pop() abuses the hash field of an Unused or Dummy slot to
hold a search finger. The hash field of Unused or Dummy slots has
no meaning otherwise.
*/
*/
#define PySet_MINSIZE 8
#define PySet_MINSIZE 8
...
...
Objects/setobject.c
Dosyayı görüntüle @
67962ab1
...
@@ -1508,24 +1508,42 @@ static PyObject *
...
@@ -1508,24 +1508,42 @@ static PyObject *
set_pop
(
PySetObject
*
so
)
set_pop
(
PySetObject
*
so
)
{
{
PyObject
*
key
;
PyObject
*
key
;
int
pos
=
0
;
register
setentry
*
entry
;
int
rv
;
register
int
i
=
0
;
if
(
!
set_next_internal
(
so
,
&
pos
,
&
key
))
{
assert
(
PyAnySet_Check
(
so
));
if
(
so
->
used
==
0
)
{
PyErr_SetString
(
PyExc_KeyError
,
"pop from an empty set"
);
PyErr_SetString
(
PyExc_KeyError
,
"pop from an empty set"
);
return
NULL
;
return
NULL
;
}
}
Py_INCREF
(
key
);
rv
=
set_discard_internal
(
so
,
key
);
/* Set entry to "the first" unused or dummy set entry. We abuse
if
(
rv
==
-
1
)
{
* the hash field of slot 0 to hold a search finger:
Py_DECREF
(
key
);
* If slot 0 has a value, use slot 0.
return
NULL
;
* Else slot 0 is being used to hold a search finger,
}
else
if
(
rv
==
DISCARD_NOTFOUND
)
{
* and we use its hash value as the first index to look.
Py_DECREF
(
key
);
*/
PyErr_SetObject
(
PyExc_KeyError
,
key
);
entry
=
&
so
->
table
[
0
];
return
NULL
;
if
(
entry
->
key
==
NULL
||
entry
->
key
==
dummy
)
{
i
=
(
int
)
entry
->
hash
;
/* The hash field may be a real hash value, or it may be a
* legit search finger, or it may be a once-legit search
* finger that's out of bounds now because it wrapped around
* or the table shrunk -- simply make sure it's in bounds now.
*/
if
(
i
>
so
->
mask
||
i
<
1
)
i
=
1
;
/* skip slot 0 */
while
((
entry
=
&
so
->
table
[
i
])
->
key
==
NULL
||
entry
->
key
==
dummy
)
{
i
++
;
if
(
i
>
so
->
mask
)
i
=
1
;
}
}
}
key
=
entry
->
key
;
Py_INCREF
(
dummy
);
entry
->
key
=
dummy
;
so
->
used
--
;
so
->
table
[
0
].
hash
=
i
+
1
;
/* next place to start */
return
key
;
return
key
;
}
}
...
...
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