Hallo,
eine kleine Testprozedur:
TStringList.Exchange : 0ms
ListBox1.items.Exchange: 1060ms
Listbox über TStringList mischen: 109ms
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
sl: TStringList;
i : Integer;
start : TDateTime;
begin
sl := TStringList.create;
for i:=0 to 9999 do
sl.add(intToStr(i));
ListBox1.Items.Assign(sl);
// durchwürfeln
start := now;
for i:=sl.count -1 downto (sl.count - 1) div 2 do
sl.Exchange(i,random(sl.count));
showMessage('TStringList.Exchange: '+IntToStr(MilliSecondsBetween(now,start)));
ListBox1.Items.BeginUpdate;
start := now;
for i:= ListBox1.Items.Count -1 downto (ListBox1.Items.Count -1) div 2 do
ListBox1.Items.Exchange(i,random(ListBox1.Items.count));
showMessage('TListBox.items.Exchange: '+IntToStr(MilliSecondsBetween(now,start)));
ListBox1.Items.EndUpdate;
start := now;
sl.Assign(ListBox1.items);
for i:=sl.count -1 downto (sl.count - 1) div 2 do
sl.Exchange(i,random(sl.count));
ListBox1.Items.Assign(sl);
showMessage('TListBox über StringList.exchange: '+IntToStr(MilliSecondsBetween(now,start)));
sl.free;
end;
Grüße
Klaus