-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtempCodeRunnerFile.cpp
120 lines (110 loc) · 3.97 KB
/
tempCodeRunnerFile.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
int length_of_movies = movies.size();
//applying filters to movies
for (int i = length_of_movies-1; i >= 0; i--) {
//Year constraints
if (year_upper_bound!=-1 && year_lower_bound != -1) {
cout << "year filter applicatoin reached" << endl;
if (movies[i].startYear > year_upper_bound || movies[i].startYear < year_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
cout << "decrement reached" << endl;
}
}
else if(year_upper_bound != -1) {
if (movies[i].startYear > year_upper_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if (year_lower_bound != -1) {
if (movies[i].startYear < year_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
//genre constraints
if (!genres.empty()) {
if (genres.count(movies[i].genre1)==0 && genres.count(movies[i].genre2)==0 && genres.count(movies[i].genre3)==0) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
//title_types constraints
if (!title_types.empty()) {
if (title_types.count(movies[i].titleType)==0) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
//runtime constraints
if (runtime_upper_bound!=-1 and runtime_lower_bound != -1) {
if (movies[i].runtimeMinutes > runtime_upper_bound || movies[i].runtimeMinutes < runtime_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if(runtime_upper_bound != -1) {
if (movies[i].runtimeMinutes > runtime_upper_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if (runtime_lower_bound != -1) {
if (movies[i].runtimeMinutes < runtime_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
//votes constraints
if (votes_upper_bound!=-1 && votes_lower_bound != -1) {
if (movies[i].numVotes > votes_upper_bound || movies[i].numVotes < votes_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if(votes_upper_bound != -1) {
if (movies[i].numVotes > votes_upper_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if (votes_lower_bound != -1) {
if (movies[i].numVotes < votes_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
//rating constraints
if (rating_upper_bound!=-1 && rating_lower_bound != -1) {
if (movies[i].averageRating > rating_upper_bound || movies[i].averageRating < rating_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if(rating_upper_bound != -1) {
if (movies[i].averageRating > rating_upper_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
else if (rating_lower_bound != -1) {
if (movies[i].averageRating < rating_lower_bound) {
movies.erase(movies.begin() + i);
i--;
continue;
}
}
}