我试图理解从 C++ 代码中提取的一段算法,这里是 C++ 代码
inline void DBGame::make_chain( Edge* &newedge, Edge *edges[], Node *node ){
newedge->length = edges[0]->length + edges[1]->length;
for (int j = 0; j < 2; j++)
{
edges[j]->parent = newedge;
edges[j]->remove();
// replace the old edge with the new edge at the other end
// -------------------------------------------------------
int k = (edges[j]->node[0] == node);
newedge->node[j] = edges[j]->node[k];
newedge->pself[j] = edges[j]->pself[k];
*newedge->pself[j] = newedge;
}
}
仅供参考,节点是一个对象,而不是一个整数。
我不明白如何int k
通过给出一个真假表达式来分配一个整数值。