Ast RTL: Map, Reduce, Where, Any

This commit is contained in:
Michael Schimmel
2025-09-18 16:09:51 +02:00
parent 1be9591a61
commit 5f110e4408
3 changed files with 233 additions and 51 deletions
+38
View File
@@ -254,6 +254,16 @@ type
property TotalCount: Int64 read GetTotalCount;
end;
TIndexSeries = class(TInterfacedObject, ISeries)
private
FIndexArray: TArray<Integer>;
function GetCount: Int64;
function GetTotalCount: Int64;
function GetItems(Idx: Integer): TScalar;
public
constructor Create(const AIndexArray: TArray<Integer>);
end;
TBinaryOperatorHelper = record helper for TBinaryOperator
function ToString: string;
end;
@@ -1557,6 +1567,34 @@ begin
Result := FTotalCount;
end;
{ TIndexSeries }
constructor TIndexSeries.Create(const AIndexArray: TArray<Integer>);
begin
inherited Create;
FIndexArray := AIndexArray;
end;
function TIndexSeries.GetCount: Int64;
begin
Result := Length(FIndexArray);
end;
function TIndexSeries.GetTotalCount: Int64;
begin
Result := GetCount;
end;
function TIndexSeries.GetItems(Idx: Integer): TScalar;
var
sourceIndex: Integer;
begin
// The series maintains the "0 is newest" convention.
// The index array was built from oldest to newest, so we access it in reverse.
sourceIndex := FIndexArray[GetCount - 1 - Idx];
Result := TScalar.FromInteger(sourceIndex);
end;
initialization
Assert(sizeof(TScalarValue) = 8);