c++ - hash_map not working -


#include <ext/hash_map>  using namespace std;  class hash_t : public __gnu_cxx::hash_map<const char*, list<time_t> > { }; hash_t hash;  ... 

i'm having problems using hash_map. const char* im using key 12 length number format 58412xxxxxxx. know there 483809 different numbers, should hash_map size after inserting everything, i'm getting 193 entries.

hash_t::iterator = hash.find(origen.c_str()); if (it != hash.end()) { //found      x++;     (*it).second.push_front(fecha);          } else { //not found      y++;     list<time_t> lista(1, fecha);     hash.insert(make_pair(origen.c_str(), lista));           }   

the same procedure works using python dictionaries (i'm getting correct number of entries) not close using c++. possible since every key begins 58412 (actually every key, not of them, , that's reason don't want chop 5 chars), im getting lot of collisions?

const char* not key, since have pointer comparison instead of string comparison (also, have dangling pointers, return value of c_str() not usable long-term).

use hash_map<std::string, list<time_t> > instead.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -