all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -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

View file

@ -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