Array (from HSLExtensions)

https://github.com/theonetruenerd/VenusPackages/blob/main/Array.pkg

The array library from HSLExtensions adds functions to help manipulate 1-D arrays. The following functions are added:

Append(array io_arrValuesA, array i_arrValuesB)

This function updates the array io_arrValuesA to add all the values from i_arrValuesB at the end of the array.

Params io_arrValuesA:

The array to which the values will be added

Params i_arrValuesB:

The array from which the values will be added

Returns:

None

Return type:

N/A

CompareArrays(array i_arrExpectedValues, array i_arrActualValues, array o_arrMissingValues, array o_arrNotExpectedValues)

This function compares two arrays and outputs arrays of values which are missing from the first array but present in the second, and values which are present in the second array but not in the first.

Params i_arrExpectedValues:

The first array, which the second array will be checked against, usually is the array of expected values

Params i_arrActualValues:

The second array, which will use the first array as a template when comparing against, usually is your “actual” array

Params o_arrMissingValues:

An output array of values which are present in the first array but not the second

Params o_arrNotExpectedValues:

An output array of values which are present in the second array but not the first (i.e. unexpected values in your actual data)

Returns:

True if both arrays contain the same values (resulting in empty output arrays), false if arrays don’t contain the same values (in which case the output arrays will have data in them)

Return type:

Boolean

Concat(array i_arrValuesA, array i_arrValuesB)

This function appends one array to the other and then returns the concatenated array. The difference between this and the Append() function is that the Append function updates an existing array, whereas this function doesn’t change the existing arrays and instead returns a new array.

Params i_arrValuesA:

The array to which the values will be added

Params i_arrValuesB:

The array from which the values will be added

Returns:

A new array which is the concatenated version of the input arrays

Return type:

Array

ContainsDuplicates(array i_arrValues)

This function checks whether the input array has multiple of the same value in it

Params i_arrValues:

The array to be checked

Returns:

An array with all values which appear more than once in the input array

Return type:

Array

ContainsValue(array i_arrValues, variable i_varValue)

This function determines whether a value exists in an array without returning its index

Params i_arrValues:

The array to be searched

Params i_varValue:

The value to be searched for

Returns:

True if the value is present, false otherwise

Return type:

Boolean

ConvertToBooleanArray(array i_arrValues, variable o_blnSuccessfullyConverted)

This function converts the input array to an array with boolean values. If it is not possible to convert one or more values of the input array, the output will be false and the output array will be empty. Cannot interact with strings, will convert a non-zero int or float into a 1, and will turn a 0 float into a 0.

Params i_arrValues:

The array to be converted

Params o_blnSuccessfullyConverted:

A boolean which tells you whether the conversion was successful or not

Returns:

The boolean version of the input array

Return type:

Array

ConvertToFloatArray(array i_arrValues, variable o_blnSuccessfullyConverted)

This function converts the input array to an array with float values. If it is not possible to convert one or more values of the input array, the output will be false and the output array will be empty. Cannot interact with strings, will convert any int into a float.

Params i_arrValues:

The array to be converted

Params o_blnSuccessfullyConverted:

A boolean which tells you whether the conversion was successful or not

Returns:

The float version of the input array

Return type:

Array

ConvertToIntArray(array i_arrValues, variable o_blnSuccessfullyConverted)

This function converts the input array to one with integer values. If it is not possible to convert one or more values of the input array, the output will be false and the output array will be empty. Cannot interact with strings, will round any floats to the nearest integer.

Params i_arrValues:

The array to be converted

Params o_blnSuccessfullyConverted:

A boolean which tells you whether the conversion was successful or not

Returns:

The integer version of the input array

Return type:

Array

ConvertToStringArray(array i_arrValues)

This function converts the input array to one with string values.

Params i_arrValues:

The array to be converted

Returns:

The float version of the input array

Return type:

Array

Copy(array i_arrValues)

This function will output an exact copy of the input array.

Params i_arrValues:

The array to be copied

Returns:

A copy of the input array

Return type:

Array

FindValue(array i_arrValues, variable i_varValue)

This function will lookup the input variable within the input array and return a 1-based array of the indices of all positions that the input variable was found.

Params i_arrValues:

The array to be searched

Params i_varValue:

The variable to be searched for

Returns:

An array of all the locations that the input variable was found

Return type:

Array

InitializeAllValues(array io_arrValues, variable i_varValue)

This function sets all values within an array to the input variable. Does not work on empty arrays.

Params io_arrValues:

The array in which all values will be converted.

Params i_varValue:

The variable to which all values will be converted.

Returns:

None

Return type:

N/A

IsBooleanArray(array i_arrValues)

This function checks whether all values in the array are booleans.

Params i_arrValues:

The array to be checked

Returns:

A boolean of whether the input array is all booleans or not

Return type:

Boolean

IsEmpty(array i_arrValues)

This function checks whether the input array is empty

Params i_arrValues:

The array to be checked

Returns:

A boolean of whether the input array is empty or not

Return type:

Boolean

IsFloatArray(array i_arrValues)

This function checks whether all values in the array are floats.

Params i_arrValues:

The array to be checked

Returns:

A boolean of whether the input array is all floats or not

Return type:

Boolean

IsIntegerArray(array i_arrValues)

This function checks whether all values in the array are integers.

Params i_arrValues:

The array to be checked

Returns:

A boolean of whether the input array is all integers or not

Return type:

Boolean

IsStringArray(array i_arrValues)

This function checks whether all values in the array are strings.

Params i_arrValues:

The array to be checked

Returns:

A boolean of whether the input array is all strings or not

Return type:

Boolean

Sort(array i_arrValues, variable i_intSortMode, o_bSuccessfulSorted)

This function outputs a sorted version of the array using the Shakersort sorting algorithm. All values in the array must share the same type for this function to work. Sort mode can either be 1 or 2, 1 is ascending and 2 is descending.

Params i_arrValues:

The array containing the values to be sorted

Params i_intSortMode:

Whether the array is to be sorted in ascending (1) or descending (2) order

Params o_bSuccesfulSorted:

A boolean of whether the sort was successful or not

Returns:

A sorted copy of the array

Return type:

Array