HxArray Class¶
-
class HxArray¶
Value type for array expressions. Such value is obtained with
HxExpression::getArrayValue()
orHxSolution::getArrayValue()
. An array contains values of type hxint, hxdouble, HxArray (for multi-dimensional arrays), HxInterval or HxCollection (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 HxArray::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 HxArray::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 HxArray::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 HxArray::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 HxArray::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 HxArray::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 HxArray::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 HxArray::isUndefined(int pos) const¶
-
bool HxArray::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.
-
hxint HxArray::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.
-
hxdouble HxArray::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.
-
HxInterval HxArray::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.
-
HxArray HxArray::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.
-
HxCollection HxArray::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.