#ifndef TOP_H #define TOP_H #include <limits> template <typename T> struct topresult { double s1, s2; T i1, i2; topresult() {s1 = s2 = std::numeric_limits<double>::infinity();} void test(double s, const T & i) { if (s < s1) { s2 = s1; i2 = i1; s1 = s; i1 = i; } else if (s < s2 && i1 != i) { // additional test because we may have several tests with the same feature s2 = s; i2 = i; } } }; #endif