-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.h
More file actions
37 lines (31 loc) · 831 Bytes
/
database.h
File metadata and controls
37 lines (31 loc) · 831 Bytes
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
#pragma once
#include "date.h"
#include "node.h"
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>
#include <memory>
#include <set>
using namespace std;
class Database {
public:
void Add (const Date& date, const string& event);
void Print (ostream& os) const;
int RemoveIf (function<bool(const Date&, const string&)> predicate);
vector<pair<Date, string>> FindIf (
function<bool(const Date&, const string&)> predicate
) const;
pair<Date, string> Last (const Date& date) const;
private:
map<Date, vector<string>> events;
map<Date, set<string>> set_events;
};
template <class K, class V>
ostream& operator << (ostream& os, const pair<K, V>& p) {
os << p.first << " " << p.second;
return os;
}