mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 15:00:16 +02:00
* TryGetValue, patch by Denis Volodarsky, mantis #24378
git-svn-id: trunk@24428 -
This commit is contained in:
parent
ce6c393ce2
commit
a98ba0287d
@ -63,6 +63,7 @@ type
|
|||||||
function FindGreater(key:TKey):TIterator;inline;
|
function FindGreater(key:TKey):TIterator;inline;
|
||||||
function FindGreaterEqual(key:TKey):TIterator;inline;
|
function FindGreaterEqual(key:TKey):TIterator;inline;
|
||||||
function GetValue(key:TKey):TValue;inline;
|
function GetValue(key:TKey):TValue;inline;
|
||||||
|
function TryGetValue(key:TKey; out Value: TValue): boolean;inline;
|
||||||
procedure Insert(key:TKey; value:TValue);inline;
|
procedure Insert(key:TKey; value:TValue);inline;
|
||||||
function InsertAndGetIterator(key:TKey; value:TValue):TIterator;inline;
|
function InsertAndGetIterator(key:TKey; value:TValue):TIterator;inline;
|
||||||
function Min:TIterator;inline;
|
function Min:TIterator;inline;
|
||||||
@ -166,6 +167,17 @@ begin
|
|||||||
GetValue:=FSet.NFind(Pair)^.Data.Value;
|
GetValue:=FSet.NFind(Pair)^.Data.Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMap.TryGetValue(key: TKey; out Value: TValue): boolean;
|
||||||
|
var Pair:TPair;
|
||||||
|
Node: TMSet.PNode;
|
||||||
|
begin
|
||||||
|
Pair.Key:=key;
|
||||||
|
Node := FSet.NFind(Pair);
|
||||||
|
Result := Node <> nil;
|
||||||
|
if Result then
|
||||||
|
Value := Node^.Data.Value;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMap.Insert(key:TKey; value:TValue);inline;
|
procedure TMap.Insert(key:TKey; value:TValue);inline;
|
||||||
var Pair:TPair;
|
var Pair:TPair;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user