PriorElem函数不同写法?
可不可以在Prior函数中调用Locate函数,用Locate得到i,for循环得到得到i-1节点?
写成这样:
bool List::PriorNode(Node* pCurrentNode, Node* pPreNode)
{
int i = 0;
i = LocateNode(pCurrentNode);
if (-1==i||0==i)
{
return false;
}
else
{
Node* currentnode = m_pList;
for (int k = 0;k < i;k++)
{
currentnode = currentnode->m_pnext;
}
pPreNode->m_idata = currentnode->m_idata;
return true;
}
}