Multimap, How to find an element in map with its value but not the key?

Hi,

I am using std::unordered_multimap, I want to use the value of element to find the key, which the element belongs to. But the member function find() can only use the key to get the value of the (first) element.

Maybe I am using wrong data structure to solve my problem. The problem is as following:

A man want to marry a person who is not coming from his family(relativities and marriages). So i would like to use the key to represents his family, every relation or marriage record belongs to the same family will store under that key. And the goal is to find a person who is not belongs to his family.

Thank you for your time and help!

Best,
Yumin
Last edited on
Family relations form a forest (a collection of "family trees").

See the union-find data structure:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
Last edited on
Topic archived. No new replies allowed.