Reputation: 2777
key is :(x,y) , that means 2 integers.
value is: 0 or 1.
And I have frequently operation of iteration of this hash map.
Which data structure is fit? I am using C++ stl or tr1. Don't consider boost.
Upvotes: 2
Views: 126
Reputation: 73625
I suggest the use of a proper hashmap (unlike std::map which isn't a hashmap):
typedef std::tr1::unordered_map<pair<int, int>, bool> MyContainer;
MyContainer m_myContainer;
Upvotes: 2
Reputation: 16081
I would use a std::hash_map or std::map. I'm not sure which would give you faster performance though.
Upvotes: 0
Reputation: 117681
Well, the data format stored obviously is a bool.
And for the key format, if you would know the bitsize of those integers and performance is a must, I would use a associative array (called a map
in C++) with twice the bitwidth integers as key:
bool val = true;
uint32 x, y; // key
uint64 combo = x << 32 + y;
std::map<uint64, bool> container;
But this would work fine too and is semantically much better:
std::map<std::pair<int, int>, bool> container.
Upvotes: 4