IsEmpty function for Queue, to Delphi compatibility.

This commit is contained in:
Henrique Gottardi Werlang 2024-04-19 07:57:45 -03:00 committed by Michael Van Canneyt
parent 40f5549e77
commit 8df83483e4

View File

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