7.2 72链表类 学习目标 了解MFC中的链表类及其常用成员函数。 2利用MFC中的链表类处理数据
7.2 链表类 学习目标 1.了解MFC中的链表类及其常用成员函数。 2.利用MFC中的链表类处理数据。 7.2 返回第7章
7.2 MFC的链表类 模板类 Clist CTypedPtrlist 非模板类 cobList CPtrList CString List
模板类 Clist CTypedPtrList 非模板类 CObList CPtrList CStringList 7.2 MFC的链表类
MFC链表类的常用成员函数—以 Clist为例 7.2 1. CList int n Block Size=10) 2. TYPE GetHead() const 3. TYPE GetTail( const 4. Remove Head () 5. Remove Tail () 6. 541: POSitION AddHead ARG TYPE newElement 原型2: void Addhead( CList* pNewlist) 7.原型1: POSITION AddTail( ARG TYPE newElement) 原型2: void addTail( CList* pNewlist) 8.RemoⅴeAll() 9. POSition Get Head Position() const 10. POSitION Get Tail Position () const 11. TYPE GetNext( position& pOsition) const 12. TYPE Get Prey( position& pOsition) const 13. TYPE GetAt( POSition poSition) const 14. void SetAt( POSition pos, ARG TYPE newElement
1.CList( int nBlockSize = 10 ); 2.TYPE GetHead( ) const; 3.TYPE GetTail() const; 4.RemoveHead() 5.RemoveTail() 6.原型1:POSITION AddHead(ARG_TYPE newElement ); 原型2:void AddHead( CList* pNewList ); 7.原型1:POSITION AddTail(ARG_TYPE newElement ); 原型2:void AddTail( CList* pNewList ); 8.RemoveAll() 9.POSITION GetHeadPosition() const; 10.POSITION GetTailPosition() const; 11.TYPE GetNext( POSITION& rPosition) const; 12.TYPE GetPrev( POSITION& rPosition ) const; 13.TYPE GetAt( POSITION position ) const; 14.void SetAt( POSITION pos, ARG_TYPE newElement ); 7.2 MFC链表类的常用成员函数——以Clist为例
MFC链表类的常用成员函数—以 Clist为例 7.2 15. void RemoveAt( POsition position 16. POSITION Insert Before( POSitIon position, ARG TYPE newElement 17. POSitioN Insert After( Position position, ARG TYPE newElement 18. position Find( ARG TYPe search Value. POSITION startAfter=NULL) const 19. POSiTION FindIndex int nIndex) const 20. int GetCount const 21. BOoL IsEmpty ()const
15.void RemoveAt( POSITION position ); 16.POSITION InsertBefore( POSITION position, ARG_TYPE newElement ); 17.POSITION InsertAfter( POSITION position, ARG_TYPE newElement ); 18 . POSITION Find ( ARG_TYPE searchValue, POSITION startAfter = NULL) const; 19.POSITION FindIndex( int nIndex ) const; 20.int GetCount() const; 21.BOOL IsEmpty( ) const; 7.2 MFC链表类的常用成员函数——以Clist为例
例题(1-2) 7.2 1创建一个基于单文档的应用程序(ist) 2.编辑对话框资源 (1)IDD DIALOG ADD IDC STATIC Group box Caption:添加结点 IDC STATIC Static Text Caption:姓名 IDC STATIC Static Text Caption:成绩 IDC EDIT NAME Edit box IDC EDIT SCORE Edit box IDOK Button Caption:确定 IDCANCEL Button Caption:取消 关联变量 IDC EDIT NAME EStrin g m strName IDC EDIT SCORE int m nscore
例题(1--2) 7.2 1.创建一个基于单文档的应用程序(List ) 2.编辑对话框资源 (1) IDD_DIALOG_ADD IDC_STATIC Group Box Caption:添加结点 IDC_STATIC Static Text Caption:姓名 IDC_STATIC Static Text Caption:成绩 IDC_EDIT_NAME Edit Box IDC_EDIT_SCORE Edit Box IDOK Button Caption:确定 IDCANCEL Button Caption:取消 关联变量: IDC_EDIT_NAME CString m_strName IDC_EDIT_SCORE int m_nScore