// free the contents of the list; erase the list

inline void ListDelete (list <void *> *pList)
{
if (pList)
{
list <void *>::iterator iNext; for (iNext = pList->begin (); iNext != pList->end (); ++iNext)
free (*iNext); pList->erase (pList->begin (), pList->end ());
}
} // ----------------------------------------------------------------------
// Delete the contents of a list; Erase the list
//
template <class T>
void ListDelete (list <T> *pList)
{
if (pList)
{
list <T>::iterator iNext; for (iNext = pList->begin (); iNext != pList->end (); )
{
// prefetch next position incase object destructor modifies list
list <T>::iterator iThis = iNext++;
delete *iThis;
} pList->erase (pList->begin (), pList->end ());
}
} // ----------------------------------------------------------------------
// Clear the contents of a list of pointers
//
template <class T>
void ListClear (list <T> *pList)
{
if (pList)
{
list <T>::iterator iNext; for (iNext = pList->begin (); iNext != pList->end (); ++iNext)
*iNext = ;
}
} // ----------------------------------------------------------------------
// Delete the contents of a map; Erase the map
//
template <class Key, class Value, class Compare>
void MapDelete (map <Key, Value, Compare> *pMap)
{
if (pMap)
{
map <Key, Value, Compare>::iterator iNext; for (iNext = pMap->begin (); iNext != pMap->end (); ++iNext)
delete (*iNext).second; pMap->erase (pMap->begin (), pMap->end ());
}
} // ----------------------------------------------------------------------
// Clears the contents of a map of pointers
// doesn't change the key values
//
template <class Key, class Value, class Compare>
void MapClear (map <Key, Value, Compare> *pMap)
{
if (pMap)
{
map <Key, Value, Compare>::iterator iNext; for (iNext = pMap->begin (); iNext != pMap->end (); ++iNext)
(*iNext).second = ;
}
} // ----------------------------------------------------------------------
// Delete the contents of a vector; Erase the vector
//
template <class Value>
void VectorDelete (vector <Value> *pvVector)
{
if (pvVector)
{
vector <Value>::iterator iNext; for (iNext = pvVector->begin (); iNext != pvVector->end (); ++iNext)
delete *iNext; pvVector->erase (pvVector->begin (), pvVector->end ());
}
} // ----------------------------------------------------------------------
// Delete the contents of a set; Erase the set
//
template <class Key, class Compare>
void SetDelete (set <Key, Compare> *pSet)
{
if (pSet)
{
set <Key, Compare>::iterator iNext; for (iNext = pSet->begin (); iNext != pSet->end (); ++iNext)
delete *iNext; pSet->erase (pSet->begin (), pSet->end ());
}
} // ----------------------------------------------------------------------
// Clears the contents of a vector of pointers
//
template <class Value>
void VectorClear (vector <Value> *pvVector)
{
if (pvVector)
{
vector <Value>::iterator iNext; for (iNext = pvVector->begin (); iNext != pvVector->end (); ++iNext)
*iNext = ;
}
} // ---------------------------------------------------------------------- template <class T>
class less_ptr : public binary_function<T, T, bool>
{
public:
OS_STRUCT_CONSTRUCT (less_ptr) bool operator () (const T& x_, const T& y_) const
{
return * x_ < * y_;
}
}; // ---------------------------------------------------------------------- template <class T>
class unary_predicate : public unary_function<T,bool>
{
public: unary_predicate(){}
virtual bool operator () ( T argument )
{
return false;
}
};

