AddNode中检测节点是否为空
为何要检测nodeIndex是否是空的呢,直接检测nodeIndex*2+1(或者2)节点是否为空不就好了if (nodeIndex * 2 + direction < 0 || nodeIndex * 2 + direction >= m_iSize)
{
return false;
}
if (m_pTree[nodeIndex * 2 + direction] == 0)
{
return false;
}
m_pTree[nodeIndex * 2 + direction] = *pNode;
return true;
我这里将direction定义为1或者2