上代码:

// test2013.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std; struct CmpByKeyNumber {
bool operator()(const int& k1, const int& k2) {
return k1 < k2; //升序排列
}
}; int _tmain(int argc, _TCHAR* argv[])
{
std::map<int, string, CmpByKeyNumber> arr; arr.insert(make_pair(, "dd"));
arr.insert(make_pair(, "bbbbb"));
arr.insert(make_pair(, "aaaaaaaaaaa")); std::map<int, string>::iterator itTemp = arr.find();
if (itTemp == arr.end())
{
return -;
} /*
这里转为反向迭代器。
注意,正向迭代器转为反向迭代器后,反向迭代器指向的是正向迭代器的前一个元素。
所以,这里用了++:先++,itTemp指向下一个元素(即是arr.end() ),
通过这样的方式,反向迭代器和正向迭代器指向的都是同一个pair。
*/
std::map<int, string>::reverse_iterator it(++itTemp);
for (; it != arr.rend(); it++)
{
int key = it->first;
string dd = it->second;
printf("pair( %d, %s )\n", key, dd.c_str());
} printf("\ndone\n");
getchar();
return ;
}

运行效果:

完。

std的find和reverse_iterator联合使用的更多相关文章

  1. 【转】cocos2d-x 2.0版本 自适应屏幕分辨率

    http://codingnow.cn/cocos2d-x/975.html 我使用的版本是cocos2d-2.0-x-2.0.4,cocos2dx-2.0版本对多分辨率适配提供了很好的支持,使用起来 ...

  2. 矩阵的特征值和特征向量的雅克比算法C/C++实现

    矩阵的特征值和特征向量是线性代数以及矩阵论中很重要的一个概念.在遥感领域也是经经常使用到.比方多光谱以及高光谱图像的主成分分析要求解波段间协方差矩阵或者相关系数矩阵的特征值和特征向量. 依据普通线性代 ...

  3. P5108 仰望半月的夜空 SAM+线段树覆盖

    $ \color{#0066ff}{ 题目描述 }$ 半月的夜空中,寄托了多少人与人之间的思念啊 曦月知道,这些思念会汇集成一个字符串\(S(n = |S|)\) 由于思念汇集的过于复杂,因此曦月希望 ...

  4. EOS 智能合约 plublic key 转换

      在做一个EOS 的action接口时,定义如下: void setbplist(const account_name bp_name, const uint64_t bp_time, const ...

  5. c++interview

    出自:https://github.com/huihut/interview Github    |    Docsify 简体中文    |    English 关于 本仓库是面向 C/C++ 技 ...

  6. 【NX二次开发】NX内部函数,libuifw.dll文件中的内部函数

    本文分为两部分:"带参数的函数"和 "带修饰的函数". 浏览这篇博客前请先阅读: [NX二次开发]NX内部函数,查找内部函数的方法 带参数的函数: void U ...

  7. std::reverse_iterator::base

    google chromium base MRU_Cache 支持反向erase iterator Erase(iterator pos) {  deletor_(pos->second);  ...

  8. C++ std::set

    std::set template < class T, // set::key_type/value_type class Compare = less<T>, // set::k ...

  9. C++ std::map

    std::map template < class Key, // map::key_type class T, // map::mapped_type class Compare = less ...

随机推荐

  1. Step by Step

    数据库设计Step by Step篇目整理及下载地址 系列篇目 1. 数据库设计 Step by Step (1)——扬帆启航 2. 数据库设计 Step by Step (2)——数据库生命周期 3 ...

  2. Hadoop学习笔记: HDFS

    注:该文内容部分来源于ChinaHadoop.cn上的hadoop视频教程. 一. HDFS概述 HDFS即Hadoop Distributed File System, 源于Google发表于200 ...

  3. How do you evaluate music?

    I’ve seen several “can’t stand” or “best of” threads in regard to music, and based on some related d ...

  4. Python:使用pymssql批量插入csv文件到数据库测试

    并行进程怎么使用? import os import sys import time def processFunc(i): time.sleep(10-i) print i if __name__= ...

  5. nyist 593 Take it easy

    http://acm.nyist.net/JudgeOnline/problem.php?pid=593 Take it easy 时间限制:1000 ms  |  内存限制:65535 KB 难度: ...

  6. SharedPreferences 轻型的数据存储方式

    //初始化,(名字,隐私或公开) SharedPreferences openTimes=getSharedPreferences("openTimes",0); //提交保存数据 ...

  7. 异常:Struts:org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find BasicDataSource

    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.common ...

  8. paper 40 :鲁棒性robust

    最近只想安心.安静的科研,不想被任何人打扰,继续做自己,不忘初心,方得始终! 首先了解下鲁棒性这个词的定义.鲁棒性是指控制系统在一定(结构,大小)的参数摄动下,维持某些性能的特性.根据对性能的不同定义 ...

  9. jq 选择器

    基本选择器 1. id选择器(指定id元素)将id="one"的元素背景色设置为黑色.(id选择器返单个元素) $(document).ready(function () {    ...

  10. 夺命雷公狗—angularjs—12—get参数的接收

    我们在实际的开发中get和post的交互都是离不开的,我们先来研究下get参数是如何接收到的.. 而且在实际开发中利用json来进行传递参数也是比较多的,这里我们就以get来接收参数为列.. 先创建一 ...