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
0ef0423c
Kaydet (Commit)
0ef0423c
authored
Ock 27, 2016
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
be59d148
37434323
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
collections.rst
Doc/library/collections.rst
+3
-0
test_deque.py
Lib/test/test_deque.py
+14
-0
_collectionsmodule.c
Modules/_collectionsmodule.c
+7
-0
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
0ef0423c
...
...
@@ -477,6 +477,9 @@ or subtracting from an empty counter.
Insert *x* into the deque at position *i*.
If the insertion causes a bounded deque to grow beyond *maxlen*, the
rightmost element is then removed to restore the size limit.
.. versionadded:: 3.5
...
...
Lib/test/test_deque.py
Dosyayı görüntüle @
0ef0423c
...
...
@@ -304,6 +304,20 @@ class TestBasic(unittest.TestCase):
s
.
insert
(
i
,
'Z'
)
self
.
assertEqual
(
list
(
d
),
s
)
def
test_index_bug_26194
(
self
):
data
=
'ABC'
for
i
in
range
(
len
(
data
)
+
1
):
d
=
deque
(
data
,
len
(
data
))
d
.
insert
(
i
,
None
)
s
=
list
(
data
)
s
.
insert
(
i
,
None
)
s
.
pop
()
self
.
assertEqual
(
list
(
d
),
s
)
if
i
<
len
(
data
):
self
.
assertIsNone
(
d
[
i
])
else
:
self
.
assertTrue
(
None
not
in
d
)
def
test_imul
(
self
):
for
n
in
(
-
10
,
-
1
,
0
,
1
,
2
,
10
,
1000
):
d
=
deque
()
...
...
Modules/_collectionsmodule.c
Dosyayı görüntüle @
0ef0423c
...
...
@@ -1085,10 +1085,17 @@ deque_insert(dequeobject *deque, PyObject *args)
Py_ssize_t
index
;
Py_ssize_t
n
=
Py_SIZE
(
deque
);
PyObject
*
value
;
PyObject
*
oldvalue
;
PyObject
*
rv
;
if
(
!
PyArg_ParseTuple
(
args
,
"nO:insert"
,
&
index
,
&
value
))
return
NULL
;
if
(
deque
->
maxlen
==
Py_SIZE
(
deque
))
{
if
(
index
>=
deque
->
maxlen
||
Py_SIZE
(
deque
)
==
0
)
Py_RETURN_NONE
;
oldvalue
=
deque_pop
(
deque
,
NULL
);
Py_DECREF
(
oldvalue
);
}
if
(
index
>=
n
)
return
deque_append
(
deque
,
value
);
if
(
index
<=
-
n
||
index
==
0
)
...
...
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