unordered_set for ROS messages

asked 2021-07-28 13:57:53 -0600

abhishek47 gravatar image

This is more a C++ than a ROS question, however the main point I want to ask about is related to ROS (I think).

I'd like to create a std::unordered_set for geometry_msgs::msg::Point. However, as I understand from How can I use a C++ unordered_set for a custom class, I'd need to define my own hash function.

To use std::unordered_set with a ROS message, what necessary functionality should go into the hash function?

I'm no expert on hash tables and hash functions and I'm not sure if lifting a generic hash function from somewhere is a good idea. This StackOverFlow answer states the == operator has to be defined that is "consistent with your hash function". So I guess that means two components are needed: i) hash function, ii) defining ==, which is also in line with another answer but for std::unordered_map.

I'm looking for some advice on setting up whatever needs to be set up so that I can create std::unordered_set<geometry_msgs::msg::Point>.

Thanks!

edit retag flag offensive close merge delete