1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// reverse_iterator::operator-> example
#include <iostream>
#include <iterator>
#include <map>
#include <string>
using namespace std;
int main () {
map<int,string> numbers;
numbers.insert (make_pair(1,"one"));
numbers.insert (make_pair(2,"two"));
numbers.insert (make_pair(3,"three"));
typedef map<int,string>::iterator map_iter;
reverse_iterator<map_iter> rev_end (numbers.begin());
reverse_iterator<map_iter> rev_iterator (numbers.end());
for ( ; rev_iterator != rev_end ; ++rev_iterator)
cout << rev_iterator->first << " " << rev_iterator->second << "\n";
return 0;
}
|