-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample6.lpr
40 lines (31 loc) · 895 Bytes
/
example6.lpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
program example6;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, SysUtils, CustApp
{ you can add units after this }
, fgl, uPerson;
type
TPersonList = specialize TFPGList<TPerson>;
var
LPersonList: TPersonList;
LPersonInterator: specialize TFPGListEnumerator<TPerson>;
LPerson: TPerson;
begin
LPersonList := TPersonList.Create;
LPersonList.Add(TPerson.Create('Malcolm', 30));
LPersonList.Add(TPerson.Create('Bob', 19));
LPersonList.Add(TPerson.Create('Alice', 30));
LPersonList.Add(TPerson.Create('Charlie', 30));
LPersonList.Sort(@ComparePerson);
LPersonInterator := LPersonList.GetEnumerator;
while LPersonInterator.MoveNext do
begin
LPerson := LPersonInterator.Current;
Writeln('Person Name: ', LPerson.Name_, ', Age: ', LPerson.Age);
end;
LPersonList.Free;
Readln;
end.