![]() |
Re: problem mit Stringlist, test auf vorhandensein einer phr
Zitat:
Delphi-Quellcode:
marabu
const
IMAX = 10000; procedure TDemoForm.MarabuClick(Sender: TObject); var i: Integer; s: String; tc: Cardinal; sl: TStringList; begin sl := TSTringList.Create; sl.Sorted := true; sl.Duplicates := dupIgnore; tc := GetTickCount; for i := 1 to IMAX do begin s := RandomStr(3); sl.Add(s); end; tc := GetTickCount - tc; ShowMessage(Format('%d dupes, %d ticks', [IMAX - sl.Count, tc])); sl.Free; end; procedure TDemoForm.RichardClick(Sender: TObject); var i: Integer; s: String; tc: Cardinal; sl: TStringList; begin sl := TSTringList.Create; sl.Sorted := true; tc := GetTickCount; for i := 1 to IMAX do begin s := RandomStr(3); if sl.IndexOf(s) = -1 then sl.Add(s); end; tc := GetTickCount - tc; ShowMessage(Format('%d dupes, %d ticks', [IMAX - sl.Count, tc])); sl.Free; end; |
Re: problem mit Stringlist, test auf vorhandensein einer phr
Wo ist RandomStr deklariert? Ich finde das in meiner OH nicht.
|
Re: problem mit Stringlist, test auf vorhandensein einer phr
Das nenne ich einen aufmerksamen Leser. Hier hast du:
Delphi-Quellcode:
marabu
function RandomStr(size: integer): string;
var i: integer; begin SetLength(Result, size); for i := 1 to Length(Result) do Result[i] := Chr(Ord('A') + Random(26)); end; |
Re: problem mit Stringlist, test auf vorhandensein einer phr
Zitat:
Danke ;) |
Re: problem mit Stringlist, test auf vorhandensein einer phr
@marabu
*zitat* bitte nur eine ja / nein antwort *zitat ende* beachte bitte den smiley dahinter gg danke dir fuer deine ausfuehrungen. dein besipiel werd ich mal genau unter die lupe nehmen. gruß richard :D //edit warum willst du die liste eigentlich unbedingt sortieren? wobei mir auffaellt das deine RandomStr routine, wesentlich mehr unterschiedliche strings liefert als gleiche |
Re: problem mit Stringlist, test auf vorhandensein einer phr
Hallo Richard.
Zitat:
Zitat:
Zitat:
marabu |
Re: problem mit Stringlist, test auf vorhandensein einer phr
ok marabu,
du hast mich ueberzeugt. hab mir grad deinen code angeschaut und ausprobiert. ich versteh zwar nich genau was binaery suche bedeutet und warum es schneller ist, aber egal. die zahlen luegen ja nich. danke dir nochmal fuer deine hilfe :) gruß richard |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:42 Uhr. |
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 by Thomas Breitkreuz