mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 01:10:22 +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
|
TStringHash = class
|
||||||
private
|
private
|
||||||
|
FAddReplacesExisting: Boolean;
|
||||||
FHashList : TFPDataHashTable;
|
FHashList : TFPDataHashTable;
|
||||||
public
|
public
|
||||||
constructor Create(ACapacity : Cardinal = 256);
|
constructor Create(ACapacity : Cardinal = 256);
|
||||||
@ -70,6 +71,7 @@ type
|
|||||||
function Modify(const Key: string; Value: Integer): Boolean;
|
function Modify(const Key: string; Value: Integer): Boolean;
|
||||||
procedure Remove(const Key: string);
|
procedure Remove(const Key: string);
|
||||||
function ValueOf(const Key: string): Integer;
|
function ValueOf(const Key: string): Integer;
|
||||||
|
Property AddReplacesExisting : Boolean Read FAddReplacesExisting Write FAddReplacesExisting;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ THashedStringList }
|
{ THashedStringList }
|
||||||
@ -262,7 +264,8 @@ end;
|
|||||||
|
|
||||||
procedure TStringHash.Add(const Key: string; Value: Integer);
|
procedure TStringHash.Add(const Key: string; Value: Integer);
|
||||||
begin
|
begin
|
||||||
FHashList.Add(Key, Pointer(Value));
|
if Not (AddReplacesExisting and Modify(Key,Value)) then
|
||||||
|
FHashList.Add(Key, Pointer(Value));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TStringHash.Clear;
|
procedure TStringHash.Clear;
|
||||||
|
Loading…
Reference in New Issue
Block a user