共用方式為


CAtlList::RemoveAt

呼叫這個方法從清單中移除單一項目。

void RemoveAt(
   POSITION pos 
) throw( );

參數

  • pos
    要移除之項目的位置值。

備註

移除 pos 參考的項目,因此,記憶體中釋放。 使用 RemoveAt 移除清單的開頭或尾端是可接受的。

在偵錯組建中,判斷提示失敗,則會產生清單不正確,或是移除項目以產生清單物件不是清單結構的一部分的記憶體。

範例

// Define the integer list
CAtlList<int> myList;

// Populate the list
myList.AddTail(100);
myList.AddTail(200);
myList.AddTail(300);

// Use RemoveAt to remove elements one by one
myList.RemoveAt(myList.Find(100));
myList.RemoveAt(myList.Find(200));
myList.RemoveAt(myList.Find(300));

// Confirm all have been deleted
ATLASSERT(myList.IsEmpty() == true);   

需求

Header: atlcoll.h

請參閱

參考

CAtlList 類別

CAtlList::RemoveAll

CAtlList::SetAt