How to detect duplicates in a vector of unordered_map?

后端 未结 2 927
死守一世寂寞
死守一世寂寞 2021-02-11 09:36

Given a vector of unordered_map, I would like to check if the vector contains any duplicated values. Two unordered_maps a

2条回答
  •  醉话见心
    2021-02-11 10:16

    you can something similar to the following :

    typedef unordered_map int_map;
    
    struct my_map_comparator
    {
        bool operator()(const int_map& a, const int_map& b) 
        { 
          a_hash = compute_hash_for_a(all keys of a)
          b_hash = compute_hash_for_b(all keys of b)
    
          return a_hash == b_hash; 
        }
    };
    
    std::unordered_set, my_map_comparator> map_list();
    

提交回复
热议问题