0

Hi want to implement an unordered hashmap ie. FIFO implementation . Below is the code.Please help me with this.

#include <hash_map>
#include <iostream.h>
int main()
{
hash_map<int,int>testMap;
testMap[1]=1;
testMap[3]=5;
testMap[2]=2;
typedef hash_map<int,int>::iterator hashIter;
for(hashIter it=testMap.begin();it!=testMap.end();it++)
{
cout<<it->second<<"\n";
}
}

It gives output as

1
2
5

But I want

1
5
2

Any suggestions ?

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by veer123
0

Maybe boost::unordered_map is what you need, but I never have used it, so I can't say if it meets your conditions.

0

I want to use the hash map in the standard library . Is there a way to do this using the Standard Library hash_map

0

You could always write your own implementation....that way it would only use things avaliable to you in the STL

Chris

0

:)
After lots of trial and error i have found the answer .

In hashmap the hashFunc::operator() has to be empty . Something like this

struct hashFunc

{

int operator() (int i) const

{

}

};

This will not sort the data it will be in the manner u insert it….It will be in the stack order. ( What you enter last will be on top ) ...
:icon_cool:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.