Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,34 @@
|
|||
class
|
||||
COUNTING_SORT
|
||||
feature
|
||||
sort(ar: ARRAY[INTEGER]; min, max: INTEGER): ARRAY[INTEGER]
|
||||
local
|
||||
count: ARRAY[INTEGER]
|
||||
i, j, z: INTEGER
|
||||
do
|
||||
create count.make_filled (0, 0, max-min)
|
||||
from
|
||||
i:= 0
|
||||
until
|
||||
i= ar.count
|
||||
loop
|
||||
count[ar[i]-min]:= count[ar[i]-min]+1
|
||||
i:= i+1
|
||||
end
|
||||
across count as c loop io.put_string (c.item.out + "%T") end
|
||||
z:= 0
|
||||
from i:= min
|
||||
until i>max
|
||||
loop
|
||||
from j:= 0
|
||||
until j= count[i-min]
|
||||
loop
|
||||
ar[z]:=i
|
||||
z:= z+1
|
||||
j:= j+1
|
||||
end
|
||||
i:= i+1
|
||||
end
|
||||
Result:= ar
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
ARGUMENTS
|
||||
create
|
||||
make
|
||||
feature
|
||||
make
|
||||
do
|
||||
create test.make_filled(0,0,5)
|
||||
test[0]:=-7
|
||||
test[1]:=4
|
||||
test[2]:=2
|
||||
test[3]:=6
|
||||
test[4]:=1
|
||||
test[5]:=3
|
||||
across test as t loop io.put_string (t.item.out + "%T") end
|
||||
create count
|
||||
test:=count.sort (test, -7, 6)
|
||||
across test as ar loop io.put_string (ar.item.out+"%T") end
|
||||
end
|
||||
count: COUNTING_SORT
|
||||
test: ARRAY[INTEGER]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue