-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
40 lines (34 loc) · 794 Bytes
/
utils.h
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
#pragma once
#include <vector>
#include <iostream>
template <typename T>
bool vector_contains(const std::vector<T> &tvec, const T &target) {
for (T t : tvec) {
if (t == target) {
return true;
}
}
return false;
}
template <typename T>
void println_vector(const std::vector<T> &tvec, std::string sep) {
for (T t : tvec) {
std::cout << t << sep;
}
std::cout << std::endl;
}
template <typename T>
T max(T t1, T t2) {
return (t1 > t2) ? t1 : t2;
}
template <typename T>
T min(T t1, T t2) {
return (t1 > t2) ? t2 : t1;
}
std::vector<std::string> parse_clargs(int argc, char **argv) {
std::vector<std::string> ret;
for (int i = 0; i < argc; ++i) {
ret.emplace_back(std::string(argv[i]));
}
return ret;
}