diff --git a/cartographer/mapping/id.h b/cartographer/mapping/id.h index c5abdf9af..f90a2c062 100644 --- a/cartographer/mapping/id.h +++ b/cartographer/mapping/id.h @@ -25,8 +25,10 @@ #include #include #include +#include #include +#include "absl/hash/hash.h" #include "absl/memory/memory.h" #include "cartographer/common/port.h" #include "cartographer/common/time.h" @@ -79,6 +81,11 @@ struct NodeId { } }; +template +H AbslHashValue(H h, const NodeId& id) { + return H::combine(std::move(h), id.trajectory_id, id.node_index); +} + inline std::ostream& operator<<(std::ostream& os, const NodeId& v) { return os << "(" << v.trajectory_id << ", " << v.node_index << ")"; } @@ -110,6 +117,11 @@ struct SubmapId { } }; +template +H AbslHashValue(H h, const SubmapId& id) { + return H::combine(std::move(h), id.trajectory_id, id.submap_index); +} + inline std::ostream& operator<<(std::ostream& os, const SubmapId& v) { return os << "(" << v.trajectory_id << ", " << v.submap_index << ")"; } @@ -420,4 +432,12 @@ class MapById { } // namespace mapping } // namespace cartographer +template <> +struct std::hash + : absl::Hash {}; + +template <> +struct std::hash + : absl::Hash {}; + #endif // CARTOGRAPHER_MAPPING_ID_H_