|
25 | 25 | #include <memory>
|
26 | 26 | #include <ostream>
|
27 | 27 | #include <tuple>
|
| 28 | +#include <utility> |
28 | 29 | #include <vector>
|
29 | 30 |
|
| 31 | +#include "absl/hash/hash.h" |
30 | 32 | #include "absl/memory/memory.h"
|
31 | 33 | #include "cartographer/common/port.h"
|
32 | 34 | #include "cartographer/common/time.h"
|
@@ -79,6 +81,11 @@ struct NodeId {
|
79 | 81 | }
|
80 | 82 | };
|
81 | 83 |
|
| 84 | +template <typename H> |
| 85 | +H AbslHashValue(H h, const NodeId& id) { |
| 86 | + return H::combine(std::move(h), id.trajectory_id, id.node_index); |
| 87 | +} |
| 88 | + |
82 | 89 | inline std::ostream& operator<<(std::ostream& os, const NodeId& v) {
|
83 | 90 | return os << "(" << v.trajectory_id << ", " << v.node_index << ")";
|
84 | 91 | }
|
@@ -110,6 +117,11 @@ struct SubmapId {
|
110 | 117 | }
|
111 | 118 | };
|
112 | 119 |
|
| 120 | +template <typename H> |
| 121 | +H AbslHashValue(H h, const SubmapId& id) { |
| 122 | + return H::combine(std::move(h), id.trajectory_id, id.submap_index); |
| 123 | +} |
| 124 | + |
113 | 125 | inline std::ostream& operator<<(std::ostream& os, const SubmapId& v) {
|
114 | 126 | return os << "(" << v.trajectory_id << ", " << v.submap_index << ")";
|
115 | 127 | }
|
@@ -420,4 +432,12 @@ class MapById {
|
420 | 432 | } // namespace mapping
|
421 | 433 | } // namespace cartographer
|
422 | 434 |
|
| 435 | +template <> |
| 436 | +struct std::hash<cartographer::mapping::NodeId> |
| 437 | + : absl::Hash<cartographer::mapping::NodeId> {}; |
| 438 | + |
| 439 | +template <> |
| 440 | +struct std::hash<cartographer::mapping::SubmapId> |
| 441 | + : absl::Hash<cartographer::mapping::SubmapId> {}; |
| 442 | + |
423 | 443 | #endif // CARTOGRAPHER_MAPPING_ID_H_
|
0 commit comments