-
Notifications
You must be signed in to change notification settings - Fork 0
/
vectorHelper.cpp
64 lines (48 loc) · 1.36 KB
/
vectorHelper.cpp
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
59
60
//
// Created by willk on 5/1/2022.
//
#include "vectorHelper.h"
vector<string> vectorHelper::combineAnd(vector<string> *a, vector<string> *b) {
vector<string> returnVector;
for(string tmpA : *a) {
for(string tmpB : *b) {
if(tmpA == tmpB) {
returnVector.push_back(tmpA);
}
}
}
return returnVector;
}
void vectorHelper::pruneVector(vector<string> *a) {
for(int i = 0; i < a->size(); i++) {
for(int j = i+1; j < a->size(); j++) {
if(a->at(i) == a->at(j)) {
a->erase(a->begin()+j);
j--;
}
}
}
}
vector<string> vectorHelper::combineOr(vector<string> *a, vector<string> *b) {
vector<string> returnString;
for(string tmpA : *a) {
returnString.push_back(tmpA);
}
for(string tmpB : *b) {
returnString.push_back(tmpB);
}
pruneVector(&returnString);
return returnString;
}
vector<string> vectorHelper::combineNot(vector<string> *a, vector<string> *remove) {
vector<string> returnVector = *a;
for(int i = 0; i < remove->size(); i++) {
for(int j = 0; j < returnVector.size(); j++) {
if(returnVector.at(j) == remove->at(i)) {
returnVector.erase(returnVector.begin()+j);
j--;
}
}
}
return returnVector;
}