mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Use common map utility to get radar product record
This commit is contained in:
parent
bde8d288bd
commit
23337b3b21
2 changed files with 14 additions and 43 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue