GNU
|
Liberty Eiffel
|
Automated Tests
|
Wiki
|
Savannah project
|
Debian packages
|
Documentation
>
libraries
>
STRING_RECYCLING_ITEM_SORTER
+
Point of view
All features
ANY
STRING_RECYCLING_POOL
STRING_RECYCLING_ITEM
STRING_RECYCLING_ITEM_SORTER
All features
expanded class STRING_RECYCLING_ITEM_SORTER
Summary
top
Direct parents
Insert list:
ABSTRACT_SORTER
,
STRING_HANDLER
Overview
top
Features
{}
lt
(x:
STRING_RECYCLING_ITEM
, y:
STRING_RECYCLING_ITEM
):
BOOLEAN
Auxiliary functions
{}
gt
(x: X_, y: X_):
BOOLEAN
lte
(x: X_, y: X_):
BOOLEAN
gte
(x: X_, y: X_):
BOOLEAN
{
ANY
}
is_sorted
(c: COLLECTION[X_]):
BOOLEAN
Is
c
already sorted ? Uses
lte
for comparison.
has
(c: COLLECTION[X_], element: X_):
BOOLEAN
index_of
(c: COLLECTION[X_], element: X_):
INTEGER_32
add
(c: COLLECTION[X_], element: X_)
Add
element
in collection
c
keeping the sorted property.
insert_index
(c: COLLECTION[X_], element: X_):
INTEGER_32
retrieve the upper index for which gt
sort
(c: COLLECTION[X_])
Sort
c
using the default most efficient sorting algorithm already implemented.
quick_sort
(c: COLLECTION[X_])
Sort
c
using the quick sort algorithm.
von_neuman_sort
(c: COLLECTION[X_])
Sort
c
using the Von Neuman algorithm.
heap_sort
(c: COLLECTION[X_])
Sort
c
using the heap sort algorithm.
bubble_sort
(c: COLLECTION[X_])
Sort
c
using the bubble sort algorithm.
{}
von_neuman_line
(src: COLLECTION[X_], dest: COLLECTION[X_], count:
INTEGER_32
, d_count:
INTEGER_32
, lower:
INTEGER_32
, imax:
INTEGER_32
)
von_neuman_inner_sort
(src: COLLECTION[X_], dest: COLLECTION[X_], sg1:
INTEGER_32
, count:
INTEGER_32
, imax:
INTEGER_32
)
heap_repair
(c: COLLECTION[X_], c_lower:
INTEGER_32
, first:
INTEGER_32
, last:
INTEGER_32
)
Repair the heap from the node number
first
It considers that the last item of c is number
last
It supposes that children are heaps.
quick_sort_region
(c: COLLECTION[X_], left:
INTEGER_32
, right:
INTEGER_32
)
lt
(x:
STRING_RECYCLING_ITEM
, y:
STRING_RECYCLING_ITEM
):
BOOLEAN
effective function
{}
top
gt
(x: X_, y: X_):
BOOLEAN
effective function
{}
top
lte
(x: X_, y: X_):
BOOLEAN
effective function
{}
top
gte
(x: X_, y: X_):
BOOLEAN
effective function
{}
top
is_sorted
(c: COLLECTION[X_]):
BOOLEAN
effective function
{
ANY
}
top
Is
c
already sorted ? Uses
lte
for comparison.
require
c /= Void
ensure
c.is_equal(old c.twin)
has
(c: COLLECTION[X_], element: X_):
BOOLEAN
effective function
{
ANY
}
top
require
c /= Void
is_sorted
(c)
ensure
Result = c.has(element)
index_of
(c: COLLECTION[X_], element: X_):
INTEGER_32
effective function
{
ANY
}
top
require
c /= Void
is_sorted
(c)
ensure
not c.is_empty implies c.valid_index(Result)
c.has(element) implies c.item(Result).is_equal(element)
add
(c: COLLECTION[X_], element: X_)
effective procedure
{
ANY
}
top
Add
element
in collection
c
keeping the sorted property.
require
c /= Void
is_sorted
(c)
ensure
c.count = old c.count + 1
is_sorted
(c)
insert_index
(c: COLLECTION[X_], element: X_):
INTEGER_32
effective function
{
ANY
}
top
retrieve the upper index for which gt
require
c /= Void
is_sorted
(c)
ensure
c.valid_index(Result) implies
gt
(c.item(Result), element)
c.valid_index(Result - 1) implies
lte
(c.item(Result - 1), element)
Result.in_range(c.lower, c.upper + 1)
sort
(c: COLLECTION[X_])
effective procedure
{
ANY
}
top
Sort
c
using the default most efficient sorting algorithm already implemented.
require
c /= Void
ensure
c.count = old c.count
is_sorted
(c)
quick_sort
(c: COLLECTION[X_])
effective procedure
{
ANY
}
top
Sort
c
using the quick sort algorithm.
require
c /= Void
ensure
c.count = old c.count
is_sorted
(c)
von_neuman_sort
(c: COLLECTION[X_])
effective procedure
{
ANY
}
top
Sort
c
using the Von Neuman algorithm.
This algorithm needs to create a second collection. Uses infix
"lte"
for comparison.
require
c /= Void
ensure
c.count = old c.count
is_sorted
(c)
heap_sort
(c: COLLECTION[X_])
effective procedure
{
ANY
}
top
Sort
c
using the heap sort algorithm.
require
c /= Void
ensure
c.count = old c.count
is_sorted
(c)
bubble_sort
(c: COLLECTION[X_])
effective procedure
{
ANY
}
top
Sort
c
using the bubble sort algorithm.
Uses infix
"<"
for comparison.
require
c /= Void
ensure
c.count = old c.count
is_sorted
(c)
von_neuman_line
(src: COLLECTION[X_], dest: COLLECTION[X_], count:
INTEGER_32
, d_count:
INTEGER_32
, lower:
INTEGER_32
, imax:
INTEGER_32
)
effective procedure
{}
top
require
src /= dest
src.lower = dest.lower
src.upper = dest.upper
count >= 1
d_count = count * 2
lower = src.lower
imax = src.upper + 1
ensure
d_count >= dest.count implies
is_sorted
(dest)
von_neuman_inner_sort
(src: COLLECTION[X_], dest: COLLECTION[X_], sg1:
INTEGER_32
, count:
INTEGER_32
, imax:
INTEGER_32
)
effective procedure
{}
top
require
src.valid_index(sg1)
heap_repair
(c: COLLECTION[X_], c_lower:
INTEGER_32
, first:
INTEGER_32
, last:
INTEGER_32
)
effective procedure
{}
top
Repair the heap from the node number
first
It considers that the last item of c is number
last
It supposes that children are heaps.
require
c /= Void
c.lower = c_lower
c_lower <= first
last <= c.upper
quick_sort_region
(c: COLLECTION[X_], left:
INTEGER_32
, right:
INTEGER_32
)
effective procedure
{}
top