-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
39 lines (35 loc) · 793 Bytes
/
util.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
#ifndef UTIL_H
#define UTIL_H
#include <string>
#include <iostream>
#include <set>
#include <string>
std::string convToLower(std::string src);
std::set<std::string> parseStringToWords(std::string line);
template <typename T>
std::set<T> setIntersection(std::set<T>& s1, std::set<T>& s2)
{
std::set<T> result;
for(typename std::set<T>::iterator it = s1.begin();
it != s1.end();
++it){
if(s2.find(*it) != s2.end()){
result.insert(*it);
}
}
return result;
}
template <typename T>
std::set<T> setUnion(std::set<T>& s1, std::set<T>& s2)
{
std::set<T> result = s2;
for(typename std::set<T>::iterator it = s1.begin();
it != s1.end();
++it){
if(result.find(*it) == result.end()){
result.insert(*it);
}
}
return result;
}
#endif