Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit List;
- interface
- uses VCL.GRIDS, System.SysUtils;
- type
- TList = class(TObject)
- private
- FNext: TList;
- FVal: Integer;
- FCount: Integer;
- public
- constructor Create; overload;
- destructor Destroy; overload;
- procedure Add(pVal: Integer);
- procedure AddFromSG(sgE: TStringGrid);
- procedure Show(E: TStringGrid);
- procedure SetNext(Next: TList);
- property Next: TList read FNext write SetNext;
- property Val: Integer read FVal;
- end;
- implementation
- constructor TList.Create;
- begin
- inherited;
- FNext := nil;
- FCount := 0;
- end;
- destructor TList.Destroy;
- begin
- if FNext <> nil then
- FNext.Destroy;
- inherited Destroy;
- end;
- procedure TList.SetNext(Next: TList);
- begin
- FNext := Next;
- end;
- procedure TList.Add(pVal: Integer);
- var
- Temp: TList;
- begin
- Temp := Self;
- while Temp.FNext <> nil do
- Temp := Temp.FNext;
- Temp.FNext := TList.Create;
- Temp.FNext.FVal := pVal;
- Inc(FCount);
- end;
- procedure TList.AddFromSG(sgE: TStringGrid);
- var
- Temp: TList;
- I: Integer;
- begin
- Temp := Self;
- while Temp.FNext <> nil do
- Temp := Temp.FNext;
- with sgE do
- begin
- for I := 0 to ColCount - 1 do
- begin
- Temp.FNext := TList.Create;
- Temp.FNext.FVal := StrToInt(Cells[I, 0]);
- Temp := Temp.FNext;
- Inc(FCount);
- end;
- end;
- end;
- procedure TList.Show(E: TStringGrid);
- var
- I: Integer;
- Temp: TList;
- begin
- Temp := FNext;
- with E do
- begin
- ColCount := FCount;
- for I := 0 to ColCount - 1 do
- begin
- Cells[I, 0] := IntToStr(Temp.FVal);
- Temp := Temp.FNext;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement