// 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. Linux期末复习题

    版权声明: https://blog.csdn.net/u014483914/article/details/36622451 1.More和less命令的差别         More命令通经常使用 ...

  2. 在CentOS6.8系统上安装MySQL5.7(转)

    mysql-57">如何在CentOS 6.8系统上安装MySQL 5.7? 一.检查系统上是否已经安装MySQL 命令: ? 1 2 3 4 5 [root@localhost ~] ...

  3. Eclipse设置自动提示(转)

    一.Eclipse编辑Spring配置文件xml时自动提示类class包名 链接:http://blog.csdn.net/hh775313602/article/details/70176531 第 ...

  4. 配置中心Server端

    为什么需要统一配置中心 1.不方便维护.一个功能被多个人开发,如果其中一个人修改了配置文件,另外一个人测试之前的功能,准备使用之前的配置. 2.配置内容安全与权限.线上的配置是不会对开发公开,特别是数 ...

  5. centos 6,7 上cgroup资源限制使用举例

    在Centos6,7使用cgroup做内存限制,使用的配置包是libcgroup,具体方案和操作步骤如下. 步骤1:安装配置管理包 Centos 6: # yum install libcgroup ...

  6. Centos6.7 运行 eclipse出错解决办法

    今天在centos下运行eclipse c++出现来点问题.主要原因是jdk点安装以及环境变量始终不对. 尝试在/etc/profile中手动配置,也没有成功. 做了如下步骤成功解决. 1.查看jdk ...

  7. Linux之chown

    命令功能: chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID:组可以是组名或者组ID:文件是以空格分开的要改变权限的文件列表,支持通配符.系统管理员经常使用chown命令, ...

  8. shell 查看去掉windons中的换行符

    查看 cat -v 1.sh 替换 sed -i 's/\r//g' 1.sh

  9. 关于MySql悲观锁与乐观锁

    悲观锁与乐观锁是两种常见的资源并发锁设计思路,也是并发编程中一个非常基础的概念.本文将对这两种常见的锁机制在数据库数据上的实现进行比较系统的介绍. 悲观锁(Pessimistic Lock) 悲观锁的 ...

  10. [蓝桥杯]ALGO-48.算法训练_关联矩阵

    题目描述: 问题描述 有一个n个结点m条边的有向图,请输出他的关联矩阵. 输入格式 第一行两个整数n.m,表示图中结点和边的数目.n<=,m<=. 接下来m行,每行两个整数a.b,表示图中 ...