Why does my hash table have blank fields

Good afternoon, I am sorry to bother and I am just stuck and not sure of something. I am creating a hash table with with my load factor a prime number and I am loading it into a vector. Now when I search for a value in my hash table. It is saying it isn't found because once it finds a blank field it thinks it is done. Now is my hash table supposed to have blank spots and if so how do I get pass that in my search knowing that I have not looked through the entire hash table? Thanks for the help
LVL 1
Corey_819Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulCaswellCommented:
There should be blank spots in your table but they should signify that the search has failed.

When adding items, the hash function calculates a 'first' location to look in for the item. If that location is already occupied with a different record, the next free location is taken.

When searching for items, the same hash function should generate the same location to begin searching.

I would suggest that your implementation is incorrect for adding items.

Paul
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sys_ProgCommented:
Please post some code so thtaw we could help in a better way

Amit
0
eranifCommented:
You said that you are using vector is this the STL vector ?
What data type are you using to hold the raws?

is it something like this?

typedef std::vector<std::string> myRaw;
std::map<unsigned long,myRaw*> myHash

// lets say you want to remove element with value 1234566767:

keyToRemove = 1234566767
myRaw *raw = myHash[keyToRemove ];//return the vector with this value

while ( /* iterate the raw*/ )
{
    if( *raw[i] == value_to_remove)
    {
        raw->erase(i);
    }
}
 

0
Corey_819Author Commented:
Thanks PaulCaswell I did figure it out I was not realizing but after I displayed my vector it was getting cleared out with all my data. And I didn't see it because I saw it being displayed when I was running my program. Thanks for the help though. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.