LSArray Class¶
-
class
localsolver.LSArray¶ Value type for array expressions. Such value is obtained with
LSExpression.GetArrayValue()orLSSolution.GetArrayValue(LSExpression). An array can contain numbers (int, double) or other LSArray (for multi-dimensional arrays).Arrays are not decisions and cannot be modified.
Since: 7.5 See: LSModel See: LSExpression See: LSOperator.Array
Summary¶
Count |
Returns the number of values in the array. |
IsBool |
Returns true if the value at the given position is a boolean. |
IsInt |
Returns true if the value at the given position is an integer. |
IsDouble |
Returns true if the value at the given position is a double. |
IsArray |
Returns true if the value at the given position is an array. |
GetIntValue |
Returns the integer value at the given position. |
GetDoubleValue |
Returns the double value at the given position. |
GetArrayValue |
Returns the array value at the given position. |
ToString |
Returns a string representation of the values in the array in the format { val0, val1, ..., valN }. |
Instance methods¶
-
int
Count()¶ Returns the number of values in the array. Elements in arrays are indexed from 0 to count()-1.
Returns: Number of values in the array. Return type: int
-
bool
IsBool(int position)¶ Returns true if the value at the given position is a boolean. You can retrieve the value with
GetIntValue().Arguments: position (int) – Position of the value to query. Returns: True if the value at the given position is a boolean. Return type: bool
-
bool
IsInt(int position)¶ Returns true if the value at the given position is an integer. You can retrieve the value with
GetIntValue().Arguments: position (int) – Position of the value to query. Returns: True if the value at the given position is an integer. Return type: bool
-
bool
IsDouble(int position)¶ Returns true if the value at the given position is a double. You can retrieve the value with
GetDoubleValue().Arguments: position (int) – Position of the value to query. Returns: True if the value at the given position is a boolean. Return type: bool
-
bool
IsArray(int position)¶ Returns true if the value at the given position is an array. You can retrieve the value with
GetArrayValue().Arguments: position (int) – Position of the value to query. Returns: True if the value at the given position is an array. Return type: bool
-
long
GetIntValue(int position)¶ Returns the integer value at the given position. If the value is neither an integer, nor a boolean, an exception is thrown.
Arguments: position (int) – Position of the value to query. Returns: Integer value. Return type: long
-
double
GetDoubleValue(int position)¶ Returns the double value at the given position. If the value is not a double, an exception is thrown.
Arguments: position (int) – Position of the value to query. Returns: Double value. Return type: double
-
LSArray
GetArrayValue(int position)¶ Returns the array value at the given position. If the value is not an array, an exception is thrown.
Arguments: position (int) – Position of the value to query. Returns: Array value. Return type: LSArray
-
string
ToString()¶ Returns a string representation of the values in the array in the format
{ val0, val1, ..., valN }.Returns: A String representation of the array Return type: string