首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

mfc collection Classes中怎的实现查询、修改、删除指定元素的功能

2012-09-25 
mfc collection Classes中怎样实现查询、修改、删除指定元素的功能侯捷的深入浅出一书中,有一点涉及到删除功

mfc collection Classes中怎样实现查询、修改、删除指定元素的功能
侯捷的深入浅出一书中,有一点涉及到删除功能,不过他是全部删除,实现代码:
void CScribbleDoc::DeleteContents() 
{
while (!m_strokeList.IsEmpty())
{
delete m_strokeList.RemoveHead();
}
CDocument::DeleteContents();
}

m_strokeList在文档类中的定义:
 CTypedPtrList<CObList,CStroke*> m_strokeList;

从链表的头部依次往尾部删除,他是通过判断链表是否为空来知道是否达到全部删除的目的。

但是如果我只想删除、修改指定的元素呢,我的想法是在元素中安插一个识别标志,到时候查询的时候,根据这个识别标志找到欲修改、删除的元素,然后删除、修改它。
具体该怎么实现呢?mfc中又是否有相应的函数?求高人指点!!



[解决办法]
CTypedPtrList Members
See Also Send Feedback
 

Updated: November 2007

Head/Tail Access 

GetHead 
 Returns the head element of the list (cannot be empty). 
 
GetTail 
 Returns the tail element of the list (cannot be empty). 
 

Operations
AddHead 
 Adds an element (or all the elements in another list) to the head of the list (makes a new head). 
 
AddTail 
 Adds an element (or all the elements in another list) to the tail of the list (makes a new tail). 
 
RemoveHead 
 Removes the element from the head of the list. 
 
RemoveTail 
 Removes the element from the tail of the list. 
 

Iteration
GetNext 
 Gets the next element for iterating. 
 
GetPrev 
 Gets the previous element for iterating. 
 

Retrieval/Modification
GetAt 
 Gets the element at a given position. 
 
SetAt 
 Sets the element at a given position. 
 

热点排行