编辑:问题:删除两个节点之间的一个节点,然后将外部节点相互链接。
在学习和构建了几个四叉树和八叉树之后,我非常喜欢细分,我决定在我的服务器中使用细分。但是,仅将节点放置在自身内部。我的问题是,如果节点在中间,我不知道如何将前一个节点链接到下一个节点。我想知道我这样做是否正确。下面是我的代码,我评论问题区域在哪里。任何帮助都会很棒!
bool deleteNode ( SOCKET s , client_information_class *prev ) {
bool return_value = false;
if ( node[0]->client_socket != s ) {
if ( node[0]->node != NULL ) {
return_value = node[0]->deleteNode ( s , *node );
} else {
cout << endl << "Can not call deleteNode anymore ... Did not find the node to delete ... " << endl;
return return_value;
}
} else {
if ( node[0]->client_state == 1 )
InterlockedDecrement(&connection_count);
if ( node[0]->node != NULL ) { // there is a next node
client_information_class **next = node[0]->node;
if ( next[0]->node != NULL ) {
// problem area
cout << endl << "next[0]->node is not null" << endl;
prev->node = next[0]->node[0]->node; // ??? I know its wrong
} else {
// problem area
cout << endl << "next[0]->node is null" << endl;
prev->node = next[0]->node; // ??? I know its wrong
}
delete node;
} else { // its the last one
prev->node = NULL;
delete node;
}
InterlockedDecrement(&socket_count);
return_value = true;
}
return return_value;
}