Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,38 @@
|
|||
class
|
||||
GNOME_SORT
|
||||
|
||||
feature
|
||||
sort(ar: ARRAY[INTEGER]): ARRAY[INTEGER]
|
||||
-- sort array ar with gnome sort
|
||||
require
|
||||
array_not_void: ar/= VOID
|
||||
local
|
||||
i,j, ith: INTEGER
|
||||
do
|
||||
from
|
||||
i:= 2
|
||||
j:= 3
|
||||
until
|
||||
i>ar.count
|
||||
loop
|
||||
if ar[i-1] <= ar[i] then
|
||||
i:= j
|
||||
j:= j+1
|
||||
else
|
||||
ith := ar[i-1]
|
||||
ar[i-1] := ar[i]
|
||||
ar[i] := ith
|
||||
i:= i-1
|
||||
if i=1 then
|
||||
i:=j
|
||||
j:= j+1
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := ar
|
||||
ensure
|
||||
same_length: ar.count = Result.count
|
||||
same_items: Result.same_items (ar)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
make
|
||||
do
|
||||
test:= <<7, 99, -7, 1, 0, 25, -10>>
|
||||
create gnome
|
||||
test:= gnome.sort (test)
|
||||
across test as ar loop io.put_string( ar.item.out + "%T") end
|
||||
end
|
||||
|
||||
test: ARRAY[INTEGER]
|
||||
gnome: GNOME_SORT[INTEGER]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue