unit Myc.Data.Tuple;

interface

type
    ITuple<T> = interface
        {$region 'private'}
        function GetItems(Idx: Integer): T;
        function GetCount: Integer;
        {$endregion}
        property Items[Idx: Integer]: T read GetItems; default;
        property Count: Integer read GetCount;
    end;

    // Concrete generic implementation
    TTupleImpl<T> = class(TInterfacedObject, ITuple<T>)
    private
        FItems: TArray<T>;
        function GetItems(Idx: Integer): T;
        function GetCount: Integer;
    public
        constructor Create(const AItems: TArray<T>);
    end;

implementation

{ TTupleImpl<T> }

constructor TTupleImpl<T>.Create(const AItems: TArray<T>);
begin
    inherited Create;
    FItems := AItems;
end;

function TTupleImpl<T>.GetCount: Integer;
begin
    Result := Length(FItems);
end;

function TTupleImpl<T>.GetItems(Idx: Integer): T;
begin
    Result := FItems[Idx];
end;

end.
