1
0
Fork 0

Allow sequential access to airports.

This commit is contained in:
david 2003-11-27 23:37:03 +00:00
parent 2be85c1b1b
commit e3737de2d6
2 changed files with 31 additions and 0 deletions

View 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];
}

View file

@ -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;
};