--
-- Last Revised: 2005 Apr 20
--
with
Astro;
generic
package Astro.Utility is
--
-- Description: These routines sort a list of numbers using the
-- quick sort algorithm. It returns a list of integers which are
-- the indices of the sorted numbers in ascending sorted
-- order. The original list of numbers is unchanged. The
-- procedure name is overloaded so that both integer and float
-- sort algorithms are available.
--
-- Errors:
--
-- The size of the input array cannot exceed 2**64. If the number
-- of numbers to be sorted is less than 1, an exception is
-- raised. It it is 1, no sorting can occur.
--
-- Implementation details:
--
-- This algorithm is normally implemented by recursive calls to
-- this procedure. This implementation, instead, uses an internal
-- stack to keep track of the unsorted segments which obviates the
-- need for recursion. This seems important because the recursive
-- depth can be as many as the number of numbers to be sorted.
-- The Sort_Randomizer is invoked from within Qsort so it does not
-- need to be invoked by the user.
--
procedure Sort_Randomizer
(Order : in out I1_Array;
Length : in Astro_Integer);
procedure Qsort
(Data : in F1_Array;
Order : in out I1_Array;
Length : in Astro_Integer);
procedure Qsort
(Data : in I1_Array;
Order : in out I1_Array;
Length : in Astro_Integer);
end Astro.Utility;