STL 的容器的清除模板 clear.h
2014-04-21 17:34
288 查看
#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
相关文章推荐
- STL 清除模板容器 clear.h
- C++ STL模板与容器 知识 初学 小结 ( 二 )
- C++面试笔记--STL模板与容器
- STL模板容器
- STL1 容器、pair 模板、容器适配器
- C++ STL模板与容器 知识 初学 小结 ( 一 )
- STL模板和容器(1)
- C++ STL模板与容器 知识 初学 小结 ( 三 )
- C++STL模板容器(一)
- C++STL模板容器(二)
- STL--模板和容器
- 程序员面试宝典9 -STL模板与容器
- C++STL模板容器(三)
- C++STL模板容器(四)
- c++的STL模板库中3种容器类:vector,list,deque的比较
- CSS中clear清除元素容器浮动
- NOIP复赛复习(七)STL容器与字符串模板
- STL中的list/set/map等容器clear之后的内存占用
- clear.cs//清除容器中文本框内容
- STL常用容器模板