Autor Beitrag
Aton
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 125

Windows XP
D7 Enterprise
BeitragVerfasst: Mo 26.04.04 07:51 
Hallo Forum,

ich möchte ein Array löschen:

ausblenden Delphi-Quelltext
1:
2:
3:
for x:=1 to 100 do
  for y:=1 to 100 do 
    Feld[x,y] := False;


Ich möchte dies optimieren, dass es schneller geht. Ich stelle mir dabei vor, bei Feld[1,1] anzufangen und einfach in den Speicher 10.000 (100*100) ein False (bzw. eine Null) zu schreiben. Leider habe ich keinen Plan, wie das gehen soll. Irgendwie mit Pointer, oder so?

ausblenden Delphi-Quelltext
1:
for i:=1 to 10000 do ???					


Danke für die Antwort,
Gruß Jens.


Zuletzt bearbeitet von Aton am Di 27.04.04 07:16, insgesamt 1-mal bearbeitet
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 26.04.04 08:21 
Hallo,

wie sieht Deine Array-Deklaration aus? Eine Möglichkeit das Array zu löschen wäre mit FillChar.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TMyArray=array[1..10000] of Boolean;

var myArr:TMyArray;
...
...
FillChar(myArr, SizeOf(TMyArray), False);
...
...

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Aton Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 125

Windows XP
D7 Enterprise
BeitragVerfasst: Mo 26.04.04 08:44 
Super, genau das habe ich gesucht. :lol:
Danke, Gruß Jens.
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Mo 26.04.04 16:00 
Und weil glaube ich ein False einer Null entspricht, kannste
alternative auch ZeroMemory benutzen...

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca
Aton Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 125

Windows XP
D7 Enterprise
BeitragVerfasst: Di 27.04.04 11:41 
Hey, schau mal, was ZeroMemory macht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
unit Windows;
...
procedure ZeroMemory(Destination: Pointer; Length: DWORD);
begin
  FillChar(Destination^, Length, 0);
end;


Gruß Jens.8)