Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
22
Добавлен:
01.05.2014
Размер:
2 Кб
Скачать
unit list;
interface
type
 vertex=record
       x,y,number:integer;
     end;

type
 plvertex=^lvertex;
 lvertex=record
   used:integer;
   x,y,number:integer;
   next,previos: plvertex;
  end;

type
 TListVertex=class
 public
       beginList,current : plvertex;
       procedure AddVector(x,y,num:integer);
       procedure DeleteVector(V:plVertex);
       constructor Create;
       procedure Free;
     end;

implementation

procedure TListVertex.AddVector(x,y,num:integer);
var T,C:plvertex;
begin
  new (T);
  T^.x:=x; T^.y:=y; T^.number:=num;
  if (beginList=nil) then
  begin
    beginList:=T; current:=T;
    T^.previos:=beginList; T^.next:=beginList;
    T^.x:=x; T^.y:=y; T^.number:=num; T^.used:=0;
  end
  else
  begin
    C:=beginList;
    while (C^.next<>beginList) do C:=C^.next;
    C^.next:=T; T^.previos:=C;T^.next:=beginList;
    beginList.previos:=T;T^.used:=0;
  end;
end;

procedure TListVertex.DeleteVector(V:plVertex);
var p,n:plVertex;
begin
  p:=V.previos; n:=V.next;
  p^.next:=n; n^.previos:=p;
  dispose(V);
end;

constructor TListVertex.Create;
begin
  beginList:=nil;
  current:=nil;
end;

procedure TListVertex.Free;
var t,b:plvertex;
begin
  if (beginList<>nil) then
  begin
    current:=beginList;
    t:=current; current:=current^.next;
    dispose(t);
    while (current<>beginList) do
    begin
      t:=current; current:=current^.next;
      dispose(t);
    end;
    current:=nil; beginList:=nil;
  end;
end;

end.

Соседние файлы в папке Source
  • #
    01.05.20141 Кб22CHILDWIN.dfm
  • #
    01.05.201421 Кб23CHILDWIN.PAS
  • #
    01.05.201490 б23Graham.txt
  • #
    01.05.20146 Кб22KURS_R93.LEX
  • #
    01.05.20142 Кб22List.dcu
  • #
    01.05.20142 Кб22LIST.PAS
  • #
    01.05.201451 б22MAIN.~ddp
  • #
    01.05.201440 Кб22MAIN.~dfm
  • #
    01.05.20147 Кб22MAIN.~PAS
  • #
    01.05.201412 Кб22MAIN.DCU
  • #
    01.05.201451 б22MAIN.ddp