cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
The usage of hash
The usage of hash
Feb 11, 2014 at 9:34pm UTC
deritha
(5)
The original code:
struct NUM
{
NUM(int a, int b) :a(a), b(b), val(a+b*sqrt(2)){}
bool operator<(const NUM& n) const{ return val > n.val; }
bool operator==(const NUM& n) const{ return a == n.a && b == n.b; }
int a, b;
double val;
};
struct HashNUM
{
size_t operator()(const NUM& n) const
{
return hash<int>()(n.a) ^ (hash<int>()(n.b)<<1);
}
};
The main code:
unordered_set<NUM, HashNUM> hash;
hash.emplace(0, 0);
NUM c(s.a + 1, s.b);
if (hash.emplace(c).second)
{
min_heap.emplace(c);
}
What's the detail usage of hash.emplace(c).second? I can't output it to get more detail information.
Thanks.
Topic archived. No new replies allowed.