Click to See Complete Forum and Search --> : map type issue
gor
December 2nd, 2002, 06:35 AM
i whant to know if i can load to a map(STL) type
1000000 recordes and work with it fine.
did this will damege the performence?
if i will run process with this type and work with it it will be ok?
Yves M
December 2nd, 2002, 07:14 AM
It depends on what you will do with this map, but it can be slow. Consider at least putting pointers to the records inside the map as opposed to the real objects.
You might also consider using hash_map instead, it's quite a bit faster on big data provided that your hash function is good and fast.
kuphryn
December 2nd, 2002, 02:20 PM
Yes, a map is one solution. There is minimal performance loss if the content of the map is sortable. Thus, the map sorts the contents in a binary tree, making it at most n - 1 height. There will experience performance loss if the contents are 1, 1, 1, 1, 1, 1, etc. such that the tree is of height n - 1.
Kuphryn
Yves M
December 2nd, 2002, 09:32 PM
Hum, well I think that most implementations use Red-Black trees to implement maps, so it will balance itself "automagically".
kuphryn
December 2nd, 2002, 10:12 PM
Yeah, the STL is magical!
Kuphryn
gor
December 3rd, 2002, 01:19 AM
thanks.
what about the memory?
shoud i allocate memory on the stack? ( local var )
or on the heap? ( whit dynamic allocation )
kuphryn
December 3rd, 2002, 01:24 AM
Program design greatly impacts memory allocation. Consider where and when you will access the map.
Kuphryn
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.