Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
Fix fingerprinting on some files
Browse files Browse the repository at this point in the history
Running `std::max_element` on a `std::map` doesn't select the highest `second` value, so manually implement a comparison function
See https://en.cppreference.com/w/cpp/utility/pair/operator_cmp for more information
  • Loading branch information
Xerbo committed Sep 9, 2021
1 parent 509b641 commit 3c465a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fingerprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class CCSDSFingerprint {
}
}

auto pair = std::max_element(sats.begin(), sats.end());
auto pair = std::max_element(sats.begin(), sats.end(), [](const std::pair<SatID, size_t>& p1, const std::pair<SatID, size_t>& p2) {
return p1.second < p2.second;
});
if (pair->second > 100 && sats.size() != 0) {
return pair->first;
}
Expand Down Expand Up @@ -143,7 +145,9 @@ SatID Fingerprint::id_noaa(std::istream &stream) {
default: break;
}

auto pair = std::max_element(sats.begin(), sats.end());
auto pair = std::max_element(sats.begin(), sats.end(), [](const std::pair<SatID, size_t>& p1, const std::pair<SatID, size_t>& p2) {
return p1.second < p2.second;
});
if (pair->second > 100) {
return pair->first;
}
Expand Down

0 comments on commit 3c465a2

Please sign in to comment.