Browse Source

IsEmpty function for Queue, to Delphi compatibility.

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

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

@@ -279,6 +279,7 @@ type
   private
     FMaxGapLength: Integer;
     FLow: SizeInt;
+    function GetIsEmpty: Boolean;
   protected
     function DoGetEnumerator: TEnumerator<T>; override;
   public
@@ -305,6 +306,8 @@ type
     function Peek: T;
     procedure Clear;
     procedure TrimExcess; override;
+
+    property IsEmpty: Boolean read GetIsEmpty;
     // Maximum gap (=amount of empty slots in array before first element)
     // before doing a rebase of the list. Defaults to 10.
     Property MaxGapLength : Integer Read FMaxGapLength Write FMaxGapLength;
@@ -1805,6 +1808,11 @@ begin
   Result := TEnumerator.Create(Self);
 end;
 
+function TQueue<T>.GetIsEmpty: Boolean;
+begin
+  Result := Count = 0;
+end;
+
 procedure TQueue<T>.SetCapacity(AValue: SizeInt);
 begin
   if AValue < Count then