Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1.修改next,prev指针
类似于课上所讲的情况,两个共享指针互相指向,会造成循环引用,引用计数无法置零,无法被回收。前一个指针“拥有”后一个指针,next为unique,prev为普通指针。
2.构造函数优化
可以使用引用,如果为模板类,可以优化速度,模板类尝试修改了一部分,学艺不精,以后再尝试。
3.修改了insert的逻辑
4.erase因为指针类型的修改,需要修改顺序
5.析构函数
每有一个Node就应该调用一次,原始案例中少了因为有循环引用问题,没有回收空间。
6.为什么删除拷贝赋值函数也不出错?
因为代码中没有调用
7.做了些简单的越界处理
8.print函数修改
增加引用