#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. centos下离线安装zip和unzip

    首先如果你的centos可以联网,那可以不用看了,直接yum install -y zip unzip就行,非常的痛快! 如果不能联网,像我一样,只能用vpn连上去,做了点限制.那就非常烦了,yum了 ...

  2. PHP中strlen和mb_strlen函数的使用方式的不同

    (1)strlen  获取字符串长度 (2)mb_strlen  使用方法:   int mb_strlen ( string $str [, string $encoding ] )返回给定的字符串 ...

  3. 003、Java的单行注释

    代码如下: package TIANPAN; public class TestDemo { public static void main(String args[]) { // JAVA的单行注释 ...

  4. Maven的原理和使用

    一.Maven能做什么 1.假设我们有10个项目,都需要引入spring core模块,那么需要十份重复的Spring Core.jar和commons-logging.jar 使用Maven:mav ...

  5. I0.0 上升边沿 清空 MW10~MW58 联系多个知识点融合

    编写程序 在I1.2 的上升边沿 触发 MW8+1的程序 实现方式1 M1.1 为中间变量 对应的STL语句表 执行结果 OK 已经仿真 . 现在尝试第2种方法 实现方式2: M1.1也是中间变量 S ...

  6. P1051复数乘法

    P1051复数乘法 转跳点:

  7. Spring入门之三-------SpringIoC之Scopes

    一.singleton和prototype public class Bean1 { public Bean1() { System.out.println(this.getClass().getSi ...

  8. Gerrit部署成功后project下不显示clone地址

    gerrit部署成功后使用admin账号登录,在project All-projects下不显示clone地址,新建仓库也不显示. 原因是:默认安装没有安装插件download-commands 安装 ...

  9. Python中的numpy函数的使用ones,zeros,eye

    在看别人写的代码时,看到的不知道的函数,就在这里记下来. 原文是这样用的: weights = ones((numfeatures,1)) 在python中help(): import numpy a ...

  10. Hadoop完全高可用集群安装

    架构图(HA模型没有SNN节点) 用vm规划了8台机器,用到了7台,SNN节点没用   NN DN SN ZKFC ZK JNN RM NM node1 *     *         node2 * ...