Avoid using transform_reduce

Not available in libstdc++ 7, apparently
This commit is contained in:
ISSOtm
2022-03-10 00:51:53 +01:00
committed by Eldred Habert
parent b9de65c9a2
commit 2099a25ee0

View File

@@ -208,20 +208,19 @@ public:
* Computes the "relative size" of a proto-palette on this palette * Computes the "relative size" of a proto-palette on this palette
*/ */
double relSizeOf(ProtoPalette const &protoPal) const { double relSizeOf(ProtoPalette const &protoPal) const {
// NOTE: this function must not call `uniqueColors`, or one of its callers will break // NOTE: this function must not call `uniqueColors`, or one of its callers will break!
return std::transform_reduce( double relSize = 0.;
protoPal.begin(), protoPal.end(), 0.0, std::plus<>(), [this](uint16_t color) { for (uint16_t color : protoPal) {
// NOTE: The paper and the associated code disagree on this: the code has // NOTE: The paper and the associated code disagree on this: the code has
// this `1 +`, whereas the paper does not; its lack causes a division by 0 // this `1 +`, whereas the paper does not; its lack causes a division by 0
// if the symbol is not found anywhere, so I'm assuming the paper is wrong. // if the symbol is not found anywhere, so I'm assuming the paper is wrong.
return 1. relSize +=
/ (1 1. / (1 + std::count_if(begin(), end(), [this, &color](ProtoPalAttrs const &attrs) {
+ std::count_if( ProtoPalette const &pal = (*_protoPals)[attrs.palIndex];
begin(), end(), [this, &color](ProtoPalAttrs const &attrs) { return std::find(pal.begin(), pal.end(), color) != pal.end();
ProtoPalette const &pal = (*_protoPals)[attrs.palIndex]; }));
return std::find(pal.begin(), pal.end(), color) != pal.end(); }
})); return relSize;
});
} }
/** /**