forked from Streptoco/EmbeddedProgrammingInLinux
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfull_schedule.cpp
More file actions
38 lines (34 loc) · 1.33 KB
/
full_schedule.cpp
File metadata and controls
38 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <algorithm>
#include "myLibrary.h"
#include "full_schedule.h"
void printFullSchedule(vector<Node*>& arr, string icao_name)
{
if(arr.empty()){
cout << "There is no info about airport " << icao_name << " in db." << endl;
}
else
{
cout << icao_name << ":" <<endl;
for (int i = 0; i < arr.size() - 1; i++)
{
if (arr[i]->getEstDepartureAirport() == icao_name)
cout << "FLight #" << arr[i]->getCallSign() << " departing to " << arr[i]->getEstArrivalAirport()
<< " from " << convertEpochToReadable(arr[i]->getFirstSeen()) << endl;
else
cout << "FLight #" << arr[i]->getCallSign() << " arriving from " << arr[i]->getEstDepartureAirport()
<< " at " << convertEpochToReadable(arr[i]->getFirstSeen()) << endl;
}
}
}
vector<Node*> full_schedule(string icao, vector<Node*>& arr)
{
vector<Node*> flightsData = get_flights_to_airport(icao, arr);
vector<Node*> departures = get_flights_from_airport(icao, arr);
flightsData.insert(flightsData.end(), departures.begin(), departures.end());
sort(flightsData.begin(), flightsData.end(), [](const Node* a, const Node* b) {
return a->getFirstSeen() < b->getFirstSeen();
});
return flightsData;
}