]> git.mxchange.org Git - flightgear.git/blob - src/Scenery/test.cxx
Fix native protocol crashes.
[flightgear.git] / src / Scenery / test.cxx
1 // some simple STL tests
2
3 #include <deque>
4 #include <map>
5 #include <iostream>
6 #include <string>
7
8 using std::deque;
9 using std::map;
10 using std::string;
11 using std::less;
12 using std::cout;
13
14 main() {
15     deque < int > mylist;
16     map < string, int, less<string> > mymap;
17     string name;
18     int i, j, size, num, age;
19
20     // printf("max_size = %d\n", mylist.max_size());
21
22     for ( i = 0; i < 2000; i++ ) {
23         mylist.push_back(i);
24     }
25
26     size = mylist.size();
27
28     deque < int > :: iterator current = mylist.begin();
29     deque < int > :: iterator last    = mylist.end();
30     
31     /*
32     for ( i = 0; i < 10000000; i++ ) {
33         while ( current != last ) {
34             num = *current++;
35         }
36     }
37     */
38      
39     /*
40     for ( i = 0; i < 1000; i++ ) {
41         for ( j = 0; j < size; j++ ) {
42             num = mylist[j];
43         }
44     }
45     */
46
47     mymap["curt"] = 30;
48     mymap["doug"] = 12;
49     mymap["doug"] = 28;
50     mymap["dan"] = 24;
51
52     printf("curt age = %d\n", mymap["curt"]);
53     printf("dan age = %d\n", mymap["dan"]);
54
55
56     map < string, int, less<string> > :: iterator test = mymap.find("doug");
57     if ( test == mymap.end() ) {
58         printf("doug age = not found\n");
59     } else {
60         printf("doug age = %d\n",  (*test).second);
61         mymap.erase( "doug" );
62     }
63
64     printf("\n");
65     map < string, int, less<string> > :: iterator mapcurrent = mymap.begin();
66     map < string, int, less<string> > :: iterator maplast = mymap.end();
67     while ( mapcurrent != maplast ) {
68         name = (*mapcurrent).first;
69         age = (*mapcurrent).second;
70         cout << name;
71         printf(" = %d\n", age);
72         *mapcurrent++;
73     }
74 }