Powerbuilder Sort Array Objects
Used
1 2 3 4 5 | Long arr[] = {10,1234,25,66,43,567,123,345,1123,5232,6,1,6,8,0,22,73} nvo_quicksort lsort lsort.of_quicksort( arr[], 1, UpperBound(arr)) |
nvo_quicksort from nonvisualobject
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | forward global type nvo_quicksort from nonvisualobject end type end forward global type nvo_quicksort from nonvisualobject autoinstantiate end type forward prototypes public subroutine of_swap (ref long al_num[], long i, long j) public subroutine of_quicksort (ref long arr[], long low, long high) public function long of_partition (ref long arr[], long low, long high) end prototypes public subroutine of_swap (ref long al_num[], long i, long j);//==================================================================== // Function: nvo_quicksort.of_swap() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference long al_num[] // value long i // value long j //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/24 //-------------------------------------------------------------------- // Usage: nvo_quicksort.of_swap ( ref long al_num[], long i, long j ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long temp temp = al_num[i]; al_num[i] = al_num[j]; al_num[j] = temp; end subroutine public subroutine of_quicksort (ref long arr[], long low, long high);//==================================================================== // Function: nvo_quicksort.of_quicksort() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference long arr[] // value long low // value long high //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/24 //-------------------------------------------------------------------- // Usage: nvo_quicksort.of_quicksort ( ref long arr[], long low, long high ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long Pi If (low < high) Then // pi is partitioning index, arr[p] // is now at right place Pi = of_partition(arr, low, high); // Separately sort elements before // partition and after partition of_quickSort(arr, low, Pi - 1); of_quickSort(arr, Pi + 1, high); End If end subroutine public function long of_partition (ref long arr[], long low, long high);//==================================================================== // Function: nvo_quicksort.of_partition() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference long arr[] // value long low // value long high //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/24 //-------------------------------------------------------------------- // Usage: nvo_quicksort.of_partition ( ref long arr[], long low, long high ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // pivot Long pivot pivot = arr[high]; // Index of smaller element and // indicates the right position // of pivot found so far Long i i = (low - 1); Long j For j = low To high // If current element is smaller // than the pivot If (arr[j] < pivot) Then // Increment index of // smaller element i++; of_swap(arr, i, j); End If Next of_swap(arr, i + 1, high); Return (i + 1); end function on nvo_quicksort.create call super::create TriggerEvent( this, "constructor" ) end on on nvo_quicksort.destroy TriggerEvent( this, "destructor" ) call super::destroy end on |
Good Luck!
Hello
There will be an example of a schedule for shifts of a medical clinic where you can register many patients for the same shift.
I have seen components like Codejock I have tried via ole with outlook. but they have not been satisfactory
Thank you very much if you have any example or component greetings