Hi,
I am currently using std::map to look up item position by key as (the key is either std::string or int, so it has operator==, operator>, and operator<):
std::map::const_iterator it = map.find( key );
if ( it != map.end() ) {
return std::distance( map.begin(), it );
}
std::map::const_iterator it = map.find( key );
if ( it != map.end() ) {
return std::distance( map.begin(), it );
}
To copy to clipboard, switch view to plain text mode
I have 500,000 items in the map, and need to iterate through all 500,000 items and get each item's position. The loop takes 1 hours!!! So it is horribly wrong.
Can someone give suggestion to speed it up, preferably still using std::map because the codes were like that originally, but if QMap can give much better performace, then I would have a reason to change to QMap...
Thanks
Bookmarks