C++删除容器数据的更多相关文章

  1. docker 12 docker容器数据卷

    数据卷概念 ♣我们知道,当我们把一个运行中的容器关闭后,容器里的数据就没有了(如果你做了docker commit操作,数据会保留到新的镜像里面).所以我们就需要用容器数据卷把容器数据进行持久化储存. ...

  2. Docker容器数据卷

    ⒈Docker容器中数据如何持久化? ①通过commit命令使容器反向为镜像 ②以容器数据卷的方式将数据抽离 ⒉容器数据卷的作用? ①容器数据的持久化 ②容器间继承.共享数据 ⒊能干嘛? 卷就是目录或 ...

  3. docker之容器数据持久化

    1.挂载本地目录为容器的数据存放目录 [root@node03 ~]# docker run -itd --name web01 -v /container_data/web:/data ubuntu ...

  4. Docker自学纪实(三)Docker容器数据持久化

    谈起数据卷 我一直觉得是个枯燥无聊的话题 但是通过今天的实操和阅读 我发现其实并不是 其实就像走夜路 没有光明,第一次都是恐惧 但是如果走的次数多了 或者静下心来去克制恐惧 也许就会驾轻就熟或者等到黎 ...

  5. Docker容器与容器数据

    Docker容器与容器数据 image 与container 镜像(Image)和容器(Container)的关系,就像是面向对象程序设计中的 类 和 实例 一样,镜像是静态的定义,容器是镜像运行时的 ...

  6. Docker容器数据卷(七)

    Docker致力于: 将运用与运行的环境打包形成容器运行 ,运行可以伴随着容器,但是我们对数据的要求希望是持久化的 容器之间希望有可能共享数据 Docker容器产生的数据,如果不通过docker co ...

  7. docker系列之六容器数据卷

    docker之容器数据卷 一.容器数据卷 docker容器运行的时候,会产生一系列的文件,那么我们希望容器产生的数据能提供给其他的容器使用,也就是说怎么实现容器间的数据的共享呢?这就需要用到我们所提到 ...

  8. 5、docker容器数据卷: -v添加共享传递容器数据卷

    1.是什么 1.docker理念 先来看看Docker的理念:*  将运用与运行的环境打包形成容器运行 ,运行可以伴随着容器,但是我们对数据的要求希望是持久化的*  容器之间希望有可能共享数据 2.保 ...

  9. Docker 容器数据卷(Data Volume)与数据管理

    卷(Volume)是容器中的一个数据挂载点,卷可以绕过联合文件系统,从而为Docker 提供持久数据,所提供的数据还可以在宿主机-容器或多个容器之间共享.通过卷,我们可以可以使修改数据直接生效,而不必 ...

随机推荐

  1. IE浏览器兼容问题

    文件兼容性用于定义让IE如何编译你的网页.此文件解释文件兼容性,如何指定你网站的文件兼容性模式以及如何判断一个网页该使用的文件模式. 为了帮助确保你的网页在所有未来的IE版本都有一致的外观,IE8引入 ...

  2. 记录:.user.ini 使用

    记录:.user.ini 使用 可以用于防跨站配置. .user.ini 注意安全问题 动态加载,默认 5 分钟自动刷新. php 5.3 以后的版本支持. 修改完成后再将文件锁定. 相关链接: 神秘 ...

  3. day 31 进程的其他方法 进程锁 进程队列

    一.进程的其他方法 1.   .name      进程名   (可指定) 2.  .pid     进程号 3.   os.getpid         在什么位置就是什么的进程号 4.   .is ...

  4. 自动化部署--shell脚本--2

    node1和node2都装apache   [root@linux-node1 ~]# yum install httpd -y Loaded plugins: fastestmirror Loadi ...

  5. [转]HashMap的实现原理

    1.    HashMap概述: HashMap是基于哈希表的Map接口的非同步实现.此实现提供所有可选的映射操作,并允许使用null值和null键.此类不保证映射的顺序,特别是它不保证该顺序恒久不变 ...

  6. 如果指针为空,返回ERROR

    if(!p) //是!p而不是p return ERROR;

  7. jmeter ---处理Cookie与Session

    有些网站保存信息是使用Cookie,有些则是使用Session.对于这两种方式,JMeter都给予一定的支持. 1.Cookie 添加方式:线程组-配置元件-HTTP Cookie 管理器,如下图: ...

  8. Redis set数据结构

    set里的数据不能重复 1. 增加set1,值为 a b c d 1 2 3 2. 返回集合元素的数量 3. 重命名set1为set100 4. 查看集合中的成员 5.sdiff set100 set ...

  9. 在Centos7上安装配置ss-libev Proxifier

    http://note.youdao.com/noteshare?id=6f768652c33a64d6b8935eb08b10a213 servier:ss-libev client:ss+Prox ...

  10. 使用 Visual Studio 分析器找出应用程序瓶颈

    VS的性能分析工具 性能分析工具的选择 打开一个“性能分析”的会话:Debug->Start Diagnotic Tools Without Debugging(或按Alt+F2),VS2013 ...