#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. Windows使用Nexus搭建Maven私服

    简介 Maven私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件,有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓库,否则,私服请求外部的 ...

  2. Day6 - F - KiKi's K-Number HDU - 2852

    For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. No ...

  3. 使用线程池测试cpu的并发计算能力

    接到一个需求是测试一下cpu并发计算能力,针对int和float求和单位时间能执行几次的问题.可能是服务器选型用到的参数. 开始使用的是fork-join,但是发现fork-join每次得到的结果值波 ...

  4. 《新标准C++程序设计》4.5(C++学习笔记15)

    实例:长度可变的整型数组类 int main() { //要编写可变长整型数组类,使之能如下使用: CArray a; //开始里的数组是空的 ; i < ; ++i) a.push_back( ...

  5. B. Sport Mafia 二分

    B. Sport Mafia time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  6. Vue - slot-scope="scope" 的意义

      <template slot-scope="scope">                     <el-button type="primary ...

  7. Struts+Hibernate+Spring面试题合集及答案(转)

    Struts+Hibernate+Spring面试题合集及答案 Struts+Hibernate+Spring 面试题合集 1 1. Hibernate部分 2 1.1. Hibernate工作原理 ...

  8. Day4-T3

    原题目 吉儿是一家古董店的老板娘,由于她经营有道,小店开得红红火火.昨天,吉儿无意之中得到了散 落民间几百年的珍宝——月亮之眼.吉儿深知“月亮之眼”价值连城:它是由许多珍珠相连而成的,工 匠们用金线连 ...

  9. 【STM32H7教程】第52章 STM32H7的LTDC应用之点阵字体和字符编码(重要)

    完整教程下载地址:http://www.armbbs.cn/forum.php?mod=viewthread&tid=86980 第52章       STM32H7的LTDC应用之点阵字体和 ...

  10. 【CS224n-2019学习笔记】Lecture 1: Introduction and Word Vectors

    附上斯坦福cs224n-2019链接:https://web.stanford.edu/class/archive/cs/cs224n/cs224n.1194/ 文章目录 1.课程简单介绍 1.1 本 ...