Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Stringliste Umkehren (https://www.delphipraxis.net/110189-stringliste-umkehren.html)

waterboy 28. Jan 2023 16:51

AW: Re: Stringliste Umkehren
 
Zitat:

Zitat von Klaus01 (Beitrag 750641)
.. 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

Super, klasse. Funktioniert einwandfrei. Vielen Dank, Klaus.
Warum es keine direkt Funktion in Delphi gibt (wie in Python z.B.) verstehe ich nicht...

viele Grüße

rainer

freimatz 30. Jan 2023 12:09

AW: Re: Stringliste Umkehren
 
Zitat:

Zitat von waterboy (Beitrag 1518013)
Warum es keine direkt Funktion in Delphi gibt (wie in Python z.B.) verstehe ich nicht...

Ich schon. Vermutlich weil es nur Dinge gibt die man auch braucht. :twisted:

Natürlich wird das Umkehren einer Liste schon benötigt. Aber meistens sind es dann nicht einfache Listen sondern gleiche komplexere Datensätze die man in einem Grid hat und dann oft auch nach allen Spalten sortieren lassen kann.

Wofür brauchst Du denn das?


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:10 Uhr.
Seite 4 von 4   « Erste     234   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz