Thema: Delphi Stringliste Umkehren

Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.768 Beiträge
 
Delphi 10.4 Sydney
 
#9

Re: Stringliste Umkehren

  Alt 14. Mär 2008, 14:46
.. ist denn TStringList.exchange nicht ehr für soetwas gut?

Delphi-Quellcode:
j:=0;
for i:=daten.count -1 downto (daten.count -1) div 2 do
  begin
    daten.exchange(i,j);
    inc(j);
  end;
[ungetestet)

Aus der Hilfe zu Exchange:
Swaps the position of two strings in the list.

procedure Exchange(Index1, Index2: Integer); override;

Description

Call Exchange to rearrange the strings in the list. The strings are specified by their index values in the Index1 and Index2 parameters. Indexes are zero-based, so the first string in the list has an index value of 0, the second has an index value of 1, and so on.

If either string has an associated object, Exchange changes the index of the object as well.

Warning: Do not call Exchange on a sorted list except to swap two identical strings with different associated objects. Exchange does not check whether the list is sorted, and can destroy the sort order of a sorted list.


Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat