type TSubstringListInvariant = class(TSubstringList)
TSubstringList comparing items with case ignored by the operating system's uppercase table, unless CaseSensitive is True.
The operating system uppercase table is the same for every "locale". When case insensitivity is required, the sorting can be 30x slower than with TSubstringList. The operating system uppercase table is capable of upper-case/lower-case round-trip.
Examples
Accented letters in either case.
delphi
uses Substr;
procedure Example;
var List: TSubstringListInvariant;
begin
List := TSubstringListInvariant.Create(2);
try
List.Add(#$C9'clair');
Assert(List.IndexOf(#$E9'CLAIR') = 0);
finally
List.Free;
end;
end;
Constructors
| Name | Description |
|---|---|
| Create (6) | An empty list with Capacity 128, case ignored by the operating system's table. |
Properties
| Name | Type | Description |
|---|---|---|
| Capacity | Integer | The number of items the list holds without growing: a multiple of 128, at least 128. |
| CaseSensitive | Boolean | Whether comparisons tell upper from lower case; False ignores it by the operating system's table. A sorted list is sorted again when it changes. |
| ChunkSize | Integer | The size of the pieces a load or save converts: ChunkSize bytes read, or ChunkSize div 2 characters written; 128 KB by default. |
| CommaText | Substring | DelimitedText with Delimiter ',' and QuoteChar '"'. |
| Count | Integer | The number of items. Setting it higher adds empty items, lower deletes the last ones. |
| DefaultEncoding | TEncoding | The encoding of a load given none whose stream has no byte order mark, and of a save before any load; TEncoding.Default at first. |
| DelimitedText | Substring | The items joined by Delimiter, each quoted by QuoteChar where it holds QuoteChar, Delimiter or, without StrictDelimiter, a character up to the space. |
| Delimiter | Char | The delimiter of DelimitedText; ',' by default. |
| Duplicates | TDuplicates | What a sorted list's Add does with a text equal to an item: dupIgnore, dupAccept or dupError. |
| Encoding | TEncoding | The encoding of the last load: the one its byte order mark named, else the one it was given, else DefaultEncoding; nil before the first load. SaveToFile and SaveToStream without an encoding write in it. |
| Items | PSubstring | Item Index (0..Count - 1) itself: every Substring member works on it in place. |
| LineBreak | string | The line break of Text; sLineBreak by default. |
| Objects | TObject | The object of item Index. |
| OwnsObjects | Boolean | Whether deleting an item, Clear and Free free the items' objects. |
| QuoteChar | Char | The quote of DelimitedText; '"' by default; #0 quotes nothing. |
| Sorted | Boolean | Whether Add places each text at its sorted place; setting it True sorts the list. |
| StrictDelimiter | Boolean | Whether only Delimiter separates the fields of DelimitedText; False by default, so the characters up to the space separate them too. |
| Strings | Substring | Item Index (0..Count - 1), read in place: no memory is taken and no character copied. |
| Text | Substring | The items as lines: each followed by LineBreak, the last one too while TrailingLineBreak is True. |
| TrailingLineBreak | Boolean | Whether Text ends with a LineBreak after the last item; True by default. |
| WriteBOM | Boolean | Whether a save writes the encoding's byte order mark first; True by default. |
Methods
| Name | Description |
|---|---|
| Add (2) | Adds S: at the end, or, in a sorted list, at its place. |
| AddObject | Adds S with the object AObject, as Add. |
| Clear | Deletes every item; the rows are kept, so the next adds take no memory. |
| Compact | Gives back the memory of the rows no item uses, and the memory loads and saves keep: Capacity becomes Count rounded up to a multiple of 128, at least 128, every item kept. |
| CustomSort | Sorts the list by Compare, stably; a sorted list is left as it is. |
| Delete | Deletes item Index; the later items move down by one. |
| DeleteRange | Deletes ACount items from Index, as TList<T>.DeleteRange. |
| Destroy | Frees the list's rows, and the items' objects when OwnsObjects is True. |
| Exchange | Swaps items Index1 and Index2. |
| Expand | Grows the list when every row is in use, keeping every item as Resize does, by half its capacity rounded up to a multiple of 128. |
| Extract | Removes the first item equal to S without freeing its object, and returns it. |
| ExtractItem | Extract from either end: the first (FromBeginning) or last (FromEnd) item equal to S. |
| Find | Searches a sorted list for S by bisection. |
| First | The first item. |
| GetEnumerator | The enumerator of for s in List. |
| IndexOf | The index of the first item equal to S, or -1. |
| IndexOfItem | IndexOf from either end: FromBeginning the first item equal to S, FromEnd the last; -1 when there is none. |
| IndexOfObject | The index of the first item whose object is AObject, or -1. |
| Insert | Inserts S at Index (0..Count); the later items move up by one. |
| InsertObject | Inserts S with the object AObject at Index, as Insert. |
| Last | The last item. |
| LoadFromFile (2) | Replaces the items with the lines of file FileName: LoadFromStream on the file, in the encoding its byte order mark names, else DefaultEncoding. |
| LoadFromStream (2) | Replaces the items with the lines of Stream from its position to its end, in the encoding its byte order mark names (UTF-8, UTF-16 or UTF-16 big-endian), else DefaultEncoding. |
| Move | Moves item CurIndex to NewIndex, the items between shifting by one. |
| Put | Writes S into item Index; S takes every text kind. |
| Remove | Deletes the first item equal to S. |
| RemoveItem | Deletes the first (FromBeginning) or last (FromEnd) item equal to S. |
| Resize | Sets Capacity to NewCapacity, any size, rounded up to a multiple of 128 and at least 128, keeping the items that fit; setting Capacity keeps none. |
| SaveToFile (2) | Writes Text to file FileName in Encoding (the encoding of the last load), else DefaultEncoding: SaveToStream on a new file. |
| SaveToStream (2) | Writes Text to Stream in Encoding (the encoding of the last load), else DefaultEncoding. |
| SetCommaText | Replaces the items by the fields of Value, delimited by a comma and quoted by a double quote; Value takes every text kind. |
| SetDelimitedText | Replaces the items by the fields of Value; Value takes every text kind. |
| SetText | Replaces the items by the lines of Value; Value takes every text kind. |
| Sort (2) | Sorts the list by its comparison, stably; a sorted list is left as it is. |
| SortAscend | Sort: ascending by the list's comparison. |
| SortDescend | Sorts descending by the list's comparison, stably; a sorted list is left as it is. |
| ToString | The items as one string: Text. |