aSort seperated
This commit is contained in:
@@ -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 <bsimser@home.com>
|
||||
* source/rtc/environ.c
|
||||
- Added OS function
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,7 @@ C_SOURCES=\
|
||||
transfrm.c \
|
||||
|
||||
PRG_SOURCES=\
|
||||
asort.prg \
|
||||
error.prg \
|
||||
errorsys.prg \
|
||||
tclass.prg \
|
||||
|
||||
63
harbour/source/rtl/asort.prg
Normal file
63
harbour/source/rtl/asort.prg
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// <aSorted> aSort( <aUnsorted>, [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( <aSort>, <nLeft>, <nRight>, <bOrder> )
|
||||
//
|
||||
// Perform a QuickSort of <aSort>.
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -469,69 +469,6 @@ function aOSet( oObject, aData )
|
||||
return oObject
|
||||
|
||||
|
||||
//
|
||||
// <aSorted> aSort( <aUnsorted>, [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( <aSort>, <nLeft>, <nRight>, <bOrder> )
|
||||
//
|
||||
// Perform a QuickSort of <aSort>.
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// <lRet> := IsData( <oObject>, <cSymbol> )
|
||||
//
|
||||
@@ -552,5 +489,3 @@ function IsMethod( oObject, cSymbol )
|
||||
return IsMessage( oObject, cSymbol ) .and. !IsMessage( oObject, "_" + cSymbol )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user