LSCollection Class¶
-
class
localsolver.LSCollection¶ Value type for collection expressions (lists).
Such a value is obtained with
LSExpression.valuewhen the expression is a list. It represents a reference to the value of a variable and the value of this variable is modified when the LSCollection object if modified.
Summary¶
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. |
__str__ |
Returns a string representation of the values in the collection in the format { val0, val1, ..., valN }ReturnsString representation of this model. |
__getitem__ |
Operator overloading for LSCollection.get(). |
__len__ |
Returns the length of the collection (same result as LSCollection.count()). |
__iter__ |
Returns an iterator for the content of this collection. |
Instance methods¶
-
LSCollection.add(val)¶ Adds the given value to this collection. Only allowed in state
LSState.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 ( int) – The value to be added.
-
LSCollection.clear()¶ Removes all values of this collection. Only allowed in state
LSState.STOPPED.
-
LSCollection.count()¶ Gets the number of values in the collection.
Returns: Number of values in this LSCollection Return type: int
-
LSCollection.get(pos)¶ Gets the value at the given position.
Parameters: pos ( int) – The considered position (must be non negative and strictly smaller than the number of values in the collection).Returns: Value at the given position Return type: int
Special operators and methods¶
-
LSCollection.__str__()¶ Returns a string representation of the values in the collection in the format
{ val0, val1, ..., valN }Returns: String representation of this model. Return type: str
-
LSCollection.__getitem__(pos)¶ Operator overloading for
LSCollection.get().
-
LSCollection.__len__()¶ Returns the length of the collection (same result as
LSCollection.count()).
-
LSCollection.__iter__()¶ Returns an iterator for the content of this collection.