]> git.mxchange.org Git - flightgear.git/commitdiff
Allow sequential access to airports.
authordavid <david>
Thu, 27 Nov 2003 23:37:03 +0000 (23:37 +0000)
committerdavid <david>
Thu, 27 Nov 2003 23:37:03 +0000 (23:37 +0000)
src/Airports/simple.cxx
src/Airports/simple.hxx

index cbfcea2a95f747bc6797f2eb3e62a6c2fc8919d1..ab3b47baf97de74471856feaf2eb147b50c9ddba 100644 (file)
@@ -73,7 +73,9 @@ FGAirportList::FGAirportList( const string& file ) {
     while ( in ) {
         in >> a;
         airports[a.id] = a;
+        airports2.push_back(&airports[a.id]);
     }
+
 }
 
 
@@ -86,3 +88,15 @@ FGAirport FGAirportList::search( const string& id) {
 // Destructor
 FGAirportList::~FGAirportList( void ) {
 }
+
+int
+FGAirportList::size () const
+{
+    return airports2.size();
+}
+
+const FGAirport *
+FGAirportList::getAirport (int index) const
+{
+    return airports2[index];
+}
index 3919b23c57b9e03de7f5cfbeff35eef227788558..881f3b3651633f48a344b7ac858746f2432bf429 100644 (file)
 
 #include STL_STRING
 #include <map>
+#include <vector>
 
 SG_USING_STD(string);
 SG_USING_STD(map);
+SG_USING_STD(vector);
 
 
 struct FGAirport {
@@ -60,12 +62,15 @@ typedef map < string, FGAirport > airport_map;
 typedef airport_map::iterator airport_map_iterator;
 typedef airport_map::const_iterator const_airport_map_iterator;
 
+typedef vector < FGAirport * > airport_list;
+
 
 class FGAirportList {
 
 private:
 
     airport_map airports;
+    airport_list airports2;
 
 public:
 
@@ -80,6 +85,18 @@ public:
     // On success, airport data is returned thru "airport" pointer.
     // "airport" is not changed if "apt" is not found.
     FGAirport search( const string& id );
+
+    /**
+     * Return the number of airports in the list.
+     */
+    int size () const;
+
+
+    /**
+     * Return a specific airport, by position.
+     */
+    const FGAirport * getAirport (int index) const;
+
 };