LSArray Class¶
-
class LSArray¶
Value type for array expressions. Such value is obtained with
LSExpression::getArrayValue()
orLSSolution::getArrayValue()
. An array contains values of type lsint, lsdouble, LSArray (for multi-dimensional arrays), LSInterval or LSCollection (list or set). Note that it’s possible to mix integers or doubles in the same array. Arrays are not decisions and cannot be modified.- See:
- See:
- Since:
7.5
Summary¶
Returns the number of elements in the array. |
|
Returns true if the value at the given position is a boolean. |
|
Returns true if the value at the given position is an integer. |
|
Returns true if the value at the given position is a double. |
|
Returns true if the value at the given position is an interval. |
|
Returns true if the value at the given position is an array. |
|
Returns true if the value at the given position is a collection (list or set). |
|
If an argument is passed to the function, returns true if the value at the given position is undefined, otherwise returns true if the array itself is undefined. |
|
Returns the integer value at the given position. |
|
Returns the double value at the given position. |
|
Returns the interval value at the given position. |
|
Returns the array value at the given position. |
|
Returns the collection value at the given position. |
|
Returns a string representation of the values in the array in the formats { val0, val1, ..., valN }. |
Functions¶
-
int LSArray::count() const¶
Returns the number of elements in the array. Elements in arrays are indexed from 0 to count()-1.
- Returns:
Number of values in the array.
-
bool LSArray::isBool(int pos) const¶
Returns true if the value at the given position is a boolean. You can retrieve the value with
getIntValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is a boolean.
-
bool LSArray::isInt(int pos) const¶
Returns true if the value at the given position is an integer. You can retrieve the value with
getIntValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is an integer.
-
bool LSArray::isDouble(int pos) const¶
Returns true if the value at the given position is a double. You can retrieve the value with
getDoubleValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is a double.
-
bool LSArray::isInterval(int pos) const¶
Returns true if the value at the given position is an interval. You can retrieve the value with
getIntervalValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is an interval.
-
bool LSArray::isArray(int pos) const¶
Returns true if the value at the given position is an array. You can retrieve the value with
getArrayValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is an array.
-
bool LSArray::isCollection(int pos) const¶
Returns true if the value at the given position is a collection (list or set). You can retrieve the value with
getCollectionValue()
.- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is a collection.
-
bool LSArray::isUndefined(int pos) const¶
-
bool LSArray::isUndefined() const¶
If an argument is passed to the function, returns true if the value at the given position is undefined, otherwise returns true if the array itself is undefined. A value can be undefined in 4 cases:
It is a double and its value is NaN (Not a Number).
It is an integer or boolean with no valid value (arithmetic or out of bounds exception).
It is an interval with at least one undefined bound.
It is the result of any ill-defined operation (at with out of bounds index or operations on undefined values for instance).
- Parameters:
pos – Position of the value to query.
- Returns:
True if the value at the given position is undefined, or if the array is undefined if no argument is passed.
-
lsint LSArray::getIntValue(int pos) const¶
Returns the integer value at the given position. If the value is neither an integer nor a boolean, an exception is thrown.
- Parameters:
pos – Position of the value to query.
- Returns:
Integer value.
-
lsdouble LSArray::getDoubleValue(int pos) const¶
Returns the double value at the given position. If the value is not a double, an exception is thrown.
- Parameters:
pos – Position of the value to query.
- Returns:
Double value.
-
LSInterval LSArray::getIntervalValue(int pos) const¶
Returns the interval value at the given position. If the value is not an interval, an exception is thrown.
- Parameters:
pos – Position of the value to query.
- Returns:
Interval value.
-
LSArray LSArray::getArrayValue(int pos) const¶
Returns the array value at the given position. If the value is not an array, an exception is thrown.
- Parameters:
pos – Position of the value to query.
- Returns:
Array value.
-
LSCollection LSArray::getCollectionValue(int pos) const¶
Returns the collection value at the given position. If the value is not a collection, an exception is thrown.
- Parameters:
pos – Position of the value to query.
- Returns:
Collection value.