I am using the hash_table as a simple dictionary type thing. But my problem is this container doesn't have a IfContainsKey function so I can easily check if a key already exists in it. How would I go about doing this type of check?
I am using the hash_table as a simple dictionary type thing. But my problem is this container doesn't have a IfContainsKey function so I can easily check if a key already exists in it. How would I go about doing this type of check?
I found out how. Simply use the count function in the hash_map. That returns the number of keys that matched the key you specify. The name count made me think it returns the number of elements in the container.
There is no standard hash_table, so make sure to indicate your compiler and standard library implementation when you have questions about it. Different libraries have very different versions of hash tables.
You might consider using the TR1 unordered_map instead, since that is quasi-standard already and should be accepted into the next standard when it is done. That means it is much more likely that it will work on other compilers and it is more likely that other programmers will be familiar with it as well.
Ahh okay. Well seeing as to how I fixed my problem and the hash table will be invisible to other users I think I'll stick with the MS hash_table for now. But I'll keep the TR1 unordered_map in mind for future projects. Thanks.