STL 清除模板容器 clear.h
2015-09-27 18:06
281 查看
#pragma once #include "GeometricMacro.h" #include "GeometricEnum.h" #include "McGePoint2d.h" _GEOMETRIC_BEGIN template<class T> inline bool clearvct(std::vector<T*>& vctVal) { for(std::vector<T*>::iterator p=vctVal.begin();p!=vctVal.end();++p) { delete static_cast<T*>(*p); *p=NULL; } vctVal.clear(); return true; } template<class T> inline bool clearlst(std::list<T*>& lstVal) { for(std::list<T*>::iterator p=lstVal.begin();p!=lstVal.end();++p) { delete static_cast<T*>(*p); *p=NULL; } lstVal.clear(); return true; } template<class T1,class T2> inline bool clearmap(std::map<T1,T2*>& mapVal) { for(std::map<T1,T2*>::iterator p=mapVal.begin();p!=mapVal.end();++p) { delete static_cast<T2*>(p->second); static_cast<T2*>(p->second)=NULL; } mapVal.clear(); return true; } _GEOMETRIC_END
相关文章推荐
- Java 大数值
- [ruby][文件操作]对当前文件夹下的文件进行重命名
- 顺序表(ArrayList)java实现
- epoll简介(二)
- JavaScript高级程序设计之面向对象的程序设计之继承之原型链 第6.3.1讲笔记
- 封装的概念和原理,set和get方法
- Maven-配置链接到私服及设置本地仓库
- 浅谈关于Java的注解使用
- 读懂程序里的--时间
- 逻辑和情绪
- OpenStack OVS GRE/VXLAN网络
- Java Web开发1___JSP指令元素:taglib指令
- HDU 5486 Difference of Clustering 图论
- LevelHostControl.xaml
- JSP的基础语法
- Http服务器实现文件上传与下载(二)
- 03_队列
- TCP、UDP、IP 协议分析
- HTML5新增的元素和废除的元素
- ajaxfileupload 能上传图片不能上传其他文件的解决方法