hash_map question

  • Thread starter Thread starter filox
  • Start date Start date
F

filox

i just don't get it:

hash_map<double, int> mapa;

double md = 0;

for(int j=0;j<1000000;++j)

{

mapa[md] = 3;

md++;

}



the above code takes up 70 MB of RAM. how??? any ideas?
 
filox said:
i just don't get it:

hash_map<double, int> mapa;

double md = 0;

for(int j=0;j<1000000;++j)

{

mapa[md] = 3;

md++;

}



the above code takes up 70 MB of RAM. how??? any ideas?

You're storing one million items in a hash_map, which has significant
overhead (hash buckets and linked lists, etc), why are you surprised?

Because of the uncertain equality of floating-point numbers, using doubles
as hash_map keys has questionable utility.
 
Back
Top