This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
ESGRAF48/source/ResultWidget/PRMap.cpp

42 lines
572 B
C++
Raw Normal View History

2018-06-14 17:19:53 +00:00
#include "PRMap.h"
unsigned int PRMap::lookup(const Age &age, const unsigned int &points)
{
if (points >= m_PRs.size())
{
return 0;
}
auto ageIndex = [&]() -> size_t {
if (m_ages.empty())
{
return 0;
}
if (age < m_ages.front())
{
return 0;
}
if (m_ages.back() < age)
{
return m_ages.size() - 1;
}
for (size_t index = 1; index < m_ages.size(); ++index)
{
if (age < m_ages.at(index))
{
return index - 1;
}
}
}();
if (ageIndex >= m_PRs.at(points).size())
{
return 0;
}
return m_PRs.at(points).at(ageIndex);
}