LocalSolver logo
is now
Hexaly logo

We're excited to share that we are moving forward. We're leaving behind the LocalSolver brand and transitioning to our new identity: Hexaly. This represents a leap forward in our mission to enable every organization to make better decisions faster when faced with operational and strategic challenges.

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 Type

type lscollection

Value type for collection expressions (lists or sets). Such a value is obtained with lsexpression.value or with lssolution.getValue().

See

lsmodel

See

lsexpression

Summary

Functions

add

Adds the given value to this collection.

clear

Removes all values of this collection.

count

Returns the number of values in the collection.

contains

Returns true if the collection contains the given value, false otherwise.

Overloaded operators

iterator

Returns an iterator than can be used within a for statement.

index

Indexer.

Functions

lscollection.add(val)

Adds the given value to this collection. Only allowed in state STOPPED. This function will fail if the given value is not an integer, is outside of the domain of the list or if this value is already included in this list (keep in mind that a list cannot contain twice the same value).

lscollection.clear()

Removes all values of this collection. Only allowed in state STOPPED.

lscollection.count()

Returns the number of values in the collection. Elements in collections are indexed from 0 to count()-1.

Returns

Number of values in the collection.

Return type

int

lscollection.contains(value)

Returns true if the collection contains the given value, false otherwise. An exception will be thrown if the provided value is not an integer.

Parameters

value (int) – Element whose presence in this collection is to be tested.

Return type

bool

Overloaded operators

lscollection.iterator()

Returns an iterator than can be used within a for statement.

lscollection.index(position)

Indexer. Gets the value at the given position.

Parameters

position (int) – The considered position. Must be non negative and striclty smaller than the number of values in the collection.

Returns

The value at the given position

Return type

long