Skip to content

Commit

Permalink
documentation hash
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Dec 23, 2024
1 parent ca7e3c9 commit 7bb69bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/loki/details/utils/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ inline void hash_combine(size_t& seed, const Rest&... rest);
template<typename... Ts>
inline size_t hash_combine(const Ts&... rest);

/// @brief `UniquePDDLEqualTo` is used to compare newly created PDDL objects for uniqueness.
/// Since the children are unique, it suffices to create a combined hash from nested pointers.
/// @brief `Hash` is our custom hasher, like std::hash.
///
/// Forwards to std::hash by default.
/// Specializations can be injected into the namespace.
template<typename T>
struct Hash
{
size_t operator()(const T& element) const { return std::hash<T>()(element); }
};

/// @brief Hash specialization for std::set.
///
/// Combines the hashes of all elements in the set.
/// @tparam T
template<typename T>
struct Hash<std::set<T>>
Expand All @@ -69,6 +73,8 @@ struct Hash<std::set<T>>
};

/// @brief Hash specialization for std::vector.
///
/// Combines the hashes of all elements in the vector.
/// @tparam T
template<typename T>
struct Hash<std::vector<T>>
Expand All @@ -88,6 +94,8 @@ struct Hash<std::vector<T>>
};

/// @brief Hash specialization for a pair.
///
/// Combines the hashes for first and second.
/// @tparam T1
/// @tparam T2
template<typename T1, typename T2>
Expand All @@ -97,6 +105,8 @@ struct Hash<std::pair<T1, T2>>
};

/// @brief Hash specialization for a tuple.
///
/// Combines the hashes of all elements in the tuple.
/// @tparam ...Ts
template<typename... Ts>
struct Hash<std::tuple<Ts...>>
Expand All @@ -110,6 +120,8 @@ struct Hash<std::tuple<Ts...>>
};

/// @brief Hash specialization for a variant.
///
/// Hashes the underlying object.
/// @tparam ...Ts
template<typename... Ts>
struct Hash<std::variant<Ts...>>
Expand Down

0 comments on commit 7bb69bd

Please sign in to comment.