Last change
on this file was 60, checked in by chronos, 2 months ago |
- Modified: Remove U prefix from unit names.
|
File size:
548 bytes
|
Line | |
---|
1 | unit Kernel.List;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Generics.Collections;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TNamedObject }
|
---|
11 |
|
---|
12 | TNamedObject = class
|
---|
13 | Name: string;
|
---|
14 | end;
|
---|
15 |
|
---|
16 | { TNamedObjects }
|
---|
17 |
|
---|
18 | TNamedObjects<T: class> = class(TObjectList<T>)
|
---|
19 | function FindByName(Name: string): T;
|
---|
20 | end;
|
---|
21 |
|
---|
22 |
|
---|
23 | implementation
|
---|
24 |
|
---|
25 | { TNamedObjects }
|
---|
26 |
|
---|
27 | function TNamedObjects<T>.FindByName(Name: string): T;
|
---|
28 | var
|
---|
29 | I: Integer;
|
---|
30 | begin
|
---|
31 | I := 0;
|
---|
32 | while (I < Count) and (TNamedObject(Items[I]).Name <> Name) do Inc(I);
|
---|
33 | if I < Count then Result := Items[I]
|
---|
34 | else Result := nil;
|
---|
35 | end;
|
---|
36 |
|
---|
37 | end.
|
---|
38 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.