Ast RTL: Map, Reduce, Where, Any
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user