From 0aaebbb4e75e37222e265df488add27dfe26a239 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 7 Sep 2015 12:12:46 +0200 Subject: [PATCH] added funct to eliminate dups in TStrings --- src/ce_common.pas | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ce_common.pas b/src/ce_common.pas index 0bd0e4c6..deaaa488 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -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.