Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
class
|
||||
APPLICATION
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
make
|
||||
-- Create and print sorted set
|
||||
do
|
||||
create my_set.make
|
||||
my_set.put_front (2)
|
||||
my_set.put_front (6)
|
||||
my_set.put_front (1)
|
||||
my_set.put_front (5)
|
||||
my_set.put_front (3)
|
||||
my_set.put_front (9)
|
||||
my_set.put_front (8)
|
||||
my_set.put_front (4)
|
||||
my_set.put_front (10)
|
||||
my_set.put_front (7)
|
||||
print ("Before: ")
|
||||
across my_set as ic loop print (ic.item.out + " ") end
|
||||
print ("%NAfter : ")
|
||||
my_set.sort
|
||||
across my_set as ic loop print (ic.item.out + " ") end
|
||||
end
|
||||
|
||||
my_set: MY_SORTED_SET [INTEGER]
|
||||
-- Set to be sorted
|
||||
end
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
class
|
||||
MY_SORTED_SET [G -> COMPARABLE]
|
||||
inherit
|
||||
TWO_WAY_SORTED_SET [G]
|
||||
redefine
|
||||
sort
|
||||
end
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
sort
|
||||
-- Sort with bubble sort
|
||||
local
|
||||
l_unchanged: BOOLEAN
|
||||
l_item_count: INTEGER
|
||||
l_temp: G
|
||||
do
|
||||
from
|
||||
l_item_count := count
|
||||
until
|
||||
l_unchanged
|
||||
loop
|
||||
l_unchanged := True
|
||||
l_item_count := l_item_count - 1
|
||||
across 1 |..| l_item_count as ic loop
|
||||
if Current [ic.item] > Current [ic.item + 1] then
|
||||
l_temp := Current [ic.item]
|
||||
Current [ic.item] := Current [ic.item + 1]
|
||||
Current [ic.item + 1] := l_temp
|
||||
l_unchanged := False
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue