Skip to content

Commit 7ca2951

Browse files
authored
Make sure the matches file does not output matches to the same user (#7)
Make sure the matches file does not output matches to the same user
1 parent 0034850 commit 7ca2951

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compare_hashes/compare_hashes.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ bool ranking_sorter(const std::pair<Submission,float> &a, const std::pair<Submis
6868

6969
// ===================================================================================
7070
// ===================================================================================
71-
void insert_others(std::map<Submission,std::set<int> > &others,
71+
void insert_others(const std::string &this_username,
72+
std::map<Submission,std::set<int> > &others,
7273
const std::map<Submission,std::vector<Sequence> > &matches) {
7374
for (std::map<Submission,std::vector<Sequence> >::const_iterator itr = matches.begin(); itr!=matches.end();itr++) {
74-
//std::set<int> foo;
7575
for (int i = 0; i < itr->second.size(); i++) {
76+
// don't include matches to this username
77+
if (this_username == itr->first.username)
78+
continue;
7679
others[itr->first].insert(itr->second[i].position);
7780
}
78-
//.insert(std::make_pair(itr->first,foo));
7981
}
8082
}
8183

@@ -259,10 +261,10 @@ int main(int argc, char* argv[]) {
259261
int pos = (itr2 == itr->second.end()) ? -1 : itr2->first;
260262
if (pos != -1 && range_start==-1) {
261263
range_start = range_end = pos;
262-
insert_others(others,itr2->second);
264+
insert_others(username,others,itr2->second);
263265
} else if (pos != -1 && range_end+1 == pos) {
264266
range_end = pos;
265-
insert_others(others,itr2->second);
267+
insert_others(username,others,itr2->second);
266268
} else if (range_start != -1) {
267269
std::map<std::string,nlohmann::json> info_data;
268270
info_data["start"]=nlohmann::json(range_start);

0 commit comments

Comments
 (0)