Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 01.03.06 19:38 
Ich habe eine Klasse TGraph, in der befindet sich ein array of Tpoint names points, jetzt möchte ich dieses array per mergesort nach den x werten sortieren, jedoch bekomme ich eine ungültige zeigeroperation, was stimmt nicht ?
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
procedure TGraph.Sort;
  procedure MergeSort(l, r: integer);
  var
    x, y, z, mid: integer;
    iarr: array of TPoint;
  begin
    SetLength(iarr, r);
    if (r - l > 0then
    begin
      mid := (r + l) div 2 ;
      MergeSort(l, mid);
      MergeSort(mid + 1, r);
      for x := mid downto l do
        iarr[x] := points[x];
      for y := mid + 1 to r do
        iarr[r + mid + 1 - y] := points[y];
      x := l;
      y := r;
      for z := l to r do
      begin
        if iarr[x].x < iarr[y].x then
        begin
          points[z] := iarr[x];
          inc(x);
        end else
        begin
          points[z] := iarr[y];
          dec(y);
        end;
      end;
    end
  end;
begin
  MergeSort(0, high(points));
end;

Vielen Dank schonmal ;)
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 03.03.06 19:07 
*push* (ich darf doch oder ^^)

also jemand ne idee ?