-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
51 lines (40 loc) · 1.22 KB
/
utils.h
File metadata and controls
51 lines (40 loc) · 1.22 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
#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <string_view>
#include <vector>
#include <chrono>
#include <unordered_set>
#include <sstream>
std::vector<std::string> Split(std::string_view sv, const std::string& delimiter=" ");
template<typename T>
std::unordered_set<T> UnorderedSetIntersection(const std::unordered_set<T>& lhs,
const std::unordered_set<T>& rhs) {
if (rhs.size() < lhs.size()) {
return UnorderedSetIntersection(rhs, lhs);
}
std::unordered_set<T> result;
result.reserve(lhs.size());
for (const T& el : lhs) {
if (rhs.count(el)) {
result.insert(el);
}
}
return result;
}
std::string ReadEverythingFromFile(const std::string& filename);
template<typename InputIterator>
void PrintSequenceWithDelimiter(std::ostream& output, InputIterator begin,
InputIterator end, const std::string& delimiter=" ") {
bool first = true;
for (InputIterator it = begin; it != end; ++it) {
if (!first) {
output << delimiter;
} else {
first = false;
}
output << *it;
}
}
std::string MakeLower(std::string);