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

@@ -72,15 +72,18 @@ public:
}
/* 删除元素 */
void remove(int index) {
int remove(int index) {
if (index >= size())
throw out_of_range("索引越界");
int num = nums[index];
// 索引 i 之后的元素都向前移动一位
for (int j = index; j < size() - 1; j++) {
nums[j] = nums[j + 1];
}
// 更新元素数量
numsSize--;
// 返回被删除元素
return num;
}
/* 列表扩容 */