首先,以我之愚见,觉得有两个地方可以优化一下,不知对否,有待商榷:

1、在list的结点定义中

template<typename T>
struct __list_node
{
typedef void* void_pointer;
void_pointer prev;
void_pointer next;
T data;
}

出现的void_pointer是否改为如下更为妥当:

template<typename T>
struct __list_node
{
typedef __list_node<T>* pointer;
pointer prev;
pointer next;
T data;
}

这样可以省略后面的大量指针转换操作(link_type与void_pointer)

2、在remove()函数的实现中:

template<class T,class Alloc>
void list<T,Alloc>::remove(const T& value)
{
iterator first=begin();
iterator last=end();
while(first!=last)
{
iterator next=first;
++next;
if(value==*first) erase(first);
first=next;
}
}

改为如下时候更简洁优化:

template<class T,class Alloc>
void list<T,Alloc>::remove(const T& value)
{
iterator first=begin();
iterator last=end();
while(first!=last)
{
first=erase(first);
}
}

最新文章

  1. codevs 2287 火车站
  2. getAttribute、setAttribute、removeAttribute
  3. react native RadioButton(单选按钮)
  4. View Controller Relationships
  5. Android三种播放视频的方式
  6. ButterKnife
  7. WPFFontCache_v0400.exe CPU使用率过高的问题
  8. 【Stage3D学习笔记续】山寨Starling(一):从事件说起
  9. nginx使用自认证的https证书
  10. Qt学习
  11. Paxos 实现日志复制同步(Multi-Paxos)
  12. RabbitMQ安装和使用(和Spring集成)
  13. 芝麻HTTP:Python爬虫实战之爬取糗事百科段子
  14. Linux多线程实践(2) --线程基本API
  15. MySql给表添加列和注释
  16. selenium+python-unittest多线程生成报告
  17. 欢迎来到GitHub世界
  18. 步步为营-30-AES加密与解密
  19. Java基础-SSM之mybatis的树形控件(自关联)
  20. miRTarBase 数据库简介

热门文章

  1. linux系统文件的颜色代表的意思
  2. HTML 页面加载动画效果
  3. 树莓派上搭建基于Python+web.py+fastcgi+lighttpd的网站
  4. Cocos2d-X 2.2嵌入MFC的子窗口
  5. Cocoapod错误 - Xcode6.4
  6. app应用程序本地化--备用
  7. delphi xe5 android 开发实现手机打电话和发短信
  8. python中的__init__ 、__new__、__call__等内置函数的剖析
  9. 需要插入子集的时候如何更新父级ID
  10. 转:在Eclipse中进行C/C++开发的配置方法(20140721最新版)