From 8290e1a09ec4377bb45d7b4fc1bc39f107f85502 Mon Sep 17 00:00:00 2001 From: Eddie Runia Date: Tue, 11 May 1999 08:44:04 +0000 Subject: [PATCH] aSort seperated --- harbour/ChangeLog | 8 ++++ harbour/makefile.b16 | 4 +- harbour/makefile.b31 | 5 ++- harbour/makefile.b32 | 4 +- harbour/source/rtl/Makefile | 1 + harbour/source/rtl/asort.prg | 63 +++++++++++++++++++++++++++++ harbour/tests/working/debugtst.prg | 65 ------------------------------ 7 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 harbour/source/rtl/asort.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ad11372209..88c195d588 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +19990511-09:40 Eddie Runia + * source/rtl/asort.prg + added a seperate function + * tests/working/debugtst.prg + asort removed + * Makefile.* + asort added to list. (Except for makefile.vc; Incomplete ?) + 19990511-00:07 MSG Bil Simser * source/rtc/environ.c - Added OS function diff --git a/harbour/makefile.b16 b/harbour/makefile.b16 index 852c422092..18800f6a13 100644 --- a/harbour/makefile.b16 +++ b/harbour/makefile.b16 @@ -11,7 +11,7 @@ PROJECT: harbour.lib libs\b16\terminal.lib libs\win16\terminal.lib harbour.exe -harbour.lib : arrays.obj classes.obj codebloc.obj dates.obj datesx.obj \ +harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj datesx.obj \ debug.obj dynsym.obj environ.obj error.obj \ errorapi.obj errorsys.obj extend.obj files.obj itemapi.obj math.obj \ mathx.obj set.obj strings.obj stringsx.obj strcmp.obj tclass.obj transfrm.obj @@ -27,6 +27,7 @@ console.obj : console.c extend.h types.h tlib .\libs\win16\terminal.lib -+$@,, arrays.obj : arrays.c extend.h types.h +asort.obj : asort.c extend.h types.h classes.obj : classes.c extend.h types.h codebloc.obj : codebloc.c extend.h types.h dates.obj : dates.c extend.h types.h @@ -49,6 +50,7 @@ stringsx.obj : stringsx.c extend.h types.h tclass.obj : tclass.c extend.h types.h transfrm.obj : transfrm.c extend.h types.h +asort.c : asort.prg harbour.exe error.c : error.prg harbour.exe errorsys.c : errorsys.prg harbour.exe tclass.c : tclass.prg harbour.exe diff --git a/harbour/makefile.b31 b/harbour/makefile.b31 index ca4765a89c..0629815856 100644 --- a/harbour/makefile.b31 +++ b/harbour/makefile.b31 @@ -11,8 +11,8 @@ PROJECT: harbour.lib hbtools.lib terminal.lib libs\win16\terminal.lib harbour.exe -harbour.lib : arrays.obj classes.obj codebloc.obj dates.obj dynsym.obj \ - environ.obj error.obj \ +harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj \ + dynsym.obj environ.obj error.obj \ errorapi.obj errorsys.obj extend.obj files.obj itemapi.obj math.obj \ set.obj strings.obj strcmp.obj tclass.obj transfrm.obj @@ -29,6 +29,7 @@ console.obj : console.c extend.h types.h # tlib .\libs\win16\terminal.lib -+$@,, arrays.obj : arrays.c extend.h types.h +asort.obj : asort.prg extend.h types.h harbour.exe classes.obj : classes.c extend.h types.h codebloc.obj : codebloc.c extend.h types.h dates.obj : dates.c extend.h types.h dates.h set.h diff --git a/harbour/makefile.b32 b/harbour/makefile.b32 index f4053be89f..58be893b5b 100644 --- a/harbour/makefile.b32 +++ b/harbour/makefile.b32 @@ -12,7 +12,7 @@ PROJECT: harbour.lib libs\b32\terminal.lib libs\win32\terminal.lib harbour.exe -harbour.lib : arrays.obj classes.obj codebloc.obj dates.obj datesx.obj \ +harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj datesx.obj \ debug.obj dynsym.obj environ.obj error.obj \ errorapi.obj errorsys.obj extend.obj files.obj itemapi.obj math.obj \ mathx.obj set.obj symbols.obj strings.obj stringsx.obj strcmp.obj \ @@ -31,6 +31,7 @@ console.obj : console.c extend.h types.h symbols.obj : symbols.asm arrays.obj : arrays.c extend.h types.h +asort.obj : asort.c extend.h types.h classes.obj : classes.c extend.h types.h codebloc.obj : codebloc.c extend.h types.h dates.obj : dates.c extend.h types.h @@ -53,6 +54,7 @@ stringsx.obj : stringsx.c extend.h types.h tclass.obj : tclass.c extend.h types.h transfrm.obj : transfrm.c extend.h types.h +asort.c : asort.prg harbour.exe error.c : error.prg harbour.exe errorsys.c : errorsys.prg harbour.exe tclass.c : tclass.prg harbour.exe diff --git a/harbour/source/rtl/Makefile b/harbour/source/rtl/Makefile index ddad6c0610..f2db5262fe 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -22,6 +22,7 @@ C_SOURCES=\ transfrm.c \ PRG_SOURCES=\ + asort.prg \ error.prg \ errorsys.prg \ tclass.prg \ diff --git a/harbour/source/rtl/asort.prg b/harbour/source/rtl/asort.prg new file mode 100644 index 0000000000..41862cdb9a --- /dev/null +++ b/harbour/source/rtl/asort.prg @@ -0,0 +1,63 @@ +// +// aSort( , [nStart], [nCount], [bBlock] ) +// +// Sort an array +// +function aSort( aIn, nStart, nCount, bBlock ) + + nStart := Default( nStart, 1 ) + QuickSort( aIn, ; + nStart, ; + Default( nCount, Len(aIn) - nStart + 1 ), ; + Default( bBlock, {| x, y | x < y } ) ) +return aIn + + +// +// QuickSort( , , , ) +// +// Perform a QuickSort of . +// +// For instructions : +// http://monty.cnri.reston.va.us/grail/demo/quicksort/quicksort.htm +// +function QuickSort( aSort, nLeft, nRight, bOrder ) + + local nUp := nLeft + local nDown := nRight + local xMiddle := aSort[ ( nLeft + nRight ) / 2 ] + local xTemp + local lOk := .T. + + do while lOk + do while Eval( bOrder, aSort[ nUp ], xMiddle ) + nUp++ + enddo + + do while Eval( bOrder, xMiddle, aSort[ nDown ] ) + nDown-- + enddo + + if nUp <= nDown + if nUp != nDown + xTemp := aSort[ nUp ] + aSort[ nUp ] := aSort[ nDown ] + aSort[ nDown ] := xTemp + endif + nUp++ + nDown-- + endif + + lOk := nUp <= nDown + enddo + + if nLeft < nDown + QuickSort( aSort, nLeft, nDown , bOrder ) + endif + + if nUp < nRight + QuickSort( aSort, nUp , nRight, bOrder ) + endif + +return nil + diff --git a/harbour/tests/working/debugtst.prg b/harbour/tests/working/debugtst.prg index c38d701556..a2a2744079 100644 --- a/harbour/tests/working/debugtst.prg +++ b/harbour/tests/working/debugtst.prg @@ -469,69 +469,6 @@ function aOSet( oObject, aData ) return oObject -// -// aSort( , [nStart], [nCount], [bBlock] ) -// -// Sort an array -// -function aSort( aIn, nStart, nCount, bBlock ) - - nStart := Default( nStart, 1 ) - QuickSort( aIn, ; - nStart, ; - Default( nCount, Len(aIn) - nStart + 1 ), ; - Default( bBlock, {| x, y | x < y } ) ) -return aIn - - -// -// QuickSort( , , , ) -// -// Perform a QuickSort of . -// -// For instructions : -// http://monty.cnri.reston.va.us/grail/demo/quicksort/quicksort.htm -// -function QuickSort( aSort, nLeft, nRight, bOrder ) - - local nUp := nLeft - local nDown := nRight - local xMiddle := aSort[ ( nLeft + nRight ) / 2 ] - local xTemp - local lOk := .T. - - do while lOk - do while Eval( bOrder, aSort[ nUp ], xMiddle ) - nUp++ - enddo - - do while Eval( bOrder, xMiddle, aSort[ nDown ] ) - nDown-- - enddo - - if nUp <= nDown - if nUp != nDown - xTemp := aSort[ nUp ] - aSort[ nUp ] := aSort[ nDown ] - aSort[ nDown ] := xTemp - endif - nUp++ - nDown-- - endif - - lOk := nUp <= nDown - enddo - - if nLeft < nDown - QuickSort( aSort, nLeft, nDown , bOrder ) - endif - - if nUp < nRight - QuickSort( aSort, nUp , nRight, bOrder ) - endif - -return nil - // // := IsData( , ) // @@ -552,5 +489,3 @@ function IsMethod( oObject, cSymbol ) return IsMessage( oObject, cSymbol ) .and. !IsMessage( oObject, "_" + cSymbol ) - -