source: trunk/Packages/Kernel/Kernel.List.pas

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 
1unit Kernel.List;
2
3interface
4
5uses
6 Classes, SysUtils, Generics.Collections;
7
8type
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
23implementation
24
25{ TNamedObjects }
26
27function TNamedObjects<T>.FindByName(Name: string): T;
28var
29 I: Integer;
30begin
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;
35end;
36
37end.
38
Note: See TracBrowser for help on using the repository browser.