LSArray Class¶
- class localsolver.LSArray¶
Value type for array expressions.
Such a value is obtained with
LSExpression.value
when the expression is an array. An array can contain numbers (int, double), other LSArray (for multi-dimensional arrays) or LSCollection (list, set).Arrays are not decisions and cannot be modified.
- Since
7.5
- See
- See
- See
Summary¶
Returns the number of values in the collection. |
|
Returns true if the value at the given position is a boolean. |
|
Returns true if the value at the given position is an integer. |
|
Returns true if the value at the given position is a double. |
|
Returns true if the value at the given position is an array. |
|
Gets the value at the given position. |
Returns a string representation of the values in the array in the format { val0, val1, ..., valN }ReturnsString representation of this array. |
|
Operator overloading for LSArray.get(). |
|
Returns the length of the array (same result as LSArray.count()). |
|
Returns an iterator for the content of this array. |
Instance methods¶
- LSArray.count()¶
Returns the number of values in the collection. Elements in arrays are indexed from 0 to count()-1.
- Returns
Number of values in this LSCollection
- Return type
int
- LSArray.is_bool(pos)¶
Returns true if the value at the given position is a boolean. You can retrieve the value with
get()
or with the special overloaded operator__getitem__()
.- Parameters
pos (
int
) – Position of the value to query.- Returns
True if the value at the given position is a boolean.
- Return type
bool
- LSArray.is_int(pos)¶
Returns true if the value at the given position is an integer. You can retrieve the value with
get()
or with the special overloaded operator__getitem__()
.- Parameters
pos (
int
) – Position of the value to query.- Returns
True if the value at the given position is an integer.
- Return type
bool
- LSArray.is_double(pos)¶
Returns true if the value at the given position is a double. You can retrieve the value with
get()
or with the special overloaded operator__getitem__()
.- Parameters
pos (
int
) – Position of the value to query.- Returns
True if the value at the given position is a boolean.
- Return type
bool
- LSArray.is_array(pos)¶
Returns true if the value at the given position is an array. You can retrieve the value with
get()
or with the special overloaded operator__getitem__()
.- Parameters
pos (
int
) – Position of the value to query.- Returns
True if the value at the given position is an array.
- Return type
bool
Special operators and methods¶
- LSArray.__str__()¶
Returns a string representation of the values in the array in the format
{ val0, val1, ..., valN }
- Returns
String representation of this array.
- Return type
str
- LSArray.__getitem__(pos)¶
Operator overloading for
LSArray.get()
.
- LSArray.__len__()¶
Returns the length of the array (same result as
LSArray.count()
).
- LSArray.__iter__()¶
Returns an iterator for the content of this array.