Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "database.h"
- using namespace std;
- void Database::Add(const Date& _Date, const string& _Event)
- {
- const auto it = Records[_Date].first.insert(_Event);
- if (it.second)
- {
- Records[_Date].second.push_back(it.first);
- }
- }
- void Database::Print(ostream& os) const
- {
- for (const auto& [_Key, _Value] : Records)
- {
- for (const auto& _Event : _Value.second)
- os << _Key << ' ' << *_Event << "\n";
- }
- }
- string Database::Last(const Date& _Date) const
- {
- const auto upperIt = Records.upper_bound(_Date);
- if (upperIt == Records.begin())
- {
- return "No entries";
- }
- return prev(upperIt)->first.DateToStr() + ' ' + *prev(upperIt)->second.second.back();
- }
Advertisement
Add Comment
Please, Sign In to add comment