added funct to eliminate dups in TStrings

This commit is contained in:
Basile Burg 2015-09-07 12:12:46 +02:00
parent 4555d43bd3
commit 0aaebbb4e7
1 changed files with 17 additions and 0 deletions

View File

@ -230,6 +230,10 @@ type
*)
function isStringDisabled(const str: string): boolean;
(**
* Deletes the duplicates in a TStrings instance.
*)
procedure deleteDups(str: TStrings);
implementation
@ -1050,6 +1054,19 @@ begin
result := true;
end;
procedure deleteDups(str: TStrings);
var
i: integer;
begin
{$HINTS OFF}
if str = nil then exit;
for i:= str.Count-1 downto 0 do
// if less than 0 -> not found -> unsigned -> greater than current index.
if cardinal(str.IndexOf(str.Strings[i])) < i then
str.Delete(i);
{$HINTS ON}
end;
initialization
registerClasses([TCEPersistentShortcut]);
end.