Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Посмотрите на структуру StopsForBusResponse
- // ...
- struct StopsForBusResponse {
- // Константные указатели на контейнеры
- // Это нормальная практика или так делать не стоит?
- const string& bus;
- const vector<string>& b2s;
- const map<string, vector<string>>& s2b;
- };
- ostream& operator<<(ostream& os, const StopsForBusResponse& r) {
- // Выводим информацию в поток
- return os;
- }
- class BusManager {
- map<string, vector<string>> buses_to_stops_;
- map<string, vector<string>> stops_to_buses_;
- public:
- // ...
- StopsForBusResponse GetStopsForBus(const string& bus) const {
- // На это не смотрим:
- vector<string> a; // Заглушка
- map<string, vector<string>> b; // Заглушка
- if (buses_to_stops_.count(bus) == 0) {
- return { bus, a, b };
- }
- // Вот этот стейтмент:
- return { bus, buses_to_stops_.at(bus), stops_to_buses_ };
- }
- // ...
- };
Advertisement
Add Comment
Please, Sign In to add comment