c++ - Does std::map::find performance depend on the key size? -


say have the following map definition:

std::map<string,storage> 

where key string representation of storage class instance.
question is, though stated map::find complexity logarithmic in size, string size has influence on performance?

the reason have map enable fast access storage class instance. however, if string representation of storage classes long? there max string size if exceeded makes use of map redundant?

notes

my intuition tells me if the string representation of storage classes long comparing classes using operator== expensive well. no matter how long string is, i'm better of using map

yes, map has perform less-than comparison of keys. lexicographical comparison , linear wrt string size.

this not affect time complexity of find method, refers number of comparisons required. affects constant factor.

whether matters or not in application should determined empirically.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -