M
mycwcgr_new
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是一个遍历树(一般的树)的算法,对不对?
下面是别人的一个遍历树(一般的树)的算法
procedure SetChildStates(Node: TTreeNode);
var
ChildNode:TTreeNode;
begin
if Node = nil then
Exit;
ChildNode:=Node.getFirstChild;
while ChildNode <>
nildo
begin
ChildNode.StateIndex:=Node.StateIndex;
UpdateRight(ChildNode.Data,ChildNode.StateIndex = ICON_CHECKED);
if ChildNode.HasChildren then
SetChildStates(ChildNode);
ChildNode:=Node.GetNextChild(ChildNode);
end;
end;
我认为应该是
procedure SetChildStates(Node: TTreeNode);
var
ChildNode:TTreeNode;
begin
if Node = nil then
Exit;
ChildNode:=Node.getFirstChild;
while ChildNode <>
nildo
begin
ChildNode.StateIndex:=Node.StateIndex;
UpdateRight(ChildNode.Data,ChildNode.StateIndex = ICON_CHECKED);
if ChildNode.HasChildren then
begin
SetChildStates(ChildNode);
end
else
begin
ChildNode:=Node.GetNextChild(ChildNode);
end;
end;
end;
我的想法对不对?还是这两种表示法是等效的?
下面是别人的一个遍历树(一般的树)的算法
procedure SetChildStates(Node: TTreeNode);
var
ChildNode:TTreeNode;
begin
if Node = nil then
Exit;
ChildNode:=Node.getFirstChild;
while ChildNode <>
nildo
begin
ChildNode.StateIndex:=Node.StateIndex;
UpdateRight(ChildNode.Data,ChildNode.StateIndex = ICON_CHECKED);
if ChildNode.HasChildren then
SetChildStates(ChildNode);
ChildNode:=Node.GetNextChild(ChildNode);
end;
end;
我认为应该是
procedure SetChildStates(Node: TTreeNode);
var
ChildNode:TTreeNode;
begin
if Node = nil then
Exit;
ChildNode:=Node.getFirstChild;
while ChildNode <>
nildo
begin
ChildNode.StateIndex:=Node.StateIndex;
UpdateRight(ChildNode.Data,ChildNode.StateIndex = ICON_CHECKED);
if ChildNode.HasChildren then
begin
SetChildStates(ChildNode);
end
else
begin
ChildNode:=Node.GetNextChild(ChildNode);
end;
end;
end;
我的想法对不对?还是这两种表示法是等效的?