ABSTRACT_SORTER | Some algorithms to sort any COLLECTION, using a given order relation
in deferred methods `lt', `gt', `lte' and `gte'.
Elements are sorted using increasing order: small elements
at the beginning of the collection, large at the end (decreasing
order is implemented by class REVERSE_COLLECTION_SORTER). Note that
"small" means "a is smaller than b" when "lt (a, b)", no matter what
`lt' is.
Some algorithms to sort any COLLECTION[COMPARABLE].
Elements are sorted using the order defined by `lt'.
|
COLLECTION_SORTER | Some algorithms to sort any COLLECTION[COMPARABLE].
Elements are sorted using increasing order: large elements at the beginning of the collection, small at the end (increasing
order is implemented by class COLLECTION_SORTER).
How to use this expanded class :
local
sorter: COLLECTION_SORTER[INTEGER]
array: ARRAY[INTEGER]
do
array := <<1,3,2>>
sorter.sort(array)
check
sorter.is_sorted(array)
end
...
|
COMPARATOR_COLLECTION_SORTER | Some algorithms to sort any COLLECTION using an external comparator.
Elements are sorted using the order given by the comparator: large elements at the beginning of the collection, small at the
end (increasing order is implemented by class COLLECTION_SORTER).
Note that without setting a comparator (using `set_comparator'), collections won't get sorted.
How to use this expanded class :
local
sorter: COMPARATOR_COLLECTION_SORTER[INTEGER]
array: ARRAY[INTEGER]
do
array := <<1,3,2>>
sorter.set_comparator(agent my_comparator)
sorter.sort(array)
check
sorter.is_sorted(array)
end
...
|
REVERSE_COLLECTION_SORTER | Some algorithms to sort any COLLECTION[COMPARABLE].
Elements are sorted using the order given by the comparator: large elements at the beginning of the collection, small at the
end (increasing order is implemented by class COLLECTION_SORTER).
How to use this expanded class :
local
sorter: REVERSE_COLLECTION_SORTER[INTEGER]
array: ARRAY[INTEGER]
do
array := <<1,3,2>>
sorter.sort(array)
check
sorter.is_sorted(array)
end
...
|