Add python code of chapter queue to docs.

This commit is contained in:
Yudong Jin
2022-12-02 00:09:34 +08:00
parent 460d42ae3d
commit e20bc251f5
18 changed files with 276 additions and 134 deletions

View File

@ -36,9 +36,10 @@ class MyList:
assert index < self.__size, "索引越界"
self.__nums[index] = num
""" 中间插入元素 """
""" 中间插入(尾部添加)元素 """
def add(self, num, index=-1):
assert index < self.__size, "索引越界"
# 若不指定索引 index ,则向数组尾部添加元素
if index == -1:
index = self.__size
# 元素数量超出容量时,触发扩容机制