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.

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 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::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.

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.

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.

std::string LSArray::toString() const

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

Returns

String representation.