那位大虾有用DELPHI写的链表的类,就200分,都拿去吧(200分)

  • 主题发起人 spacebar
  • 开始时间
S

spacebar

Unregistered / Unconfirmed
GUEST, unregistred user!
我刚开始用DELPHI,不会写这个类,有没有源码参一下考?
 
我这里有个堆栈的(不是用的数组)
 
我这有个用链表的源文件
但不是类
要的话留下mail
 
你到
http://www.et888.com/link.rar
下载吧
Linked_QueueAdt.pas单元定义了对链表的基本操作
 
t365 我下载了,RAR解不开,能不能给我发MAIL
spacebar@163.com谢谢 了
 
你下载一个rar解压工具就行了
我没法给你一个个发文件啊!
 
type
PStackRec=^TStackRec;
TStackRec=record
Data:char;
Next:pStackRec;
Prev:pStackRec;
end;
TStack=class
private
pHead:pStackRec;
protected
procedure FreeAllNode;
public
constructor Create;
destructor Destroy;
override;
function IsEmpty:boolean;
function GetData(var a_ch:char):boolean;
function PopData(var a_ch:char):boolean;
function PushData(a_ch:char):boolean;
end;

implementation
{TStack}
constructor TStack.Create;
begin
GetMem(pHead,SizeOf(TStackRec));
pHead^.Next:=pHead;
pHead^.Prev:=pHead;
inherited;
end;

procedure TStack.FreeAllNode;
var
pNode:pStackRec;
begin
while pHead^.Next<>pHeaddo
begin
pNode:=pHead^.Next;
pHead^.Next:=pNode^.Next;
FreeMem(pNode);
end;
pHead^.Next:=pHead;
pHead^.Prev:=pHead;
end;

destructor TStack.Destroy;
begin
FreeAllNode;
FreeMem(pHead);
inherited;
end;

function TStack.IsEmpty:boolean;
begin
Result:=False;
if pHead^.Next=pHead then
Result:=True;
end;

function TStack.GetData(var a_ch:char):boolean;
begin
if not IsEmpty then
begin
a_ch:=pHead^.Prev^.Data;
Result:=True;
end
else
begin
Result:=False;
end;
end;

function TStack.PopData(var a_ch:char):boolean;
var
pTemp:pStackRec;
begin
if not IsEmpty then
begin
pTemp:=pHead^.Prev;
a_ch:=pTemp^.Data;
pHead^.Prev:=pTemp^.Prev;
pTemp^.Prev^.Next:=pHead;
FreeMem(pTemp);
Result:=True;
end
else
Result:=False;
end;

function TStack.PushData(a_ch:char):boolean;
var
pTemp:pStackRec;
begin
GetMem(pTemp,SizeOf(TStackRec));
pTemp^.Data:=a_ch;
pTemp^.Next:=pHead;
pTemp^.Prev:=pHead^.Prev;
pHead^.Prev^.Next:=pTemp;
pHead^.Prev:=pTemp;
Result:=True;
end;
 
t365,谢谢,我有RAR,但是解开文件时出错,能不能用WINZIP压一个MAIL给我
 
谢谢两位。t365 150分,xiao_min 50分行不?
 
顶部