-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_map2.cpp
63 lines (49 loc) · 1.13 KB
/
std_map2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* =====================================================================================
*
* Filename: Map.cpp
*
* Description:
*
* Version: 1.0
* Created: 2018-01-05 08:50:47
* Last Modified: 2018-01-05 08:50:56
* Revision: none
* Compiler: gcc
*
* Author: zt (),
* Organization:
*
* =====================================================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <iostream>
#include <map>
#include <vector>
typedef std::map<int, time_t> map_fd_time_t;
int main ( int argc, char* argv[] )
{
( void ) argc;
( void ) argv;
map_fd_time_t mymap;
time_t a;
time ( &a );
mymap.insert ( map_fd_time_t::value_type ( 1, a ) );
sleep ( 1 );
time ( &a );
mymap.insert ( map_fd_time_t::value_type ( 2, a ) );
sleep ( 1 );
time ( &a );
mymap.insert ( map_fd_time_t::value_type ( 3, a ) );
sleep ( 1 );
auto iter = mymap.find ( 2 );
iter->second = 12345;
for ( auto& e : mymap )
{
std::cout << e.first << " " << e.second << std::endl;
}
return 0;
}