This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

LSArray Class

class LSArray

Value type for array expressions. Such value is obtained with LSExpression::getArrayValue() or LSSolution::getArrayValue(). An array contains values of type lsint, lsdouble, LSArray (for multi-dimensional arrays) 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:

LSSolution

See:

LSExpression

Since:

7.5

Summary

Functions

count

Returns the number of elements 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.

isInterval

Returns true if the value at the given position is an interval.

isArray

Returns true if the value at the given position is an array.

isCollection

Returns true if the value at the given position is a collection (list or set).

isUndefined

Returns true if the value at the given position is undefined.

getIntValue

Returns the integer value at the given position.

getDoubleValue

Returns the double value at the given position.

getIntervalValue

Returns the interval value at the given position.

getArrayValue

Returns the array value at the given position.

getCollectionValue

Returns the collection value at the given position.

toString

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

Returns true if the value at the given position is undefined. A value can be undefined in 4 cases:

  • It is a 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.

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.

std::string LSArray::toString() const

Returns a string representation of the values in the array in the formats { val0, val1, ..., valN }.

Returns:

String representation.