📄 list.cpp
字号:
// List.cpp : implementation file
//
#include "stdafx.h"
#include "AI.h"
#include "List.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// List
List::~List()
{
Node *next;
while(first){
next=first->next;
delete first;
first=next;
}
}
BEGIN_MESSAGE_MAP(List, CWnd)
//{{AFX_MSG_MAP(List)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// List message handlers
int List::Length() const
{
Node *current=first;
int len=0;
while(current){
len++;
current=current->next;
}
return len;
}
int List::Locate(const CString& x) const
{
Node *current=first;
int index=1;
while(current && current->data!=x){
current=current->next;
index++;
}
if(current) return index;
return 0;
}
void List::Insert(const CString& x)
{
Node *y=new Node;
y->data=x;
if(!Empty()){
y->next=first;
first=y;
}
else
first=y;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -