//通过索引删除元素
public T DeleteByIndex(int index) {
if (index < 1 || index > this._currentLength) {
Console.WriteLine("索引非法!");
return default(T);
}
T deleteData = this._data[index - 1];
for (int i = index - 1; i < this._currentLength - 1; i++) {
this._data[i] = this._data[i + 1];
}
this._currentLength--;
return deleteData;
}
先检查要删除的位置有没有超过范围了,超过了你删条毛啊
将要删除位置的后面元素往前覆盖就删掉了
后面乜有元素?长度-1也是访问不到删除元素的了,也是删除了的意思