Use common map utility to get radar product record

This commit is contained in:
Dan Paulat 2022-05-23 22:32:22 -05:00
parent bde8d288bd
commit 23337b3b21
2 changed files with 14 additions and 43 deletions

View file

@ -8,10 +8,10 @@ namespace scwx
namespace util
{
template<class Key, class T>
std::optional<T> GetBoundedElement(std::map<Key, T>& map, Key key)
template<class Key, class T, class ReturnType = std::optional<T>>
ReturnType GetBoundedElement(std::map<Key, T>& map, Key key)
{
std::optional<T> element = std::nullopt;
ReturnType element;
// Find the first element greater than the key requested
auto it = map.upper_bound(key);
@ -37,5 +37,11 @@ std::optional<T> GetBoundedElement(std::map<Key, T>& map, Key key)
return element;
}
template<class Key, class T>
inline T GetBoundedElementValue(std::map<Key, T>& map, Key key)
{
return GetBoundedElement<Key, T, T>(map, key);
}
} // namespace util
} // namespace scwx