Functions working with arrays (type[])

AnyLogic provides a set of functions aimed for working with Java arrays (storing values of primitive type: int[], double[], or instances of some Java class: Object[]).

Return type

Name

Description

boolean

contains(double[] array, double value)

Returns true if the array contains the given value.

boolean

contains(int[] array, int value)

Returns true if the array contains the given value.

boolean

contains(Object[] array, Object value)

Returns true if the array contains the given value. Objects are compared using .equals() function.

int

indexOf(double[] array, double value)

Returns the index of the first occurrence of the given value in the array. Returns -1 if value not found or if passed array is null or empty.

int

indexOf(int[] array, int value)

Returns the index of the first occurrence of the given value in the array. Returns -1 if value not found or if passed array is null or empty.

int

indexOf(Object[] array, Object value)

Returns the index of the first occurrence of the given object in the array. Objects are compared using .equals() function.
Returns -1 if value not found or if passed array is null or empty.
Arrays of any object type are supported.

int

indexOfMax(double[] array)

 Returns the index of the maximum value from the given array.

int

indexOfMax(int[] array)

 Returns the index of the maximum value from the given array.

int

indexOfMin(double[] array)

Returns the index of the minimum value from the given array.

int

indexOfMin(int[] array)

 Returns the index of the minimum value from the given array.

double

max(double[] array)

Returns the maximum value from the given array.
Returns Double.NaN if array contains only Double.NaN values.
Throws error if passed array is null or empty.

double

max(int[] array)

Returns the maximum value from the given array.
Throws error if passed array is null or empty.

double

min(double[] array)

Returns the minimum value from the given array.
Returns Double.NaN if array contains only Double.NaN values.
Throws error if passed array is null or empty.

double

min(int[] array)

Returns the minimum value from the given array.
Throws error if passed array is null or empty.