hashtree

C++ unordered_map using a custom class type as the key

ぃ、小莉子 提交于 2020-01-03 05:08:16
问题 I am trying to use a custom class as key for an unordered_map , like the following: #include <iostream> #include <algorithm> #include <unordered_map> using namespace std; class node; class Solution; class Node { public: int a; int b; int c; Node(){} Node(vector<int> v) { sort(v.begin(), v.end()); a = v[0]; b = v[1]; c = v[2]; } bool operator==(Node i) { if ( i.a==this->a && i.b==this->b &&i.c==this->c ) { return true; } else { return false; } } }; int main() { unordered_map<Node, int> m;

java.lang.IllegalArgumentException: Contents must be presorted [closed]

巧了我就是萌 提交于 2019-12-12 04:34:55
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . java.lang.IllegalArgumentException: Contents must be presorted - added value -2146647068 is less than preceding value 2147447602 at org.netbeans.core.output2.IntList.add(IntList.java:76) at org.netbeans.core.output2.AbstractLines.lineUpdated(AbstractLines.java:764) at org.netbeans.core.output2.OutWriter.write

C++ unordered_map using a custom class type as the key

独自空忆成欢 提交于 2019-12-12 04:17:02
问题 I am trying to use a custom class as key for an unordered_map , like the following: #include <iostream> #include <algorithm> #include <unordered_map> using namespace std; class node; class Solution; class Node { public: int a; int b; int c; Node(){} Node(vector<int> v) { sort(v.begin(), v.end()); a = v[0]; b = v[1]; c = v[2]; } bool operator==(Node i) { if ( i.a==this->a && i.b==this->b &&i.c==this->c ) { return true; } else { return false; } } }; int main() { unordered_map<Node, int> m;

C++ unordered_map using a custom class type as the key

隐身守侯 提交于 2019-11-25 22:00:16
问题 I am trying to use a custom class as key for an unordered_map , like the following: #include <iostream> #include <algorithm> #include <unordered_map> using namespace std; class node; class Solution; class Node { public: int a; int b; int c; Node(){} Node(vector<int> v) { sort(v.begin(), v.end()); a = v[0]; b = v[1]; c = v[2]; } bool operator==(Node i) { if ( i.a==this->a && i.b==this->b &&i.c==this->c ) { return true; } else { return false; } } }; int main() { unordered_map<Node, int> m;