+
Point of view
All features
expanded class COLLECTION_SORTER [X_ -> COMPARABLE]
Summary
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
            ...
Direct parents
Insert list: ABSTRACT_SORTER
Overview
Features
{}
Auxiliary functions
{}
{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.
{}
lt (x: X_, y: X_): BOOLEAN
effective function
{}
gt (x: X_, y: X_): BOOLEAN
effective function
{}
lte (x: X_, y: X_): BOOLEAN
effective function
{}
gte (x: X_, y: X_): BOOLEAN
effective function
{}
is_sorted (c: COLLECTION[X_]): BOOLEAN
effective function
{ANY}
Is c already sorted ? Uses lte for comparison.
has (c: COLLECTION[X_], element: X_): BOOLEAN
effective function
{ANY}
index_of (c: COLLECTION[X_], element: X_): INTEGER_32
effective function
{ANY}
add (c: COLLECTION[X_], element: X_)
effective procedure
{ANY}
Add element in collection c keeping the sorted property.
insert_index (c: COLLECTION[X_], element: X_): INTEGER_32
effective function
{ANY}
retrieve the upper index for which gt
sort (c: COLLECTION[X_])
effective procedure
{ANY}
Sort c using the default most efficient sorting algorithm already implemented.
quick_sort (c: COLLECTION[X_])
effective procedure
{ANY}
Sort c using the quick sort algorithm.
von_neuman_sort (c: COLLECTION[X_])
effective procedure
{ANY}
Sort c using the Von Neuman algorithm.
heap_sort (c: COLLECTION[X_])
effective procedure
{ANY}
Sort c using the heap sort algorithm.
bubble_sort (c: COLLECTION[X_])
effective procedure
{ANY}
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)
effective procedure
{}
von_neuman_inner_sort (src: COLLECTION[X_], dest: COLLECTION[X_], sg1: INTEGER_32, count: INTEGER_32, imax: INTEGER_32)
effective procedure
{}
heap_repair (c: COLLECTION[X_], c_lower: INTEGER_32, first: INTEGER_32, last: INTEGER_32)
effective procedure
{}
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)
effective procedure
{}