【发布时间】:2017-03-17 17:38:04
【问题描述】:
我正在尝试了解地图的工作原理以及如何为图表实现它们。我不断收到上面的错误。我认为这是因为“
using namespace std;
struct Node {
string name;
int val;
Node(string n) {
name = n;
val = 0;
}
};
struct AdjList {
map<Node, list<Node*>> adj;
map<Node, list<Node*>>::iterator it;
int type;
AdjList(int a) {
type = a;
}
void add(Node temp) {
it = adj.end();
list <Node*> hi;
adj.insert(pair <Node, list <Node*>>(temp, hi));
}
void connect(Node *a, Node *b) {
adj.find(*a)->second.push_back(b);
if (type == 1) {
adj.find(*b)->second.push_back(a);
}
}
void connect(Node *a, vector <Node*> b) {
for (int i = 0; i < b.size(); i++) {
connect(a, b[i]);
}
}
};
【问题讨论】:
标签: c++ dictionary