Example #1
0
      /** Compare two peaks using the stored criteria */
      inline bool operator()(const Peak& a, const Peak& b)
      {
        for (size_t i = 0; i < criteria.size(); i++)
        {
          std::string & col = criteria[i].first;
          bool ascending = criteria[i].second;
          bool lessThan = false;
          if (col == "BankName")
          {
            // If this criterion is equal, move on to the next one
            std::string valA = a.getBankName();
            std::string valB = b.getBankName();
            // Move on to lesser criterion if equal
            if (valA == valB)
              continue;
            lessThan = (valA < valB);
          }
          else
          {
            // General double comparison
            double valA = a.getValueByColName(col);
            double valB = b.getValueByColName(col);
            // Move on to lesser criterion if equal
            if (valA == valB)
              continue;
            lessThan = (valA < valB);
          }
          // Flip the sign of comparison if descending.
          if (ascending)
            return lessThan;
          else
            return !lessThan;

        }
        // If you reach here, all criteria were ==; so not <, so return false
        return false;
      }