Difference between revisions of "SortATPAByMiddleEx"
From SCAR Divi Manual
Line 8: | Line 8: | ||
==Description== | ==Description== | ||
− | Sorts the given [[T2DPointArray]] '''ATPA''' by the distance of the middle of the points calculated with [[TPAMiddle]] to the [[TPoint]] given in '''Point''' using the fast [http://en.wikipedia.org/wiki/Shell_sort ShellSort] algorithm. | + | Sorts the given [[T2DPointArray]] '''ATPA''' by the distance of the middle of the points of every non-empty subarray calculated with [[TPAMiddle]] to the [[TPoint]] given in '''Point''' using the fast [http://en.wikipedia.org/wiki/Shell_sort ShellSort] algorithm. Empty subarrays are placed at the start of the array. |
==Example== | ==Example== | ||
Line 17: | Line 17: | ||
begin | begin | ||
− | SetLength(ATPA, | + | SetLength(ATPA, 4); |
ATPA[0] := [Point(1, 6), Point(5, 4), Point(1, 5)]; | ATPA[0] := [Point(1, 6), Point(5, 4), Point(1, 5)]; | ||
ATPA[1] := [Point(1, 1), Point(2, 2)]; | ATPA[1] := [Point(1, 1), Point(2, 2)]; | ||
− | ATPA[2] := [Point(5, 10)]; | + | ATPA[2] := []; |
+ | ATPA[3] := [Point(5, 10)]; | ||
SortATPAByMiddleEx(ATPA, Point(5, 5)); | SortATPAByMiddleEx(ATPA, Point(5, 5)); | ||
for i := 0 to High(ATPA) do | for i := 0 to High(ATPA) do | ||
Line 28: | Line 29: | ||
Output: | Output: | ||
+ | |||
(1,6);(5,4);(1,5) | (1,6);(5,4);(1,5) | ||
(5,10) | (5,10) |
Revision as of 10:03, 24 October 2011
Definition
procedure SortATPAByMiddleEx(var ATPA: T2DPointArray; const Point: TPoint);
Availability
SCAR Divi 3.28 > Current
Description
Sorts the given T2DPointArray ATPA by the distance of the middle of the points of every non-empty subarray calculated with TPAMiddle to the TPoint given in Point using the fast ShellSort algorithm. Empty subarrays are placed at the start of the array.
Example
var ATPA: T2DPointArray; i: Integer; begin SetLength(ATPA, 4); ATPA[0] := [Point(1, 6), Point(5, 4), Point(1, 5)]; ATPA[1] := [Point(1, 1), Point(2, 2)]; ATPA[2] := []; ATPA[3] := [Point(5, 10)]; SortATPAByMiddleEx(ATPA, Point(5, 5)); for i := 0 to High(ATPA) do WriteLn(TPAToStr(ATPA[i])); end.
Output:
(1,6);(5,4);(1,5) (5,10) (1,1);(2,2)