next up previous contents index
Next: Bitwise Logic Up: Main Functions 2 Previous: Main Functions 2   Contents   Index

Arrays

(int) ArrayDims(out_array, array)
This function returns the size (number of storage locations) of an array, and possibly the size of each dimension. Arrays can have from one to three dimensions. If the first argument is an array with size three or larger, the size of each dimension of the array in the second argument is stored in the first three locations of the first argument array, with the 0'th index being the lowest order. Unused dimensions are saved as 0. If the first argument is an integer 0, no dimension size information is returned. The size of the array (number of storage locations, which should equal the product of the nonzero dimensions) is returned by the function.

(int) ArrayDimension(out_array, array)
This function is very similar to ArrayDims, and the arguments have the same types and purpose as for that function. The return value is the number of dimensions used (1-3) if the second argument is an array, 0 otherwise. Unlike ArrayDims, this function does not fail if the second argument is not an array.

(int) GetDims(array, out_array)
This is for backward compatibility. This function is equivalent to ArrayDimension, but the two arguments are in reverse order. This function may disappear - don't use.

(int) DupArray(desc_array, src_array)
This function duplicates the src_array into the dest_array. The dest_array argument must be an unreferenced array. Upon successful return, the dest_array will be a copy of the src_array, and the return value is 1. If the dest_array can not be resized due to its being referenced by a pointer, 0 is returned. The function will fail if either argument is not an array.

(int) SortArray(array, size, descend, indices)
This function will sort the elements of the array passed as the first argument. The number of elements to sort is given in the second argument. The function will fail if size is negative, or will return without action if size is 0. The size is implicitly limited to the size of the array. The sorted values will be ascending if the third argument is 0, descending otherwise. The fourth argument, if nonzero, is an array which will be filled in with the index mapping applied to the array. For example, if array[5] is moved to array[0] during the sort, the value of indices[0] will be 5. This array will be resized if necessary, but the function will fail if resizing fails.

If the array being sorted is multi-dimensional, the sorting will use the internal linear order. The return value is the actual number of items sorted, which will be the value of size unless this was limited by the actual array size.


next up previous contents index
Next: Bitwise Logic Up: Main Functions 2 Previous: Main Functions 2   Contents   Index
Stephen R. Whiteley 2024-09-29