HxCollection Class¶
- class hexaly.optimizer.HxCollection¶
Value type for collection expressions (lists or sets). Such a value is obtained with
HxExpression.value
when 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 HxCollection object if modified.
Summary¶
Adds the given value to this collection. |
|
Removes all values of this collection. |
|
Returns the number of values in the collection. |
|
Returns true if the collection contains the given value, false otherwise. |
|
Gets the value at the given position. |
|
Returns true if the collection is undefined. |
Returns a string representation of the values in the collection in the format { val0, val1, ..., valN }ReturnsString representation of this collection. |
|
Operator overloading for HxCollection.get(). |
|
Operator overloading for HxCollection.contains(). |
|
Returns the length of the collection (same result as HxCollection.count()). |
|
Returns an iterator for the content of this collection. |
Instance methods¶
- HxCollection.add(val)¶
Adds the given value to this collection. Only allowed in state
HxState.STOPPED
. This function will fail if the given value 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).- Parameters:
val (
int
) – The value to be added.
- HxCollection.clear()¶
Removes all values of this collection. Only allowed in state
HxState.STOPPED
.
- HxCollection.count()¶
Returns the number of values in the collection. Elements in collections are indexed from 0 to count()-1.
- Returns:
Number of values in this HxCollection
- Return type:
int
- HxCollection.contains(value)¶
Returns true if the collection contains the given value, false otherwise.
- Parameters:
value – Element whose presence in this collection is to be tested.
- Returns:
True if the collection contains the value
- Return type:
bool
- HxCollection.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
- HxCollection.is_undefined()¶
Returns true if the collection is undefined. A collection can be undefined if it is the result of any ill-defined operation (at with out of bounds index or operations on undefined values for instance).
- Returns:
True if the collection is undefined.
- Return type:
bool
Special operators and methods¶
- HxCollection.__str__()¶
Returns a string representation of the values in the collection in the format
{ val0, val1, ..., valN }
- Returns:
String representation of this collection.
- Return type:
str
- HxCollection.__getitem__(pos)¶
Operator overloading for
HxCollection.get()
.
- HxCollection.__contains__(value)¶
Operator overloading for
HxCollection.contains()
.
- HxCollection.__len__()¶
Returns the length of the collection (same result as
HxCollection.count()
).
- HxCollection.__iter__()¶
Returns an iterator for the content of this collection.