Skip to content

Commit

Permalink
add std::hash<DataTamer::RegistrationID>
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Feb 1, 2024
1 parent 9f0fee3 commit f2cbed0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions data_tamer_cpp/include/data_tamer/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,18 @@ std::string ToStr(const Schema& schema);
[[nodiscard]] uint64_t AddFieldToHash(const TypeField& field, uint64_t hash);

} // namespace DataTamer


template <>
struct std::hash<DataTamer::RegistrationID>
{
std::size_t operator()( const DataTamer::RegistrationID& id ) const
{
// Compute individual hash values for first, second and third
// http://stackoverflow.com/a/1646913/126995
std::size_t res = 17;
res = res * 31 + hash<size_t>()( id.first_index );
res = res * 31 + hash<size_t>()( id.fields_count );
return res;
}
};

0 comments on commit f2cbed0

Please sign in to comment.