我现在有以下代码:C++ - 印刷地图<结构,结构,构造>类型
struct LR0Item{
LR0Item(const string& lhs_p, vector<string> rhs_p, int dpos_p)
: lhs(lhs_p), rhs(rhs_p), dpos(dpos_p) {}
string lhs;
vector<string> rhs;
int dpos;
};
struct Node{
Node(LR0Item* lr) : item(lr) {}
LR0Item* item;
map<string, Node*> tr;
};
struct fizz{
bool operator()(
const LR0Item &a,
const LR0Item &b) {
if(a.lhs != b.lhs)
return a.lhs<b.lhs;
if(a.dpos != b.dpos)
return a.dpos<b.dpos;
return a.rhs<b.rhs;
}
};
vector<Node*> N;
map<LR0Item,Node*,fizz> nmap;
我有一些杂代码来填充NMAP用数据。我想知道如何以良好的格式打印数据(横向nmap)。我也不完全确定'嘶嘶声'在做什么。
通过在 “好” 的格式打印,你的意思是如何横穿'nmap'? – P0W
你应该查看'map'的文档来看看“fizz”在做什么:http://www.cplusplus.com/reference/map/map/ – leewz
@PW是的,我的意思是横切nmap,为了清晰起见编辑。 – Dohrann