-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
32 lines (29 loc) · 989 Bytes
/
util.cpp
File metadata and controls
32 lines (29 loc) · 989 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
#include<vector>
#include <iostream>
#include <iomanip>
#include <type_traits>
#include <limits>
namespace util {
template <typename T>
bool is_in_vector(const T& location, const std::vector<T>& to_check) {
if (std::find(to_check.begin(), to_check.end(), location)
!= to_check.end()) {
return true;
}
return false;
}
template <typename T>
void print(const std::vector<std::vector<T>>& matrix) {
std::cout << std::setprecision(3) << std::fixed;
for (int j=0; j < matrix[0].size(); j++) {
for (int i=0; i < matrix.size(); i++) {
if (matrix[i][j] == std::numeric_limits<T>::lowest()) {
std::cout << "✗ ";
continue;
}
std::cout << matrix[i][j] << " ";
}
std::cout << "\n";
}
}
}