Overview | Group | Tree | Graph | Index | Concepts |
IlcIntArray
is the array class for the basic integer class.
It is a handle class.
For each basic type, Solver defines a corresponding array class. This
array class is a handle class. In other words, an object of this class
contains a pointer to another object allocated on the Solver heap associated
with a solver (an instance of IloSolver
).
Exploiting handles in this way greatly simplifies the programming interface
since the handle can then be an automatic object: as a developer using
handles, you do not have to worry about memory allocation.
Empty Handle or Null Array
It is possible to create a null array, or in other words, an empty handle. When you do so, only these operations are allowed on that null array:
getSize
for the null array returns 0 (zero).
ok
returns
IlcFalse
for a null array.Attempts to access a null array in any other way will throw an exception
(an instance of IloSolver::SolverErrorException
).
See Also:
IlcConstIntArray, IlcIntExp, IlcIntSet, operator<<
Constructor Summary | |
---|---|
public | IlcIntArray() |
public | IlcIntArray(IlcInt * impl) |
public | IlcIntArray(IloSolver solver, IlcInt size, IlcInt * values) |
public | IlcIntArray(IloSolver solver, IlcInt size, IlcInt prototype=0) |
public | IlcIntArray(IloSolver solver, IlcInt size, IlcInt exp0, IlcInt exp...) |
Method Summary | |
---|---|
public IlcInt * | getImpl() const |
public IlcInt | getSize() const |
public IloSolver | getSolver() const |
public void | operator=(const IlcIntArray & h) |
public IlcIntExp | operator[](const IlcIntExp rank) const |
public IlcInt & | operator[](IlcInt i) const |
Constructor Detail |
---|
This constructor creates an empty handle. You must initialize it before you use it.
This constructor creates a handle object from a pointer to an implementation object.
This constructor creates an array of integers containing the values in the array values
. The argument size
must be the length of the array values
; it must also be strictly greater than 0 (zero). Solver does not keep a pointer to the array values
.
Here is one way to create an array containing the integers 1, 3, 2.
IlcInt values [3]; values[0] = 1; values[1] = 3; values[2] = 2; IlcIntArray array1 (s, 3, values);
This constructor creates an array of size
elements. The argument size
must be strictly greater than 0 (zero). The elements of this array are initialized to the value of prototype
.
This constructor accepts a variable number of arguments. Its first argument, size
, indicates the length of the
array that this constructor will create; size
must be the number of arguments minus one; it must also be
strictly greater than 0 (zero). The constructor creates an array of the values indicated by the other arguments.
Here is another way to create an array containing the integers 1,3,2.
IlcIntArray array2 (s, 3, 1, 3, 2);
Method Detail |
---|
This member function returns a pointer to the implementation object of the invoking handle.
This member function returns the number of elements in the array.
This member function returns an instance of IloSolver
associated with the invoking object.
This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the provided argument.
This subscripting operator returns a constrained integer expression. For clarity, let's call A
the invoking array. When rank
is bound to the value i
, the value of the expression is A[i]
. More generally, the domain of the expression is the set of values A[i]
where the i
are in the domain of rank
.
This operator returns a reference to the element at rank i
. This operator can be used for accessing (that is, simply reading) the element or for modifying (that is, writing) it.
Here is still another way to create an array containing the integers 1, 3, 2.
IlcIntArray array5 (s, 3); array5[0] = 1; array5[1] = 3; array5[2] = 2;