mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 09:06:02 +02:00
Patch from Alexander S. Klenin
* Implemented TLookupList.FirstKeyByValue and ValuesToStrings git-svn-id: trunk@12344 -
This commit is contained in:
parent
8056591845
commit
4b5bc94bff
@ -251,7 +251,9 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Add(const AKey, AValue: Variant);
|
procedure Add(const AKey, AValue: Variant);
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
|
function FirstKeyByValue(const AValue: Variant): Variant;
|
||||||
function ValueOfKey(const AKey: Variant): Variant;
|
function ValueOfKey(const AKey: Variant): Variant;
|
||||||
|
procedure ValuesToStrings(AStrings: TStrings);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TField }
|
{ TField }
|
||||||
@ -2314,6 +2316,20 @@ begin
|
|||||||
FList.Clear;
|
FList.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLookupList.FirstKeyByValue(const AValue: Variant): Variant;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := 0 to FList.Count - 1 do
|
||||||
|
with PLookupListRec(FList[i])^ do
|
||||||
|
if Value = AValue then
|
||||||
|
begin
|
||||||
|
Result := Key;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
Result := Null;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLookupList.ValueOfKey(const AKey: Variant): Variant;
|
function TLookupList.ValueOfKey(const AKey: Variant): Variant;
|
||||||
|
|
||||||
Function VarArraySameValues(VarArray1,VarArray2 : Variant) : Boolean;
|
Function VarArraySameValues(VarArray1,VarArray2 : Variant) : Boolean;
|
||||||
@ -2346,6 +2362,19 @@ begin
|
|||||||
if i >= 0 then Result := PLookupListRec(FList.Items[I])^.Value;
|
if i >= 0 then Result := PLookupListRec(FList.Items[I])^.Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLookupList.ValuesToStrings(AStrings: TStrings);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
p: PLookupListRec;
|
||||||
|
begin
|
||||||
|
AStrings.Clear;
|
||||||
|
for i := 0 to FList.Count - 1 do
|
||||||
|
begin
|
||||||
|
p := PLookupListRec(FList[i]);
|
||||||
|
AStrings.AddObject(p^.Value, TObject(p));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure DisposeMem(var Buffer; Size: Integer);
|
procedure DisposeMem(var Buffer; Size: Integer);
|
||||||
begin
|
begin
|
||||||
if Pointer(Buffer) <> nil then
|
if Pointer(Buffer) <> nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user