The park queue, as explained above, contains vehicles whose starting time is in the future. Here is a mechanism for the park queue.
{}
class Link {
...
private:
typedef multimap<Time,Veh*> ParkQueue ;
ParkQueue parkQueue_ ;
public:
void addToPark( Veh* veh ) {
parkQueue_.insert( make_pair( veh->startTime(), veh ) ) ; // see txt
}
Veh* firstInPark() {
if ( parkQueue_.size()>=1 ) {
return parkQueue_.begin()->second ;
} else {
return NULL ;
}
}
void rmFirstInPark() {
assert( parkQueue_.size() >= 1 ) ;
parkQueue_.erase( parkQueue_.begin() ) ;
}
...
};
Note that the implementation for ParkQueue is
{}
typedef multimap<Time,Veh*> ParkQueue ;
We have in fact already used a multimap for the implementation
of ``fair'' intersections (Sec. 7.5). An
additional function now is erase().
Overall, this implements a priority queue, where the element with the lowest key is always available via begin(). ``Lowest key'' here means the earliest starting time.