Hi Chong! ;)
=> That's not a special thing itself! but usually algorithms to implement that, is somewhat complicated(but there is simple ones too, it depends on efficiency).
But what's a hashtable? it's a table of hashes! in programming it's a data structure that you can save some key/value pairs in that, then when you want a value, you just need to specify its key and you have the value, just like an array. But the main difference is the way it saves and returns a value, the special algorithm comes here, it will compute key of the value and returns that, then you can use the key later to retrieve the value. Also the structure is a little different from an array, but its implementation is easy(it may use pointers). The main characteristic of a hash table is 'returns value of a key very fast'. Actually, the special way of saving and returning values(the algorithm) is a mean to achieve that speed. You can find the algorithms and data structures for hash tables in Data Structures books(you can find infos in websites and also by downloading an eBook).
Then, we should consider two main things to implement a hash table : 1.Structure 2.Algorithm
In C++, you can use 'hash_map' that is an associative container from STL :
#include <hash_map>
The infos about that exist in MSDN.
Enter your message below
Sign in or Join us (it's free).