Advertisement
Guest User

Untitled

a guest
Sep 7th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.70 KB | None | 0 0
  1. Procedure QuickSort(FList: PPointerList; L, R : Longint;Compare: TListSortCompare);
  2. var
  3.   I, J, P: Longint;
  4.   PItem, Q : Pointer;
  5. begin
  6.  repeat
  7.    I := L;
  8.    J := R;
  9.    P := (L + R) div 2;
  10.    repeat
  11.      PItem := FList^[P];
  12.      while Compare(PItem, FList^[i]) > 0 do
  13.        I := I + 1;
  14.      while Compare(PItem, FList^[J]) < 0 do
  15.        J := J - 1;
  16.      If I <= J then
  17.      begin
  18.        Q := FList^[I];
  19.        Flist^[I] := FList^[J];
  20.        FList^[J] := Q;
  21.        if P = I then
  22.         P := J
  23.        else if P = J then
  24.         P := I;
  25.        I := I + 1;
  26.        J := J - 1;
  27.      end;
  28.    until I > J;
  29.    if L < J then
  30.      QuickSort(FList, L, J, Compare);
  31.    L := I;
  32.  until I >= R;
  33. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement