// 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. openstack--8--控制节点部署Dashboard

    Horizon介绍 Dashboard服务,这里具体的产品就是Horizon1.它提供一个Web界面操作Openstack的系统2.使用Django框架基于Openstack API开发3.支持将Se ...

  2. tomcat源码阅读之BackupManager

    一. 配置: <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOpti ...

  3. kafka 知识点

    Replica如何分布 为了尽量做好负载均衡和容错能力,需要将同一个Partition的Replica尽量分散到不同的机器.如果所有的Replica都在同一个Broker上,那一旦该Broker宕机, ...

  4. dojo:如何为表格添加从数据库获得存储的下拉框

    为表格添加下拉框的例子官网上就有,但如果下拉框的数据是从数据库请求的.需要有一些注意的地方. 首先希望实现的效果如下图所示: 表格初始数据为空,点击查询后获得表格表格数据,但下拉框的数据是在对应的fo ...

  5. Qt中的标准对话框之QMessageBox

    1. Qt标准对话框 Qt为开发者提供了一些可复用的对话框类型 Qt提供的可复用对话框全部继承自QDialog类 Qt中的对话框的使用方式和QDialog完全一致 2. 标准对话框的使用步骤 ①定义对 ...

  6. position 分层固定在屏幕某位置

    很多网站我们看到在屏幕右下角有一个,返回顶部,始终在那儿,还有些网站顶部菜单栏永远也是固定的不动,就是通过今天学习的position来做的. 在style中加入 positon:fixed;top 0 ...

  7. NAND FLASH控制器

    一.nand flash访问原理 地址空间概念 nand的编址 nand命令  命令,地址,数据 使用S3C2440的nand flash控制器访问nand flash 前几个编译出来的文件都小于4k ...

  8. libextobjc使用

    pod 'libextobjc' #import "extobjc.h" 使用@weakify(self); @strongify(self)

  9. 数据挖掘标准规范之CRISP-DM基础

    一.前言 每每提到数据挖掘,总有些人上来就是ETL.是算法.是数学模型,作为搞工程实施的我而言,很是头疼.其实作为数据挖掘的而言,算法只是其实现手段.是工具和实现手段而已,我们不是在创造算法(国外职业 ...

  10. 【jdk】使用wget下载jdk8

    因为在oracle官网下载jdk需要 如果直接在linux中使用 wget命令下载,实际下载是一个html文件,所以需要通过一下命令 wget --no-check-certificate --no- ...