-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoc_utils.hpp
More file actions
58 lines (43 loc) · 1 KB
/
aoc_utils.hpp
File metadata and controls
58 lines (43 loc) · 1 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "default.hpp"
#pragma once
class InputReader {
public:
void readFile(const string &fileName);
vector<string> &getLines();
private:
vector<string> m_lines;
};
class StringTokenizer {
public:
StringTokenizer() = delete;
static vector<string> sGetTokens(string str, string delimiter);
};
template <typename ValueType>
class TreeNode {
public:
bool isLeaf() {
return m_children.empty();
}
vector<TreeNode *> &getChildren() {
return m_children;
}
TreeNode() = default;
TreeNode(ValueType val) : m_val(val){};
ValueType getVal() {
return m_val;
}
void addChild(TreeNode *pChild) {
m_children.push_back(pChild);
}
private:
ValueType m_val;
vector<TreeNode *> m_children;
};
struct PairHash {
template <class T1, class T2>
std::size_t operator()(const std::pair<T1, T2> &p) const {
auto h1 = std::hash<T1>{}(p.first);
auto h2 = std::hash<T2>{}(p.second);
return h1 ^ h2;
}
};