Add python code of chapter queue to docs.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/* 列表扩容 */
|
||||
|
||||
Reference in New Issue
Block a user