diff --git a/wxdata/include/scwx/util/map.hpp b/wxdata/include/scwx/util/map.hpp index 3392b5d7..b6282807 100644 --- a/wxdata/include/scwx/util/map.hpp +++ b/wxdata/include/scwx/util/map.hpp @@ -8,19 +8,20 @@ namespace scwx namespace util { -template::const_pointer> -ReturnType GetBoundedElementPointer(std::map& map, const Key& key) +template +ReturnType GetBoundedElementPointer(Container& container, + const typename Container::key_type& key) { ReturnType elementPtr {nullptr}; // Find the first element greater than the key requested - auto it = map.upper_bound(key); + auto it = container.upper_bound(key); // An element with a key greater was found - if (it != map.cend()) + if (it != container.cend()) { // Are there elements prior to this element? - if (it != map.cbegin()) + if (it != container.cbegin()) { // Get the element immediately preceding, this the element we are // looking for @@ -32,11 +33,11 @@ ReturnType GetBoundedElementPointer(std::map& map, const Key& key) elementPtr = &(*it); } } - else if (map.size() > 0) + else if (container.size() > 0) { // An element with a key greater was not found. If it exists, it must be // the last element. - elementPtr = &(*map.rbegin()); + elementPtr = &(*container.rbegin()); } return elementPtr; @@ -48,8 +49,8 @@ ReturnType GetBoundedElement(std::map& map, const Key& key) ReturnType element; typename std::map::pointer elementPtr = - GetBoundedElementPointer::pointer>(map, - key); + GetBoundedElementPointer, + typename std::map::pointer>(map, key); if (elementPtr != nullptr) { element = elementPtr->second;