#pragma once
#include "stdafx.h"
#include<windows.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std; bool badvalue(int x)
{
if (x == || x==)
return true; return false;
}
map<int, vector<int>> g_map;
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> vec;
vec.push_back();
vec.push_back();
vec.push_back();
vec.push_back();
//std::remove(vec.begin(), vec.end(), 2); //删除指定元素为2
vec.erase(remove_if(vec.begin(), vec.end(), badvalue), vec.end());//删除符合判断的元素
g_map.insert(make_pair(, vec));
g_map.insert(make_pair(, vec));
map<int, vector<int>>::iterator it = g_map.begin();
//for (; it != g_map.end(); /*it++*/)
//{
// g_map.erase(it++);
//}
it = g_map.begin();
for (; it != g_map.end(); it++)
{
printf("map:%d\n", it->first);
vector<int>::iterator iter = it->second.begin();
int i = ;
while (iter != it->second.end())
{
printf("vector:%d\n", *iter);
iter++;
}
}
system("pause");
return ;
}

vector删除指定元素的更多相关文章

  1. jquery数组删除指定元素的方法:grep()

    jquery数组删除指定元素的方法:grep() 金刚 数组 jquery javascript 元素 遇到的问题 今天遇到一个问题,删除数组中的一个指定元素,并返回新的数组. 我定义的js数组是这样 ...

  2. List 循环删除 指定元素的 方法

    使用Iterator进行循环,在删除指定元素.如果使用for 或 foreach 在删除指定下标是,list.size 会相应的缩短且下标前移,导致相邻满足条件的元素未删除 Iterator<S ...

  3. java集合遍历删除指定元素异常分析总结

    在使用集合的过程中,我们经常会有遍历集合元素,删除指定的元素的需求,而对于这种需求我们往往使用会犯些小错误,导致程序抛异常或者与预期结果不对,本人很早之前就遇到过这个坑,当时没注意总结,结果前段时间又 ...

  4. ES6数组中删除指定元素

    知识点: ES6从数组中删除指定元素 findIndex()方法返回数组中满足提供的测试函数的第一个元素的索引.否则返回-1. arr.splice(arr.findIndex(item => ...

  5. es6删除指定元素

    原数组: let arr =[{id:1},{id:2},{id:3},{id:8}] 待删除数据 obj = {id:1} 删除原数组指定元素 arr.splice(arr.findIndex(it ...

  6. vector list map 遍历删除指定元素

    #include <stdio.h> #include <stdint.h> #include <vector> #include <list> #in ...

  7. vector删除特定元素

    删除vector中小于20的元素,注意要使迭代器失效,不能简单的删除. #include <iostream>#include <vector>using namespace ...

  8. js 数组删除指定元素

    Array.prototype.remove = function(obj) { for (var i = 0; i < this.length; i++) { var temp = this[ ...

  9. jq从数组中删除指定元素(根据自定义条件) 超好用的 $.grep() 方法

    转: jQuery.grep() 什么是jQuery.grep()? jQuery.grep()是一个查找满足过滤函数的数组元素的函数.原始数组不受影响,返回值为数组. 用法介绍: 写法: jQuer ...

随机推荐

  1. PhoneGap简易配置使用

    在Android Studio 里新一下Android项目, 这个不用说了. 链接: https://pan.baidu.com/s/1qYcCBEW 密码: ymhh 添加 cordovaapp-c ...

  2. springboot学习3事务控制

    springboot学习3事务控制 spring的事务控制本质上是通过aop实现的. 在springboot中使用时,可以通过注解@Transactional进行类或者方法级别的事务控制,也可以自己通 ...

  3. Netty 异步模型

    简介 Netty中的 I/O 操作是异步的, 包括 Bind.Write.Connect 等操作会简单的返回一个ChannelFuture. 调用者不能立刻获得结果, 而是通过Future-Liste ...

  4. Numpy中np.random.randn与np.random.rand的区别,及np.mgrid与np.ogrid的理解

    np.random.randn是基于标准正态分布产生的随机数,np.random.rand是基于均匀分布产生的随机数,其值在[0,1). np.mgrid 与np.ogrid的理解及区别:np.mgr ...

  5. maven的本地仓库

    今天新建的一个maven项目的依赖出了问题,想删除本地仓库的相关依赖文件夹,再重新加载,结果半天没找到文件夹位置. 我因为是改了maven的setting文件的,所以是直接到设置的文件夹里面找,结果半 ...

  6. 小程序中的web-view与h5网页之间的交互

    官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html web-view 基础库 1.6.4 开始支 ...

  7. 使用 Exchange 命令行管理程序查看动态通讯组的成员

    本示例返回名为 "全职员工" 的动态通讯组的成员列表. 第一个命令将动态通讯组对象存储在变量$FTE中. 第二个命令使用 Get-Recipient cmdlet 列出与为动态通讯 ...

  8. CentOs 后台运行jar

    1.启动jar包,后台运行 nohup java -jar xxxx.jar & 2.结束运行 查出正在运行的进程 ps -ef | grep java 杀掉进程 kill pid 上面橙色字 ...

  9. mysql怎么查看当前登录用户

    mysql> select user();+----------------+| user()         |+----------------+| root@localhost |+--- ...

  10. python itertools 用法

    1.介绍itertools 是python的迭代器模块,itertools提供的工具相当高效且节省内存.使用这些工具,你将能够创建自己定制的迭代器用于高效率的循环.- 无限迭代器 itertools包 ...