The arrays package provides general routines pretaining to SparForte
single-dimension arrays. This includes determining the size of the array, sorting
the array or moving the items in the array.
GCC Ada Equivalent: array attributes, GNAT sort packages
first( a ) last( a ) length( a )
bubble_sort( a ) bubble_sort_descending( a )
heap_sort( a ) heap_sort_descending( a )
shuffle( a ) flip( a )
shift_left( a ) shift_right( a )
rotate_left( a ) rotate_right( a )
Help Command: Contents of the arrays package
arrays.bubble_sort( a )
Bubble sort the array, treating the elements as strings or numbers
depending on the element type.
Return the number of elements in the array (last index - first index + 1).
Example
n := arrays.length( sales_array );
Parameters
Param
Mode
Type
Default
Description
a
in
array type
required
the array to examine
n
return value
natural
required
the number of elements in the array
Exceptions
-
See Also
strings.length
Compare With
Ada: 'length attribute PHP: count
arrays.flip( a )
Reverse the order of the elements in the array, moving the last element
to the first position and the first element to the last position. (Prior to
version 1.1, this was arrays.reverse but was renamed to avoid a conflict with the Ada
reserved word "reverse".)
Example
arrays.flip( backwards_array );
Parameters
Param
Mode
Type
Default
Description
a
in out
any array type
required
the array to sort
Exceptions
-
See Also
-
Compare With
Ada: N/A PHP: array_reverse
arrays.rotate_left( a )
Move all elements of the array one element toward the first position, moving
the first element to the last position.