Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[4360] >질문< TList에서의 소트방법??
yunto [ ] 1244 읽음    1998-09-03 12:40
TList를 사용하여 소트하는 방법을 모르겠습니다.
처음엔 링크드리스트로 구현 했는데..
메모리 Free가 잘 안되더라구요..
혹시
소트하는 방법아시면.. 부탁드립니다...
너무 막연해서??

  type TListSortCompare = function (Item1, Item2: Pointer): Integer;
  procedure Sort(Compare: TListSortCompare);

procedure TForm1.FormButton1Click(Sender: TObject);

type
  PMyList = ^AList;
  AList = record
    I: Integer;
    C: Char;
  end;

var

  MyList: TList;
  ARecord: PMyList;
  B: Byte;
  Y: Word;
begin
  MyList := TList.Create;
  New(ARecord);
  ARecord^.I := 100;
  ARecord^.C := 'Z';
  MyList.Add(ARecord); {Add integer 100 and character Z to list}
  New(ARecord);
  ARecord^.I := 200;
  ARecord^.C := 'X';
  MyList.Add(ARecord); {Add integer 200 and character X to list}

  { Now paint the items onto the paintbox )
  Y := 10;             {Variable used in TextOut function}

//전 이곳에서 MyList를 I값에 있는 상수로 소트하고자
//합니다..
//그런데.. 그걸 잘 모르겠더라구요.. 어떻게 해야되는지를..

------>>> MyList.Sort(????);

  for B := 0 to (MyList.Count - 1) do

  begin
    ARecord := MyList.Items[B];
    Canvas.TextOut(10, Y, IntToStr(ARecord^.I)); {Display I}
    Y := Y + 30;  {Increment Y Value again}
    Canvas.TextOut(10, Y, ARecord^.C);  {Display C}
    Y := Y + 30;  {Increment Y Value}
  end;

  { Cleanup: must free the list items as well as the list }
for B := 0 to (MyList.Count - 1) do
begin
    ARecord := MyList.Items[B];
    Dispose(ARecord);
end;

MyList.Free;
end;


+ -

관련 글 리스트
4360 >질문< TList에서의 소트방법?? yunto 1244 1998/09/03
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.