Skip to content

Instantly share code, notes, and snippets.

@bero
Created January 3, 2022 04:16
Show Gist options
  • Save bero/c253d71d27a661259086d38dcdac5cad to your computer and use it in GitHub Desktop.
Save bero/c253d71d27a661259086d38dcdac5cad to your computer and use it in GitHub Desktop.
unit uEtl;
interface
uses
Generics.Collections;
type
IETL = interface
function Transform(aOld: TDictionary<integer, TList<string>>): TDictionary<string, integer>;
end;
TETL = class(TInterfacedObject, IETL)
private
fDict: TDictionary<string, integer>;
public
constructor Create;
destructor Destroy; override;
function Transform(aOld: TDictionary<integer, TList<string>>): TDictionary<string, integer>;
end;
function ETL: IETL;
implementation
function ETL: IETL;
begin
Result := TETL.Create;
end;
constructor TETL.Create;
begin
inherited;
fDict := TDictionary<string, integer>.Create;
end;
destructor TETL.Destroy;
begin
fDict.Free;
inherited;
end;
function TETL.Transform(aOld: TDictionary<integer, TList<string>>): TDictionary<string, integer>;
var
vPair: TPair<Integer, String>;
begin
for vPair in aOld do
fDict.Add(vPair.Value, vPair.Key);
Result := fDict;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment