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.

LSCollection Class

class localsolver::LSCollection

Value type for collection expressions (lists).

Such a value is obtained with LSExpression::getCollectionValue(). It represents a reference to the value of a variable and the value of this variable is modified when the LSCollection object is modified.

See:

LSModel

LSExpression

Since:

5.5

Summary

Functions
add Adds the given value to this collection.
clear Removes all values of this collection.
count Gets the number of values in the collection.
get Gets the value at the given position.
toString Returns a string representation of the values in the collection in the format “{ val0, val1, .
Overloaded operators
operator[] Operator overloading for get.

Functions

void add(lsint val)

Adds the given value to this collection.

Only allowed in state S_Stopped. This function will fail if the given value is outside of the range of the list or if this value is already included in this list (remind that a list cannot contain twice the same value).

Parameters:val - The value to be added.

void clear()

Removes all values of this collection.

Only allowed in state S_Stopped.

lsint count() const

Gets the number of values in the collection.

lsint get(int position) const

Gets the value at the given position.

Parameters:position - The considered position (must be non negative and strictly smaller than the number of values in the collection).

lsint operator[](int i) const

Operator overloading for get.

std::string toString() const

Returns a string representation of the values in the collection in the format “{ val0, val1, ..., valN }”.

Return:String representation.