Browse Source

+ TFPGObjectList.GetEnumerator and TFPGInterfacedObjectList.GetEnumerator, resolves #18094

git-svn-id: trunk@16471 -
florian 14 years ago
parent
commit
6b42ba170b
1 changed files with 14 additions and 0 deletions
  1. 14 0
      rtl/objpas/fgl.pp

+ 14 - 0
rtl/objpas/fgl.pp

@@ -140,6 +140,7 @@ type
       TTypeList = array[0..MaxGListSize] of T;
       TTypeList = array[0..MaxGListSize] of T;
       PTypeList = ^TTypeList;
       PTypeList = ^TTypeList;
       PT = ^T;
       PT = ^T;
+      TFPGListEnumeratorSpec = specialize TFPGListEnumerator<T>;
   {$ifndef OldSyntax}protected var{$else}var protected{$endif}
   {$ifndef OldSyntax}protected var{$else}var protected{$endif}
       FOnCompare: TCompareFunc;
       FOnCompare: TCompareFunc;
       FFreeObjects: Boolean;
       FFreeObjects: Boolean;
@@ -154,6 +155,7 @@ type
     function Add(const Item: T): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
     function Add(const Item: T): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
     function Extract(const Item: T): T; {$ifdef CLASSESINLINE} inline; {$endif}
     function Extract(const Item: T): T; {$ifdef CLASSESINLINE} inline; {$endif}
     function First: T; {$ifdef CLASSESINLINE} inline; {$endif}
     function First: T; {$ifdef CLASSESINLINE} inline; {$endif}
+    function GetEnumerator: TFPGListEnumeratorSpec; {$ifdef CLASSESINLINE} inline; {$endif}
     function IndexOf(const Item: T): Integer;
     function IndexOf(const Item: T): Integer;
     procedure Insert(Index: Integer; const Item: T); {$ifdef CLASSESINLINE} inline; {$endif}
     procedure Insert(Index: Integer; const Item: T); {$ifdef CLASSESINLINE} inline; {$endif}
     function Last: T; {$ifdef CLASSESINLINE} inline; {$endif}
     function Last: T; {$ifdef CLASSESINLINE} inline; {$endif}
@@ -174,6 +176,7 @@ type
       TTypeList = array[0..MaxGListSize] of T;
       TTypeList = array[0..MaxGListSize] of T;
       PTypeList = ^TTypeList;
       PTypeList = ^TTypeList;
       PT = ^T;
       PT = ^T;
+      TFPGListEnumeratorSpec = specialize TFPGListEnumerator<T>;
   {$ifndef OldSyntax}protected var{$else}var protected{$endif}
   {$ifndef OldSyntax}protected var{$else}var protected{$endif}
       FOnCompare: TCompareFunc;
       FOnCompare: TCompareFunc;
     procedure CopyItem(Src, Dest: Pointer); override;
     procedure CopyItem(Src, Dest: Pointer); override;
@@ -187,6 +190,7 @@ type
     function Add(const Item: T): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
     function Add(const Item: T): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
     function Extract(const Item: T): T; {$ifdef CLASSESINLINE} inline; {$endif}
     function Extract(const Item: T): T; {$ifdef CLASSESINLINE} inline; {$endif}
     function First: T; {$ifdef CLASSESINLINE} inline; {$endif}
     function First: T; {$ifdef CLASSESINLINE} inline; {$endif}
+    function GetEnumerator: TFPGListEnumeratorSpec; {$ifdef CLASSESINLINE} inline; {$endif}
     function IndexOf(const Item: T): Integer;
     function IndexOf(const Item: T): Integer;
     procedure Insert(Index: Integer; const Item: T); {$ifdef CLASSESINLINE} inline; {$endif}
     procedure Insert(Index: Integer; const Item: T); {$ifdef CLASSESINLINE} inline; {$endif}
     function Last: T; {$ifdef CLASSESINLINE} inline; {$endif}
     function Last: T; {$ifdef CLASSESINLINE} inline; {$endif}
@@ -880,6 +884,11 @@ begin
   Result := T(inherited First^);
   Result := T(inherited First^);
 end;
 end;
 
 
+function TFPGObjectList.GetEnumerator: TFPGListEnumeratorSpec;
+begin
+  Result := TFPGListEnumeratorSpec.Create(Self);
+end;
+
 function TFPGObjectList.IndexOf(const Item: T): Integer;
 function TFPGObjectList.IndexOf(const Item: T): Integer;
 begin
 begin
   Result := 0;
   Result := 0;
@@ -990,6 +999,11 @@ begin
   Result := T(inherited First^);
   Result := T(inherited First^);
 end;
 end;
 
 
+function TFPGInterfacedObjectList.GetEnumerator: TFPGListEnumeratorSpec;
+begin
+  Result := TFPGListEnumeratorSpec.Create(Self);
+end;
+
 function TFPGInterfacedObjectList.IndexOf(const Item: T): Integer;
 function TFPGInterfacedObjectList.IndexOf(const Item: T): Integer;
 begin
 begin
   Result := 0;
   Result := 0;