打印本文 打印本文 关闭窗口 关闭窗口
自己编写树(Tree)的封装类
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4966  更新时间:2009/4/23 18:34:19  文章录入:mintao  责任编辑:mintao
    FFirstNode.Delete; 

end;

 

constructor TYuTree.Create;

begin

  FFirstNode := nil;

end;

 

procedure TYuTree.Delete(Node: TYuNode);

begin

  Node.Delete;

end;

 

destructor TYuTree.Destroy;

begin

  Clear;

  inherited;

end;

 

function TYuTree.Insert(Brother: TYuNode): TYuNode;

var

  Prev, Next: TYuNode;

begin

  if Brother = nil then

  begin

    Result := Add(nil);

    Exit;

  end;

 

  if Brother.GetNextBrother = nil then

    Result := Add(Brother)

  else

  begin

    Prev := Brother;

    Next := Brother.GetNextBrother;

    Result := TYuNode.Create(Self);

 

    Prev.FDownRight := Result;

    Next.FUpRight := Result;

 

    Result.FUpRight := Prev;

    Result.FDownRight := Next;

  end;

end;

 

end.

 

//――――――结束―――――――――――――――――――――――――――-

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] 

打印本文 打印本文 关闭窗口 关闭窗口