// 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. 是“帐”还是“账” --- 由 FastAdmin 用户中心引出的讨论

    是"帐"还是"账" --- 由 FastAdmin 用户中心引出的讨论 有小伙伴对 FastAdmin 用户中心的"账号"提出异议,应该为& ...

  2. Maven知识整理

    一.概念: Maven是一个项目管理工具,它包含了一个项目对象模型(Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统( ...

  3. Apache Kafka监控之Kafka Web Console

    Kafka Web Console:是一款开源的系统,源码的地址在https://github.com/claudemamo/kafka-web-console中.Kafka Web Console也 ...

  4. Delphi 的 Bit

    我一直感觉 Delphi 下的Bit操作不是很好使, 所以一直屏蔽着这方面的学习.不过最近收集整理了一下代码. 原因是这样的. 由于某个需求被分解成 在 0~n(不定) 中,有几个数字被置换成了“tr ...

  5. IDE0022 使用方法的表达式主体

    这错误提示意思应该是:推荐您将此方法改为用“表达式主体”形式实现 所谓表达式主体,是类似 public void DisplayName() => Console.WriteLine(ToStr ...

  6. Excel导出文件流下载

    Controller.cs @CrossOrigin(allowCredentials="true", allowedHeaders="*", methods= ...

  7. Maven编译错误记录:Some Enforcer rules have failed

    一.错误信息 添加httpclient与httpcore依赖后编译Maven报错. 错误信息如下: Failed to execute goal org.apache.maven.plugins:ma ...

  8. java设计模式-Iterator

    Iterator模式 主要是用在容器的遍历上,其他的地方都不怎么用:理解一下,会用了就可以了:   1.背景 请动手自己写一个可以动态添加对象的容器: 代码: ArrayList.java(是自己实现 ...

  9. java1.8新特性(optional 使用)

    经常在程序中出现 java.lang.NullPointerException  为了避免  报错,总是要进行一些 是否为null 的if else 判断 ,1.8 可以使用optional 类 来简 ...

  10. 廖雪峰Java1-3流程控制-5循环

    while循环 while循环首先判断条件: 条件满足时循环:条件不满足时退出循环 如果一开始条件就不满足,一次都不循环.如while false int sum = 0; int n = 1; wh ...