Files
lazarus-ccr/applications/json_packager/ugenericcollection.pas
gbamber 4789d0cffa Initial V0.1.8.0
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5403 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2016-12-04 15:13:38 +00:00

51 lines
894 B
ObjectPascal

unit ugenericcollection;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TGenericCollection }
generic TGenericCollection<T> = class(TCollection)
private
function GetItems(Index: integer): T;
procedure SetItems(Index: integer; AValue: T);
public
constructor Create;
public
function Add: T;
public
property Items[Index: integer]: T read GetItems write SetItems; default;
end;
implementation
{ TGenericCollection }
function TGenericCollection.GetItems(Index: integer): T;
begin
Result := T(inherited Items[Index]);
end;
procedure TGenericCollection.SetItems(Index: integer; AValue: T);
begin
Items[Index].Assign(AValue);
end;
constructor TGenericCollection.Create;
begin
inherited Create(T);
end;
function TGenericCollection.Add: T;
begin
Result := T(inherited Add);
end;
end.