Skip to main content

TDuplicates

TDuplicates = (dupIgnore, dupAccept, dupError)

Example​

procedure ConfigureNames(Names: TStringList);
begin
Names.Sorted := True;
Names.Duplicates := dupError;
end;

Usage​

TDuplicates controls whether a sorted string list ignores, accepts or rejects a value that compares equal to an existing item.

Members​

ValueOrdinalMeaning
dupIgnore0Leave the existing equal entry in place and do not add the new duplicate.
dupAccept1Insert the new entry even when an equal entry already exists.
dupError2Raise a duplicate-string/list exception instead of inserting.

Behavior and boundaries​

  • Set Sorted and Duplicates before populating the list so every insertion follows one policy.
  • On Velox TStringList, duplicate policy is meaningful for sorted insertion. An unsorted list can retain duplicates regardless of this setting.
  • dupIgnore can hide an attempted update if the caller expected the new entry or its associated object to replace the old entry.
  • dupError is the safest validation policy when duplicate input indicates malformed configuration, but callers must handle the exception and preserve partial-list state.

Additional Technical Info​

TDuplicates controls duplicate insertion policy for sorted list implementations such as TStringList. Equality follows the list's active comparison rules, including CaseSensitive; it is not necessarily byte-for-byte text identity.

The policy is consulted while a sorted list inserts a value. It does not retroactively scan or remove entries that were present before the policy changed.

Related Code Library entries

External references

Created 2026-07-15