C++删除容器数据
// 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++删除容器数据的更多相关文章
- docker 12 docker容器数据卷
数据卷概念 ♣我们知道,当我们把一个运行中的容器关闭后,容器里的数据就没有了(如果你做了docker commit操作,数据会保留到新的镜像里面).所以我们就需要用容器数据卷把容器数据进行持久化储存. ...
- Docker容器数据卷
⒈Docker容器中数据如何持久化? ①通过commit命令使容器反向为镜像 ②以容器数据卷的方式将数据抽离 ⒉容器数据卷的作用? ①容器数据的持久化 ②容器间继承.共享数据 ⒊能干嘛? 卷就是目录或 ...
- docker之容器数据持久化
1.挂载本地目录为容器的数据存放目录 [root@node03 ~]# docker run -itd --name web01 -v /container_data/web:/data ubuntu ...
- Docker自学纪实(三)Docker容器数据持久化
谈起数据卷 我一直觉得是个枯燥无聊的话题 但是通过今天的实操和阅读 我发现其实并不是 其实就像走夜路 没有光明,第一次都是恐惧 但是如果走的次数多了 或者静下心来去克制恐惧 也许就会驾轻就熟或者等到黎 ...
- Docker容器与容器数据
Docker容器与容器数据 image 与container 镜像(Image)和容器(Container)的关系,就像是面向对象程序设计中的 类 和 实例 一样,镜像是静态的定义,容器是镜像运行时的 ...
- Docker容器数据卷(七)
Docker致力于: 将运用与运行的环境打包形成容器运行 ,运行可以伴随着容器,但是我们对数据的要求希望是持久化的 容器之间希望有可能共享数据 Docker容器产生的数据,如果不通过docker co ...
- docker系列之六容器数据卷
docker之容器数据卷 一.容器数据卷 docker容器运行的时候,会产生一系列的文件,那么我们希望容器产生的数据能提供给其他的容器使用,也就是说怎么实现容器间的数据的共享呢?这就需要用到我们所提到 ...
- 5、docker容器数据卷: -v添加共享传递容器数据卷
1.是什么 1.docker理念 先来看看Docker的理念:* 将运用与运行的环境打包形成容器运行 ,运行可以伴随着容器,但是我们对数据的要求希望是持久化的* 容器之间希望有可能共享数据 2.保 ...
- Docker 容器数据卷(Data Volume)与数据管理
卷(Volume)是容器中的一个数据挂载点,卷可以绕过联合文件系统,从而为Docker 提供持久数据,所提供的数据还可以在宿主机-容器或多个容器之间共享.通过卷,我们可以可以使修改数据直接生效,而不必 ...
随机推荐
- 我发起了一个 用 C 语言 作为 中间语言 的 编译器 项目 VMBC
大家好 , 我发起了一个 用 C 语言 作为 中间语言 的 编译器 项目 VMBC . VMBC , 全称是 Virtual Machine Base on C . 有一种说法 , C 语言是 ...
- requestAnimationFrame 知识点
与setTimeout相比,requestAnimationFrame最大的优势是由系统来决定回调函数的执行时机.具体一点讲,如果屏幕刷新率是60Hz,那么回调函数就每16.7ms被执行一次,如果刷新 ...
- Python random模块sample、randint、shuffle、choice随机函数
一.random模块简介 Python标准库中的random函数,可以生成随机浮点数.整数.字符串,甚至帮助你随机选择列表序列中的一个元素,打乱一组数据等. 二.random模块重要函数 1 ).ra ...
- JFrame包含的容器(JRootPane)
JFrame对象创建后,此对象包含JRootPane类型的容器.JRootPane 下有GlassPane, 和 LayeredPane,LayeredPane下又有ContentPane , ...
- Hive HiveServer2+beeline+jdbc客户端访问操作
HiveServer 查看/home/hadoop/bigdatasoftware/apache-hive-0.13.1-bin/bin目录文件,其中有hiveserver2 启动hiveserver ...
- Visual Studio: 一键卸载所有组件工具,彻底卸载干净。
第一步.手动卸载VS主体 第二步.下载工具并解压 网盘下载地址:https://pan.baidu.com/s/1eSHRYxW 也可以在Github上下载最新版本:https://github.co ...
- minicom的安装及配置
1. sudo apt-get install minicom 2. 配置 (1). sudo minicom –s (2). (3). 按“A”配置设备,再按回车保存.按”F”,把留空改为NO.回车 ...
- windows环境下把Python代码打包成独立执行的exe
windows环境下把Python代码打包成独立执行的exe可执行文件 有时候因为出差,突然急需处理一批数据.虽然写好的脚本存储在云端随用随取,然而编译的环境还需要重新搭建,模块也需要重新装载,从 ...
- ubuntu-docker入门到放弃(二)docker初探(基本用法及命令)
一.使用公共镜像 docker有一个开源的镜像管理系统,上面有很多常见的images,如mysql,nginx,tomcat等,可以直接根据自己的需求下载下来用,还有系统images,如redhat, ...
- HTML和CSS的静态页面
链接:https://pan.baidu.com/s/1fGajigyQJDLIHqxJn2LXsQ 提取码:7sry 复制这段内容后打开百度网盘手机App,操作更方便哦 设计思路,把网页分成几个模块 ...