From e3737de2d6b0dd73cf48722ed085e9e3669165e2 Mon Sep 17 00:00:00 2001
From: david <david>
Date: Thu, 27 Nov 2003 23:37:03 +0000
Subject: [PATCH] Allow sequential access to airports.

---
 src/Airports/simple.cxx | 14 ++++++++++++++
 src/Airports/simple.hxx | 17 +++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx
index cbfcea2a9..ab3b47baf 100644
--- a/src/Airports/simple.cxx
+++ b/src/Airports/simple.cxx
@@ -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];
+}
diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx
index 3919b23c5..881f3b365 100644
--- a/src/Airports/simple.hxx
+++ b/src/Airports/simple.hxx
@@ -40,9 +40,11 @@
 
 #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;
+
 };