Autor Beitrag
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 08.02.06 15:06 
Dieser Kot (!) soll eine stringlist (result = TString) auf doppelte Einträge überprüfen und diese ggf. löschen.
Die Procedure:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
repeat
For x := 0 to result.Count-1 do
  begin
  ende := true;
  result[x] := ansilowercase(result[x]);
  if schonda.IndexOf(result[x]) >= 0 then
    begin
    result.Delete(x);
    ende := false;
    break;
    end
    else
    begin
    schonda.Add(ansilowercase(result[x]));
    end;
  end;
until ende = true;
produziert mir dauerhaft 100% CPU-Last. Ich finde den Fehler nicht... Wahrscheinlich steh ich eh nur wieder auf der Leitung... :cry:
µaTh
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 08.02.06 15:13 
ich glaube indexOf fängt bei 1 an; wenn er nicht da, dann 0
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 08.02.06 15:14 
Count verändert sich ja immer in der Schleife.
Deshalb:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
x := 0;
while x < result.Count do
begin
   result[x] := ansilowercase(result[x]);
   if schonda.IndexOf(result[x]) >= 0 then  
      result.Delete(x)
   else
   begin
      schonda.Add(ansilowercase(result[x])); 
      inc(x);
   end;
end;

Beste Grüße
Tastaro
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 08.02.06 15:18 
Prima funzt.
Dass sich count verändert ist ja klar, das hab ich ja - wenn auch umständlich - mit dem break; und der repaet versucht zu lösen...
egal, danke nochmals :oops: