This commit is contained in:
krahets
2024-09-28 09:26:54 +08:00
parent 03a6cd27ca
commit 4ac4f94628
25 changed files with 119 additions and 162 deletions

View File

@@ -1721,7 +1721,7 @@ comments: true
remove(index) {
if (index < 0 || index >= this.#size) throw new Error('索引越界');
let num = this.#arr[index];
// 将索引 index 之后的元素都向前移动一位
// 将索引 index 之后的元素都向前移动一位
for (let j = index; j < this.#size - 1; j++) {
this.#arr[j] = this.#arr[j + 1];
}