53 std::list<AGBus>::iterator it1 =
buses.begin();
54 std::list<AGBus>::iterator it2 =
revBuses.begin();
56 std::list<std::pair<int, std::string> > drivingBuses1, drivingBuses2;
59 if (it1->getDeparture() > it2->getDeparture()) {
60 if (drivingBuses2.size() == 0) {
61 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
62 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
63 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
66 it2->setName(drivingBuses2.front().second);
67 drivingBuses2.pop_front();
69 drivingBuses1.push_back(make_pair(
getReady(it2->getDeparture()), it2->getName()));
72 if (drivingBuses1.size() == 0) {
73 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
74 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
75 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
78 it1->setName(drivingBuses1.front().second);
79 drivingBuses1.pop_front();
81 drivingBuses2.push_back(make_pair(
getReady(it1->getDeparture()), it1->getName()));
85 if (it1 !=
buses.end()) {
86 if (drivingBuses1.size() == 0) {
88 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
91 it1->setName(drivingBuses1.front().second);
92 drivingBuses1.pop_front();
97 if (drivingBuses2.size() == 0) {
99 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
102 it2->setName(drivingBuses2.front().second);
103 drivingBuses2.pop_front();
112 std::ostringstream os;
127 return static_cast<int>(
buses.size());
153 std::list<AGBus>::iterator it;
154 std::cout <<
"\n ----------- BUS LINE " <<
lineNumber <<
" PRINTING -------------\n" << std::endl;
155 std::cout <<
"\n -------------------------- First way ---------------------------\n" << std::endl;
156 for (it =
buses.begin(); it !=
buses.end(); ++it) {
159 std::cout <<
"\n -------------------------- Second way --------------------------\n" << std::endl;
163 std::cout <<
"\n ----------------------------------------------------------------\n" << std::endl;
void locateRevStation(AGPosition pos)
void locateStation(AGPosition pos)
std::list< AGPosition > stations
void generateBuses(int start, int stop, int rate)
std::list< AGBus > revBuses
std::list< AGPosition > revStations
void setMaxTripTime(int time)
A location in the 2D plane freely positioned on a street.
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes
void addMinutes(int min)
addition of minutes to the current moment
void addSeconds(int sec)
addition of seconds to the current moment