Hash utility

This commit is contained in:
Dan Paulat 2022-10-02 23:12:41 -05:00
parent 8d2fcf3802
commit 32e8ca72a0
3 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#pragma once
#include <string>
#include <utility>
namespace scwx
{
namespace util
{
template<class Key>
struct hash;
template<>
struct hash<std::pair<std::string, std::string>>
{
size_t operator()(const std::pair<std::string, std::string>& x) const;
};
} // namespace util
} // namespace scwx

View file

@ -0,0 +1,20 @@
#include <scwx/util/hash.hpp>
#include <boost/container_hash/hash.hpp>
namespace scwx
{
namespace util
{
size_t hash<std::pair<std::string, std::string>>::operator()(
const std::pair<std::string, std::string>& x) const
{
size_t seed = 0;
boost::hash_combine(seed, x.first);
boost::hash_combine(seed, x.second);
return seed;
}
} // namespace util
} // namespace scwx

View file

@ -46,6 +46,7 @@ set(SRC_PROVIDER source/scwx/provider/aws_level2_data_provider.cpp
source/scwx/provider/nexrad_data_provider_factory.cpp)
set(HDR_UTIL include/scwx/util/environment.hpp
include/scwx/util/float.hpp
include/scwx/util/hash.hpp
include/scwx/util/iterator.hpp
include/scwx/util/logger.hpp
include/scwx/util/map.hpp
@ -56,6 +57,7 @@ set(HDR_UTIL include/scwx/util/environment.hpp
include/scwx/util/vectorbuf.hpp)
set(SRC_UTIL source/scwx/util/environment.cpp
source/scwx/util/float.cpp
source/scwx/util/hash.cpp
source/scwx/util/logger.cpp
source/scwx/util/rangebuf.cpp
source/scwx/util/streams.cpp