|
@@ -305,6 +305,7 @@ type
|
|
|
function Add(const AKey: TKey; const AData: TData): 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 TryGetValue(const AKey: TKey; out AData: TData): Boolean; {$ifdef CLASSESINLINE} inline; {$endif}
|
|
|
function IndexOf(const AKey: TKey): Integer; {$ifdef CLASSESINLINE} inline; {$endif}
|
|
|
function IndexOfData(const AData: TData): Integer;
|
|
|
procedure InsertKey(Index: Integer; const AKey: TKey);
|
|
@@ -1481,6 +1482,17 @@ begin
|
|
|
Result := inherited Find(@AKey, Index);
|
|
|
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;
|
|
|
begin
|
|
|
Result := inherited IndexOf(@AKey);
|