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
ce8185e6
Kaydet (Commit)
ce8185e6
authored
Agu 13, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More function re-ordering (placing like functions together).
üst
ed6c1ef8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
86 deletions
+86
-86
setobject.c
Objects/setobject.c
+86
-86
No files found.
Objects/setobject.c
Dosyayı görüntüle @
ce8185e6
...
@@ -566,6 +566,57 @@ set_contains_entry(PySetObject *so, setentry *entry)
...
@@ -566,6 +566,57 @@ set_contains_entry(PySetObject *so, setentry *entry)
return
key
!=
NULL
&&
key
!=
dummy
;
return
key
!=
NULL
&&
key
!=
dummy
;
}
}
static
PyObject
*
set_pop
(
PySetObject
*
so
)
{
PyObject
*
key
;
register
setentry
*
entry
;
register
int
i
=
0
;
assert
(
PyAnySet_Check
(
so
));
if
(
so
->
used
==
0
)
{
PyErr_SetString
(
PyExc_KeyError
,
"pop from an empty set"
);
return
NULL
;
}
/* Set entry to "the first" unused or dummy set entry. We abuse
* the hash field of slot 0 to hold a search finger:
* If slot 0 has a value, use slot 0.
* Else slot 0 is being used to hold a search finger,
* and we use its hash value as the first index to look.
*/
entry
=
&
so
->
table
[
0
];
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
;
}
PyDoc_STRVAR
(
pop_doc
,
"Remove and return an arbitrary set element."
);
static
int
set_len
(
PyObject
*
so
)
{
return
((
PySetObject
*
)
so
)
->
used
;
}
/***** Set iterator type ***********************************************/
/***** Set iterator type ***********************************************/
static
PyTypeObject
PySetIter_Type
;
/* Forward */
static
PyTypeObject
PySetIter_Type
;
/* Forward */
...
@@ -682,12 +733,6 @@ static PyTypeObject PySetIter_Type = {
...
@@ -682,12 +733,6 @@ static PyTypeObject PySetIter_Type = {
(
iternextfunc
)
setiter_iternext
,
/* tp_iternext */
(
iternextfunc
)
setiter_iternext
,
/* tp_iternext */
};
};
static
int
set_len
(
PyObject
*
so
)
{
return
((
PySetObject
*
)
so
)
->
used
;
}
static
int
static
int
set_update_internal
(
PySetObject
*
so
,
PyObject
*
other
)
set_update_internal
(
PySetObject
*
so
,
PyObject
*
other
)
{
{
...
@@ -918,41 +963,6 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
...
@@ -918,41 +963,6 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
}
}
}
}
static
int
set_contains
(
PySetObject
*
so
,
PyObject
*
key
)
{
PyObject
*
tmpkey
;
int
rv
;
rv
=
set_contains_key
(
so
,
key
);
if
(
rv
==
-
1
)
{
if
(
!
PyAnySet_Check
(
key
)
||
!
PyErr_ExceptionMatches
(
PyExc_TypeError
))
return
-
1
;
PyErr_Clear
();
tmpkey
=
make_new_set
(
&
PyFrozenSet_Type
,
NULL
);
if
(
tmpkey
==
NULL
)
return
-
1
;
set_swap_bodies
((
PySetObject
*
)
tmpkey
,
(
PySetObject
*
)
key
);
rv
=
set_contains
(
so
,
tmpkey
);
set_swap_bodies
((
PySetObject
*
)
tmpkey
,
(
PySetObject
*
)
key
);
Py_DECREF
(
tmpkey
);
}
return
rv
;
}
static
PyObject
*
set_direct_contains
(
PySetObject
*
so
,
PyObject
*
key
)
{
long
result
;
result
=
set_contains
(
so
,
key
);
if
(
result
==
-
1
)
return
NULL
;
return
PyBool_FromLong
(
result
);
}
PyDoc_STRVAR
(
contains_doc
,
"x.__contains__(y) <==> y in x."
);
static
PyObject
*
static
PyObject
*
set_copy
(
PySetObject
*
so
)
set_copy
(
PySetObject
*
so
)
{
{
...
@@ -1537,6 +1547,41 @@ PyDoc_STRVAR(add_doc,
...
@@ -1537,6 +1547,41 @@ PyDoc_STRVAR(add_doc,
\n
\
\n
\
This has no effect if the element is already present."
);
This has no effect if the element is already present."
);
static
int
set_contains
(
PySetObject
*
so
,
PyObject
*
key
)
{
PyObject
*
tmpkey
;
int
rv
;
rv
=
set_contains_key
(
so
,
key
);
if
(
rv
==
-
1
)
{
if
(
!
PyAnySet_Check
(
key
)
||
!
PyErr_ExceptionMatches
(
PyExc_TypeError
))
return
-
1
;
PyErr_Clear
();
tmpkey
=
make_new_set
(
&
PyFrozenSet_Type
,
NULL
);
if
(
tmpkey
==
NULL
)
return
-
1
;
set_swap_bodies
((
PySetObject
*
)
tmpkey
,
(
PySetObject
*
)
key
);
rv
=
set_contains
(
so
,
tmpkey
);
set_swap_bodies
((
PySetObject
*
)
tmpkey
,
(
PySetObject
*
)
key
);
Py_DECREF
(
tmpkey
);
}
return
rv
;
}
static
PyObject
*
set_direct_contains
(
PySetObject
*
so
,
PyObject
*
key
)
{
long
result
;
result
=
set_contains
(
so
,
key
);
if
(
result
==
-
1
)
return
NULL
;
return
PyBool_FromLong
(
result
);
}
PyDoc_STRVAR
(
contains_doc
,
"x.__contains__(y) <==> y in x."
);
static
PyObject
*
static
PyObject
*
set_remove
(
PySetObject
*
so
,
PyObject
*
key
)
set_remove
(
PySetObject
*
so
,
PyObject
*
key
)
{
{
...
@@ -1596,51 +1641,6 @@ PyDoc_STRVAR(discard_doc,
...
@@ -1596,51 +1641,6 @@ PyDoc_STRVAR(discard_doc,
\n
\
\n
\
If the element is not a member, do nothing."
);
If the element is not a member, do nothing."
);
static
PyObject
*
set_pop
(
PySetObject
*
so
)
{
PyObject
*
key
;
register
setentry
*
entry
;
register
int
i
=
0
;
assert
(
PyAnySet_Check
(
so
));
if
(
so
->
used
==
0
)
{
PyErr_SetString
(
PyExc_KeyError
,
"pop from an empty set"
);
return
NULL
;
}
/* Set entry to "the first" unused or dummy set entry. We abuse
* the hash field of slot 0 to hold a search finger:
* If slot 0 has a value, use slot 0.
* Else slot 0 is being used to hold a search finger,
* and we use its hash value as the first index to look.
*/
entry
=
&
so
->
table
[
0
];
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
;
}
PyDoc_STRVAR
(
pop_doc
,
"Remove and return an arbitrary set element."
);
static
PyObject
*
static
PyObject
*
set_reduce
(
PySetObject
*
so
)
set_reduce
(
PySetObject
*
so
)
{
{
...
...
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