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