16,472
社区成员
发帖
与我相关
我的任务
分享
void Test_Clist()
{
CList <int, int> mTestList;
for(int i=0; i<10; i++)
mTestList.AddTail(i);
POSITION pos = mTestList.GetHeadPosition();
while(pos)
{
int Cell = mTestList.GetAt(pos);
TRACE( _T("%d\n"), Cell);
if(Cell == 5) //删除值为5的节点
{
POSITION posDel = pos; //保留当前节点
mTestList.GetPrev(pos); //pos指向上一个节点 以便GetNext能指向正确的位置
mTestList.RemoveAt(posDel); //删除当前节点
}
mTestList.GetNext(pos);//指向下一节点
}
}