Browse Source

IsEmpty functoin in the TList to Delphi compability.

Henrique Gottardi Werlang 1 year ago
parent
commit
dee43db2a7
1 changed files with 7 additions and 0 deletions
  1. 7 0
      packages/rtl/src/generics.collections.pas

+ 7 - 0
packages/rtl/src/generics.collections.pas

@@ -185,6 +185,7 @@ type
   private
   private
     function GetItem(AIndex: SizeInt): T;
     function GetItem(AIndex: SizeInt): T;
     procedure SetItem(AIndex: SizeInt; const AValue: T);
     procedure SetItem(AIndex: SizeInt; const AValue: T);
+    function GetIsEmpty: Boolean;
   public
   public
     type
     type
       TEnumerator = class(TCustomListEnumerator<T>);
       TEnumerator = class(TCustomListEnumerator<T>);
@@ -236,6 +237,7 @@ type
     function BinarySearch(const AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
     function BinarySearch(const AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
 
 
     property Count: SizeInt read FLength write SetCount;
     property Count: SizeInt read FLength write SetCount;
+    property IsEmpty: Boolean read GetIsEmpty;
     property Items[Index: SizeInt]: T read GetItem write SetItem; default;
     property Items[Index: SizeInt]: T read GetItem write SetItem; default;
   end;
   end;
 
 
@@ -890,6 +892,11 @@ begin
   Result := GetEnumerator;
   Result := GetEnumerator;
 end;
 end;
 
 
+function TList<T>.GetIsEmpty: Boolean;
+begin
+  Result := Count = 0;
+end;
+
 function TList<T>.GetItem(AIndex: SizeInt): T;
 function TList<T>.GetItem(AIndex: SizeInt): T;
 begin
 begin
   if (AIndex < 0) or (AIndex >= Count) then
   if (AIndex < 0) or (AIndex >= Count) then