Conditional function
This commit is contained in:
parent
1318c9d100
commit
b8acc073c1
|
@ -5,7 +5,7 @@ Unit m_QuickSort;
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
Const
|
Const
|
||||||
mdlMaxSortSize = 5000;
|
mdlMaxSortSize = 10000;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TSortMethod = (qAscending, qDescending);
|
TSortMethod = (qAscending, qDescending);
|
||||||
|
@ -23,8 +23,9 @@ Type
|
||||||
Constructor Create;
|
Constructor Create;
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
|
|
||||||
Function Add (Name: String; Ptr: LongInt) : Boolean;
|
Function Add (Name: String; Ptr: Cardinal) : Boolean;
|
||||||
Procedure Sort (Left, Right: Word; Mode: TSortMethod);
|
Procedure Conditional (Name: String; Ptr: Cardinal; ListMin: Word);
|
||||||
|
Procedure Sort (Left, Right: Word; Mode: TSortMethod);
|
||||||
Procedure Clear;
|
Procedure Clear;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ Begin
|
||||||
Total := 0;
|
Total := 0;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function TQuickSort.Add (Name: String; Ptr: LongInt) : Boolean;
|
Function TQuickSort.Add (Name: String; Ptr: Cardinal) : Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
|
@ -72,6 +73,20 @@ Begin
|
||||||
Result := True;
|
Result := True;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Procedure TQuickSort.Conditional (Name: String; Ptr: Cardinal; ListMin: Word);
|
||||||
|
Var
|
||||||
|
Count : Word;
|
||||||
|
Begin
|
||||||
|
If Total < ListMin Then
|
||||||
|
Self.Add(Name, Ptr)
|
||||||
|
Else
|
||||||
|
For Count := Total DownTo 1 Do
|
||||||
|
If Data[Count].Name < Name Then Begin
|
||||||
|
Data[Count].Name := Name;
|
||||||
|
Data[Count].Ptr := Ptr;
|
||||||
|
End;
|
||||||
|
End;
|
||||||
|
|
||||||
Procedure TQuickSort.Sort (Left, Right: Word; Mode: TSortMethod);
|
Procedure TQuickSort.Sort (Left, Right: Word; Mode: TSortMethod);
|
||||||
Var
|
Var
|
||||||
Temp : PQuickSortRec;
|
Temp : PQuickSortRec;
|
||||||
|
|
Loading…
Reference in New Issue