Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,44 @@
class
COMB_SORT[G -> COMPARABLE]
feature
combsort (ar: ARRAY[G]): ARRAY[G]
require
array_not_empty: ar.count >0
local
gap, i: INTEGER
swap: G
swapped: BOOLEAN
shrink: REAL_64
do
gap:= ar.count
from
until
gap= 1 and swapped = false
loop
from
i:= 1
swapped:= false
until
i+gap > ar.count
loop
if ar[i]> ar[i+gap] then
swap:= ar[i]
ar[i]:= ar[i+gap]
ar[i+gap]:= swap
swapped:= TRUE
end
i:= i+1
end
shrink:= gap/1.3
gap:= shrink.floor
if gap <1 then
gap:= 1
end
end
RESULT:= ar
ensure
RESULT_is_set: Result /= VOID
end
end

View file

@ -0,0 +1,24 @@
class
APPLICATION
inherit
ARGUMENTS
create
make
feature
make
do
test:= <<1,5,99,2,95, 7,-7>>
io.put_string ("unsorted"+"%N")
across test as ar loop io.put_string(ar.item.out + "%T") end
io.put_string ("%N"+"sorted:"+"%N")
create combsort
test:=combsort.combsort(test)
across test as ar loop io.put_string (ar.item.out + "%T") end
end
combsort: COMB_SORT[INTEGER]
test: ARRAY[INTEGER]
end