c++ - How to maintain a set of vectors with no repetitions -
i have program in c++ producing lot of vectors of integers (each vector sorted), , being produced fast , in large number, need keep track of them , remove repetitions, , print them in end. data structure should use?
i tried using hash_map
, unordered_map
got lot's of errors , seems not support hash map of vectors (so how support strings though?) :
(.text+0xdc56): undefined reference `std::tr1::hash<std::vector<int, std::allocator<int> > >::operator()(std::vector<int, std::allocator<int> >) const' objects/prog.o: in function `std::tr1::_hashtable<std::vector<int, std::allocator<int> >, std::pair<std::vector<int, std::allocator<int> > const, int>, std::allocator<std::pair<std::vector<int, std::allocator<int> > const, int> >, std::_select1st<std::pair<std::vector<int, std::allocator<int> > const, int> >, std::equal_to<std::vector<int, std::allocator<int> > >, std::tr1::hash<std::vector<int, std::allocator<int> > >, std::tr1::__detail::_mod_range_hashing, std::tr1::__detail::_default_ranged_hash, std::tr1::__detail::_prime_rehash_policy, false, false, true>::_m_rehash(unsigned long)': prog.cpp:(.text._znst3tr110_hashtableist6vectoriisaiieest4pairiks3_iesais6_est10_select1stis6_est8equal_tois3_ens_4hashis3_eens_8__detail18_mod_range_hashingense_20_default_ranged_hashense_20_prime_rehash_policyelb0elb0elb1ee9_m_rehashem[std::tr1::_hashtable<std::vector<int, std::allocator<int> >, std::pair<std::vector<int, std::allocator<int> > const, int>, std::allocator<std::pair<std::vector<int, std::allocator<int> > const, int> >, std::_select1st<std::pair<std::vector<int, std::allocator<int> > const, int> >, std::equal_to<std::vector<int, std::allocator<int> > >, std::tr1::hash<std::vector<int, std::allocator<int> > >, std::tr1::__detail::_mod_range_hashing, std::tr1::__detail::_default_ranged_hash, std::tr1::__detail::_prime_rehash_policy, false, false, true>::_m_rehash(unsigned long)]+0x126): undefined reference `std::tr1::hash<std::vector<int, std::allocator<int> > >::operator()(std::vector<int, std::allocator<int> >) const' collect2: ld returned 1 exit status make: *** [run] error 1
is there other way around this? there other data structure better efficiency?
you need provide hash function vector use unordered_map. hash function string provided default. alternatively, can use std::set. elements of std::set guaranteed have no dupilcates.
Comments
Post a Comment