Created
January 3, 2022 04:16
-
-
Save bero/c253d71d27a661259086d38dcdac5cad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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