HxCollection Class¶
- class Hexaly.Optimizer.HxCollection¶
Value type for collection expressions (lists or sets). Such a value is obtained with
HxExpression.GetCollectionValue()
. It represents a reference to the value of a variable and the value of this variable is modified when the HxCollection object is modified.- Since:
5.5
- See:
- See:
- See:
Summary¶
Adds the given value to this collection. |
|
Removes all values of this collection. |
|
Returns the number of values in the collection. |
|
Gets the value at the given position. |
|
Returns true if the collection contains the given value, false otherwise. |
|
Copy all the values of the collection to the given array. |
|
Gets the enumerator for the content of this collection. |
|
Returns true if the collection is undefined. |
|
Returns a string representation of the values in the collection in the format { val0, val1, ..., valN }. |
Indexer. |
Instance methods¶
- void Add(long val)¶
Adds the given value to this collection. Only allowed in state
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).- Arguments:
val (long) – The value to be added.
- int 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
- long Get(int position)¶
Gets the value at the given position.
- Arguments:
position (int) – The considered position (must be non negative and strictly smaller than the number of values in the collection).
- Returns:
The value at the given position
- Return type:
long
- bool Contains(long value)¶
Returns true if the collection contains the given value, false otherwise.
- Arguments:
value (long) – Element whose presence in this collection is to be tested.
- Returns:
True if the collection contains the value
- Return type:
bool
- void CopyTo(long[] values)¶
Copy all the values of the collection to the given array.
The length of the array can be different from the number of elements in the collection. In that case, only the elements that fit in the array are copied.
This method is recommended if you need to access all the values of the collection, instead of the roughly equivalent, but less performant, following code:
for(int i = 0; i < Math.Min(values.Length, collection.Count()); i++) { values[i] = collection.Get(i); }
- Arguments:
values (long[]) – Array that will receive the values of the collection.
- IEnumerator<long> GetEnumerator()¶
- IEnumerator GetEnumerator()
Gets the enumerator for the content of this collection.
- bool IsUndefined()¶
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
- string ToString()¶
Returns a string representation of the values in the collection in the format
{ val0, val1, ..., valN }
.- Returns:
A String representation of the collection
- Return type:
string
Overloaded operators and indexers¶
- long this(int position)¶
Indexer. Gets the value at the given position.
- Arguments:
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