mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 23:06:07 +02:00
* Patch from Silvio Clecio to add a TryGetValue method to TFPGMap (bug ID 29397)
git-svn-id: trunk@32942 -
This commit is contained in:
parent
b96d3cc517
commit
64c324caaf
@ -305,6 +305,7 @@ type
|
|||||||
function Add(const AKey: TKey; const AData: TData): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
function Add(const AKey: TKey; const AData: TData): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
||||||
function Add(const AKey: TKey): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
function Add(const AKey: TKey): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
||||||
function Find(const AKey: TKey; out Index: Integer): Boolean; {$ifdef CLASSESINLINE} inline; {$endif}
|
function Find(const AKey: TKey; out Index: Integer): Boolean; {$ifdef CLASSESINLINE} inline; {$endif}
|
||||||
|
function TryGetValue(const AKey: TKey; out AData: TData): Boolean; {$ifdef CLASSESINLINE} inline; {$endif}
|
||||||
function IndexOf(const AKey: TKey): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
function IndexOf(const AKey: TKey): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
||||||
function IndexOfData(const AData: TData): Integer;
|
function IndexOfData(const AData: TData): Integer;
|
||||||
procedure InsertKey(Index: Integer; const AKey: TKey);
|
procedure InsertKey(Index: Integer; const AKey: TKey);
|
||||||
@ -1481,6 +1482,17 @@ begin
|
|||||||
Result := inherited Find(@AKey, Index);
|
Result := inherited Find(@AKey, Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFPGMap.TryGetValue(const AKey: TKey; out AData: TData): Boolean;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := inherited Find(@AKey, I);
|
||||||
|
if Result then
|
||||||
|
AData := TData(inherited GetData(I)^)
|
||||||
|
else
|
||||||
|
AData := Default(TData);
|
||||||
|
end;
|
||||||
|
|
||||||
function TFPGMap.IndexOf(const AKey: TKey): Integer;
|
function TFPGMap.IndexOf(const AKey: TKey): Integer;
|
||||||
begin
|
begin
|
||||||
Result := inherited IndexOf(@AKey);
|
Result := inherited IndexOf(@AKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user