hash_set : need the location /index where stored .
Posted on 2004-04-26
I am using hash_set which is available from gcc ( and which i presume is not part of the C++ standard yet )
okay , In hash tables the key is used by a hash function to calculate a index and the object is stored under that key.
I would like to have the index value. I want to iterate over all the objects stored in the hash_set and get all the objects and their index. )
The aim is to display the hash_set graphically, so that we can visually see how the objects are stored and are they distributed evenly or there is high collision and we arent getting much benifit out of using hash_set as compared to using a list.
Also for classes created by us , we have to define our own hash functions and in that case we can calculate it from the object itself. BUt what if we just have a pointer to the hash_set object and have no idea what the hash function is ?
second problem is when we define a hash_set
hash_set(size_type n) Creates an empty hash_set with at least n buckets.
this creates a hash_set with _at least_ n buckets . Is there any way we can make sure that exactly n buckets are created. cos if our custom hash function returns a value from 0 to n-1 i dont see any use of creating a hash_set with more than n buckets.
Phew I hope i was clear enough :)