size_t printAllEqual(const vector<StudentAttempt>& v, const StudentAttempt& sa, stringstream& ss ) {
vector<StudentAttempt>::const_iterator i = v.begin();
size_t sz = 0;
bool bFirst = true;
while (i != v.end()) {
if(isDistEqual(*i,sa)) {
if (!bFirst) ss << ',';
ss << i->studentName;
++sz;
// we can stop here when encountering distances
// larger than the one we're since the vector is
// sorted in ascending order (if not, this would cause errors)
// Higher distances will never equal ours
if (i->distance > sa.distance) break;
}
++i;
bFirst = false;
}
return sz;
}
|