Class TSorArray (unit mwSArray) |
Inherits from
TObject
TSorArray class
function Add(Item: Pointer): Integer;
procedure Clear;
procedure CombSortW(SorCompare: TSortArrayCompare);
Driver for the " Comb " routine.
destructor Destroy;
Create } { TSorArray
function Last: Pointer;
procedure MergeSort(SorCompare: TSortArrayCompare);
Non-recursive Mergesort.
procedure QuickSort(SorCompare: TSortArrayCompare);
Based on a non-recursive QuickSort from the SWAG-Archive.
function Comb(jumpsize0: Integer; SorCompare: TSortArrayCompare): boolean;
Multipication by 0.
function Get(Index: Integer): Pointer;
procedure Merge(SorCompare: TSortArrayCompare);
Unfortunately the " Merge " routine needs additional memory
An Algorithm to perform merging in linear time without extra space
is described in:
B.
procedure Put(Index: Integer; Item: Pointer);
procedure Expand;
procedure SetCapacity(NewCapacity:Integer);
property Capacity : Integer
property Count : Integer
property Items : Pointer
property SorArray : PDynArray
fCapacity : Integer;
FCount : Integer;
FLeftArray : TSubArray;
FRightArray : TSubArray;
FSorArray : PDynArray;
SwapArray : PDynArray;
TempArray : PDynArray;
function Add(Item: Pointer): Integer;
procedure Clear;
procedure CombSortW(SorCompare: TSortArrayCompare);
Driver for the " Comb " routine.
Based on routines from the SWAG-Archive.
Very fast, for a smaller number of items with large keys
" Comb " may outperform Quicksort.
( Only a few thousends
destructor Destroy;
Create } { TSorArray
function Last: Pointer;
procedure MergeSort(SorCompare: TSortArrayCompare);
Non-recursive Mergesort.
Very fast, if enough memory available.
The number of comparisions used is nearly optimal, about 3/4 of QuickSort.
If comparision plays a very more important role than exchangement,
it outperforms QuickSort in any case.
( Large keys in pointer arrays, for example text with few short lines. )
From all Algoritms with O(N lg N) it's the only stable, meaning it lefts
equal keys in the order of input. This may be important in some cases.
procedure QuickSort(SorCompare: TSortArrayCompare);
Based on a non-recursive QuickSort from the SWAG-Archive.
( TV Sorting Unit by Brad Williams )
function Comb(jumpsize0: Integer; SorCompare: TSortArrayCompare): boolean;
Multipication by 0.76 gives a slightly better result than
division by 1.3.
Because of the FOR loop it runs faster on arrays starting with one
function Get(Index: Integer): Pointer;
procedure Merge(SorCompare: TSortArrayCompare);
Unfortunately the " Merge " routine needs additional memory
An Algorithm to perform merging in linear time without extra space
is described in:
B. Huang and M. Langston, " Practical In-place Merging ",
Communications of the ACM 31(1988), 348-352.
procedure Put(Index: Integer; Item: Pointer);
procedure Expand;
procedure SetCapacity(NewCapacity:Integer);
property Capacity : Integer
property Count : Integer
property Items : Pointer
property SorArray : PDynArray
fCapacity : Integer;
FCount : Integer;
FLeftArray : TSubArray;
FRightArray : TSubArray;
FSorArray : PDynArray;
SwapArray : PDynArray;
TempArray : PDynArray;