mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 09:10:25 +02:00
* Added AddReplacesExisting
git-svn-id: trunk@26728 -
This commit is contained in:
parent
b7c6455b89
commit
4490a61981
@ -61,6 +61,7 @@ type
|
||||
|
||||
TStringHash = class
|
||||
private
|
||||
FAddReplacesExisting: Boolean;
|
||||
FHashList : TFPDataHashTable;
|
||||
public
|
||||
constructor Create(ACapacity : Cardinal = 256);
|
||||
@ -70,6 +71,7 @@ type
|
||||
function Modify(const Key: string; Value: Integer): Boolean;
|
||||
procedure Remove(const Key: string);
|
||||
function ValueOf(const Key: string): Integer;
|
||||
Property AddReplacesExisting : Boolean Read FAddReplacesExisting Write FAddReplacesExisting;
|
||||
end;
|
||||
|
||||
{ THashedStringList }
|
||||
@ -262,7 +264,8 @@ end;
|
||||
|
||||
procedure TStringHash.Add(const Key: string; Value: Integer);
|
||||
begin
|
||||
FHashList.Add(Key, Pointer(Value));
|
||||
if Not (AddReplacesExisting and Modify(Key,Value)) then
|
||||
FHashList.Add(Key, Pointer(Value));
|
||||
end;
|
||||
|
||||
procedure TStringHash.Clear;
|
||||
|
Loading…
Reference in New Issue
Block a user