AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Stringliste Umkehren

Ein Thema von simon790 · begonnen am 14. Mär 2008 · letzter Beitrag vom 30. Jan 2023
Antwort Antwort
Seite 4 von 4   « Erste     234   
waterboy

Registriert seit: 9. Jan 2023
4 Beiträge
 
#31

AW: Re: Stringliste Umkehren

  Alt 28. Jan 2023, 16:51
.. 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
  Mit Zitat antworten Zitat
freimatz

Registriert seit: 20. Mai 2010
1.380 Beiträge
 
Delphi 11 Alexandria
 
#32

AW: Re: Stringliste Umkehren

  Alt 30. Jan 2023, 12:09
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.

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?
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 4 von 4   « Erste     234   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz