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
| Value | Ordinal | Meaning |
|---|---|---|
dupIgnore | 0 | Leave the existing equal entry in place and do not add the new duplicate. |
dupAccept | 1 | Insert the new entry even when an equal entry already exists. |
dupError | 2 | Raise a duplicate-string/list exception instead of inserting. |
Behavior and boundaries
- Set
SortedandDuplicatesbefore 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. dupIgnorecan hide an attempted update if the caller expected the new entry or its associated object to replace the old entry.dupErroris 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
- TStringList.Duplicates - exact property behavior.
- TStringList.Sorted - sorting prerequisite and reordering effects.
- TStringList - list ownership and comparison context.
External references
- Embarcadero TDuplicates - Delphi duplicate-policy definitions.
- Free Pascal TDuplicates - compatible string-list duplicate type.
- Embarcadero enumerated types - Delphi ordinal and enumeration semantics.
- Free Pascal ordinal types - compatible enumeration and ordinal concepts.