Autor Beitrag
Arne
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mo 17.11.08 09:27 
Moin zusammen,

die Suche hat nix erbracht und die online-Hilfe von D2007 hält sich zu dem Thema bedeckt:

Wie kann ich bei einem mehrdimesionalen Array die Funktionen Low() und High() auf die einzelnen Dimensionen anwenden? Wie sage ich den o.g. Funktionen von welcher Dimension ich gerne die Grenzen haben möchte?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  myIndexX, myIndexY : Integer;
  myArray            : array[0..30..15of Byte;
begin
  for myIndexX := Low(myArray) to High(myArray) do begin
    for myIndexY := Low(myArray) to High(myArray) do begin
    ...
    end;
  end;
end;

Wie lasse ich also myIndexX von 0..3 laufen und myIndexY von 0..15? oder geht das mit Low() / High() gar nicht?

thanx, Arne
ene
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Mo 17.11.08 09:33 
Müsste doch eigentlich so gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  myIndexX, myIndexY : Integer;
  myArray            : array[0..30..15of Byte;
begin
  for myIndexX := Low(myArray) to High(myArray) do begin
    for myIndexY := Low(myArray[myIndexX]) to High(myArray[myIndexX]) do begin
    ...
    end;
  end;
end;

_________________
Wir, die guten Willens sind, geführt von Ahnungslosen, Versuchen für die Undankbaren das Unmögliche zu vollbringen.
Wir haben soviel mit so wenig so lange versucht, daß wir jetzt qualifiziert sind, fast alles mit Nichts zu bewerkstelligen.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 17.11.08 14:31 
Low \ High arbeiten immer auf dem äußerten Array was ihnen übergeben wird. Somit liefert High(Arr) die Größe des äußerten Arrays, High(Arr[0]) die Anzahl der Arrayelemente des Arrays vom 0. Eintrag in Arr und so weiter.

WENN man rechteckige Arrays hat UND jede Ebene immer gleich viele Einträge hat, kann man statt MyIndex auch 0 übergeben, was etwas mehr Performance liefert. Ansonsten ist die Lösung von user profile iconene die allgemeingültige.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 17.11.08 18:16 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
WENN man rechteckige Arrays.

Mal so am Rande: Was sind denn bitte rechteckige Arrays?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 17.11.08 18:38 
Ich denke, er meint zweidimensionale, weil die halt "aussehen", wie ein Rechteck.

_________________
PROGRAMMER: A device for converting coffee into software.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 17.11.08 18:45 
user profile iconmatze hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
WENN man rechteckige Arrays.

Mal so am Rande: Was sind denn bitte rechteckige Arrays?


Darf ich ich mit einem Nicht-Rechteckigen Array antworten?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var nonrectangular_array: array of array of Foo; bar: Integer;
const baz = 42;
begin
    SetLength(nonrectangular_array, Baz);
    for Bar := 0 to Baz - 1 do
        SetLength(nonrectangular_array[Bar], Bar + 1);
end;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 17.11.08 19:27 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
WENN man rechteckige Arrays hat UND jede Ebene immer gleich viele Einträge hat

Wenn ich das mit rechteckigen Arras jetzt richtig verstanden habe, sind die beiden Bedingungen doch immer gleich - ein rechteckiges Array hat doch immer in jeder Ebene gleich viele Einträge. :gruebel:
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Mo 17.11.08 20:07 
Der Vorteil von "rechteckigen" Arrays ist das man einmalig low(Array) und high(Array) Variablen zu ordnen kann und dan diese verwenden kann.
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 17.11.08 22:31 
Ihr meint quadratisch, nicht rechteckig...

ausblenden Delphi-Quelltext
1:
2:
var only_rectangular_array: array [1..10of array [1..18of Integer;
var quadratic_array: array [1..10of array [1..10of Integer;

Und wenn das zweite der Fall ist, dann kann man halt nur einmal High(quadratic_array); speichern und damit dann alle ebenen durchgehen...

Rechteck ist vieles...
Quadrat beschränkt sich da schon ziemlich...

_________________
1405006117752879898543142606244511569936384000000000.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 17.11.08 22:34 
user profile iconWolle92 hat folgendes geschrieben Zum zitierten Posting springen:
Ihr meint quadratisch, nicht rechteckig...

ausblenden Delphi-Quelltext
1:
2:
var only_rectangular_array: array [1..10of array [1..18of Integer;
var quadratic_array: array [1..10of array [1..10of Integer;

Und wenn das zweite der Fall ist, dann kann man halt nur einmal High(quadratic_array); speichern und damit dann alle ebenen durchgehen...

Ich meine nicht-rechteckig ;-) Um genau zu sein, war mein Array dreieckig ;-)

user profile iconWolle92 hat folgendes geschrieben Zum zitierten Posting springen:
Rechteck ist vieles...
Quadrat beschränkt sich da schon ziemlich...

Und nicht-rechteckig noch viel mehr ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ene
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Di 18.11.08 08:18 
Weil Worte..
Einloggen, um Attachments anzusehen!
_________________
Wir, die guten Willens sind, geführt von Ahnungslosen, Versuchen für die Undankbaren das Unmögliche zu vollbringen.
Wir haben soviel mit so wenig so lange versucht, daß wir jetzt qualifiziert sind, fast alles mit Nichts zu bewerkstelligen.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Di 18.11.08 08:30 
Oder, vom Bauchgefühl her:
Ritter-Sport = Quadratisch
Alpia = Rechteckig
Von ein paar Duplo abgebissen und übereinandergelegt = Nichtgeometrisch
Von ein paar Duplo abgebissen, der Länge nach sortiert und übereinandergelegt = Rautenförmig

usw.

_________________
Na denn, dann. Bis dann, denn.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 18.11.08 10:06 
user profile iconalzaimar hat folgendes geschrieben Zum zitierten Posting springen:
Oder, vom Bauchgefühl her:
Ritter-Sport = Quadratisch
Alpia = Rechteckig
Von ein paar Duplo abgebissen und übereinandergelegt = Nichtgeometrisch
Von ein paar Duplo abgebissen, der Länge nach sortiert und übereinandergelegt = Rautenförmig

Ich finde diesen Vergleich wunderbar. Damit habe auch ich es verstanden! Ich hätte mir nur etwas kalorienärmeres gewünscht!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
ene
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Di 18.11.08 10:32 
Rechteckig ist Knäckebrot, Quadratisch ist der Kraftklotz (heißt bei uns so).
Nichtgeometrisch sind dann angebissene Knäckebrote...nur fürs Dosenbrot fehlt mir der Verlgeich.

_________________
Wir, die guten Willens sind, geführt von Ahnungslosen, Versuchen für die Undankbaren das Unmögliche zu vollbringen.
Wir haben soviel mit so wenig so lange versucht, daß wir jetzt qualifiziert sind, fast alles mit Nichts zu bewerkstelligen.
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Di 18.11.08 14:40 
user profile iconene hat folgendes geschrieben Zum zitierten Posting springen:
Rechteckig ist Knäckebrot, Quadratisch ist der Kraftklotz (heißt bei uns so).
Nichtgeometrisch sind dann angebissene Knäckebrote...nur fürs Dosenbrot fehlt mir der Verlgeich.



Vorschlag: Dosenbrot=ein in einer Datenstruktur gekapseltes Array. (z.B. Tlist)
Arne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 19.11.08 07:41 
user profile iconene hat folgendes geschrieben Zum zitierten Posting springen:
Müsste doch eigentlich so gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  myIndexX, myIndexY : Integer;
  myArray            : array[0..30..15of Byte;
begin
  for myIndexX := Low(myArray) to High(myArray) do begin
    for myIndexY := Low(myArray[myIndexX]) to High(myArray[myIndexX]) do begin
    ...
    end;
  end;
end;


Danke, genau so gehts auch. Schade, dass sowas nicht in der Onlinehilfe steht.
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mi 19.11.08 17:01 
weils in der Onlinehilfe nicht alles gibt...

Und sowas ist halt etwas, was man sich selbst ausdenken muss, wenn alles in Bausteinen in der Onlinehilfe stünde, dann müssten Programmierer ja nichts mehr selbst machen...

_________________
1405006117752879898543142606244511569936384000000000.