473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

hash_set : need the location /index where stored .

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 :)

/abhijit/
Jul 22 '05 #1
1 1958

"Abhijit Ray" <av********@yahoo.com> wrote in message
news:ab**************************@posting.google.c om...
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 ?
gcc define a method that returns the hash_set's hash function, can't
remember what its called (hash_funct I think), look it up.


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.


Write a better hash function I think. IIIRC gcc's hash_set rounds up the
number of buckets to a prime number, so no I don't think there is any way to
do what you are asking.

Since you seem to have very specific requirements why not write your own
hash set, its prerty easy to do.

john
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Alex Gerdemann | last post by:
Hello, I have spent a bunch of time converting a Java program I wrote to C++ in order to improve performance, and have found that it is not necessarily faster. Specifically, I'm writing a...
5
by: Bart Blommerde | last post by:
Hi, My question is about the STL extensions hash_set and hash_map, especially the SGI versions of these templates. When defining a class like this : #include <hash_set> class MyClass : public...
1
by: Timo Qvist | last post by:
Hi, I'm a bit new to STL and really new to SGI's hash_set implementation and I've having problem instantiating a hash_set with a custom hash function, I could really use some help sifting through...
3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
1
by: zs | last post by:
Hi! I get warning message shown below in VS.NET 2k3. Is this deprecated by microsoft or by standard? I need hash_set to store and search small strings (<20 chars long). I'll have less then 300...
2
by: Pierre Couderc | last post by:
Generally, is there somewhere a good tutorial and examplefor the use of SGI STL hash_set? I am lost in SGI documentation. More specifically, i am trying to use hat I need that a hash_set : ...
5
by: Amit Bhatia | last post by:
Hi, I was wondering if I have a hash_set, can I modify its elements using an iterator: given the fact that the changes I make will not change the position or the key of the object that the...
3
by: eagerlearner | last post by:
I have the following code, which does not sort the list in alphabetical order, how can I sort everything in alphabetical order ? Before that, I want to ask, when an insertion occur, does it compare...
5
by: Markus Dehmann | last post by:
Do I have to handle hash collisions in a hash_set myself? I did a test in which I use find() to look for objects in a hash_set. These objects are definitely not contained, but find() sometimes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.