刪除時判空
bool List::ListDelete(int i, int *e)
{
if(ListEmpty())
{
return false;
}
...
bool List::ListDelete(int i, int *e)
{
if(ListEmpty())
{
return false;
}
...
2017-01-07
插入過程 讓 m_iLength+1不超過m_iSize
bool List::ListInsert(int i, int *e)
{
if(i<0||i<=m_iLength)
{
return false;
}
if(m_iLength+1>m_iSize)
{
return false;
}
for(int k=m_iLength-1;k>=i;k--)
{
m_pList[k+1] = m_pList[k];
}
m_pList[i] = *e;
m_iLength++;
return true;
}
bool List::ListInsert(int i, int *e)
{
if(i<0||i<=m_iLength)
{
return false;
}
if(m_iLength+1>m_iSize)
{
return false;
}
for(int k=m_iLength-1;k>=i;k--)
{
m_pList[k+1] = m_pList[k];
}
m_pList[i] = *e;
m_iLength++;
return true;
}
2017-01-07
回復(fù)樓下:這些數(shù)據(jù)結(jié)構(gòu)在php中都有對應(yīng)的實(shí)現(xiàn),可以直接使用,你不用重新造輪子。SplQueue SqlStack SqlDoublyLinkedList
2017-01-06